Skip to content

Commit 36e828f

Browse files
Rollup merge of #126301 - nnethercote:sort-crate-attributes, r=davidtwco
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`). r? `@davidtwco`
2 parents ac73965 + 75b164d commit 36e828f

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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 9 additions & 7 deletions
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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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;

0 commit comments

Comments
 (0)