Skip to content

Commit 75b164d

Browse files
committed
Use tidy to sort crate attributes for all compiler crates.
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
1 parent ebcb862 commit 75b164d

File tree

58 files changed

+219
-100
lines changed

Some content is hidden

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

58 files changed

+219
-100
lines changed

compiler/rustc_abi/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
#![cfg_attr(feature = "nightly", feature(step_trait))]
1+
// tidy-alphabetical-start
22
#![cfg_attr(feature = "nightly", allow(internal_features))]
33
#![cfg_attr(feature = "nightly", doc(rust_logo))]
44
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
5+
#![cfg_attr(feature = "nightly", feature(step_trait))]
6+
// tidy-alphabetical-end
57

68
use std::fmt;
79
use std::num::{NonZeroUsize, ParseIntError};

compiler/rustc_arena/src/lib.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@
77
//!
88
//! This crate implements several kinds of arena.
99
10+
// tidy-alphabetical-start
11+
#![allow(clippy::mut_from_ref)] // Arena allocators are one place where this pattern is fine.
12+
#![allow(internal_features)]
13+
#![cfg_attr(test, feature(test))]
14+
#![deny(unsafe_op_in_unsafe_fn)]
1015
#![doc(
1116
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
1217
test(no_crate_inject, attr(deny(warnings)))
1318
)]
1419
#![doc(rust_logo)]
15-
#![feature(rustdoc_internals)]
1620
#![feature(core_intrinsics)]
21+
#![feature(decl_macro)]
1722
#![feature(dropck_eyepatch)]
18-
#![feature(new_uninit)]
1923
#![feature(maybe_uninit_slice)]
20-
#![feature(decl_macro)]
24+
#![feature(new_uninit)]
2125
#![feature(rustc_attrs)]
22-
#![cfg_attr(test, feature(test))]
26+
#![feature(rustdoc_internals)]
2327
#![feature(strict_provenance)]
24-
#![deny(unsafe_op_in_unsafe_fn)]
25-
#![allow(internal_features)]
26-
#![allow(clippy::mut_from_ref)] // Arena allocators are one of the places where this pattern is fine.
28+
// tidy-alphabetical-end
2729

2830
use smallvec::SmallVec;
2931

compiler/rustc_ast/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
//!
55
//! This API is completely unstable and subject to change.
66
7+
// tidy-alphabetical-start
8+
#![allow(internal_features)]
79
#![doc(
810
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
911
test(attr(deny(warnings)))
1012
)]
1113
#![doc(rust_logo)]
12-
#![allow(internal_features)]
13-
#![feature(rustdoc_internals)]
1414
#![feature(associated_type_defaults)]
1515
#![feature(box_patterns)]
1616
#![feature(if_let_guard)]
1717
#![feature(let_chains)]
18-
#![feature(never_type)]
1918
#![feature(negative_impls)]
19+
#![feature(never_type)]
20+
#![feature(rustdoc_internals)]
2021
#![feature(stmt_expr_attributes)]
22+
// tidy-alphabetical-end
2123

