Skip to content

Commit 468d7a0

Browse files
committed
feat: run cargo fix --edition
1 parent 339239d commit 468d7a0

File tree

9 files changed

+45
-46
lines changed

9 files changed

+45
-46
lines changed

src/ast/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3698,7 +3698,7 @@ impl fmt::Display for Statement {
36983698
local = if *local { " LOCAL" } else { "" },
36993699
path = path
37003700
)?;
3701-
if let Some(ref ff) = file_format {
3701+
if let Some(ff) = file_format {
37023702
write!(f, " STORED AS {ff}")?
37033703
}
37043704
write!(f, " {source}")
@@ -3750,7 +3750,7 @@ impl fmt::Display for Statement {
37503750
}
37513751
}
37523752

3753-
if let Some(ref parts) = partitions {
3753+
if let Some(parts) = partitions {
37543754
if !parts.is_empty() {
37553755
write!(f, " PARTITION ({})", display_comma_separated(parts))?;
37563756
}
@@ -3817,7 +3817,7 @@ impl fmt::Display for Statement {
38173817
"ANALYZE{}{table_name}",
38183818
if *has_table_keyword { " TABLE " } else { " " }
38193819
)?;
3820-
if let Some(ref parts) = partitions {
3820+
if let Some(parts) = partitions {
38213821
if !parts.is_empty() {
38223822
write!(f, " PARTITION ({})", display_comma_separated(parts))?;
38233823
}
@@ -4139,7 +4139,7 @@ impl fmt::Display for Statement {
41394139
overwrite = if *overwrite { "OVERWRITE " } else { "" },
41404140
table_name = table_name,
41414141
)?;
4142-
if let Some(ref parts) = &partitioned {
4142+
if let Some(parts) = &partitioned {
41434143
if !parts.is_empty() {
41444144
write!(f, " PARTITION ({})", display_comma_separated(parts))?;
41454145
}

src/keywords.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use sqlparser_derive::{Visit, VisitMut};
3636
/// Defines a string constant for a single keyword: `kw_def!(SELECT);`
3737
/// expands to `pub const SELECT = "SELECT";`
3838
macro_rules! kw_def {
39-
($ident:ident = $string_keyword:expr) => {
39+
($ident:ident = $string_keyword:expr_2021) => {
4040
pub const $ident: &'static str = $string_keyword;
4141
};
4242
($ident:ident) => {
@@ -48,7 +48,7 @@ macro_rules! kw_def {
4848
/// and defines an ALL_KEYWORDS array of the defined constants.
4949
macro_rules! define_keywords {
5050
($(
51-
$ident:ident $(= $string_keyword:expr)?
51+
$ident:ident $(= $string_keyword:expr_2021)?
5252
),*) => {
5353
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Hash)]
5454
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

src/parser/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub enum ParserError {
5050

5151
// Use `Parser::expected` instead, if possible
5252
macro_rules! parser_err {
53-
($MSG:expr, $loc:expr) => {
53+
($MSG:expr_2021, $loc:expr_2021) => {
5454
Err(ParserError::ParserError(format!("{}{}", $MSG, $loc)))
5555
};
5656
}
@@ -14727,7 +14727,7 @@ mod tests {
1472714727
use crate::test_utils::TestedDialects;
1472814728

1472914729
macro_rules! test_parse_data_type {
14730-
($dialect:expr, $input:expr, $expected_type:expr $(,)?) => {{
14730+
($dialect:expr_2021, $input:expr_2021, $expected_type:expr_2021 $(,)?) => {{
1473114731
$dialect.run_parser_method(&*$input, |parser| {
1473214732
let data_type = parser.parse_data_type().unwrap();
1473314733
assert_eq!($expected_type, data_type);
@@ -15045,7 +15045,7 @@ mod tests {
1504515045
fn test_parse_schema_name() {
1504615046
// The expected name should be identical as the input name, that's why I don't receive both
1504715047
macro_rules! test_parse_schema_name {
15048-
($input:expr, $expected_name:expr $(,)?) => {{
15048+
($input:expr_2021, $expected_name:expr_2021 $(,)?) => {{
1504915049
all_dialects().run_parser_method(&*$input, |parser| {
1505015050
let schema_name = parser.parse_schema_name().unwrap();
1505115051
// Validate that the structure is the same as expected
@@ -15077,7 +15077,7 @@ mod tests {
1507715077
#[test]
1507815078
fn mysql_parse_index_table_constraint() {
1507915079
macro_rules! test_parse_table_constraint {
15080-
($dialect:expr, $input:expr, $expected:expr $(,)?) => {{
15080+
($dialect:expr_2021, $input:expr_2021, $expected:expr_2021 $(,)?) => {{
1508115081
$dialect.run_parser_method(&*$input, |parser| {
1508215082
let constraint = parser.parse_optional_table_constraint().unwrap().unwrap();
1508315083
// Validate that the structure is the same as expected
@@ -15255,7 +15255,7 @@ mod tests {
1525515255
#[test]
1525615256
fn test_parse_multipart_identifier_negative() {
1525715257
macro_rules! test_parse_multipart_identifier_error {
15258-
($input:expr, $expected_err:expr $(,)?) => {{
15258+
($input:expr_2021, $expected_err:expr_2021 $(,)?) => {{
1525915259
all_dialects().run_parser_method(&*$input, |parser| {
1526015260
let actual_err = parser.parse_multipart_identifier().unwrap_err();
1526115261
assert_eq!(actual_err.to_string(), $expected_err);

src/test_utils.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ pub fn assert_eq_vec<T: ToString>(expected: &[&str], actual: &[T]) {
302302

303303
pub fn only<T>(v: impl IntoIterator<Item = T>) -> T {
304304
let mut iter = v.into_iter();
305-
if let (Some(item), None) = (iter.next(), iter.next()) {
305+
match (iter.next(), iter.next()) { (Some(item), None) => {
306306
item
307-
} else {
307+
} _ => {
308308
panic!("only called on collection without exactly one item")
309-
}
309+
}}
310310
}
311311

312312
pub fn expr_from_projection(item: &SelectItem) -> &Expr {

src/tokenizer.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -281,26 +281,26 @@ impl fmt::Display for Token {
281281
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
282282
match self {
283283
Token::EOF => f.write_str("EOF"),
284-
Token::Word(ref w) => write!(f, "{w}"),
285-
Token::Number(ref n, l) => write!(f, "{}{long}", n, long = if *l { "L" } else { "" }),
286-
Token::Char(ref c) => write!(f, "{c}"),
287-
Token::SingleQuotedString(ref s) => write!(f, "'{s}'"),
288-
Token::TripleSingleQuotedString(ref s) => write!(f, "'''{s}'''"),
289-
Token::DoubleQuotedString(ref s) => write!(f, "\"{s}\""),
290-
Token::TripleDoubleQuotedString(ref s) => write!(f, "\"\"\"{s}\"\"\""),
291-
Token::DollarQuotedString(ref s) => write!(f, "{s}"),
292-
Token::NationalStringLiteral(ref s) => write!(f, "N'{s}'"),
293-
Token::EscapedStringLiteral(ref s) => write!(f, "E'{s}'"),
294-
Token::UnicodeStringLiteral(ref s) => write!(f, "U&'{s}'"),
295-
Token::HexStringLiteral(ref s) => write!(f, "X'{s}'"),
296-
Token::SingleQuotedByteStringLiteral(ref s) => write!(f, "B'{s}'"),
297-
Token::TripleSingleQuotedByteStringLiteral(ref s) => write!(f, "B'''{s}'''"),
298-
Token::DoubleQuotedByteStringLiteral(ref s) => write!(f, "B\"{s}\""),
299-
Token::TripleDoubleQuotedByteStringLiteral(ref s) => write!(f, "B\"\"\"{s}\"\"\""),
300-
Token::SingleQuotedRawStringLiteral(ref s) => write!(f, "R'{s}'"),
301-
Token::DoubleQuotedRawStringLiteral(ref s) => write!(f, "R\"{s}\""),
302-
Token::TripleSingleQuotedRawStringLiteral(ref s) => write!(f, "R'''{s}'''"),
303-
Token::TripleDoubleQuotedRawStringLiteral(ref s) => write!(f, "R\"\"\"{s}\"\"\""),
284+
Token::Word(w) => write!(f, "{w}"),
285+
Token::Number(n, l) => write!(f, "{}{long}", n, long = if *l { "L" } else { "" }),
286+
Token::Char(c) => write!(f, "{c}"),
287+
Token::SingleQuotedString(s) => write!(f, "'{s}'"),
288+
Token::TripleSingleQuotedString(s) => write!(f, "'''{s}'''"),
289+
Token::DoubleQuotedString(s) => write!(f, "\"{s}\""),
290+
Token::TripleDoubleQuotedString(s) => write!(f, "\"\"\"{s}\"\"\""),
291+
Token::DollarQuotedString(s) => write!(f, "{s}"),
292+
Token::NationalStringLiteral(s) => write!(f, "N'{s}'"),
293+
Token::EscapedStringLiteral(s) => write!(f, "E'{s}'"),
294+
Token::UnicodeStringLiteral(s) => write!(f, "U&'{s}'"),
295+
Token::HexStringLiteral(s) => write!(f, "X'{s}'"),
296+
Token::SingleQuotedByteStringLiteral(s) => write!(f, "B'{s}'"),
297+
Token::TripleSingleQuotedByteStringLiteral(s) => write!(f, "B'''{s}'''"),
298+
Token::DoubleQuotedByteStringLiteral(s) => write!(f, "B\"{s}\""),
299+
Token::TripleDoubleQuotedByteStringLiteral(s) => write!(f, "B\"\"\"{s}\"\"\""),
300+
Token::SingleQuotedRawStringLiteral(s) => write!(f, "R'{s}'"),
301+
Token::DoubleQuotedRawStringLiteral(s) => write!(f, "R\"{s}\""),
302+
Token::TripleSingleQuotedRawStringLiteral(s) => write!(f, "R'''{s}'''"),
303+
Token::TripleDoubleQuotedRawStringLiteral(s) => write!(f, "R\"\"\"{s}\"\"\""),
304304
Token::Comma => f.write_str(","),
305305
Token::Whitespace(ws) => write!(f, "{ws}"),
306306
Token::DoubleEq => f.write_str("=="),
@@ -368,7 +368,7 @@ impl fmt::Display for Token {
368368
Token::TildeEqual => f.write_str("~="),
369369
Token::ShiftLeftVerticalBar => f.write_str("<<|"),
370370
Token::VerticalBarShiftRight => f.write_str("|>>"),
371-
Token::Placeholder(ref s) => write!(f, "{s}"),
371+
Token::Placeholder(s) => write!(f, "{s}"),
372372
Token::Arrow => write!(f, "->"),
373373
Token::LongArrow => write!(f, "->>"),
374374
Token::HashArrow => write!(f, "#>"),

tests/sqlparser_clickhouse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ fn parse_select_parametric_function() {
994994
match &projection[0] {
995995
UnnamedExpr(Expr::Function(f)) => {
996996
let args = match &f.args {
997-
FunctionArguments::List(ref args) => args,
997+
FunctionArguments::List(args) => args,
998998
_ => unreachable!(),
999999
};
10001000
assert_eq!(args.args.len(), 2);

tests/sqlparser_common.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,9 @@ fn parse_column_aliases() {
11231123
let select = verified_only_select(sql);
11241124
if let SelectItem::ExprWithAlias {
11251125
expr: Expr::BinaryOp {
1126-
ref op, ref right, ..
1126+
op, right, ..
11271127
},
1128-
ref alias,
1128+
alias,
11291129
} = only(&select.projection)
11301130
{
11311131
assert_eq!(&BinaryOperator::Plus, op);
@@ -3280,17 +3280,16 @@ fn test_double_value() {
32803280

32813281
for (input, expected) in test_cases {
32823282
for (i, expr) in input.iter().enumerate() {
3283-
if let Statement::Query(query) =
3284-
dialects.one_statement_parses_to(&format!("SELECT {}", expr), "")
3285-
{
3283+
match dialects.one_statement_parses_to(&format!("SELECT {}", expr), "")
3284+
{ Statement::Query(query) => {
32863285
if let SetExpr::Select(select) = *query.body {
32873286
assert_eq!(expected[i], select.projection[0]);
32883287
} else {
32893288
panic!("Expected a SELECT statement");
32903289
}
3291-
} else {
3290+
} _ => {
32923291
panic!("Expected a SELECT statement");
3293-
}
3292+
}}
32943293
}
32953294
}
32963295
}
@@ -7071,7 +7070,7 @@ fn parse_ctes() {
70717070
let sql = &format!("SELECT ({with})");
70727071
let select = verified_only_select(sql);
70737072
match expr_from_projection(only(&select.projection)) {
7074-
Expr::Subquery(ref subquery) => {
7073+
Expr::Subquery(subquery) => {
70757074
assert_ctes_in_select(&cte_sqls, subquery.as_ref());
70767075
}
70777076
_ => panic!("Expected: subquery"),

tests/sqlparser_regression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use sqlparser::dialect::GenericDialect;
2121
use sqlparser::parser::Parser;
2222

2323
macro_rules! tpch_tests {
24-
($($name:ident: $value:expr,)*) => {
24+
($($name:ident: $value:expr_2021,)*) => {
2525
const QUERIES: &[&str] = &[
2626
$(include_str!(concat!("queries/tpch/", $value, ".sql"))),*
2727
];

tests/test_utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use sqlparser::test_utils::*;
3030

3131
#[macro_export]
3232
macro_rules! nest {
33-
($base:expr $(, $join:expr)*) => {
33+
($base:expr_2021 $(, $join:expr_2021)*) => {
3434
TableFactor::NestedJoin { table_with_joins: Box::new(TableWithJoins {
3535
relation: $base,
3636
joins: vec![$(join($join)),*]

0 commit comments

Comments
 (0)