Fix clippy warnings on rust 1.83 (#1570)

This commit is contained in:
Ifeanyi Ubah 2024-11-29 12:37:06 +01:00 committed by GitHub
parent 5a510ac4d9
commit 6291afb2c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 18 additions and 17 deletions

View file

@ -1327,15 +1327,18 @@ pub enum ColumnOption {
/// `DEFAULT <restricted-expr>` /// `DEFAULT <restricted-expr>`
Default(Expr), Default(Expr),
/// ClickHouse supports `MATERIALIZE`, `EPHEMERAL` and `ALIAS` expr to generate default values.
/// Syntax: `b INT MATERIALIZE (a + 1)`
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)
/// `MATERIALIZE <expr>` /// `MATERIALIZE <expr>`
/// Syntax: `b INT MATERIALIZE (a + 1)`
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)
Materialized(Expr), Materialized(Expr),
/// `EPHEMERAL [<expr>]` /// `EPHEMERAL [<expr>]`
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)
Ephemeral(Option<Expr>), Ephemeral(Option<Expr>),
/// `ALIAS <expr>` /// `ALIAS <expr>`
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)
Alias(Expr), Alias(Expr),
/// `{ PRIMARY KEY | UNIQUE } [<constraint_characteristics>]` /// `{ PRIMARY KEY | UNIQUE } [<constraint_characteristics>]`
@ -1552,7 +1555,7 @@ pub enum GeneratedExpressionMode {
#[must_use] #[must_use]
fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ { fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
struct ConstraintName<'a>(&'a Option<Ident>); struct ConstraintName<'a>(&'a Option<Ident>);
impl<'a> fmt::Display for ConstraintName<'a> { impl fmt::Display for ConstraintName<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(name) = self.0 { if let Some(name) = self.0 {
write!(f, "CONSTRAINT {name} ")?; write!(f, "CONSTRAINT {name} ")?;
@ -1573,7 +1576,7 @@ fn display_option<'a, T: fmt::Display>(
option: &'a Option<T>, option: &'a Option<T>,
) -> impl fmt::Display + 'a { ) -> impl fmt::Display + 'a {
struct OptionDisplay<'a, T>(&'a str, &'a str, &'a Option<T>); struct OptionDisplay<'a, T>(&'a str, &'a str, &'a Option<T>);
impl<'a, T: fmt::Display> fmt::Display for OptionDisplay<'a, T> { impl<T: fmt::Display> fmt::Display for OptionDisplay<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(inner) = self.2 { if let Some(inner) = self.2 {
let (prefix, postfix) = (self.0, self.1); let (prefix, postfix) = (self.0, self.1);

View file

@ -110,7 +110,7 @@ where
sep: &'static str, sep: &'static str,
} }
impl<'a, T> fmt::Display for DisplaySeparated<'a, T> impl<T> fmt::Display for DisplaySeparated<'_, T>
where where
T: fmt::Display, T: fmt::Display,
{ {

View file

@ -1713,7 +1713,7 @@ impl fmt::Display for Join {
} }
fn suffix(constraint: &'_ JoinConstraint) -> impl fmt::Display + '_ { fn suffix(constraint: &'_ JoinConstraint) -> impl fmt::Display + '_ {
struct Suffix<'a>(&'a JoinConstraint); struct Suffix<'a>(&'a JoinConstraint);
impl<'a> fmt::Display for Suffix<'a> { impl fmt::Display for Suffix<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 { match self.0 {
JoinConstraint::On(expr) => write!(f, " ON {expr}"), JoinConstraint::On(expr) => write!(f, " ON {expr}"),

View file

@ -261,7 +261,7 @@ pub struct EscapeQuotedString<'a> {
quote: char, quote: char,
} }
impl<'a> fmt::Display for EscapeQuotedString<'a> { impl fmt::Display for EscapeQuotedString<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// EscapeQuotedString doesn't know which mode of escape was // EscapeQuotedString doesn't know which mode of escape was
// chosen by the user. So this code must to correctly display // chosen by the user. So this code must to correctly display
@ -325,7 +325,7 @@ pub fn escape_double_quote_string(s: &str) -> EscapeQuotedString<'_> {
pub struct EscapeEscapedStringLiteral<'a>(&'a str); pub struct EscapeEscapedStringLiteral<'a>(&'a str);
impl<'a> fmt::Display for EscapeEscapedStringLiteral<'a> { impl fmt::Display for EscapeEscapedStringLiteral<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.0.chars() { for c in self.0.chars() {
match c { match c {
@ -359,7 +359,7 @@ pub fn escape_escaped_string(s: &str) -> EscapeEscapedStringLiteral<'_> {
pub struct EscapeUnicodeStringLiteral<'a>(&'a str); pub struct EscapeUnicodeStringLiteral<'a>(&'a str);
impl<'a> fmt::Display for EscapeUnicodeStringLiteral<'a> { impl fmt::Display for EscapeUnicodeStringLiteral<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for c in self.0.chars() { for c in self.0.chars() {
match c { match c {

View file

@ -26,7 +26,7 @@ use crate::{
tokenizer::Token, tokenizer::Token,
}; };
impl<'a> Parser<'a> { impl Parser<'_> {
pub fn parse_alter_role(&mut self) -> Result<Statement, ParserError> { pub fn parse_alter_role(&mut self) -> Result<Statement, ParserError> {
if dialect_of!(self is PostgreSqlDialect) { if dialect_of!(self is PostgreSqlDialect) {
return self.parse_pg_alter_role(); return self.parse_pg_alter_role();

View file

@ -10883,13 +10883,12 @@ impl<'a> Parser<'a> {
Ok(ExprWithAlias { expr, alias }) Ok(ExprWithAlias { expr, alias })
} }
/// Parses an expression with an optional alias /// Parses an expression with an optional alias
///
/// Examples: /// Examples:
///
/// ```sql /// ```sql
/// SUM(price) AS total_price /// SUM(price) AS total_price
/// ``` /// ```
/// ```sql /// ```sql
/// SUM(price) /// SUM(price)
/// ``` /// ```
@ -10905,7 +10904,6 @@ impl<'a> Parser<'a> {
/// assert_eq!(Some("b".to_string()), expr_with_alias.alias.map(|x|x.value)); /// assert_eq!(Some("b".to_string()), expr_with_alias.alias.map(|x|x.value));
/// # Ok(()) /// # Ok(())
/// # } /// # }
pub fn parse_expr_with_alias(&mut self) -> Result<ExprWithAlias, ParserError> { pub fn parse_expr_with_alias(&mut self) -> Result<ExprWithAlias, ParserError> {
let expr = self.parse_expr()?; let expr = self.parse_expr()?;
let alias = if self.parse_keyword(Keyword::AS) { let alias = if self.parse_keyword(Keyword::AS) {

View file

@ -584,7 +584,7 @@ struct State<'a> {
pub col: u64, pub col: u64,
} }
impl<'a> State<'a> { impl State<'_> {
/// return the next character and advance the stream /// return the next character and advance the stream
pub fn next(&mut self) -> Option<char> { pub fn next(&mut self) -> Option<char> {
match self.peekable.next() { match self.peekable.next() {