Skip to content

Commit 8f0fb9e

Browse files
authored
chore: rust 2024 (#224)
* chore: rust 2024 * chore: rust 2024 * fixes * fixes * fixes * fixes * fixes * fixes * fixes * fix: format * fix: toolchain * regen * more fixes * more fixes * more fixes * more fixes * more fixes * more fixes * fix * more fixes * more fixes * fix: config
1 parent 2ed3129 commit 8f0fb9e

File tree

121 files changed

+545
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+545
-474
lines changed

Cargo.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ resolver = "2"
55
[workspace.package]
66
authors = ["Supabase Communnity"]
77
categories = ["development-tools", "postgres", "supabase"]
8-
edition = "2021"
8+
edition = "2024"
99
homepage = "https://supabase.com/"
1010
keywords = ["linter", "typechecker", "postgres", "language-server"]
1111
license = "MIT"
1212
repository = "https://github.com/supabase-community/postgres_lsp"
13-
rust-version = "1.82.0"
13+
rust-version = "1.85.0"
1414

1515
[workspace.dependencies]
1616
# supporting crates unrelated to postgres
@@ -31,7 +31,7 @@ quote = "1.0.33"
3131
rayon = "1.10.0"
3232
regex = "1.11.1"
3333
rustc-hash = "2.0.0"
34-
schemars = { version = "0.8.21", features = ["indexmap2", "smallvec"] }
34+
schemars = { version = "0.8.22", features = ["indexmap2", "smallvec"] }
3535
serde = "1.0.195"
3636
serde_json = "1.0.114"
3737
similar = "2.6.0"

crates/pglt_analyse/src/categories.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use enumflags2::{bitflags, BitFlags};
1+
use enumflags2::{BitFlags, bitflags};
22
use std::borrow::Cow;
33

44
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -288,8 +288,8 @@ impl schemars::JsonSchema for RuleCategories {
288288
String::from("RuleCategories")
289289
}
290290

291-
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
292-
<Vec<RuleCategory>>::json_schema(gen)
291+
fn json_schema(r#gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
292+
<Vec<RuleCategory>>::json_schema(r#gen)
293293
}
294294
}
295295

crates/pglt_analyse/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use pglt_diagnostics::category_concat;
1111

1212
pub use crate::categories::{
1313
ActionCategory, RefactorKind, RuleCategories, RuleCategoriesBuilder, RuleCategory,
14-
SourceActionKind, SUPPRESSION_ACTION_CATEGORY,
14+
SUPPRESSION_ACTION_CATEGORY, SourceActionKind,
1515
};
1616
pub use crate::filter::{AnalysisFilter, GroupKey, RuleFilter, RuleKey};
1717
pub use crate::options::{AnalyserOptions, AnalyserRules};

crates/pglt_analyse/src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ macro_rules! declare_lint_rule {
2424
( $( #[doc = $doc:literal] )+ $vis:vis $id:ident {
2525
version: $version:literal,
2626
name: $name:tt,
27-
$( $key:ident: $value:expr, )*
27+
$( $key:ident: $value:expr_2021, )*
2828
} ) => {
2929

3030
pglt_analyse::declare_rule!(
@@ -53,7 +53,7 @@ macro_rules! declare_rule {
5353
( $( #[doc = $doc:literal] )+ $vis:vis $id:ident {
5454
version: $version:literal,
5555
name: $name:tt,
56-
$( $key:ident: $value:expr, )*
56+
$( $key:ident: $value:expr_2021, )*
5757
} ) => {
5858
$( #[doc = $doc] )*
5959
$vis enum $id {}

crates/pglt_analyse/src/registry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::{borrow, collections::BTreeSet};
22

33
use crate::{
4+
AnalyserOptions,
45
context::RuleContext,
56
filter::{AnalysisFilter, GroupKey, RuleKey},
67
rule::{GroupCategory, Rule, RuleDiagnostic, RuleGroup},
7-
AnalyserOptions,
88
};
99

1010
pub trait RegistryVisitor {

crates/pglt_analyse/src/rule.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pglt_console::fmt::Display;
2-
use pglt_console::{markup, MarkupBuf};
2+
use pglt_console::{MarkupBuf, markup};
33
use pglt_diagnostics::advice::CodeSuggestionAdvice;
44
use pglt_diagnostics::{
55
Advices, Category, Diagnostic, DiagnosticTags, Location, LogCategory, MessageAndDescription,

crates/pglt_analyser/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ mod tests {
7272

7373
use pglt_analyse::{AnalyserOptions, AnalysisFilter, RuleFilter};
7474
use pglt_console::{
75+
Markup,
7576
fmt::{Formatter, Termcolor},
76-
markup, Markup,
77+
markup,
7778
};
7879
use pglt_diagnostics::PrintDiagnostic;
7980
use termcolor::NoColor;

crates/pglt_analyser/src/lint/safety/adding_required_field.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pglt_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource};
1+
use pglt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule};
22
use pglt_console::markup;
33

44
declare_lint_rule! {

crates/pglt_analyser/src/lint/safety/ban_drop_column.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pglt_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource};
1+
use pglt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule};
22
use pglt_console::markup;
33

44
declare_lint_rule! {

crates/pglt_analyser/src/lint/safety/ban_drop_not_null.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pglt_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource};
1+
use pglt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule};
22
use pglt_console::markup;
33

44
declare_lint_rule! {

crates/pglt_analyser/src/lint/safety/ban_drop_table.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use pglt_analyse::{context::RuleContext, declare_lint_rule, Rule, RuleDiagnostic, RuleSource};
1+
use pglt_analyse::{Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule};
22
use pglt_console::markup;
33

44
declare_lint_rule! {

crates/pglt_cli/src/changed.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ pub(crate) fn get_changed_files(
1818
(Some(since), Some(_)) => since,
1919
(Some(since), None) => since,
2020
(None, Some(branch)) => branch,
21-
(None, None) => return Err(CliDiagnostic::incompatible_end_configuration("The `--changed` flag was set, but couldn't determine the base to compare against. Either set configuration.vcs.default_branch or use the --since argument.")),
21+
(None, None) => {
22+
return Err(CliDiagnostic::incompatible_end_configuration(
23+
"The `--changed` flag was set, but couldn't determine the base to compare against. Either set configuration.vcs.default_branch or use the --since argument.",
24+
));
25+
}
2226
};
2327

2428
let changed_files = fs.get_changed_files(base)?;

crates/pglt_cli/src/cli_options.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::logging::LoggingKind;
21
use crate::LoggingLevel;
2+
use crate::logging::LoggingKind;
33
use bpaf::Bpaf;
44
use pglt_configuration::ConfigurationPathHint;
55
use pglt_diagnostics::Severity;
@@ -208,7 +208,10 @@ impl FromStr for MaxDiagnostics {
208208
if let Ok(value) = s.parse::<u32>() {
209209
Ok(MaxDiagnostics::Limit(value))
210210
} else {
211-
Err(format!("Invalid value provided. Provide 'none' to lift the limit, or a number between 0 and {}.", u32::MAX))
211+
Err(format!(
212+
"Invalid value provided. Provide 'none' to lift the limit, or a number between 0 and {}.",
213+
u32::MAX
214+
))
212215
}
213216
}
214217
}

crates/pglt_cli/src/commands/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use biome_deserialize::Merge;
44
use pglt_configuration::PartialConfiguration;
55
use pglt_console::Console;
66
use pglt_fs::FileSystem;
7-
use pglt_workspace::{configuration::LoadedConfiguration, DynRef, Workspace, WorkspaceError};
7+
use pglt_workspace::{DynRef, Workspace, WorkspaceError, configuration::LoadedConfiguration};
88
use std::ffi::OsString;
99

10-
use super::{get_files_to_process_with_cli_options, CommandRunner};
10+
use super::{CommandRunner, get_files_to_process_with_cli_options};
1111

1212
pub(crate) struct CheckCommandPayload {
1313
pub(crate) configuration: Option<PartialConfiguration>,

crates/pglt_cli/src/commands/daemon.rs

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
use crate::{
2-
open_transport,
2+
CliDiagnostic, CliSession, open_transport,
33
service::{self, ensure_daemon, open_socket, run_daemon},
4-
CliDiagnostic, CliSession,
54
};
6-
use pglt_console::{markup, ConsoleExt};
5+
use pglt_console::{ConsoleExt, markup};
76
use pglt_lsp::ServerFactory;
8-
use pglt_workspace::{workspace::WorkspaceClient, TransportError, WorkspaceError};
7+
use pglt_workspace::{TransportError, WorkspaceError, workspace::WorkspaceClient};
98
use std::{env, fs, path::PathBuf};
109
use tokio::io;
1110
use tokio::runtime::Runtime;
1211
use tracing::subscriber::Interest;
13-
use tracing::{debug_span, metadata::LevelFilter, Instrument, Metadata};
12+
use tracing::{Instrument, Metadata, debug_span, metadata::LevelFilter};
1413
use tracing_appender::rolling::Rotation;
1514
use tracing_subscriber::{
15+
Layer,
1616
layer::{Context, Filter},
1717
prelude::*,
18-
registry, Layer,
18+
registry,
1919
};
2020
use tracing_tree::HierarchicalLayer;
2121

@@ -49,22 +49,25 @@ pub(crate) fn start(
4949
pub(crate) fn stop(session: CliSession) -> Result<(), CliDiagnostic> {
5050
let rt = Runtime::new()?;
5151

52-
if let Some(transport) = open_transport(rt)? {
53-
let client = WorkspaceClient::new(transport)?;
54-
match client.shutdown() {
55-
// The `ChannelClosed` error is expected since the server can
56-
// shutdown before sending a response
57-
Ok(()) | Err(WorkspaceError::TransportError(TransportError::ChannelClosed)) => {}
58-
Err(err) => return Err(CliDiagnostic::from(err)),
59-
};
52+
match open_transport(rt)? {
53+
Some(transport) => {
54+
let client = WorkspaceClient::new(transport)?;
55+
match client.shutdown() {
56+
// The `ChannelClosed` error is expected since the server can
57+
// shutdown before sending a response
58+
Ok(()) | Err(WorkspaceError::TransportError(TransportError::ChannelClosed)) => {}
59+
Err(err) => return Err(CliDiagnostic::from(err)),
60+
};
6061

61-
session.app.console.log(markup! {
62-
"The server was successfully stopped"
63-
});
64-
} else {
65-
session.app.console.log(markup! {
66-
"The server was not running"
67-
});
62+
session.app.console.log(markup! {
63+
"The server was successfully stopped"
64+
});
65+
}
66+
_ => {
67+
session.app.console.log(markup! {
68+
"The server was not running"
69+
});
70+
}
6871
}
6972

7073
Ok(())

crates/pglt_cli/src/commands/init.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{CliDiagnostic, CliSession};
22
use pglt_configuration::PartialConfiguration;
3-
use pglt_console::{markup, ConsoleExt};
3+
use pglt_console::{ConsoleExt, markup};
44
use pglt_fs::ConfigName;
55
use pglt_workspace::configuration::create_config;
66

crates/pglt_cli/src/commands/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use crate::changed::{get_changed_files, get_staged_files};
2-
use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg};
2+
use crate::cli_options::{CliOptions, CliReporter, ColorsArg, cli_options};
33
use crate::execute::Stdin;
44
use crate::logging::LoggingKind;
55
use crate::{
6-
execute_mode, setup_cli_subscriber, CliDiagnostic, CliSession, Execution, LoggingLevel, VERSION,
6+
CliDiagnostic, CliSession, Execution, LoggingLevel, VERSION, execute_mode, setup_cli_subscriber,
77
};
88
use bpaf::Bpaf;
9-
use pglt_configuration::{partial_configuration, PartialConfiguration};
9+
use pglt_configuration::{PartialConfiguration, partial_configuration};
1010
use pglt_console::Console;
1111
use pglt_fs::FileSystem;
12-
use pglt_workspace::configuration::{load_configuration, LoadedConfiguration};
12+
use pglt_workspace::configuration::{LoadedConfiguration, load_configuration};
1313
use pglt_workspace::settings::PartialConfigurationExt;
1414
use pglt_workspace::workspace::UpdateSettingsParams;
1515
use pglt_workspace::{DynRef, Workspace, WorkspaceError};
@@ -183,7 +183,7 @@ impl PgltCommand {
183183
| PgltCommand::Stop
184184
| PgltCommand::Init
185185
| PgltCommand::RunServer { .. }
186-
| PgltCommand::Clean { .. }
186+
| PgltCommand::Clean
187187
| PgltCommand::PrintSocket => None,
188188
}
189189
}

crates/pglt_cli/src/commands/version.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use pglt_console::fmt::Formatter;
2-
use pglt_console::{fmt, markup, ConsoleExt};
2+
use pglt_console::{ConsoleExt, fmt, markup};
33
use pglt_workspace::workspace::ServerInfo;
44

55
use crate::{CliDiagnostic, CliSession, VERSION};

crates/pglt_cli/src/execute/mod.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ mod std_in;
44
pub(crate) mod traverse;
55

66
use crate::cli_options::{CliOptions, CliReporter};
7-
use crate::execute::traverse::{traverse, TraverseResult};
7+
use crate::execute::traverse::{TraverseResult, traverse};
88
use crate::reporter::github::{GithubReporter, GithubReporterVisitor};
99
use crate::reporter::gitlab::{GitLabReporter, GitLabReporterVisitor};
1010
use crate::reporter::junit::{JunitReporter, JunitReporterVisitor};
1111
use crate::reporter::terminal::{ConsoleReporter, ConsoleReporterVisitor};
1212
use crate::{CliDiagnostic, CliSession, DiagnosticsPayload, Reporter};
13-
use pglt_diagnostics::{category, Category};
13+
use pglt_diagnostics::{Category, category};
1414
use pglt_fs::PgLTPath;
1515
use std::borrow::Borrow;
1616
use std::ffi::OsString;
@@ -103,7 +103,7 @@ pub enum TraversalMode {
103103
impl Display for TraversalMode {
104104
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
105105
match self {
106-
TraversalMode::Dummy { .. } => write!(f, "dummy"),
106+
TraversalMode::Dummy => write!(f, "dummy"),
107107
TraversalMode::Check { .. } => write!(f, "check"),
108108
}
109109
}
@@ -165,33 +165,33 @@ impl Execution {
165165

166166
pub(crate) fn as_diagnostic_category(&self) -> &'static Category {
167167
match self.traversal_mode {
168-
TraversalMode::Dummy { .. } => category!("dummy"),
168+
TraversalMode::Dummy => category!("dummy"),
169169
TraversalMode::Check { .. } => category!("check"),
170170
}
171171
}
172172

173173
pub(crate) const fn is_dummy(&self) -> bool {
174-
matches!(self.traversal_mode, TraversalMode::Dummy { .. })
174+
matches!(self.traversal_mode, TraversalMode::Dummy)
175175
}
176176

177177
/// Whether the traversal mode requires write access to files
178178
pub(crate) const fn requires_write_access(&self) -> bool {
179179
match self.traversal_mode {
180-
TraversalMode::Dummy { .. } => false,
180+
TraversalMode::Dummy => false,
181181
TraversalMode::Check { .. } => false,
182182
}
183183
}
184184

185185
pub(crate) fn as_stdin_file(&self) -> Option<&Stdin> {
186186
match &self.traversal_mode {
187-
TraversalMode::Dummy { .. } => None,
187+
TraversalMode::Dummy => None,
188188
TraversalMode::Check { stdin, .. } => stdin.as_ref(),
189189
}
190190
}
191191

192192
pub(crate) fn is_vcs_targeted(&self) -> bool {
193193
match &self.traversal_mode {
194-
TraversalMode::Dummy { .. } => false,
194+
TraversalMode::Dummy => false,
195195
TraversalMode::Check { vcs_targeted, .. } => {
196196
vcs_targeted.staged || vcs_targeted.changed
197197
}
@@ -205,7 +205,7 @@ impl Execution {
205205
/// Returns [true] if the user used the `--write`/`--fix` option
206206
pub(crate) fn is_write(&self) -> bool {
207207
match self.traversal_mode {
208-
TraversalMode::Dummy { .. } => false,
208+
TraversalMode::Dummy => false,
209209
TraversalMode::Check { .. } => false,
210210
}
211211
}
@@ -223,7 +223,10 @@ pub fn execute_mode(
223223
execution.max_diagnostics = if cli_options.reporter.is_default() {
224224
cli_options.max_diagnostics.into()
225225
} else {
226-
info!("Removing the limit of --max-diagnostics, because of a reporter different from the default one: {}", cli_options.reporter);
226+
info!(
227+
"Removing the limit of --max-diagnostics, because of a reporter different from the default one: {}",
228+
cli_options.reporter
229+
);
227230
u32::MAX
228231
};
229232

0 commit comments

Comments
 (0)