From b1afb6c49fdcc11988ad6626909731e7f6fa93ac Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Sun, 12 Nov 2023 22:34:13 +0300 Subject: [PATCH 01/13] bootstrap: simplify setting unstable-options for tools We unconditionally set this to avoid recompiling tools between `x check $tool` and `x test $tool` executions. See https://github.com/rust-lang/rust/issues/116538 for more information. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/check.rs | 4 ---- src/bootstrap/src/core/build_steps/tool.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 121925b56a056..f2785dee32dac 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -463,10 +463,6 @@ macro_rules! tool_check_step { cargo.arg("--all-targets"); } - // Enable internal lints for clippy and rustdoc - // NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]` - // See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776 - cargo.rustflag("-Zunstable-options"); let _guard = builder.msg_check(&concat!(stringify!($name), " artifacts").to_lowercase(), target); run_cargo( builder, diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index d1bc05e51d731..f11a08c8b2bfd 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -203,6 +203,16 @@ pub fn prepare_tool_cargo( if !features.is_empty() { cargo.arg("--features").arg(&features.join(", ")); } + + // Enable internal lints for clippy and rustdoc + // NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]` + // See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776 + // + // NOTE: We unconditionally set this here to avoid recompiling tools between `x check $tool` + // and `x test $tool` executions. + // See https://github.com/rust-lang/rust/issues/116538 + cargo.rustflag("-Zunstable-options"); + cargo } From cc7d451c36f3671196034afb2c921d19dbd5ad93 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 13 Nov 2023 08:13:51 -0600 Subject: [PATCH 02/13] docs(release): Remove cargo-as-a-lib change --- RELEASES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 3b764fd773b64..b3a40bdaeb4b3 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -70,7 +70,6 @@ These APIs are now stable in const contexts: Cargo ----- -- [fix: Set MSRV for internal packages](https://github.com/rust-lang/cargo/pull/12381/) - [config: merge lists in precedence order](https://github.com/rust-lang/cargo/pull/12515/) - [fix(update): Clarify meaning of --aggressive as --recursive](https://github.com/rust-lang/cargo/pull/12544/) - [fix(update): Make `-p` more convenient by being positional](https://github.com/rust-lang/cargo/pull/12545/) From 2aad0604dac0540c60d8b4ebba1d91c24bd1f514 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 13 Nov 2023 08:20:05 -0600 Subject: [PATCH 03/13] docs(release): Add missing cargo-clean change --- RELEASES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASES.md b/RELEASES.md index b3a40bdaeb4b3..ea0637062a85c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -77,6 +77,7 @@ Cargo - [feat(pkgid): Allow incomplete versions when unambigious](https://github.com/rust-lang/cargo/pull/12614/) - [feat: stabilize credential-process and registry-auth](https://github.com/rust-lang/cargo/pull/12649/) - [feat(cli): Add '-n' to dry-run](https://github.com/rust-lang/cargo/pull/12660/) +- [Added `--dry-run` flag and summary line at the end for `cargo clean`](https://github.com/rust-lang/cargo/pull/12638) - [Add support for `target.'cfg(..)'.linker`](https://github.com/rust-lang/cargo/pull/12535/) - [Stabilize `--keep-going`](https://github.com/rust-lang/cargo/pull/12568/) - [feat: Stabilize lints](https://github.com/rust-lang/cargo/pull/12648/) From 40e8a43a425e876c3b3590cf3a0362caa1410fbe Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 13 Nov 2023 08:28:23 -0600 Subject: [PATCH 04/13] docs(release): Clarify cargo line items --- RELEASES.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index ea0637062a85c..05f91073d327d 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -70,17 +70,17 @@ These APIs are now stable in const contexts: Cargo ----- -- [config: merge lists in precedence order](https://github.com/rust-lang/cargo/pull/12515/) -- [fix(update): Clarify meaning of --aggressive as --recursive](https://github.com/rust-lang/cargo/pull/12544/) -- [fix(update): Make `-p` more convenient by being positional](https://github.com/rust-lang/cargo/pull/12545/) -- [feat(help): Add styling to help output ](https://github.com/rust-lang/cargo/pull/12578/) -- [feat(pkgid): Allow incomplete versions when unambigious](https://github.com/rust-lang/cargo/pull/12614/) -- [feat: stabilize credential-process and registry-auth](https://github.com/rust-lang/cargo/pull/12649/) -- [feat(cli): Add '-n' to dry-run](https://github.com/rust-lang/cargo/pull/12660/) -- [Added `--dry-run` flag and summary line at the end for `cargo clean`](https://github.com/rust-lang/cargo/pull/12638) +- [In `.cargo/config.toml`, merge lists in precedence order](https://github.com/rust-lang/cargo/pull/12515/) +- [For `cargo update`, clarify meaning of --aggressive as --recursive](https://github.com/rust-lang/cargo/pull/12544/) +- [For `cargo update`, make `--package` more convenient by being positional](https://github.com/rust-lang/cargo/pull/12545/) +- [Add styling to `--help` output](https://github.com/rust-lang/cargo/pull/12578/) +- [Allow version-prefixes in pkgid's (e.g. `--package` flags) to resolve ambiguities](https://github.com/rust-lang/cargo/pull/12614/) +- [Stabilize credential-process and registry-auth](https://github.com/rust-lang/cargo/pull/12649/) +- [Add '-n' as an alias for `--dry-run`](https://github.com/rust-lang/cargo/pull/12660/) +- [For `cargo clean`, add `--dry-run` flag and summary line at the end](https://github.com/rust-lang/cargo/pull/12638) - [Add support for `target.'cfg(..)'.linker`](https://github.com/rust-lang/cargo/pull/12535/) -- [Stabilize `--keep-going`](https://github.com/rust-lang/cargo/pull/12568/) -- [feat: Stabilize lints](https://github.com/rust-lang/cargo/pull/12648/) +- [Stabilize `--keep-going` build flag](https://github.com/rust-lang/cargo/pull/12568/) +- [In `Cargo.toml`, stabilize `[lints]`](https://github.com/rust-lang/cargo/pull/12648/) From 64c0ec65315fe6023d0bc217703c16474d5f12a4 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 13 Nov 2023 08:30:31 -0600 Subject: [PATCH 05/13] docs(release): Very rough 'importance' sort --- RELEASES.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 05f91073d327d..6327b1d74fb3b 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -70,17 +70,17 @@ These APIs are now stable in const contexts: Cargo ----- -- [In `.cargo/config.toml`, merge lists in precedence order](https://github.com/rust-lang/cargo/pull/12515/) -- [For `cargo update`, clarify meaning of --aggressive as --recursive](https://github.com/rust-lang/cargo/pull/12544/) -- [For `cargo update`, make `--package` more convenient by being positional](https://github.com/rust-lang/cargo/pull/12545/) -- [Add styling to `--help` output](https://github.com/rust-lang/cargo/pull/12578/) -- [Allow version-prefixes in pkgid's (e.g. `--package` flags) to resolve ambiguities](https://github.com/rust-lang/cargo/pull/12614/) +- [In `Cargo.toml`, stabilize `[lints]`](https://github.com/rust-lang/cargo/pull/12648/) - [Stabilize credential-process and registry-auth](https://github.com/rust-lang/cargo/pull/12649/) -- [Add '-n' as an alias for `--dry-run`](https://github.com/rust-lang/cargo/pull/12660/) +- [Stabilize `--keep-going` build flag](https://github.com/rust-lang/cargo/pull/12568/) +- [Add styling to `--help` output](https://github.com/rust-lang/cargo/pull/12578/) - [For `cargo clean`, add `--dry-run` flag and summary line at the end](https://github.com/rust-lang/cargo/pull/12638) +- [For `cargo update`, make `--package` more convenient by being positional](https://github.com/rust-lang/cargo/pull/12545/) +- [For `cargo update`, clarify meaning of --aggressive as --recursive](https://github.com/rust-lang/cargo/pull/12544/) +- [Add '-n' as an alias for `--dry-run`](https://github.com/rust-lang/cargo/pull/12660/) +- [Allow version-prefixes in pkgid's (e.g. `--package` flags) to resolve ambiguities](https://github.com/rust-lang/cargo/pull/12614/) +- [In `.cargo/config.toml`, merge lists in precedence order](https://github.com/rust-lang/cargo/pull/12515/) - [Add support for `target.'cfg(..)'.linker`](https://github.com/rust-lang/cargo/pull/12535/) -- [Stabilize `--keep-going` build flag](https://github.com/rust-lang/cargo/pull/12568/) -- [In `Cargo.toml`, stabilize `[lints]`](https://github.com/rust-lang/cargo/pull/12648/) From c8330ba354928d4c67884a88b50df3e7dc02054f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 14 Nov 2023 10:20:06 -0600 Subject: [PATCH 06/13] docs(release): Remove unstable cargo change --- RELEASES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 6327b1d74fb3b..951930ba1737a 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -198,7 +198,6 @@ These APIs are now stable in const contexts: Cargo ----- -- [Encode URL params correctly for `SourceId` in `Cargo.lock`.](https://github.com/rust-lang/cargo/pull/12280/) - [Bail out an error when using `cargo::` in custom build script.](https://github.com/rust-lang/cargo/pull/12332/) From 000767564e574f15ed4e6cd9ee0b56ecad6ae748 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 15 Nov 2023 15:40:57 +1100 Subject: [PATCH 07/13] Remove unused features. --- compiler/rustc_query_system/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs index 1944ac443eaed..2ed420f356439 100644 --- a/compiler/rustc_query_system/src/lib.rs +++ b/compiler/rustc_query_system/src/lib.rs @@ -2,9 +2,7 @@ #![feature(core_intrinsics)] #![feature(hash_raw_entry)] #![feature(min_specialization)] -#![feature(extern_types)] #![feature(let_chains)] -#![feature(inline_const)] #![allow(rustc::potential_query_instability)] #![deny(rustc::untranslatable_diagnostic)] #![deny(rustc::diagnostic_outside_of_impl)] From 1c1b7897d8dc7edc25bdbb0eabf082a5b65bb0bd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 15 Nov 2023 19:23:04 +0100 Subject: [PATCH 08/13] avoid exhaustive i16 test in Miri --- library/core/tests/fmt/num.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/core/tests/fmt/num.rs b/library/core/tests/fmt/num.rs index 1ddcd5ab7955f..bc387a46ea7dd 100644 --- a/library/core/tests/fmt/num.rs +++ b/library/core/tests/fmt/num.rs @@ -152,8 +152,11 @@ fn test_format_int_exp_precision() { assert_eq!(format!("{:+10.3e}", 1), " +1.000e0"); // test precision remains correct when rounding to next power - - for i in i16::MIN..=i16::MAX { + #[cfg(miri)] // can't cover all of `i16` in Miri + let range = [i16::MIN, -1, 1, i16::MAX]; + #[cfg(not(miri))] + let range = i16::MIN..=i16::MAX; + for i in range { for p in 0..=5 { assert_eq!( format!("{i:.p$e}"), From 8f669f558a02037feaafc3002207a1ac121b744d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 15 Nov 2023 16:15:38 +1100 Subject: [PATCH 09/13] Reduce exposure of things. --- compiler/rustc_middle/src/dep_graph/mod.rs | 4 +-- .../rustc_query_system/src/dep_graph/edges.rs | 10 +++--- .../rustc_query_system/src/dep_graph/graph.rs | 36 +++++++++---------- .../rustc_query_system/src/dep_graph/mod.rs | 7 ++-- .../src/dep_graph/serialized.rs | 2 +- compiler/rustc_query_system/src/ich/hcx.rs | 2 +- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_middle/src/dep_graph/mod.rs b/compiler/rustc_middle/src/dep_graph/mod.rs index 76ef62f9f2728..dc0da165af67d 100644 --- a/compiler/rustc_middle/src/dep_graph/mod.rs +++ b/compiler/rustc_middle/src/dep_graph/mod.rs @@ -8,8 +8,8 @@ mod dep_node; pub use rustc_query_system::dep_graph::debug::EdgeFilter; pub use rustc_query_system::dep_graph::{ - debug::DepNodeFilter, hash_result, DepContext, DepGraphQuery, DepNodeColor, DepNodeIndex, Deps, - SerializedDepGraph, SerializedDepNodeIndex, TaskDeps, TaskDepsRef, WorkProduct, WorkProductId, + debug::DepNodeFilter, hash_result, DepContext, DepGraphQuery, DepNodeIndex, Deps, + SerializedDepGraph, SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, }; diff --git a/compiler/rustc_query_system/src/dep_graph/edges.rs b/compiler/rustc_query_system/src/dep_graph/edges.rs index 6ba3924f65eb0..400f128d5833b 100644 --- a/compiler/rustc_query_system/src/dep_graph/edges.rs +++ b/compiler/rustc_query_system/src/dep_graph/edges.rs @@ -5,7 +5,7 @@ use std::iter::Extend; use std::ops::Deref; #[derive(Default, Debug)] -pub struct EdgesVec { +pub(crate) struct EdgesVec { max: u32, edges: SmallVec<[DepNodeIndex; EdgesVec::INLINE_CAPACITY]>, } @@ -18,21 +18,21 @@ impl Hash for EdgesVec { } impl EdgesVec { - pub const INLINE_CAPACITY: usize = 8; + pub(crate) const INLINE_CAPACITY: usize = 8; #[inline] - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self::default() } #[inline] - pub fn push(&mut self, edge: DepNodeIndex) { + pub(crate) fn push(&mut self, edge: DepNodeIndex) { self.max = self.max.max(edge.as_u32()); self.edges.push(edge); } #[inline] - pub fn max_index(&self) -> u32 { + pub(crate) fn max_index(&self) -> u32 { self.max } } diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 6cace01955e75..831062b1678f4 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -18,7 +18,7 @@ use std::sync::atomic::Ordering::Relaxed; use super::query::DepGraphQuery; use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex}; use super::{DepContext, DepKind, DepNode, Deps, HasDepContext, WorkProductId}; -use crate::dep_graph::EdgesVec; +use crate::dep_graph::edges::EdgesVec; use crate::ich::StableHashingContext; use crate::query::{QueryContext, QuerySideEffects}; @@ -41,8 +41,7 @@ rustc_index::newtype_index! { } impl DepNodeIndex { - pub const INVALID: DepNodeIndex = DepNodeIndex::MAX; - pub const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0); + const SINGLETON_DEPENDENCYLESS_ANON_NODE: DepNodeIndex = DepNodeIndex::from_u32(0); pub const FOREVER_RED_NODE: DepNodeIndex = DepNodeIndex::from_u32(1); } @@ -53,20 +52,20 @@ impl From for QueryInvocationId { } } -pub struct MarkFrame<'a> { +pub(crate) struct MarkFrame<'a> { index: SerializedDepNodeIndex, parent: Option<&'a MarkFrame<'a>>, } #[derive(PartialEq)] -pub enum DepNodeColor { +enum DepNodeColor { Red, Green(DepNodeIndex), } impl DepNodeColor { #[inline] - pub fn is_green(self) -> bool { + fn is_green(self) -> bool { match self { DepNodeColor::Red => false, DepNodeColor::Green(_) => true, @@ -74,7 +73,7 @@ impl DepNodeColor { } } -pub struct DepGraphData { +pub(crate) struct DepGraphData { /// The new encoding of the dependency graph, optimized for red/green /// tracking. The `current` field is the dependency graph of only the /// current compilation session: We don't merge the previous dep-graph into @@ -185,7 +184,7 @@ impl DepGraph { } #[inline] - pub fn data(&self) -> Option<&DepGraphData> { + pub(crate) fn data(&self) -> Option<&DepGraphData> { self.data.as_deref() } @@ -333,7 +332,7 @@ impl DepGraphData { /// /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/queries/incremental-compilation.html #[inline(always)] - pub fn with_task, A: Debug, R>( + pub(crate) fn with_task, A: Debug, R>( &self, key: DepNode, cx: Ctxt, @@ -398,7 +397,7 @@ impl DepGraphData { /// Executes something within an "anonymous" task, that is, a task the /// `DepNode` of which is determined by the list of inputs it read from. - pub fn with_anon_task, OP, R>( + pub(crate) fn with_anon_task, OP, R>( &self, cx: Tcx, dep_kind: DepKind, @@ -618,7 +617,7 @@ impl DepGraph { impl DepGraphData { #[inline] - pub fn dep_node_index_of_opt(&self, dep_node: &DepNode) -> Option { + fn dep_node_index_of_opt(&self, dep_node: &DepNode) -> Option { if let Some(prev_index) = self.previous.node_to_index_opt(dep_node) { self.current.prev_index_to_index.lock()[prev_index] } else { @@ -627,7 +626,7 @@ impl DepGraphData { } #[inline] - pub fn dep_node_exists(&self, dep_node: &DepNode) -> bool { + fn dep_node_exists(&self, dep_node: &DepNode) -> bool { self.dep_node_index_of_opt(dep_node).is_some() } @@ -643,21 +642,21 @@ impl DepGraphData { /// Returns true if the given node has been marked as green during the /// current compilation session. Used in various assertions #[inline] - pub fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool { + pub(crate) fn is_index_green(&self, prev_index: SerializedDepNodeIndex) -> bool { self.colors.get(prev_index).is_some_and(|c| c.is_green()) } #[inline] - pub fn prev_fingerprint_of(&self, prev_index: SerializedDepNodeIndex) -> Fingerprint { + pub(crate) fn prev_fingerprint_of(&self, prev_index: SerializedDepNodeIndex) -> Fingerprint { self.previous.fingerprint_by_index(prev_index) } #[inline] - pub fn prev_node_of(&self, prev_index: SerializedDepNodeIndex) -> DepNode { + pub(crate) fn prev_node_of(&self, prev_index: SerializedDepNodeIndex) -> DepNode { self.previous.index_to_node(prev_index) } - pub fn mark_debug_loaded_from_disk(&self, dep_node: DepNode) { + pub(crate) fn mark_debug_loaded_from_disk(&self, dep_node: DepNode) { self.debug_loaded_from_disk.lock().insert(dep_node); } } @@ -684,8 +683,9 @@ impl DepGraph { self.data.as_ref().unwrap().debug_loaded_from_disk.lock().contains(&dep_node) } + #[cfg(debug_assertions)] #[inline(always)] - pub fn register_dep_node_debug_str(&self, dep_node: DepNode, debug_str_gen: F) + pub(crate) fn register_dep_node_debug_str(&self, dep_node: DepNode, debug_str_gen: F) where F: FnOnce() -> String, { @@ -725,7 +725,7 @@ impl DepGraphData { /// A node will have an index, when it's already been marked green, or when we can mark it /// green. This function will mark the current task as a reader of the specified node, when /// a node index can be found for that node. - pub fn try_mark_green>( + pub(crate) fn try_mark_green>( &self, qcx: Qcx, dep_node: &DepNode, diff --git a/compiler/rustc_query_system/src/dep_graph/mod.rs b/compiler/rustc_query_system/src/dep_graph/mod.rs index 624ae680a8ff7..feb69ecd07867 100644 --- a/compiler/rustc_query_system/src/dep_graph/mod.rs +++ b/compiler/rustc_query_system/src/dep_graph/mod.rs @@ -6,11 +6,8 @@ mod query; mod serialized; pub use dep_node::{DepKind, DepKindStruct, DepNode, DepNodeParams, WorkProductId}; -pub use edges::EdgesVec; -pub use graph::{ - hash_result, DepGraph, DepGraphData, DepNodeColor, DepNodeIndex, TaskDeps, TaskDepsRef, - WorkProduct, WorkProductMap, -}; +pub(crate) use graph::DepGraphData; +pub use graph::{hash_result, DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap}; pub use query::DepGraphQuery; pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex}; diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index fcf46be6e6f5a..e97ef8072045d 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -37,7 +37,7 @@ use super::query::DepGraphQuery; use super::{DepKind, DepNode, DepNodeIndex, Deps}; -use crate::dep_graph::EdgesVec; +use crate::dep_graph::edges::EdgesVec; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fingerprint::PackedFingerprint; use rustc_data_structures::fx::FxHashMap; diff --git a/compiler/rustc_query_system/src/ich/hcx.rs b/compiler/rustc_query_system/src/ich/hcx.rs index 5593a15412fb7..eec0433ae68d2 100644 --- a/compiler/rustc_query_system/src/ich/hcx.rs +++ b/compiler/rustc_query_system/src/ich/hcx.rs @@ -28,7 +28,7 @@ pub struct StableHashingContext<'a> { // `CachingSourceMapView`, so we initialize it lazily. raw_source_map: &'a SourceMap, caching_source_map: Option>, - pub(super) hashing_controls: HashingControls, + hashing_controls: HashingControls, } /// The `BodyResolver` allows mapping a `BodyId` to the corresponding `hir::Body`. From 5dfe47acd42c35aec03e4fd36d7884f21b536888 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 6 Nov 2023 15:44:27 +1100 Subject: [PATCH 10/13] Inline and remove `create_lint_store`. --- compiler/rustc_interface/src/passes.rs | 11 ----------- compiler/rustc_interface/src/queries.rs | 8 ++++++-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 7d14d088e595e..39bf96e5d8ff2 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -72,17 +72,6 @@ fn count_nodes(krate: &ast::Crate) -> usize { counter.count } -pub(crate) fn create_lint_store( - sess: &Session, - register_lints: Option, -) -> LintStore { - let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); - if let Some(register_lints) = register_lints { - register_lints(sess, &mut lint_store); - } - lint_store -} - fn pre_expansion_lint<'a>( sess: &Session, features: &Features, diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 3a5f788e8ddb6..3e913b3cc0156 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -148,8 +148,12 @@ impl<'tcx> Queries<'tcx> { ); let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id)?; - let lint_store = - Lrc::new(passes::create_lint_store(sess, self.compiler.register_lints.as_deref())); + let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); + if let Some(register_lints) = self.compiler.register_lints.as_deref() { + register_lints(sess, &mut lint_store); + } + let lint_store = Lrc::new(lint_store); + let cstore = FreezeLock::new(Box::new(CStore::new( self.codegen_backend().metadata_loader(), stable_crate_id, From 73c1fc5bc0632b16705756fc91174c3c3a44e52d Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 6 Nov 2023 15:56:41 +1100 Subject: [PATCH 11/13] Remove dead lint code. --- compiler/rustc_lint/src/context.rs | 32 +++++------------------------- compiler/rustc_lint/src/late.rs | 2 -- compiler/rustc_lint/src/levels.rs | 4 ---- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index a5f4c5ff0459e..cd4c0d07e55f5 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -497,9 +497,6 @@ pub struct LateContext<'tcx> { /// Items accessible from the crate being checked. pub effective_visibilities: &'tcx EffectiveVisibilities, - /// The store of registered lints and the lint levels. - pub lint_store: &'tcx LintStore, - pub last_node_with_lint_attrs: hir::HirId, /// Generic type parameters in scope for the item we are in. @@ -515,21 +512,14 @@ pub struct EarlyContext<'a> { pub buffered: LintBuffer, } -pub trait LintPassObject: Sized {} - -impl LintPassObject for EarlyLintPassObject {} - -impl LintPassObject for LateLintPassObject<'_> {} - -pub trait LintContext: Sized { - type PassObject: LintPassObject; - +pub trait LintContext { fn sess(&self) -> &Session; - fn lints(&self) -> &LintStore; - /// Emit a lint at the appropriate level, with an optional associated span and an existing diagnostic. + /// Emit a lint at the appropriate level, with an optional associated span and an existing + /// diagnostic. /// - /// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation. + /// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed + /// explanation. /// /// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature #[rustc_lint_diagnostics] @@ -1059,17 +1049,11 @@ impl<'a> EarlyContext<'a> { } impl<'tcx> LintContext for LateContext<'tcx> { - type PassObject = LateLintPassObject<'tcx>; - /// Gets the overall compiler `Session` object. fn sess(&self) -> &Session { &self.tcx.sess } - fn lints(&self) -> &LintStore { - &*self.lint_store - } - #[rustc_lint_diagnostics] fn lookup>( &self, @@ -1094,17 +1078,11 @@ impl<'tcx> LintContext for LateContext<'tcx> { } impl LintContext for EarlyContext<'_> { - type PassObject = EarlyLintPassObject; - /// Gets the overall compiler `Session` object. fn sess(&self) -> &Session { &self.builder.sess() } - fn lints(&self) -> &LintStore { - self.builder.lint_store() - } - #[rustc_lint_diagnostics] fn lookup>( &self, diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index 6c8b60c8d7413..6d5bbadcbc2d8 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -353,7 +353,6 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( cached_typeck_results: Cell::new(None), param_env: ty::ParamEnv::empty(), effective_visibilities: &tcx.effective_visibilities(()), - lint_store: unerased_lint_store(tcx), last_node_with_lint_attrs: tcx.hir().local_def_id_to_hir_id(module_def_id), generics: None, only_module: true, @@ -412,7 +411,6 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) { cached_typeck_results: Cell::new(None), param_env: ty::ParamEnv::empty(), effective_visibilities: &tcx.effective_visibilities(()), - lint_store: unerased_lint_store(tcx), last_node_with_lint_attrs: hir::CRATE_HIR_ID, generics: None, only_module: false, diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 0d20f6232db15..ecbb3426511ca 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -548,10 +548,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> { self.features } - pub(crate) fn lint_store(&self) -> &LintStore { - self.store - } - fn current_specs(&self) -> &FxHashMap { self.provider.current_specs() } From a3b4961d5f4ddbb0e86d323ebaeccc391f04d8a7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 6 Nov 2023 16:52:38 +1100 Subject: [PATCH 12/13] Move `lint_store` from `GlobalCtxt` to `Session`. This was made possible by the removal of plugin support, which simplified lint store creation. This simplifies the places in rustc and rustdoc that call `describe_lints`, which are early on. The lint store is now built before those places, so they don't have to create their own lint store for temporary use, they can just use the main one. --- compiler/rustc_driver_impl/src/lib.rs | 22 +++++-------------- compiler/rustc_interface/src/interface.rs | 10 +++++++++ compiler/rustc_interface/src/passes.rs | 6 ++--- compiler/rustc_interface/src/queries.rs | 7 ------ compiler/rustc_lint/src/late.rs | 20 +++++++++++------ compiler/rustc_lint/src/levels.rs | 4 ++-- compiler/rustc_middle/src/ty/context.rs | 11 +--------- compiler/rustc_session/src/session.rs | 16 +++++++++++++- src/librustdoc/lib.rs | 9 +------- .../clippy/tests/ui/macro_use_imports.stderr | 12 +++++----- 10 files changed, 56 insertions(+), 61 deletions(-) diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index b323ae8d29e05..4ad7b9f6cd186 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -33,7 +33,7 @@ use rustc_feature::find_gated_cfg; use rustc_fluent_macro::fluent_messages; use rustc_interface::util::{self, collect_crate_types, get_codegen_backend}; use rustc_interface::{interface, Queries}; -use rustc_lint::{unerased_lint_store, LintStore}; +use rustc_lint::unerased_lint_store; use rustc_metadata::locator; use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS}; use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType, TrimmedDefPaths}; @@ -356,16 +356,7 @@ fn run_compiler( let handler = EarlyErrorHandler::new(sopts.error_format); if sopts.describe_lints { - let mut lint_store = - rustc_lint::new_lint_store(compiler.session().enable_internal_lints()); - let registered_lints = - if let Some(register_lints) = compiler.register_lints() { - register_lints(compiler.session(), &mut lint_store); - true - } else { - false - }; - describe_lints(compiler.session(), &lint_store, registered_lints); + describe_lints(compiler.session()); return; } let should_stop = print_crate_info( @@ -442,9 +433,7 @@ fn run_compiler( } if sess.opts.describe_lints { - queries - .global_ctxt()? - .enter(|tcx| describe_lints(sess, unerased_lint_store(tcx), true)); + describe_lints(sess); return early_exit(); } @@ -991,7 +980,7 @@ the command line flag directly. } /// Write to stdout lint command options, together with a list of all available lints -pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_lints: bool) { +pub fn describe_lints(sess: &Session) { safe_println!( " Available lint options: @@ -1017,6 +1006,7 @@ Available lint options: lints } + let lint_store = unerased_lint_store(sess); let (loaded, builtin): (Vec<_>, _) = lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded); let loaded = sort_lints(sess, loaded); @@ -1094,7 +1084,7 @@ Available lint options: print_lint_groups(builtin_groups, true); - match (loaded_lints, loaded.len(), loaded_groups.len()) { + match (sess.registered_lints, loaded.len(), loaded_groups.len()) { (false, 0, _) | (false, _, 0) => { safe_println!("Lint tools like Clippy can load additional lints and lint groups."); } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 89125c54a6afe..02a023885b70e 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -485,6 +485,16 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se sess.opts.untracked_state_hash = hasher.finish() } + // Even though the session holds the lint store, we can't build the + // lint store until after the session exists. And we wait until now + // so that `register_lints` sees the fully initialized session. + let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); + if let Some(register_lints) = config.register_lints.as_deref() { + register_lints(&sess, &mut lint_store); + sess.registered_lints = true; + } + sess.lint_store = Some(Lrc::new(lint_store)); + let compiler = Compiler { sess: Lrc::new(sess), codegen_backend: Lrc::from(codegen_backend), diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 39bf96e5d8ff2..0baf77c4f7e19 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -127,7 +127,7 @@ fn configure_and_expand( let tcx = resolver.tcx(); let sess = tcx.sess; let features = tcx.features(); - let lint_store = unerased_lint_store(tcx); + let lint_store = unerased_lint_store(&tcx.sess); let crate_name = tcx.crate_name(LOCAL_CRATE); let lint_check_node = (&krate, pre_configured_attrs); pre_expansion_lint( @@ -319,7 +319,7 @@ fn early_lint_checks(tcx: TyCtxt<'_>, (): ()) { } }); - let lint_store = unerased_lint_store(tcx); + let lint_store = unerased_lint_store(&tcx.sess); rustc_lint::check_ast_node( sess, tcx.features(), @@ -634,7 +634,6 @@ pub fn create_global_ctxt<'tcx>( compiler: &'tcx Compiler, crate_types: Vec, stable_crate_id: StableCrateId, - lint_store: Lrc, dep_graph: DepGraph, untracked: Untracked, gcx_cell: &'tcx OnceLock>, @@ -665,7 +664,6 @@ pub fn create_global_ctxt<'tcx>( sess, crate_types, stable_crate_id, - lint_store, arena, hir_arena, untracked, diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 3e913b3cc0156..ace5ec732fbc5 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -148,12 +148,6 @@ impl<'tcx> Queries<'tcx> { ); let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id)?; - let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); - if let Some(register_lints) = self.compiler.register_lints.as_deref() { - register_lints(sess, &mut lint_store); - } - let lint_store = Lrc::new(lint_store); - let cstore = FreezeLock::new(Box::new(CStore::new( self.codegen_backend().metadata_loader(), stable_crate_id, @@ -168,7 +162,6 @@ impl<'tcx> Queries<'tcx> { self.compiler, crate_types, stable_crate_id, - lint_store, dep_graph, untracked, &self.gcx_cell, diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs index 6d5bbadcbc2d8..10c4c0dc79f9f 100644 --- a/compiler/rustc_lint/src/late.rs +++ b/compiler/rustc_lint/src/late.rs @@ -17,22 +17,25 @@ use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore}; use rustc_ast as ast; use rustc_data_structures::stack::ensure_sufficient_stack; -use rustc_data_structures::sync::join; +use rustc_data_structures::sync::{join, Lrc}; use rustc_hir as hir; use rustc_hir::def_id::{LocalDefId, LocalModDefId}; use rustc_hir::intravisit as hir_visit; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::lint::LintPass; +use rustc_session::Session; use rustc_span::Span; use std::any::Any; use std::cell::Cell; /// Extract the `LintStore` from the query context. -/// This function exists because we've erased `LintStore` as `dyn Any` in the context. -pub fn unerased_lint_store(tcx: TyCtxt<'_>) -> &LintStore { - let store: &dyn Any = &*tcx.lint_store; +/// This function exists because we've erased `LintStore` as `dyn Any` in the session. +pub fn unerased_lint_store(sess: &Session) -> &LintStore { + assert!(sess.lint_store.is_some()); + let store: &Lrc<_> = sess.lint_store.as_ref().unwrap(); + let store: &dyn Any = &**store; store.downcast_ref().unwrap() } @@ -361,8 +364,11 @@ pub fn late_lint_mod<'tcx, T: LateLintPass<'tcx> + 'tcx>( // Note: `passes` is often empty. In that case, it's faster to run // `builtin_lints` directly rather than bundling it up into the // `RuntimeCombinedLateLintPass`. - let mut passes: Vec<_> = - unerased_lint_store(tcx).late_module_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect(); + let mut passes: Vec<_> = unerased_lint_store(&tcx.sess) + .late_module_passes + .iter() + .map(|mk_pass| (mk_pass)(tcx)) + .collect(); if passes.is_empty() { late_lint_mod_inner(tcx, module_def_id, context, builtin_lints); } else { @@ -399,7 +405,7 @@ fn late_lint_mod_inner<'tcx, T: LateLintPass<'tcx>>( fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) { // Note: `passes` is often empty. let mut passes: Vec<_> = - unerased_lint_store(tcx).late_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect(); + unerased_lint_store(&tcx.sess).late_passes.iter().map(|mk_pass| (mk_pass)(tcx)).collect(); if passes.is_empty() { return; diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index ecbb3426511ca..ee5fa87e45db1 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -123,7 +123,7 @@ impl LintLevelSets { } fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExpectation)> { - let store = unerased_lint_store(tcx); + let store = unerased_lint_store(&tcx.sess); let mut builder = LintLevelsBuilder { sess: tcx.sess, @@ -152,7 +152,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp #[instrument(level = "trace", skip(tcx), ret)] fn shallow_lint_levels_on(tcx: TyCtxt<'_>, owner: hir::OwnerId) -> ShallowLintLevelMap { - let store = unerased_lint_store(tcx); + let store = unerased_lint_store(&tcx.sess); let attrs = tcx.hir_attrs(owner); let mut levels = LintLevelsBuilder { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index e635c3f96ec91..ee23c9c48978e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -39,7 +39,7 @@ use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::steal::Steal; -use rustc_data_structures::sync::{self, FreezeReadGuard, Lock, Lrc, WorkerLocal}; +use rustc_data_structures::sync::{FreezeReadGuard, Lock, WorkerLocal}; use rustc_data_structures::unord::UnordSet; use rustc_errors::{ DecorateLint, DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed, MultiSpan, @@ -69,7 +69,6 @@ use rustc_type_ir::TyKind::*; use rustc_type_ir::WithCachedTypeInfo; use rustc_type_ir::{CollectAndApply, Interner, TypeFlags}; -use std::any::Any; use std::borrow::Borrow; use std::cmp::Ordering; use std::fmt; @@ -544,12 +543,6 @@ pub struct GlobalCtxt<'tcx> { /// `rustc_symbol_mangling` crate for more information. stable_crate_id: StableCrateId, - /// This only ever stores a `LintStore` but we don't want a dependency on that type here. - /// - /// FIXME(Centril): consider `dyn LintStoreMarker` once - /// we can upcast to `Any` for some additional type safety. - pub lint_store: Lrc, - pub dep_graph: DepGraph, pub prof: SelfProfilerRef, @@ -709,7 +702,6 @@ impl<'tcx> TyCtxt<'tcx> { s: &'tcx Session, crate_types: Vec, stable_crate_id: StableCrateId, - lint_store: Lrc, arena: &'tcx WorkerLocal>, hir_arena: &'tcx WorkerLocal>, untracked: Untracked, @@ -730,7 +722,6 @@ impl<'tcx> TyCtxt<'tcx> { sess: s, crate_types, stable_crate_id, - lint_store, arena, hir_arena, interners, diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index e9655a5587dbe..38e09f47eacdf 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -16,7 +16,9 @@ use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_data_structures::jobserver::{self, Client}; use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef}; -use rustc_data_structures::sync::{AtomicU64, Lock, Lrc, OneThread, Ordering::SeqCst}; +use rustc_data_structures::sync::{ + AtomicU64, DynSend, DynSync, Lock, Lrc, OneThread, Ordering::SeqCst, +}; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter; use rustc_errors::emitter::{DynEmitter, EmitterWriter, HumanReadableErrorType}; use rustc_errors::json::JsonEmitter; @@ -37,6 +39,7 @@ use rustc_target::spec::{ DebuginfoKind, SanitizerSet, SplitDebuginfo, StackProtector, Target, TargetTriple, TlsModel, }; +use std::any::Any; use std::cell::{self, RefCell}; use std::env; use std::fmt; @@ -167,6 +170,15 @@ pub struct Session { /// false positives about a job server in our environment. pub jobserver: Client, + /// This only ever stores a `LintStore` but we don't want a dependency on that type here. + /// + /// FIXME(Centril): consider `dyn LintStoreMarker` once + /// we can upcast to `Any` for some additional type safety. + pub lint_store: Option>, + + /// Should be set if any lints are registered in `lint_store`. + pub registered_lints: bool, + /// Cap lint level specified by a driver specifically. pub driver_lint_caps: FxHashMap, @@ -1483,6 +1495,8 @@ pub fn build_session( optimization_fuel, print_fuel, jobserver: jobserver::client(), + lint_store: None, + registered_lints: false, driver_lint_caps, ctfe_backtrace, miri_unleashed_features: Lock::new(Default::default()), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index a43ea5582b786..5144bbdaf5e1d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -797,14 +797,7 @@ fn main_args( let sess = compiler.session(); if sess.opts.describe_lints { - let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints()); - let registered_lints = if let Some(register_lints) = compiler.register_lints() { - register_lints(sess, &mut lint_store); - true - } else { - false - }; - rustc_driver::describe_lints(sess, &lint_store, registered_lints); + rustc_driver::describe_lints(sess); return Ok(()); } diff --git a/src/tools/clippy/tests/ui/macro_use_imports.stderr b/src/tools/clippy/tests/ui/macro_use_imports.stderr index 6de869699ec6d..bafe8cfddb478 100644 --- a/src/tools/clippy/tests/ui/macro_use_imports.stderr +++ b/src/tools/clippy/tests/ui/macro_use_imports.stderr @@ -1,23 +1,23 @@ error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:25:5 + --> $DIR/macro_use_imports.rs:23:5 | LL | #[macro_use] - | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` + | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::mut_mut, inner::try_err};` | = note: `-D clippy::macro-use-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::macro_use_imports)]` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:23:5 + --> $DIR/macro_use_imports.rs:21:5 | LL | #[macro_use] - | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::mut_mut, inner::try_err};` + | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;` error: `macro_use` attributes are no longer needed in the Rust 2018 edition - --> $DIR/macro_use_imports.rs:21:5 + --> $DIR/macro_use_imports.rs:25:5 | LL | #[macro_use] - | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;` + | ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;` error: `macro_use` attributes are no longer needed in the Rust 2018 edition --> $DIR/macro_use_imports.rs:19:5 From dededd2f8b1785f0393c376065be0bdd999475ac Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 7 Nov 2023 09:07:10 +1100 Subject: [PATCH 13/13] Remove `Compiler::register_lints`. Lint registration now happens early enough that we can run it from `Config`, before `Compiler` is created. --- compiler/rustc_interface/src/interface.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 02a023885b70e..d113e03896668 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -40,7 +40,6 @@ pub type Result = result::Result; pub struct Compiler { pub(crate) sess: Lrc, codegen_backend: Lrc, - pub(crate) register_lints: Option>, pub(crate) override_queries: Option, } @@ -51,9 +50,6 @@ impl Compiler { pub fn codegen_backend(&self) -> &Lrc { &self.codegen_backend } - pub fn register_lints(&self) -> &Option> { - &self.register_lints - } pub fn build_output_filenames( &self, sess: &Session, @@ -498,7 +494,6 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let compiler = Compiler { sess: Lrc::new(sess), codegen_backend: Lrc::from(codegen_backend), - register_lints: config.register_lints, override_queries: config.override_queries, };