Auto merge of #116477 - nnethercote:tidy-alpha-deps, r=wesleywiser

Use tidy to enforce alphabetical dependency ordering

I get annoyed when dependencies in `Cargo.toml` files are not in alphabetical order. The [style guide](https://github.com/rust-lang/rust/blob/master/src/doc/style-guide/src/cargo.md) agrees with me.

There are ongoing efforts to provide linting/formatting of `Cargo.toml` files, e.g. https://github.com/rust-lang/rustfmt/pull/5240, https://crates.io/crates/cargo-toml-lint, and https://github.com/TimonPost/cargo-toml-format. But it's far from clear what's the right approach.

So this PR does something very simple: it uses the order checking already present in tidy. This allows incremental application of ordering, starting right now, and avoiding the need for any kind of all-at-once conversion.

If we do end up using some more comprehensive `Cargo.toml` linting/formatting solution in the future, the `tidy-alphabetical` lines will be easy to remove.

r? `@wesleywiser`
This commit is contained in:
bors 2023-10-17 02:48:03 +00:00
commit c07693c160
2 changed files with 30 additions and 28 deletions

View File

@ -6,53 +6,55 @@ edition = "2021"
[lib] [lib]
[dependencies] [dependencies]
time = { version = "0.3", default-features = false, features = ["formatting", ] } # tidy-alphabetical-start
tracing = { version = "0.1.35" } rustc_ast = { path = "../rustc_ast" }
serde_json = "1.0.59"
rustc_log = { path = "../rustc_log" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" } rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" } rustc_ast_passes = { path = "../rustc_ast_passes" }
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
rustc_attr = { path = "../rustc_attr" } rustc_attr = { path = "../rustc_attr" }
rustc_borrowck = { path = "../rustc_borrowck" } rustc_borrowck = { path = "../rustc_borrowck" }
rustc_builtin_macros = { path = "../rustc_builtin_macros" } rustc_builtin_macros = { path = "../rustc_builtin_macros" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_const_eval = { path = "../rustc_const_eval" } rustc_const_eval = { path = "../rustc_const_eval" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_codes = { path = "../rustc_error_codes" }
rustc_error_messages = { path = "../rustc_error_messages" } rustc_error_messages = { path = "../rustc_error_messages" }
rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }
rustc_hir_typeck = { path = "../rustc_hir_typeck" } rustc_feature = { path = "../rustc_feature" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" } rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_hir = { path = "../rustc_hir" }
rustc_hir_analysis = { path = "../rustc_hir_analysis" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_hir_typeck = { path = "../rustc_hir_typeck" }
rustc_incremental = { path = "../rustc_incremental" } rustc_incremental = { path = "../rustc_incremental" }
rustc_infer = { path = "../rustc_infer" } rustc_infer = { path = "../rustc_infer" }
rustc_interface = { path = "../rustc_interface" }
rustc_lint = { path = "../rustc_lint" }
rustc_log = { path = "../rustc_log" }
rustc_macros = { path = "../rustc_macros" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_middle = { path = "../rustc_middle" }
rustc_mir_build = { path = "../rustc_mir_build" } rustc_mir_build = { path = "../rustc_mir_build" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" } rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_mir_transform = { path = "../rustc_mir_transform" }
rustc_monomorphize = { path = "../rustc_monomorphize" } rustc_monomorphize = { path = "../rustc_monomorphize" }
rustc_parse = { path = "../rustc_parse" }
rustc_passes = { path = "../rustc_passes" } rustc_passes = { path = "../rustc_passes" }
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
rustc_privacy = { path = "../rustc_privacy" } rustc_privacy = { path = "../rustc_privacy" }
rustc_query_system = { path = "../rustc_query_system" } rustc_query_system = { path = "../rustc_query_system" }
rustc_resolve = { path = "../rustc_resolve" } rustc_resolve = { path = "../rustc_resolve" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_symbol_mangling = { path = "../rustc_symbol_mangling" } rustc_symbol_mangling = { path = "../rustc_symbol_mangling" }
rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" } rustc_ty_utils = { path = "../rustc_ty_utils" }
rustc_middle = { path = "../rustc_middle" } serde_json = "1.0.59"
rustc_ast_pretty = { path = "../rustc_ast_pretty" } time = { version = "0.3", default-features = false, features = ["formatting", ] }
rustc_target = { path = "../rustc_target" } tracing = { version = "0.1.35" }
rustc_lint = { path = "../rustc_lint" } # tidy-alphabetical-end
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
rustc_hir = { path = "../rustc_hir" }
rustc_hir_pretty = { path = "../rustc_hir_pretty" }
rustc_macros = { path = "../rustc_macros" }
rustc_metadata = { path = "../rustc_metadata" }
rustc_parse = { path = "../rustc_parse" }
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_session = { path = "../rustc_session" }
rustc_error_codes = { path = "../rustc_error_codes" }
rustc_interface = { path = "../rustc_interface" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
rustc_hir_analysis = { path = "../rustc_hir_analysis" }
rustc_mir_transform = { path = "../rustc_mir_transform" }
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
libc = "0.2" libc = "0.2"

View File

@ -30,8 +30,8 @@ fn is_close_bracket(c: char) -> bool {
} }
// Don't let tidy check this here :D // Don't let tidy check this here :D
const START_COMMENT: &str = concat!("// tidy-alphabetical", "-start"); const START_COMMENT: &str = concat!("tidy-alphabetical", "-start");
const END_COMMENT: &str = "// tidy-alphabetical-end"; const END_COMMENT: &str = "tidy-alphabetical-end";
fn check_section<'a>( fn check_section<'a>(
file: impl Display, file: impl Display,