Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu

Use `RUSTC_LINT_FLAGS` more

An alternative to the failed #138084.

Fixes #138106.

r? ````@jieyouxu````
This commit is contained in:
Matthias Krüger 2025-03-12 17:59:08 +01:00 committed by GitHub
commit d93ef397ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
71 changed files with 38 additions and 94 deletions

View file

@ -5,7 +5,6 @@
#![cfg_attr(feature = "nightly", feature(rustc_attrs))] #![cfg_attr(feature = "nightly", feature(rustc_attrs))]
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))] #![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
#![cfg_attr(feature = "nightly", feature(step_trait))] #![cfg_attr(feature = "nightly", feature(step_trait))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
/*! ABI handling for rustc /*! ABI handling for rustc

View file

@ -23,7 +23,6 @@
#![feature(maybe_uninit_slice)] #![feature(maybe_uninit_slice)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::alloc::Layout; use std::alloc::Layout;

View file

@ -19,7 +19,6 @@
#![feature(never_type)] #![feature(never_type)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod util { pub mod util {

View file

@ -9,7 +9,6 @@
#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(never_type))] #![cfg_attr(feature = "nightly", feature(never_type))]
#![cfg_attr(feature = "nightly", feature(rustc_attrs))] #![cfg_attr(feature = "nightly", feature(rustc_attrs))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]

View file

@ -39,7 +39,6 @@
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::sync::Arc; use std::sync::Arc;

View file

@ -10,7 +10,6 @@
#![feature(iter_is_partitioned)] #![feature(iter_is_partitioned)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod ast_validation; pub mod ast_validation;

View file

@ -3,7 +3,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod helpers; mod helpers;

View file

@ -3,7 +3,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod attributes; mod attributes;

View file

@ -80,7 +80,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
#[macro_use] #[macro_use]

View file

@ -23,6 +23,7 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![allow(elided_lifetimes_in_paths)] #![allow(elided_lifetimes_in_paths)]
#![allow(internal_features)] #![allow(internal_features)]
#![allow(unreachable_pub)] // because this crate is mostly generated code
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code // #![warn(unreachable_pub)] // don't use because this crate is mostly generated code

View file

@ -13,7 +13,6 @@
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::borrow::Cow; use std::borrow::Cow;

View file

@ -18,7 +18,6 @@
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(string_from_utf8_lossy_owned)] #![feature(string_from_utf8_lossy_owned)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
extern crate proc_macro; extern crate proc_macro;

View file

@ -19,7 +19,6 @@
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(slice_as_array)] #![feature(slice_as_array)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::any::Any; use std::any::Any;

View file

@ -14,7 +14,6 @@
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(trait_alias)] #![feature(trait_alias)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
//! This crate contains codegen code that is used by all codegen backends (LLVM and others). //! This crate contains codegen code that is used by all codegen backends (LLVM and others).

View file

@ -16,7 +16,6 @@
#![feature(unqualified_local_imports)] #![feature(unqualified_local_imports)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![warn(unqualified_local_imports)] #![warn(unqualified_local_imports)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod check_consts; pub mod check_consts;

View file

@ -3,7 +3,7 @@ use std::cmp::max;
use super::*; use super::*;
use crate::fx::FxHashMap; use crate::fx::FxHashMap;
pub struct TestGraph { pub(super) struct TestGraph {
num_nodes: usize, num_nodes: usize,
start_node: usize, start_node: usize,
successors: FxHashMap<usize, Vec<usize>>, successors: FxHashMap<usize, Vec<usize>>,
@ -11,7 +11,7 @@ pub struct TestGraph {
} }
impl TestGraph { impl TestGraph {
pub fn new(start_node: usize, edges: &[(usize, usize)]) -> Self { pub(super) fn new(start_node: usize, edges: &[(usize, usize)]) -> Self {
let mut graph = TestGraph { let mut graph = TestGraph {
num_nodes: start_node + 1, num_nodes: start_node + 1,
start_node, start_node,

View file

@ -313,7 +313,7 @@ pub struct Error<O, E> {
mod helper { mod helper {
use super::*; use super::*;
pub type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>; pub(super) type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>;
impl<O: ForestObligation> ObligationForest<O> { impl<O: ForestObligation> ObligationForest<O> {
#[cfg_attr(not(bootstrap), define_opaque(ObligationTreeIdGenerator))] #[cfg_attr(not(bootstrap), define_opaque(ObligationTreeIdGenerator))]
pub fn new() -> ObligationForest<O> { pub fn new() -> ObligationForest<O> {

View file

@ -88,7 +88,7 @@ mod mode {
// Whether thread safety might be enabled. // Whether thread safety might be enabled.
#[inline] #[inline]
pub fn might_be_dyn_thread_safe() -> bool { pub(super) fn might_be_dyn_thread_safe() -> bool {
DYN_THREAD_SAFE_MODE.load(Ordering::Relaxed) != DYN_NOT_THREAD_SAFE DYN_THREAD_SAFE_MODE.load(Ordering::Relaxed) != DYN_NOT_THREAD_SAFE
} }

View file

@ -46,7 +46,7 @@ pub fn parallel_guard<R>(f: impl FnOnce(&ParallelGuard) -> R) -> R {
ret ret
} }
pub fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB) fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
where where
A: FnOnce() -> RA, A: FnOnce() -> RA,
B: FnOnce() -> RB, B: FnOnce() -> RB,

View file

@ -7,7 +7,7 @@ use crate::stable_hasher::{HashStable, StableHasher};
/// A tag type used in [`TaggedRef`] tests. /// A tag type used in [`TaggedRef`] tests.
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Tag2 { enum Tag2 {
B00 = 0b00, B00 = 0b00,
B01 = 0b01, B01 = 0b01,
B10 = 0b10, B10 = 0b10,

View file

@ -16,7 +16,6 @@
#![feature(result_flattening)] #![feature(result_flattening)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::cmp::max; use std::cmp::max;

View file

@ -6,7 +6,6 @@
#![deny(rustdoc::invalid_codeblock_attributes)] #![deny(rustdoc::invalid_codeblock_attributes)]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
// This higher-order macro defines the error codes that are in use. It is used // This higher-order macro defines the error codes that are in use. It is used

View file

@ -4,7 +4,6 @@
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::borrow::Cow; use std::borrow::Cow;

View file

@ -25,7 +25,6 @@
#![feature(trait_alias)] #![feature(trait_alias)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
extern crate self as rustc_errors; extern crate self as rustc_errors;

View file

@ -13,7 +13,6 @@
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
extern crate proc_macro as pm; extern crate proc_macro as pm;

View file

@ -15,7 +15,6 @@
#![allow(internal_features)] #![allow(internal_features)]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod accepted; mod accepted;

View file

@ -7,7 +7,6 @@
#![feature(proc_macro_span)] #![feature(proc_macro_span)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(track_path)] #![feature(track_path)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use proc_macro::TokenStream; use proc_macro::TokenStream;

View file

@ -277,7 +277,6 @@
)] )]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::borrow::Cow; use std::borrow::Cow;

View file

@ -13,7 +13,6 @@
#![feature(never_type)] #![feature(never_type)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(variant_count)] #![feature(variant_count)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
extern crate self as rustc_hir; extern crate self as rustc_hir;

View file

@ -73,7 +73,6 @@ This API is completely unstable and subject to change.
#![feature(slice_partition_dedup)] #![feature(slice_partition_dedup)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![feature(unwrap_infallible)] #![feature(unwrap_infallible)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
// These are used by Clippy. // These are used by Clippy.

View file

@ -3,7 +3,6 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![recursion_limit = "256"] #![recursion_limit = "256"]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::cell::Cell; use std::cell::Cell;

View file

@ -8,7 +8,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(never_type)] #![feature(never_type)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod _match; mod _match;

View file

@ -7,7 +7,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(file_buffered)] #![feature(file_buffered)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod assert_dep_graph; mod assert_dep_graph;

View file

@ -4,7 +4,6 @@
#![cfg_attr(feature = "nightly", feature(extend_one, step_trait, test))] #![cfg_attr(feature = "nightly", feature(extend_one, step_trait, test))]
#![cfg_attr(feature = "nightly", feature(new_range_api))] #![cfg_attr(feature = "nightly", feature(new_range_api))]
#![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))] #![cfg_attr(feature = "nightly", feature(new_zeroed_alloc))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod bit_set; pub mod bit_set;

View file

@ -305,7 +305,7 @@ impl Parse for Newtype {
} }
} }
pub fn newtype(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub(crate) fn newtype(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as Newtype); let input = parse_macro_input!(input as Newtype);
input.0.into() input.0.into()
} }

View file

@ -24,7 +24,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![recursion_limit = "512"] // For rustdoc #![recursion_limit = "512"] // For rustdoc
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod errors; mod errors;

View file

@ -4,7 +4,6 @@
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod callbacks; mod callbacks;

View file

@ -23,7 +23,6 @@
// We want to be able to build this crate with a stable compiler, // We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added. // so no `#![feature]` attributes should be added.
#![deny(unstable_features)] #![deny(unstable_features)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod cursor; mod cursor;

View file

@ -32,7 +32,6 @@
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod async_closures; mod async_closures;

View file

@ -1,7 +1,3 @@
// tidy-alphabetical-start
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use rustc_abi::ExternAbi; use rustc_abi::ExternAbi;
use rustc_ast::AttrId; use rustc_ast::AttrId;
use rustc_ast::attr::AttributeExt; use rustc_ast::attr::AttributeExt;

View file

@ -4,7 +4,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(extern_types)] #![feature(extern_types)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::cell::RefCell; use std::cell::RefCell;

View file

@ -6,7 +6,6 @@
#![feature(proc_macro_diagnostic)] #![feature(proc_macro_diagnostic)]
#![feature(proc_macro_span)] #![feature(proc_macro_span)]
#![feature(proc_macro_tracked_env)] #![feature(proc_macro_tracked_env)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use proc_macro::TokenStream; use proc_macro::TokenStream;

View file

@ -15,7 +15,6 @@
#![feature(proc_macro_internals)] #![feature(proc_macro_internals)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(trusted_len)] #![feature(trusted_len)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
extern crate proc_macro; extern crate proc_macro;

View file

@ -61,7 +61,6 @@
#![feature(try_trait_v2_yeet)] #![feature(try_trait_v2_yeet)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
#[cfg(test)] #[cfg(test)]

View file

@ -8,7 +8,6 @@
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
// The `builder` module used to be named `build`, but that was causing GitHub's // The `builder` module used to be named `build`, but that was causing GitHub's

View file

@ -7,7 +7,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(never_type)] #![feature(never_type)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use rustc_middle::ty; use rustc_middle::ty;

View file

@ -12,7 +12,6 @@
#![feature(never_type)] #![feature(never_type)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use hir::ConstContext; use hir::ConstContext;

View file

@ -4,7 +4,6 @@
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)] #![feature(impl_trait_in_assoc_type)]
#![feature(let_chains)] #![feature(let_chains)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;

View file

@ -6,7 +6,6 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![allow(rustc::usage_of_type_ir_inherent)] #![allow(rustc::usage_of_type_ir_inherent)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod canonicalizer; pub mod canonicalizer;

View file

@ -12,7 +12,6 @@
#![feature(iter_intersperse)] #![feature(iter_intersperse)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(string_from_utf8_lossy_owned)] #![feature(string_from_utf8_lossy_owned)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};

View file

@ -13,7 +13,6 @@
html_playground_url = "https://play.rust-lang.org/", html_playground_url = "https://play.rust-lang.org/",
test(attr(deny(warnings))) test(attr(deny(warnings)))
)] )]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub use Alignment::*; pub use Alignment::*;

View file

@ -12,7 +12,6 @@
#![feature(map_try_insert)] #![feature(map_try_insert)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use rustc_middle::query::Providers; use rustc_middle::query::Providers;

View file

@ -6,7 +6,6 @@
#![allow(rustc::diagnostic_outside_of_impl)] #![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)] #![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(feature = "rustc", feature(let_chains))] #![cfg_attr(feature = "rustc", feature(let_chains))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod constructor; pub mod constructor;

View file

@ -5,7 +5,7 @@ use rustc_pattern_analysis::usefulness::{PlaceValidity, UsefulnessReport};
use rustc_pattern_analysis::{MatchArm, PatCx, PrivateUninhabitedField}; use rustc_pattern_analysis::{MatchArm, PatCx, PrivateUninhabitedField};
/// Sets up `tracing` for easier debugging. Tries to look like the `rustc` setup. /// Sets up `tracing` for easier debugging. Tries to look like the `rustc` setup.
pub fn init_tracing() { fn init_tracing() {
use tracing_subscriber::Layer; use tracing_subscriber::Layer;
use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt; use tracing_subscriber::util::SubscriberInitExt;
@ -24,7 +24,7 @@ pub fn init_tracing() {
/// A simple set of types. /// A simple set of types.
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Ty { pub(super) enum Ty {
/// Booleans /// Booleans
Bool, Bool,
/// 8-bit unsigned integers /// 8-bit unsigned integers
@ -41,7 +41,7 @@ pub enum Ty {
/// The important logic. /// The important logic.
impl Ty { impl Ty {
pub fn sub_tys(&self, ctor: &Constructor<Cx>) -> Vec<Self> { pub(super) fn sub_tys(&self, ctor: &Constructor<Cx>) -> Vec<Self> {
use Constructor::*; use Constructor::*;
match (ctor, *self) { match (ctor, *self) {
(Struct, Ty::Tuple(tys)) => tys.iter().copied().collect(), (Struct, Ty::Tuple(tys)) => tys.iter().copied().collect(),
@ -63,7 +63,7 @@ impl Ty {
} }
} }
pub fn ctor_set(&self) -> ConstructorSet<Cx> { fn ctor_set(&self) -> ConstructorSet<Cx> {
match *self { match *self {
Ty::Bool => ConstructorSet::Bool, Ty::Bool => ConstructorSet::Bool,
Ty::U8 => ConstructorSet::Integers { Ty::U8 => ConstructorSet::Integers {
@ -104,7 +104,7 @@ impl Ty {
} }
} }
pub fn write_variant_name( fn write_variant_name(
&self, &self,
f: &mut std::fmt::Formatter<'_>, f: &mut std::fmt::Formatter<'_>,
ctor: &Constructor<Cx>, ctor: &Constructor<Cx>,
@ -120,7 +120,7 @@ impl Ty {
} }
/// Compute usefulness in our simple context (and set up tracing for easier debugging). /// Compute usefulness in our simple context (and set up tracing for easier debugging).
pub fn compute_match_usefulness<'p>( pub(super) fn compute_match_usefulness<'p>(
arms: &[MatchArm<'p, Cx>], arms: &[MatchArm<'p, Cx>],
ty: Ty, ty: Ty,
scrut_validity: PlaceValidity, scrut_validity: PlaceValidity,
@ -137,7 +137,7 @@ pub fn compute_match_usefulness<'p>(
} }
#[derive(Debug)] #[derive(Debug)]
pub struct Cx; pub(super) struct Cx;
/// The context for pattern analysis. Forwards anything interesting to `Ty` methods. /// The context for pattern analysis. Forwards anything interesting to `Ty` methods.
impl PatCx for Cx { impl PatCx for Cx {

View file

@ -6,7 +6,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(try_blocks)] #![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod errors; mod errors;

View file

@ -8,7 +8,6 @@
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use rustc_data_structures::stable_hasher::HashStable; use rustc_data_structures::stable_hasher::HashStable;

View file

@ -5,7 +5,6 @@
#![feature(dropck_eyepatch)] #![feature(dropck_eyepatch)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod cache; pub mod cache;

View file

@ -20,7 +20,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};

View file

@ -5,7 +5,6 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![feature(let_chains)] #![feature(let_chains)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod cfi; pub mod cfi;

View file

@ -14,7 +14,6 @@
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(never_type)] #![feature(never_type)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub use self::serialize::{Decodable, Decoder, Encodable, Encoder}; pub use self::serialize::{Decodable, Decoder, Encodable, Encoder};

View file

@ -7,7 +7,6 @@
// To generate CodegenOptionsTargetModifiers and UnstableOptionsTargetModifiers enums // To generate CodegenOptionsTargetModifiers and UnstableOptionsTargetModifiers enums
// with macro_rules, it is necessary to use recursive mechanic ("Incremental TT Munchers"). // with macro_rules, it is necessary to use recursive mechanic ("Incremental TT Munchers").
#![recursion_limit = "256"] #![recursion_limit = "256"]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod errors; pub mod errors;

View file

@ -15,7 +15,6 @@
)] )]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod rustc_internal; pub mod rustc_internal;

View file

@ -32,7 +32,6 @@
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![feature(slice_as_chunks)] #![feature(slice_as_chunks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
// The code produced by the `Encodable`/`Decodable` derive macros refer to // The code produced by the `Encodable`/`Decodable` derive macros refer to

View file

@ -93,7 +93,6 @@
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use rustc_hir::def::DefKind; use rustc_hir::def::DefKind;

View file

@ -16,7 +16,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};

View file

@ -31,7 +31,6 @@
#![feature(unwrap_infallible)] #![feature(unwrap_infallible)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![recursion_limit = "512"] // For rustdoc #![recursion_limit = "512"] // For rustdoc
#![warn(unreachable_pub)] // For rustdoc
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod error_reporting; pub mod error_reporting;

View file

@ -2,7 +2,6 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![recursion_limit = "256"] #![recursion_limit = "256"]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod codegen; mod codegen;

View file

@ -1,6 +1,5 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![feature(never_type)] #![feature(never_type)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set}; pub(crate) use rustc_data_structures::fx::{FxIndexMap as Map, FxIndexSet as Set};

View file

@ -16,7 +16,6 @@
#![feature(let_chains)] #![feature(let_chains)]
#![feature(never_type)] #![feature(never_type)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
use rustc_middle::query::Providers; use rustc_middle::query::Providers;

View file

@ -6,7 +6,6 @@
feature(associated_type_defaults, never_type, rustc_attrs, negative_impls) feature(associated_type_defaults, never_type, rustc_attrs, negative_impls)
)] )]
#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", allow(internal_features))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
extern crate self as rustc_type_ir; extern crate self as rustc_type_ir;

View file

@ -1045,8 +1045,11 @@ impl Builder<'_> {
// so this line allows the use of custom libcs. // so this line allows the use of custom libcs.
cargo.env("LIBC_CHECK_CFG", "1"); cargo.env("LIBC_CHECK_CFG", "1");
if source_type == SourceType::InTree {
let mut lint_flags = Vec::new(); let mut lint_flags = Vec::new();
// Lints for all in-tree code: compiler, rustdoc, cranelift, gcc,
// clippy, rustfmt, rust-analyzer, etc.
if source_type == SourceType::InTree {
// When extending this list, add the new lints to the RUSTFLAGS of the // When extending this list, add the new lints to the RUSTFLAGS of the
// build_bootstrap function of src/bootstrap/bootstrap.py as well as // build_bootstrap function of src/bootstrap/bootstrap.py as well as
// some code doesn't go through this `rustc` wrapper. // some code doesn't go through this `rustc` wrapper.
@ -1058,28 +1061,33 @@ impl Builder<'_> {
rustdocflags.arg("-Dwarnings"); rustdocflags.arg("-Dwarnings");
} }
// This does not use RUSTFLAGS due to caching issues with Cargo.
// Clippy is treated as an "in tree" tool, but shares the same
// cache as other "submodule" tools. With these options set in
// RUSTFLAGS, that causes *every* shared dependency to be rebuilt.
// By injecting this into the rustc wrapper, this circumvents
// Cargo's fingerprint detection. This is fine because lint flags
// are always ignored in dependencies. Eventually this should be
// fixed via better support from Cargo.
cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" "));
rustdocflags.arg("-Wrustdoc::invalid_codeblock_attributes"); rustdocflags.arg("-Wrustdoc::invalid_codeblock_attributes");
} }
// Lints just for `compiler/` crates.
if mode == Mode::Rustc { if mode == Mode::Rustc {
rustflags.arg("-Wrustc::internal"); lint_flags.push("-Wrustc::internal");
rustflags.arg("-Drustc::symbol_intern_string_literal"); lint_flags.push("-Drustc::symbol_intern_string_literal");
// FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all // FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all
// of the individual lints are satisfied. // of the individual lints are satisfied.
rustflags.arg("-Wkeyword_idents_2024"); lint_flags.push("-Wkeyword_idents_2024");
rustflags.arg("-Wunsafe_op_in_unsafe_fn"); lint_flags.push("-Wunreachable_pub");
lint_flags.push("-Wunsafe_op_in_unsafe_fn");
} }
// This does not use RUSTFLAGS for two reasons.
// - Due to caching issues with Cargo. Clippy is treated as an "in
// tree" tool, but shares the same cache as other "submodule" tools.
// With these options set in RUSTFLAGS, that causes *every* shared
// dependency to be rebuilt. By injecting this into the rustc
// wrapper, this circumvents Cargo's fingerprint detection. This is
// fine because lint flags are always ignored in dependencies.
// Eventually this should be fixed via better support from Cargo.
// - RUSTFLAGS is ignored for proc macro crates that are being built on
// the host (because `--target` is given). But we want the lint flags
// to be applied to proc macro crates.
cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" "));
if self.config.rust_frame_pointers { if self.config.rust_frame_pointers {
rustflags.arg("-Cforce-frame-pointers=true"); rustflags.arg("-Cforce-frame-pointers=true");
} }