diff --git a/Cargo.lock b/Cargo.lock index 2d16515500878..b56b92217a1de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4355,6 +4355,7 @@ version = "0.0.0" dependencies = [ "fluent-bundle", "fluent-syntax", + "indexmap", "proc-macro2", "quote", "syn", diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 214d653d23c13..0598fbfad6e4d 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -641,7 +641,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // Unlike all the other GC helpers where we check if an `AllocId` is found in the interpreter or // is live, here all the IDs in the map are for dead allocations so we don't // need to check for liveness. - #[allow(rustc::potential_query_instability)] // Only used from Miri, not queries. self.memory.dead_alloc_map.retain(|id, _| reachable_allocs.contains(id)); } } diff --git a/compiler/rustc_macros/Cargo.toml b/compiler/rustc_macros/Cargo.toml index f097aee54abb6..8f52685eb1975 100644 --- a/compiler/rustc_macros/Cargo.toml +++ b/compiler/rustc_macros/Cargo.toml @@ -10,6 +10,7 @@ proc-macro = true # tidy-alphabetical-start fluent-bundle = "0.16" fluent-syntax = "0.12" +indexmap = "2.4.0" proc-macro2 = "1" quote = "1" syn = { version = "2.0.9", features = ["full"] } diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs index 094736e94870b..63561e409b0ae 100644 --- a/compiler/rustc_macros/src/diagnostics/message.rs +++ b/compiler/rustc_macros/src/diagnostics/message.rs @@ -1,7 +1,8 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use fluent_bundle::FluentResource; use fluent_syntax::ast::{Expression, InlineExpression, Pattern, PatternElement}; +use indexmap::IndexMap; use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::ext::IdentExt; @@ -17,9 +18,6 @@ pub(crate) struct Message { } impl Message { - // About `allow(rustc::potential_query_instability)`: The order of key/values of `fields` and - // `field_map` doesn't matters. - #[allow(rustc::potential_query_instability)] pub(crate) fn new( attr_span: Span, message_span: Span, @@ -36,8 +34,8 @@ impl Message { panic!("Did not parse into a message") }; - let mut fields: HashMap = - HashMap::with_capacity(field_map.len()); + let mut fields: IndexMap = + IndexMap::with_capacity(field_map.len()); for (_, (ident, _)) in field_map { fields.insert(ident.unraw().to_string(), (ident, false)); } diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index f9ef016a16af6..c99575ff7431d 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -92,8 +92,6 @@ impl SubdiagnosticDerive { let diag = &self.diag; - // FIXME(edition_2024): Fix the `keyword_idents_2024` lint to not trigger here? - #[allow(keyword_idents_2024)] let ret = structure.gen_impl(quote! { gen impl rustc_errors::Subdiagnostic for @Self { fn add_to_diag<__G>( diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index b65e39469ec51..3cace48e3fb27 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -1,8 +1,9 @@ use std::cell::RefCell; -use std::collections::{BTreeSet, HashMap, HashSet}; +use std::collections::{BTreeSet, HashSet}; use std::fmt; use std::str::FromStr; +use indexmap::IndexMap; use proc_macro::Span; use proc_macro2::{Ident, TokenStream}; use quote::{ToTokens, format_ident, quote}; @@ -260,7 +261,7 @@ impl SetOnce for SpannedOption { } } -pub(super) type FieldMap = HashMap; +pub(super) type FieldMap = IndexMap; /// In the strings in the attributes supplied to this macro, we want callers to be able to /// reference fields in the format string. For example: diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index 8624e0524b04e..399f20ebfe1eb 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -1,5 +1,12 @@ // tidy-alphabetical-start -#![allow(rustc::default_hash_types)] +#![allow( + rustc::default_hash_types, + reason = "we like performance but can't use `rustc_data_structures`" +)] +#![deny( + rustc::potential_query_instability, + reason = "macros shall produce deterministic output/errors" +)] #![feature(never_type)] #![feature(proc_macro_diagnostic)] #![feature(proc_macro_tracked_env)] diff --git a/compiler/rustc_macros/src/print_attribute.rs b/compiler/rustc_macros/src/print_attribute.rs index 0114e0dfde0db..132a98a98ee07 100644 --- a/compiler/rustc_macros/src/print_attribute.rs +++ b/compiler/rustc_macros/src/print_attribute.rs @@ -120,7 +120,6 @@ pub(crate) fn print_attribute(input: Structure<'_>) -> TokenStream { } }; - #[allow(keyword_idents_2024)] input.gen_impl(quote! { #[allow(unused)] gen impl PrintAttribute for @Self { diff --git a/compiler/rustc_macros/src/symbols.rs b/compiler/rustc_macros/src/symbols.rs index 44cd63e57af4c..9ecd63caf4226 100644 --- a/compiler/rustc_macros/src/symbols.rs +++ b/compiler/rustc_macros/src/symbols.rs @@ -24,8 +24,7 @@ //! CFG_RELEASE="0.0.0" cargo +nightly expand > /tmp/rustc_span.rs //! ``` -use std::collections::HashMap; - +use indexmap::IndexMap; use proc_macro2::{Span, TokenStream}; use quote::quote; use syn::parse::{Parse, ParseStream, Result}; @@ -148,12 +147,12 @@ struct Predefined { } struct Entries { - map: HashMap, + map: IndexMap, } impl Entries { fn with_capacity(capacity: usize) -> Self { - Entries { map: HashMap::with_capacity(capacity) } + Entries { map: IndexMap::with_capacity(capacity) } } fn insert(&mut self, span: Span, s: &str, errors: &mut Errors) -> u32 { diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 9e405c801867e..324ce0a4025e7 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -3,7 +3,7 @@ //! [`rustc`] module. // tidy-alphabetical-start -#![allow(unused_crate_dependencies)] +#![cfg_attr(test, allow(unused_crate_dependencies))] // Used for integration tests, not unit tests // tidy-alphabetical-end pub(crate) mod checks; diff --git a/compiler/rustc_session/src/config/sigpipe.rs b/compiler/rustc_session/src/config/sigpipe.rs index 1830ee034855b..5777e82d65d0e 100644 --- a/compiler/rustc_session/src/config/sigpipe.rs +++ b/compiler/rustc_session/src/config/sigpipe.rs @@ -5,21 +5,17 @@ /// /// Note that `SIG_IGN` has been the Rust default since 2014. See /// . -#[allow(dead_code)] pub const DEFAULT: u8 = 0; /// Do not touch `SIGPIPE`. Use whatever the parent process uses. -#[allow(dead_code)] pub const INHERIT: u8 = 1; /// Change `SIGPIPE` to `SIG_IGN` so that failed writes results in `EPIPE` /// that are eventually converted to `ErrorKind::BrokenPipe`. -#[allow(dead_code)] pub const SIG_IGN: u8 = 2; /// Change `SIGPIPE` to `SIG_DFL` so that the process is killed when trying /// to write to a closed pipe. This is usually the desired behavior for CLI /// apps that produce textual output that you want to pipe to other programs /// such as `head -n 1`. -#[allow(dead_code)] pub const SIG_DFL: u8 = 3;