chore: upgrade Rust to nightly 2022-12-20 (#772)

* chore: upgrade Rust to nightly 2022-12-20

* chore: upgrade Rust to nightly 2022-12-20

Co-authored-by: luofucong <luofucong@greptime.com>
This commit is contained in:
LFC
2022-12-21 19:32:30 +08:00
committed by GitHub
parent d0ebcc3b5a
commit ea9af42091
145 changed files with 366 additions and 515 deletions

View File

@@ -322,8 +322,7 @@ impl<'a> ParserContext<'a> {
// Report unexpected token
pub(crate) fn expected<T>(&self, expected: &str, found: Token) -> Result<T> {
Err(ParserError::ParserError(format!(
"Expected {}, found: {}",
expected, found
"Expected {expected}, found: {found}",
)))
.context(SyntaxSnafu { sql: self.sql })
}

View File

@@ -65,6 +65,6 @@ mod tests {
pub fn test_parse_invalid_insert() {
let sql = r"INSERT INTO table_1 VALUES ("; // intentionally a bad sql
let result = ParserContext::create_with_dialect(sql, &GenericDialect {});
assert!(result.is_err(), "result is: {:?}", result);
assert!(result.is_err(), "result is: {result:?}");
}
}

View File

@@ -65,8 +65,7 @@ pub fn table_idents_to_full_name(obj_name: &ObjectName) -> Result<(String, Strin
)),
_ => error::InvalidSqlSnafu {
msg: format!(
"expect table name to be <catalog>.<schema>.<table>, <schema>.<table> or <table>, actual: {}",
obj_name
"expect table name to be <catalog>.<schema>.<table>, <schema>.<table> or <table>, actual: {obj_name}",
),
}
.fail(),
@@ -94,7 +93,7 @@ fn parse_string_to_value(
Ok(Value::Date(date))
} else {
ParseSqlValueSnafu {
msg: format!("Failed to parse {} to Date value", s),
msg: format!("Failed to parse {s} to Date value"),
}
.fail()
}
@@ -104,7 +103,7 @@ fn parse_string_to_value(
Ok(Value::DateTime(datetime))
} else {
ParseSqlValueSnafu {
msg: format!("Failed to parse {} to DateTime value", s),
msg: format!("Failed to parse {s} to DateTime value"),
}
.fail()
}
@@ -117,7 +116,7 @@ fn parse_string_to_value(
)))
} else {
ParseSqlValueSnafu {
msg: format!("Failed to parse {} to Timestamp value", s),
msg: format!("Failed to parse {s} to Timestamp value"),
}
.fail()
}
@@ -172,7 +171,7 @@ where
match n.parse::<R>() {
Ok(n) => Ok(n),
Err(e) => ParseSqlValueSnafu {
msg: format!("Fail to parse number {}, {:?}", n, e),
msg: format!("Fail to parse number {n}, {e:?}"),
}
.fail(),
}
@@ -220,7 +219,7 @@ fn parse_column_default_constraint(
}
ColumnOption::Default(Expr::Function(func)) => {
// Always use lowercase for function expression
ColumnDefaultConstraint::Function(format!("{}", func).to_lowercase())
ColumnDefaultConstraint::Function(format!("{func}").to_lowercase())
}
ColumnOption::Default(expr) => {
return UnsupportedDefaultValueSnafu {
@@ -391,7 +390,7 @@ mod tests {
assert_eq!(Value::Int32(999), v);
let v = sql_number_to_value(&ConcreteDataType::string_datatype(), "999");
assert!(v.is_err(), "parse value error is: {:?}", v);
assert!(v.is_err(), "parse value error is: {v:?}");
}
#[test]
@@ -417,18 +416,17 @@ mod tests {
let sql_val = SqlValue::Number("3.0".to_string(), false);
let v = sql_value_to_value("a", &ConcreteDataType::boolean_datatype(), &sql_val);
assert!(v.is_err());
assert!(format!("{:?}", v)
assert!(format!("{v:?}")
.contains("Fail to parse number 3.0, invalid column type: Boolean(BooleanType)"));
let sql_val = SqlValue::Boolean(true);
let v = sql_value_to_value("a", &ConcreteDataType::float64_datatype(), &sql_val);
assert!(v.is_err());
assert!(
format!("{:?}", v).contains(
format!("{v:?}").contains(
"column_name: \"a\", expect: Float64(Float64Type), actual: Boolean(BooleanType)"
),
"v is {:?}",
v
"v is {v:?}",
);
}

View File

@@ -72,20 +72,20 @@ fn sql_exprs_to_values(exprs: &Vec<Vec<Expr>>) -> Result<Vec<Vec<Value>>> {
{
if let Expr::Value(Value::Number(s, b)) = &**expr {
match op {
UnaryOperator::Minus => Value::Number(format!("-{}", s), *b),
UnaryOperator::Minus => Value::Number(format!("-{s}"), *b),
UnaryOperator::Plus => Value::Number(s.to_string(), *b),
_ => unreachable!(),
}
} else {
return error::ParseSqlValueSnafu {
msg: format!("{:?}", expr),
msg: format!("{expr:?}"),
}
.fail();
}
}
_ => {
return error::ParseSqlValueSnafu {
msg: format!("{:?}", expr),
msg: format!("{expr:?}"),
}
.fail()
}
@@ -103,8 +103,7 @@ impl TryFrom<Statement> for Insert {
match value {
Statement::Insert { .. } => Ok(Insert { inner: value }),
unexp => Err(ParserError::ParserError(format!(
"Not expected to be {}",
unexp
"Not expected to be {unexp}"
))),
}
}

View File

@@ -28,8 +28,8 @@ impl fmt::Display for ShowKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ShowKind::All => write!(f, "ALL"),
ShowKind::Like(ident) => write!(f, "LIKE {}", ident),
ShowKind::Where(expr) => write!(f, "WHERE {}", expr),
ShowKind::Like(ident) => write!(f, "LIKE {ident}"),
ShowKind::Where(expr) => write!(f, "WHERE {expr}"),
}
}
}