2224
pub mod util {
2325
pub mod case;

compiler/rustc_ast_ir/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// tidy-alphabetical-start
2+
#![cfg_attr(feature = "nightly", allow(internal_features))]
13
#![cfg_attr(feature = "nightly", feature(never_type))]
24
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
3-
#![cfg_attr(feature = "nightly", allow(internal_features))]
5+
// tidy-alphabetical-end
46

57
#[cfg(feature = "nightly")]
68
use rustc_macros::{Decodable, Encodable, HashStable_NoContext};

compiler/rustc_ast_lowering/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
//! get confused if the spans from leaf AST nodes occur in multiple places
3131
//! in the HIR, especially for multiple identifiers.
3232
33+
// tidy-alphabetical-start
3334
#![allow(internal_features)]
34-
#![feature(rustdoc_internals)]
3535
#![doc(rust_logo)]
3636
#![feature(assert_matches)]
3737
#![feature(box_patterns)]
3838
#![feature(let_chains)]
39+
#![feature(rustdoc_internals)]
40+
// tidy-alphabetical-end
3941

4042
use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
4143
use rustc_ast::node_id::NodeMap;

compiler/rustc_ast_passes/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
//!
55
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
66
7+
// tidy-alphabetical-start
78
#![allow(internal_features)]
89
#![doc(rust_logo)]
9-
#![feature(rustdoc_internals)]
1010
#![feature(box_patterns)]
1111
#![feature(if_let_guard)]
1212
#![feature(iter_is_partitioned)]
1313
#![feature(let_chains)]
14+
#![feature(rustdoc_internals)]
15+
// tidy-alphabetical-end
1416

1517
pub mod ast_validation;
1618
mod errors;

compiler/rustc_ast_pretty/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// tidy-alphabetical-start
12
#![allow(internal_features)]
2-
#![feature(rustdoc_internals)]
33
#![doc(rust_logo)]
44
#![feature(box_patterns)]
5+
#![feature(rustdoc_internals)]
6+
// tidy-alphabetical-end
57

68
mod helpers;
79
pub mod pp;

compiler/rustc_attr/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
//! The goal is to move the definition of `MetaItem` and things that don't need to be in `syntax`
55
//! to this crate.
66
7+
// tidy-alphabetical-start
78
#![allow(internal_features)]
8-
#![feature(rustdoc_internals)]
99
#![doc(rust_logo)]
1010
#![feature(let_chains)]
11+
#![feature(rustdoc_internals)]
12+
// tidy-alphabetical-end
1113

1214
mod builtin;
1315
mod session_diagnostics;

compiler/rustc_baked_icu_data/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
//! --cldr-tag latest --icuexport-tag latest -o src/data
2121
//! ```
2222
23+
// tidy-alphabetical-start
24+
#![allow(elided_lifetimes_in_paths)]
2325
#![allow(internal_features)]
24-
#![feature(rustdoc_internals)]
2526
#![doc(rust_logo)]
26-
#![allow(elided_lifetimes_in_paths)]
27+
#![feature(rustdoc_internals)]
28+
// tidy-alphabetical-end
2729

2830
mod data {
2931
include!("data/mod.rs");

compiler/rustc_borrowck/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This query borrow-checks the MIR to (further) ensure it is not broken.
22
3+
// tidy-alphabetical-start
34
#![allow(internal_features)]
4-
#![feature(rustdoc_internals)]
55
#![doc(rust_logo)]
66
#![feature(assert_matches)]
77
#![feature(box_patterns)]
@@ -10,8 +10,10 @@
1010
#![feature(min_specialization)]
1111
#![feature(never_type)]
1212
#![feature(rustc_attrs)]
13+
#![feature(rustdoc_internals)]
1314
#![feature(stmt_expr_attributes)]
1415
#![feature(try_blocks)]
16+
// tidy-alphabetical-end
1517

1618
#[macro_use]
1719
extern crate tracing;

compiler/rustc_builtin_macros/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! This crate contains implementations of built-in macros and other code generating facilities
22
//! injecting code into the crate before it is lowered to HIR.
33
4+
// tidy-alphabetical-start
45
#![allow(internal_features)]
56
#![allow(rustc::diagnostic_outside_of_impl)]
67
#![allow(rustc::untranslatable_diagnostic)]
7-
#![feature(rustdoc_internals)]
8-
#![doc(rust_logo)]
98
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
9+
#![doc(rust_logo)]
1010
#![feature(assert_matches)]
1111
#![feature(box_patterns)]
1212
#![feature(decl_macro)]
@@ -15,7 +15,9 @@
1515
#![feature(lint_reasons)]
1616
#![feature(proc_macro_internals)]
1717
#![feature(proc_macro_quote)]
18+
#![feature(rustdoc_internals)]
1819
#![feature(try_blocks)]
20+
// tidy-alphabetical-end
1921

2022
extern crate proc_macro;
2123

compiler/rustc_codegen_cranelift/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
// tidy-alphabetical-start
2+
#![allow(rustc::diagnostic_outside_of_impl)]
3+
#![allow(rustc::untranslatable_diagnostic)]
14
#![cfg_attr(doc, allow(internal_features))]
2-
#![cfg_attr(doc, feature(rustdoc_internals))]
35
#![cfg_attr(doc, doc(rust_logo))]
6+
#![cfg_attr(doc, feature(rustdoc_internals))]
7+
// Note: please avoid adding other feature gates where possible
48
#![feature(rustc_private)]
59
// Note: please avoid adding other feature gates where possible
6-
#![allow(rustc::diagnostic_outside_of_impl)]
7-
#![allow(rustc::untranslatable_diagnostic)]
810
#![warn(rust_2018_idioms)]
9-
#![warn(unused_lifetimes)]
1011
#![warn(unreachable_pub)]
12+
#![warn(unused_lifetimes)]
13+
// tidy-alphabetical-end
1114

1215
extern crate jobserver;
1316
#[macro_use]

compiler/rustc_codegen_llvm/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
//!
55
//! This API is completely unstable and subject to change.
66
7+
// tidy-alphabetical-start
78
#![allow(internal_features)]
8-
#![feature(rustdoc_internals)]
9-
#![doc(rust_logo)]
109
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
10+
#![doc(rust_logo)]
1111
#![feature(exact_size_is_empty)]
1212
#![feature(extern_types)]
1313
#![feature(hash_raw_entry)]
14+
#![feature(impl_trait_in_assoc_type)]
1415
#![feature(iter_intersperse)]
1516
#![feature(let_chains)]
16-
#![feature(impl_trait_in_assoc_type)]
17+
#![feature(rustdoc_internals)]
18+
// tidy-alphabetical-end
1719

1820
use back::owned_target_machine::OwnedTargetMachine;
1921
use back::write::{create_informational_target_machine, create_target_machine};

compiler/rustc_codegen_ssa/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
2-
#![doc(rust_logo)]
3-
#![feature(rustdoc_internals)]
1+
// tidy-alphabetical-start
42
#![allow(internal_features)]
53
#![allow(rustc::diagnostic_outside_of_impl)]
64
#![allow(rustc::untranslatable_diagnostic)]
5+
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
6+
#![doc(rust_logo)]
77
#![feature(box_patterns)]
88
#![feature(if_let_guard)]
99
#![feature(let_chains)]
1010
#![feature(negative_impls)]
11+
#![feature(rustdoc_internals)]
1112
#![feature(strict_provenance)]
1213
#![feature(try_blocks)]
14+
// tidy-alphabetical-end
1315

1416
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
1517
//! The backend-agnostic functions of this crate use functions defined in various traits that

compiler/rustc_const_eval/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1+
// tidy-alphabetical-start
12
#![allow(internal_features)]
23
#![allow(rustc::diagnostic_outside_of_impl)]
3-
#![feature(rustdoc_internals)]
44
#![doc(rust_logo)]
55
#![feature(assert_matches)]
66
#![feature(box_patterns)]
77
#![feature(decl_macro)]
8+
#![feature(if_let_guard)]
89
#![feature(let_chains)]
10+
#![feature(never_type)]
11+
#![feature(rustdoc_internals)]
912
#![feature(slice_ptr_get)]
1013
#![feature(strict_provenance)]
11-
#![feature(never_type)]
1214
#![feature(trait_alias)]
1315
#![feature(try_blocks)]
1416
#![feature(yeet_expr)]
15-
#![feature(if_let_guard)]
17+
// tidy-alphabetical-end
1618

1719
pub mod check_consts;
1820
pub mod const_eval;

compiler/rustc_driver/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// This crate is intentionally empty and a re-export of `rustc_driver_impl` to allow the code in
22
// `rustc_driver_impl` to be compiled in parallel with other crates.
33

4+
// tidy-alphabetical-start
45
#![allow(internal_features)]
5-
#![feature(rustdoc_internals)]
66
#![doc(rust_logo)]
7+
#![feature(rustdoc_internals)]
8+
// tidy-alphabetical-end
79

810
pub use rustc_driver_impl::*;

compiler/rustc_driver_impl/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
//!
55
//! This API is completely unstable and subject to change.
66
7+
// tidy-alphabetical-start
8+
#![allow(internal_features)]
79
#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
810
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
911
#![doc(rust_logo)]
10-
#![feature(rustdoc_internals)]
11-
#![allow(internal_features)]
1212
#![feature(decl_macro)]
1313
#![feature(let_chains)]
1414
#![feature(panic_backtrace_config)]
1515
#![feature(panic_update_hook)]
1616
#![feature(result_flattening)]
17+
#![feature(rustdoc_internals)]
18+
// tidy-alphabetical-end
1719

1820
use rustc_ast as ast;
1921
use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};

compiler/rustc_error_codes/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! This library is used to gather all error codes into one place, to make
22
//! their maintenance easier.
33
4+
// tidy-alphabetical-start
45
#![allow(internal_features)]
5-
#![feature(rustdoc_internals)]
6-
#![doc(rust_logo)]
76
#![deny(rustdoc::invalid_codeblock_attributes)]
7+
#![doc(rust_logo)]
8+
#![feature(rustdoc_internals)]
9+
// tidy-alphabetical-end
810

911
// This higher-order macro defines the error codes that are in use. It is used
1012
// in the `rustc_errors` crate. Removed error codes are listed in the comment

compiler/rustc_error_messages/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// tidy-alphabetical-start
2+
#![allow(internal_features)]
13
#![doc(rust_logo)]
2-
#![feature(rustdoc_internals)]
34
#![feature(rustc_attrs)]
5+
#![feature(rustdoc_internals)]
46
#![feature(type_alias_impl_trait)]
5-
#![allow(internal_features)]
7+
// tidy-alphabetical-end
68

79
use fluent_bundle::FluentResource;
810
use fluent_syntax::parser::ParserError;

compiler/rustc_feature/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
//! even if it is stabilized or removed, *do not remove it*. Instead, move the
1212
//! symbol to the `accepted` or `removed` modules respectively.
1313
14+
// tidy-alphabetical-start
1415
#![allow(internal_features)]
15-
#![feature(rustdoc_internals)]
1616
#![doc(rust_logo)]
17+
#![feature(rustdoc_internals)]
18+
// tidy-alphabetical-end
1719

1820
mod accepted;
1921
mod builtin_attrs;

compiler/rustc_fluent_macro/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// tidy-alphabetical-start
2+
#![allow(internal_features)]
3+
#![allow(rustc::default_hash_types)]
14
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
25
#![doc(rust_logo)]
3-
#![allow(internal_features)]
4-
#![feature(rustdoc_internals)]
56
#![feature(proc_macro_diagnostic)]
67
#![feature(proc_macro_span)]
7-
#![allow(rustc::default_hash_types)]
8+
#![feature(rustdoc_internals)]
9+
// tidy-alphabetical-end
810

911
use proc_macro::TokenStream;
1012

compiler/rustc_fs_util/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// tidy-alphabetical-start
12
use std::ffi::CString;
23
use std::fs;
34
use std::io;
45
use std::path::{absolute, Path, PathBuf};
6+
// tidy-alphabetical-end
57

68
// Unfortunately, on windows, it looks like msvcrt.dll is silently translating
79
// verbatim paths under the hood to non-verbatim paths! This manifests itself as

0 commit comments

Comments
 (0)