Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings on rust 1.83 #1570

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/ast/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,15 +1327,18 @@ pub enum ColumnOption {
/// `DEFAULT <restricted-expr>`
Default(Expr),

/// ClickHouse supports `MATERIALIZE`, `EPHEMERAL` and `ALIAS` expr to generate default values.
/// `MATERIALIZE <expr>`
/// Syntax: `b INT MATERIALIZE (a + 1)`
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)

/// `MATERIALIZE <expr>`
Materialized(Expr),
/// `EPHEMERAL [<expr>]`
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)
Ephemeral(Option<Expr>),
/// `ALIAS <expr>`
///
/// [ClickHouse](https://clickhouse.com/docs/en/sql-reference/statements/create/table#default_values)
Alias(Expr),

/// `{ PRIMARY KEY | UNIQUE } [<constraint_characteristics>]`
Expand Down Expand Up @@ -1552,7 +1555,7 @@ pub enum GeneratedExpressionMode {
#[must_use]
fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
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 {
if let Some(name) = self.0 {
write!(f, "CONSTRAINT {name} ")?;
Expand All @@ -1573,7 +1576,7 @@ fn display_option<'a, T: fmt::Display>(
option: &'a Option<T>,
) -> impl fmt::Display + 'a {
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 {
if let Some(inner) = self.2 {
let (prefix, postfix) = (self.0, self.1);
Expand Down
2 changes: 1 addition & 1 deletion src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ where
sep: &'static str,
}

impl<'a, T> fmt::Display for DisplaySeparated<'a, T>
impl<T> fmt::Display for DisplaySeparated<'_, T>
where
T: fmt::Display,
{
Expand Down
2 changes: 1 addition & 1 deletion src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ impl fmt::Display for Join {
}
fn suffix(constraint: &'_ JoinConstraint) -> impl fmt::Display + '_ {
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 {
match self.0 {
JoinConstraint::On(expr) => write!(f, " ON {expr}"),
Expand Down
6 changes: 3 additions & 3 deletions src/ast/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub struct EscapeQuotedString<'a> {
quote: char,
}

impl<'a> fmt::Display for EscapeQuotedString<'a> {
impl fmt::Display for EscapeQuotedString<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// EscapeQuotedString doesn't know which mode of escape was
// chosen by the user. So this code must to correctly display
Expand Down Expand Up @@ -325,7 +325,7 @@ pub fn escape_double_quote_string(s: &str) -> EscapeQuotedString<'_> {

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 {
for c in self.0.chars() {
match c {
Expand Down Expand Up @@ -359,7 +359,7 @@ pub fn escape_escaped_string(s: &str) -> EscapeEscapedStringLiteral<'_> {

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 {
for c in self.0.chars() {
match c {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
tokenizer::Token,
};

impl<'a> Parser<'a> {
impl Parser<'_> {
pub fn parse_alter_role(&mut self) -> Result<Statement, ParserError> {
if dialect_of!(self is PostgreSqlDialect) {
return self.parse_pg_alter_role();
Expand Down
6 changes: 2 additions & 4 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10883,13 +10883,12 @@ impl<'a> Parser<'a> {
Ok(ExprWithAlias { expr, alias })
}
/// Parses an expression with an optional alias

///
/// Examples:

///
/// ```sql
/// SUM(price) AS total_price
/// ```

/// ```sql
/// SUM(price)
/// ```
Expand All @@ -10905,7 +10904,6 @@ impl<'a> Parser<'a> {
/// assert_eq!(Some("b".to_string()), expr_with_alias.alias.map(|x|x.value));
/// # Ok(())
/// # }

pub fn parse_expr_with_alias(&mut self) -> Result<ExprWithAlias, ParserError> {
let expr = self.parse_expr()?;
let alias = if self.parse_keyword(Keyword::AS) {
Expand Down
2 changes: 1 addition & 1 deletion src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ struct State<'a> {
pub col: u64,
}

impl<'a> State<'a> {
impl State<'_> {
/// return the next character and advance the stream
pub fn next(&mut self) -> Option<char> {
match self.peekable.next() {
Expand Down