Skip to content

Commit

Permalink
cargo +nightly fix --edition
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed Nov 27, 2024
1 parent 312dfbf commit 9021633
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions examples/sql_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ fn main() {
}
}
});
if let Err(e) = result {
match result { Err(e) => {
eprintln!("Panic: {e:?} in {arg}");
}
} _ => {}}
}
}
4 changes: 2 additions & 2 deletions examples/sql_cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ fn main() {
}
}
});
if let Err(e) = result {
match result { Err(e) => {
eprintln!("Panic: {e:?} in {arg}");
}
} _ => {}}
}
}
2 changes: 1 addition & 1 deletion src/lexer/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ fn analyze_filter_keyword(
}

macro_rules! try_with_position {
($scanner:expr, $expr:expr) => {
($scanner:expr_2021, $expr:expr_2021) => {
match $expr {
Ok(val) => val,
Err(err) => {
Expand Down
6 changes: 3 additions & 3 deletions src/lexer/sql/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ fn expect_parser_err_msg(input: &[u8], error_msg: &str) {
}
fn expect_parser_err(input: &[u8], err: ParserError) {
let r = parse(input);
if let Error::ParserError(e, _) = r.unwrap_err() {
match r.unwrap_err() { Error::ParserError(e, _) => {
assert_eq!(e, err);
} else {
} _ => {
panic!("unexpected error type")
};
}};
}
fn parse_cmd(input: &[u8]) -> Cmd {
parse(input).unwrap().unwrap()
Expand Down
8 changes: 4 additions & 4 deletions src/parser/ast/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ impl CreateTableBody {
let mut generated_count = 0;
for c in columns.values() {
for cs in &c.constraints {
if let ColumnConstraint::Generated { .. } = cs.constraint {
match cs.constraint { ColumnConstraint::Generated { .. } => {
generated_count += 1;
}
} _ => {}}
}
}
if generated_count == columns.len() {
Expand Down Expand Up @@ -259,9 +259,9 @@ impl CreateTableBody {
}
if let Some(constraints) = constraints {
for c in constraints {
if let TableConstraint::PrimaryKey { .. } = c.constraint {
match c.constraint { TableConstraint::PrimaryKey { .. } => {
return true;
}
} _ => {}}
}
}
}
Expand Down
56 changes: 28 additions & 28 deletions src/parser/ast/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,10 +515,10 @@ impl ToTokens for Stmt {
}
Self::Vacuum(name, expr) => {
s.append(TK_VACUUM, None)?;
if let Some(ref name) = name {
if let &Some(ref name) = name {
name.to_tokens(s)?;
}
if let Some(ref expr) = expr {
if let &Some(ref expr) = expr {
s.append(TK_INTO, None)?;
expr.to_tokens(s)?;
}
Expand Down Expand Up @@ -557,7 +557,7 @@ impl ToTokens for Expr {
else_expr,
} => {
s.append(TK_CASE, None)?;
if let Some(ref base) = base {
if let &Some(ref base) = base {
base.to_tokens(s)?;
}
for (when, then) in when_then_pairs {
Expand All @@ -566,7 +566,7 @@ impl ToTokens for Expr {
s.append(TK_THEN, None)?;
then.to_tokens(s)?;
}
if let Some(ref else_expr) = else_expr {
if let &Some(ref else_expr) = else_expr {
s.append(TK_ELSE, None)?;
else_expr.to_tokens(s)?;
}
Expand All @@ -577,7 +577,7 @@ impl ToTokens for Expr {
s.append(TK_LP, None)?;
expr.to_tokens(s)?;
s.append(TK_AS, None)?;
if let Some(ref type_name) = type_name {
if let &Some(ref type_name) = type_name {
type_name.to_tokens(s)?;
}
s.append(TK_RP, None)
Expand Down Expand Up @@ -756,10 +756,10 @@ impl Display for Expr {
impl ToTokens for Literal {
fn to_tokens<S: TokenStream>(&self, s: &mut S) -> Result<(), S::Error> {
match self {
Self::Numeric(ref num) => s.append(TK_FLOAT, Some(num)), // TODO Validate TK_FLOAT
Self::String(ref str) => s.append(TK_STRING, Some(str)),
Self::Blob(ref blob) => s.append(TK_BLOB, Some(blob)),
Self::Keyword(ref str) => s.append(TK_ID, Some(str)), // TODO Validate TK_ID
&Self::Numeric(ref num) => s.append(TK_FLOAT, Some(num)), // TODO Validate TK_FLOAT
&Self::String(ref str) => s.append(TK_STRING, Some(str)),
&Self::Blob(ref blob) => s.append(TK_BLOB, Some(blob)),
&Self::Keyword(ref str) => s.append(TK_ID, Some(str)), // TODO Validate TK_ID
Self::Null => s.append(TK_NULL, None),
Self::CurrentDate => s.append(TK_CTIME_KW, Some("CURRENT_DATE")),
Self::CurrentTime => s.append(TK_CTIME_KW, Some("CURRENT_TIME")),
Expand Down Expand Up @@ -897,22 +897,22 @@ impl ToTokens for OneSelect {
window_clause,
} => {
s.append(TK_SELECT, None)?;
if let Some(ref distinctness) = distinctness {
if let &Some(ref distinctness) = distinctness {
distinctness.to_tokens(s)?;
}
comma(columns, s)?;
if let Some(ref from) = from {
if let &Some(ref from) = from {
s.append(TK_FROM, None)?;
from.to_tokens(s)?;
}
if let Some(ref where_clause) = where_clause {
if let &Some(ref where_clause) = where_clause {
s.append(TK_WHERE, None)?;
where_clause.to_tokens(s)?;
}
if let Some(ref group_by) = group_by {
if let &Some(ref group_by) = group_by {
group_by.to_tokens(s)?;
}
if let Some(ref window_clause) = window_clause {
if let &Some(ref window_clause) = window_clause {
s.append(TK_WINDOW, None)?;
comma(window_clause, s)?;
}
Expand Down Expand Up @@ -982,11 +982,11 @@ impl ToTokens for ResultColumn {
impl ToTokens for As {
fn to_tokens<S: TokenStream>(&self, s: &mut S) -> Result<(), S::Error> {
match self {
Self::As(ref name) => {
&Self::As(ref name) => {
s.append(TK_AS, None)?;
name.to_tokens(s)
}
Self::Elided(ref name) => name.to_tokens(s),
&Self::Elided(ref name) => name.to_tokens(s),
}
}
}
Expand Down Expand Up @@ -1054,7 +1054,7 @@ impl ToTokens for JoinOperator {
match self {
Self::Comma => s.append(TK_COMMA, None),
Self::TypedJoin(join_type) => {
if let Some(ref join_type) = join_type {
if let &Some(ref join_type) = join_type {
join_type.to_tokens(s)?;
}
s.append(TK_JOIN, None)
Expand Down Expand Up @@ -1442,22 +1442,22 @@ impl ToTokens for ForeignKeyClause {
impl ToTokens for RefArg {
fn to_tokens<S: TokenStream>(&self, s: &mut S) -> Result<(), S::Error> {
match self {
Self::OnDelete(ref action) => {
&Self::OnDelete(ref action) => {
s.append(TK_ON, None)?;
s.append(TK_DELETE, None)?;
action.to_tokens(s)
}
Self::OnInsert(ref action) => {
&Self::OnInsert(ref action) => {
s.append(TK_ON, None)?;
s.append(TK_INSERT, None)?;
action.to_tokens(s)
}
Self::OnUpdate(ref action) => {
&Self::OnUpdate(ref action) => {
s.append(TK_ON, None)?;
s.append(TK_UPDATE, None)?;
action.to_tokens(s)
}
Self::Match(ref name) => {
&Self::Match(ref name) => {
s.append(TK_MATCH, None)?;
name.to_tokens(s)
}
Expand Down Expand Up @@ -1529,7 +1529,7 @@ impl ToTokens for IndexedColumn {
impl ToTokens for Indexed {
fn to_tokens<S: TokenStream>(&self, s: &mut S) -> Result<(), S::Error> {
match self {
Self::IndexedBy(ref name) => {
&Self::IndexedBy(ref name) => {
s.append(TK_INDEXED, None)?;
s.append(TK_BY, None)?;
name.to_tokens(s)
Expand Down Expand Up @@ -1634,7 +1634,7 @@ impl ToTokens for TriggerEvent {
Self::Delete => s.append(TK_DELETE, None),
Self::Insert => s.append(TK_INSERT, None),
Self::Update => s.append(TK_UPDATE, None),
Self::UpdateOf(ref col_names) => {
&Self::UpdateOf(ref col_names) => {
s.append(TK_UPDATE, None)?;
s.append(TK_OF, None)?;
comma(col_names.deref(), s)
Expand Down Expand Up @@ -1883,8 +1883,8 @@ impl ToTokens for FunctionTail {
impl ToTokens for Over {
fn to_tokens<S: TokenStream>(&self, s: &mut S) -> Result<(), S::Error> {
match self {
Self::Window(ref window) => window.to_tokens(s),
Self::Name(ref name) => name.to_tokens(s),
&Self::Window(ref window) => window.to_tokens(s),
&Self::Name(ref name) => name.to_tokens(s),
}
}
}
Expand Down Expand Up @@ -1923,14 +1923,14 @@ impl ToTokens for Window {
impl ToTokens for FrameClause {
fn to_tokens<S: TokenStream>(&self, s: &mut S) -> Result<(), S::Error> {
self.mode.to_tokens(s)?;
if let Some(ref end) = self.end {
match self.end { Some(ref end) => {
s.append(TK_BETWEEN, None)?;
self.start.to_tokens(s)?;
s.append(TK_AND, None)?;
end.to_tokens(s)?;
} else {
} _ => {
self.start.to_tokens(s)?;
}
}}
if let Some(ref exclude) = self.exclude {
s.append(TK_EXCLUDE, None)?;
exclude.to_tokens(s)?;
Expand Down
28 changes: 14 additions & 14 deletions src/parser/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,20 +687,20 @@ impl SelectBody {
pub(crate) fn push(&mut self, cs: CompoundSelect) -> Result<(), ParserError> {
use crate::ast::check::ColumnCount;
if let ColumnCount::Fixed(n) = self.select.column_count() {
if let ColumnCount::Fixed(m) = cs.select.column_count() {
match cs.select.column_count() { ColumnCount::Fixed(m) => {
if n != m {
return Err(custom_err!(
"SELECTs to the left and right of {} do not have the same number of result columns",
cs.operator
));
}
}
} _ => {}}
}
if let Some(ref mut v) = self.compounds {
match self.compounds { Some(ref mut v) => {
v.push(cs);
} else {
} _ => {
self.compounds = Some(vec![cs]);
}
}}
Ok(())
}
}
Expand Down Expand Up @@ -787,11 +787,11 @@ impl FromClause {
"a NATURAL join may not have an ON or USING clause"
));
}
if let Some(ref mut joins) = self.joins {
match self.joins { Some(ref mut joins) => {
joins.push(jst);
} else {
} _ => {
self.joins = Some(vec![jst]);
}
}}
} else {
if jc.is_some() {
return Err(custom_err!("a JOIN clause is required before ON"));
Expand Down Expand Up @@ -1243,10 +1243,10 @@ impl ColumnDefinition {
{
let mut generated = false;
for constraint in &cd.constraints {
if let ColumnConstraint::Generated { .. } = constraint.constraint {
match constraint.constraint { ColumnConstraint::Generated { .. } => {
generated = true;
break;
}
} _ => {}}
}
generated
} else {
Expand All @@ -1259,14 +1259,14 @@ impl ColumnDefinition {
}
}
for constraint in &cd.constraints {
if let ColumnConstraint::ForeignKey {
match &constraint.constraint
{ ColumnConstraint::ForeignKey {
clause:
ForeignKeyClause {
tbl_name, columns, ..
},
..
} = &constraint.constraint
{
} => {
// The child table may reference the primary key of the parent without specifying the primary key column
if columns.as_ref().map_or(0, Vec::len) > 1 {
return Err(custom_err!(
Expand All @@ -1275,7 +1275,7 @@ impl ColumnDefinition {
tbl_name
));
}
}
} _ => {}}
}
columns.insert(col_name.clone(), cd);
Ok(())
Expand Down
10 changes: 5 additions & 5 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ macro_rules! custom_err {
($msg:literal $(,)?) => {
$crate::parser::ParserError::Custom($msg.to_owned())
};
($err:expr $(,)?) => {
($err:expr_2021 $(,)?) => {
$crate::parser::ParserError::Custom(format!($err))
};
($fmt:expr, $($arg:tt)*) => {
($fmt:expr_2021, $($arg:tt)*) => {
$crate::parser::ParserError::Custom(format!($fmt, $($arg)*))
};
}
Expand Down Expand Up @@ -82,15 +82,15 @@ impl<'input> Context<'input> {

/// Consume parsed command
pub fn cmd(&mut self) -> Option<Cmd> {
if let Some(stmt) = self.stmt.take() {
match self.stmt.take() { Some(stmt) => {
match self.explain.take() {
Some(ExplainKind::Explain) => Some(Cmd::Explain(stmt)),
Some(ExplainKind::QueryPlan) => Some(Cmd::ExplainQueryPlan(stmt)),
None => Some(Cmd::Stmt(stmt)),
}
} else {
} _ => {
None
}
}}
}

fn constraint_name(&mut self) -> Option<Name> {
Expand Down

0 comments on commit 9021633

Please sign in to comment.