Skip to content

Commit 9824971

Browse files
authored
Unrolled build for #143110
Rollup merge of #143110 - yotamofek:pr/tidy-sort-for-symbols, r=nnethercote Use tidy to sort `sym::*` items Use tidy to sort the symbols in the invocation of `symbols!`, instead of implementing the ordering check inside the proc macro. (asked `````@nnethercote````` about this on zulip, he didn't have any reservations about making this change) This has a couple of benefits: - tidy's "version sort" (thanks to #141311 !) is nicer than the naive-cmp sort, so, e.g. `AtomicI{8, 16, 32, 64, 128}` are properly sorted by bit width. - consistency with the rest of the repo - allows us to remove a bit of order-verifying code from the `symbols!` proc macro impl
2 parents 11ad40b + 00b64f8 commit 9824971

File tree

3 files changed

+64
-94
lines changed

3 files changed

+64
-94
lines changed

compiler/rustc_macros/src/symbols.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,6 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
190190
let mut symbols_stream = quote! {};
191191
let mut prefill_stream = quote! {};
192192
let mut entries = Entries::with_capacity(input.keywords.len() + input.symbols.len() + 10);
193-
let mut prev_key: Option<(Span, String)> = None;
194-
195-
let mut check_order = |span: Span, s: &str, errors: &mut Errors| {
196-
if let Some((prev_span, ref prev_str)) = prev_key {
197-
if s < prev_str {
198-
errors.error(span, format!("Symbol `{s}` must precede `{prev_str}`"));
199-
errors.error(prev_span, format!("location of previous symbol `{prev_str}`"));
200-
}
201-
}
202-
prev_key = Some((span, s.to_string()));
203-
};
204193

205194
// Generate the listed keywords.
206195
for keyword in input.keywords.iter() {
@@ -219,7 +208,6 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
219208
// Generate the listed symbols.
220209
for symbol in input.symbols.iter() {
221210
let name = &symbol.name;
222-
check_order(symbol.name.span(), &name.to_string(), &mut errors);
223211

224212
let value = match &symbol.value {
225213
Value::SameAsName => name.to_string(),

compiler/rustc_macros/src/symbols/tests.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,3 @@ fn check_dup_symbol_and_keyword() {
8484
};
8585
test_symbols_macro(input, &["Symbol `splat` is duplicated", "location of previous definition"]);
8686
}
87-
88-
#[test]
89-
fn check_symbol_order() {
90-
let input = quote! {
91-
Keywords {}
92-
Symbols {
93-
zebra,
94-
aardvark,
95-
}
96-
};
97-
test_symbols_macro(
98-
input,
99-
&["Symbol `aardvark` must precede `zebra`", "location of previous symbol `zebra`"],
100-
);
101-
}

0 commit comments

Comments
 (0)