diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index fbb20ed101055..472835388620c 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -969,14 +969,18 @@ where let mut lint = Diag::new(dcx, level, msg!("unknown lint: `{$name}`")) .with_arg("name", lint_id.lint.name_lower()) .with_note(msg!("the `{$name}` lint is unstable")); - rustc_session::diagnostics::add_feature_diagnostics_for_issue( - &mut lint, - sess, - feature, - GateIssue::Language, - lint_from_cli, - None, - ); + // `staged_api` is only intended for the standard library, so don't + // suggest enabling it just to use this lint. + if feature != sym::staged_api { + rustc_session::diagnostics::add_feature_diagnostics_for_issue( + &mut lint, + sess, + feature, + GateIssue::Language, + lint_from_cli, + None, + ); + } lint } } diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 5ee3c5a741bdc..e955a8b819020 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -54,6 +54,7 @@ pub mod hardwired { FUNCTION_ITEM_REFERENCES, HIDDEN_GLOB_REEXPORTS, ILL_FORMED_ATTRIBUTE_INPUT, + INCOMPATIBLE_REEXPORT_STABILITY, INCOMPLETE_INCLUDE, INEFFECTIVE_UNSTABLE_TRAIT_IMPL, INLINE_NO_SANITIZE, @@ -2791,6 +2792,41 @@ declare_lint! { "detects deprecation attributes with no effect", } +declare_lint! { + /// The `incompatible_reexport_stability` lint detects stability + /// annotations on re-exports that are incompatible with the stability + /// metadata of the re-exported item. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// #![feature(staged_api)] + /// #![stable(feature = "test", since = "1.0.0")] + /// + /// #[stable(feature = "original", since = "1.0.0")] + /// pub struct S; + /// + /// #[stable(feature = "different", since = "1.0.0")] + /// pub use self::S as T; + /// + /// fn main() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Stability annotations on re-exports should be compatible with the + /// stability metadata of the item being re-exported. Stable metadata is + /// compared by feature and `since`, while unstable metadata is compared by + /// feature and issue. Stable re-exports of unstable definitions remain + /// handled by the existing stability machinery. + pub INCOMPATIBLE_REEXPORT_STABILITY, + Deny, + "detects incompatible stability annotations on re-exports", + @feature_gate = staged_api; +} + declare_lint! { /// The `ineffective_unstable_trait_impl` lint detects `#[unstable]` attributes which are not used. /// diff --git a/compiler/rustc_passes/src/diagnostics.rs b/compiler/rustc_passes/src/diagnostics.rs index 16a2cc4007318..a2e3f5da36dce 100644 --- a/compiler/rustc_passes/src/diagnostics.rs +++ b/compiler/rustc_passes/src/diagnostics.rs @@ -964,6 +964,10 @@ pub(crate) struct UnnecessaryPartialStableFeature { #[note("see issue #55436 for more information")] pub(crate) struct IneffectiveUnstableImpl; +#[derive(Diagnostic)] +#[diag("stability annotation on this re-export does not match the re-exported item")] +pub(crate) struct IncompatibleReexportStability; + // FIXME(jdonszelmann): move back to rustc_attr #[derive(Diagnostic)] #[diag( diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 37ec1dc01bd4b..fc459e0dd89b3 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -18,9 +18,11 @@ use rustc_hir::{ }; use rustc_lint_defs as lint; use rustc_lint_defs::builtin::{ - DEPRECATED, DUPLICATE_FEATURES, INEFFECTIVE_UNSTABLE_TRAIT_IMPL, STABLE_FEATURES, + DEPRECATED, DUPLICATE_FEATURES, INCOMPATIBLE_REEXPORT_STABILITY, + INEFFECTIVE_UNSTABLE_TRAIT_IMPL, STABLE_FEATURES, }; use rustc_middle::hir::nested_filter; +use rustc_middle::metadata::Reexport; use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures}; use rustc_middle::middle::privacy::EffectiveVisibilities; use rustc_middle::middle::stability::{AllowUnstable, Deprecated, DeprecationEntry, EvalResult}; @@ -523,7 +525,9 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { /// Cross-references the feature names of unstable APIs with enabled /// features and possibly prints errors. fn check_mod_unstable_api_usage(tcx: TyCtxt<'_>, mod_id: LocalModId) { - tcx.hir_visit_item_likes_in_module(mod_id, &mut Checker { tcx }); + let mut checker = Checker { tcx, mod_id, reexport_stability: FxIndexMap::default() }; + tcx.hir_visit_item_likes_in_module(mod_id, &mut checker); + checker.emit_incompatible_reexport_stability(); let is_staged_api = tcx.sess.opts.unstable_opts.force_unstable_if_unmarked || tcx.features().staged_api(); @@ -553,8 +557,183 @@ pub(crate) fn provide(providers: &mut Providers) { }; } +struct ReexportStability { + hir_id: HirId, + span: Span, + has_target: bool, + all_targets_compatible: bool, +} + struct Checker<'tcx> { tcx: TyCtxt<'tcx>, + mod_id: LocalModId, + reexport_stability: FxIndexMap, +} + +impl<'tcx> Checker<'tcx> { + fn reexport_stability_attr(&self, item: &'tcx hir::Item<'tcx>) -> Option<(Stability, Span)> { + let attrs = self.tcx.hir_attrs(item.hir_id()); + find_attr!(attrs, Stability { stability, span } => (*stability, *span)) + } + + fn stability_is_compatible(reexport: &Stability, target: &Stability) -> bool { + match (&reexport.level, &target.level) { + ( + StabilityLevel::Stable { since: reexport_since, .. }, + StabilityLevel::Stable { since: target_since, .. }, + ) => { + // Avoid another error for an invalid `since`. + matches!( + (*reexport_since, *target_since), + (StableSince::Err(_), _) | (_, StableSince::Err(_)) + ) || (reexport.feature == target.feature && reexport_since == target_since) + } + + ( + StabilityLevel::Unstable { issue: reexport_issue, .. }, + StabilityLevel::Unstable { issue: target_issue, .. }, + ) => reexport.feature == target.feature && reexport_issue == target_issue, + + // An unstable re-export cannot make a stable item unstable. + (StabilityLevel::Unstable { .. }, StabilityLevel::Stable { .. }) => false, + + // Stable re-exports of unstable items are handled elsewhere. + (StabilityLevel::Stable { .. }, StabilityLevel::Unstable { .. }) => true, + } + } + + fn classify_reexport_targets( + &self, + own_stability: &Stability, + targets: impl IntoIterator>, + ) -> (bool, bool) { + let mut has_target = false; + let mut all_targets_compatible = true; + + for res in targets { + match res { + Res::Def(_, def_id) => { + has_target = true; + + if let Some(target_stability) = self.tcx.lookup_stability(def_id) + && !Self::stability_is_compatible(own_stability, &target_stability) + { + all_targets_compatible = false; + } + } + + Res::PrimTy(_) => { + has_target = true; + + // Primitives are stable and have no DefId. + if own_stability.level.is_unstable() { + all_targets_compatible = false; + } + } + + // No stability metadata to compare. + _ => {} + } + } + + (has_target, all_targets_compatible) + } + + fn record_reexport_stability( + &mut self, + item: &'tcx hir::Item<'tcx>, + attr_span: Span, + span: Span, + has_target: bool, + all_targets_compatible: bool, + ) { + let entry = self.reexport_stability.entry(attr_span).or_insert(ReexportStability { + hir_id: item.hir_id(), + span, + has_target: false, + all_targets_compatible: true, + }); + + entry.has_target |= has_target; + + // Keep the first bad path for the diagnostic. + if entry.all_targets_compatible && !all_targets_compatible { + entry.span = span; + } + + entry.all_targets_compatible &= all_targets_compatible; + } + + fn check_single_reexport_stability( + &mut self, + item: &'tcx hir::Item<'tcx>, + path: &'tcx UsePath<'tcx>, + ) { + let Some((own_stability, attr_span)) = self.reexport_stability_attr(item) else { + return; + }; + + let (has_target, all_targets_compatible) = + self.classify_reexport_targets(&own_stability, path.res.present_items()); + + self.record_reexport_stability( + item, + attr_span, + path.span, + has_target, + all_targets_compatible, + ); + } + + fn check_glob_reexport_stability( + &mut self, + item: &'tcx hir::Item<'tcx>, + path: &'tcx UsePath<'tcx>, + ) { + let Some((own_stability, attr_span)) = self.reexport_stability_attr(item) else { + return; + }; + + let glob_def_id = item.owner_id.def_id.to_def_id(); + + let targets = self + .tcx + .module_children_local(self.mod_id.to_local_def_id()) + .iter() + .filter(|child| { + child.reexport_chain.iter().any(|reexport| { + matches!( + *reexport, + Reexport::Glob(def_id) if def_id == glob_def_id + ) + }) + }) + .map(|child| child.res); + + let (has_target, all_targets_compatible) = + self.classify_reexport_targets(&own_stability, targets); + + self.record_reexport_stability( + item, + attr_span, + path.span, + has_target, + all_targets_compatible, + ); + } + + fn emit_incompatible_reexport_stability(&self) { + for reexport in self.reexport_stability.values() { + if reexport.has_target && !reexport.all_targets_compatible { + self.tcx.emit_node_span_lint( + INCOMPATIBLE_REEXPORT_STABILITY, + reexport.hir_id, + reexport.span, + diagnostics::IncompatibleReexportStability, + ); + } + } + } } impl<'tcx> Visitor<'tcx> for Checker<'tcx> { @@ -583,6 +762,20 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> { self.tcx.check_stability(def_id, Some(item.hir_id()), item.span, None); } + hir::ItemKind::Use(path, hir::UseKind::Single(_)) + if self.tcx.features().staged_api() + && self.tcx.local_visibility(item.owner_id.def_id).is_public() => + { + self.check_single_reexport_stability(item, path); + } + + hir::ItemKind::Use(path, hir::UseKind::Glob) + if self.tcx.features().staged_api() + && self.tcx.local_visibility(item.owner_id.def_id).is_public() => + { + self.check_glob_reexport_stability(item, path); + } + // For implementations of traits, check the stability of each item // individually as it's possible to have a stable trait with unstable // items. diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index c0d7d8b605227..e544ba5915cce 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -4,6 +4,8 @@ #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This facade has its own path stability. pub use core::alloc::*; use core::mem::Alignment; use core::ptr::{self, NonNull}; diff --git a/library/alloc/src/collections/mod.rs b/library/alloc/src/collections/mod.rs index 2cc6b8e894664..682caa93ad797 100644 --- a/library/alloc/src/collections/mod.rs +++ b/library/alloc/src/collections/mod.rs @@ -20,6 +20,8 @@ pub mod btree_map { //! An ordered map based on a B-Tree. #[stable(feature = "rust1", since = "1.0.0")] #[cfg(not(test))] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Public facade over internal B-tree items. pub use super::btree::map::*; } @@ -29,6 +31,8 @@ pub mod btree_set { //! An ordered set based on a B-Tree. #[stable(feature = "rust1", since = "1.0.0")] #[cfg(not(test))] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Public facade over internal B-tree items. pub use super::btree::set::*; } diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index e3ff2ba51aba0..349110b48e40d 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -600,10 +600,14 @@ pub use core::fmt::{Arguments, write}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::fmt::{Binary, Octal}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::fmt::{Debug, Display}; #[unstable(feature = "formatting_options", issue = "118117")] pub use core::fmt::{DebugAsHex, FormattingOptions, Sign}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::fmt::{Formatter, Result, Write}; diff --git a/library/alloc/src/io/mod.rs b/library/alloc/src/io/mod.rs index 44d780292317f..8bff6ad500904 100644 --- a/library/alloc/src/io/mod.rs +++ b/library/alloc/src/io/mod.rs @@ -194,6 +194,8 @@ pub use core::io::SimpleMessage; pub use core::io::const_error; #[unstable(feature = "core_io_borrowed_buf", issue = "117693")] pub use core::io::{BorrowedBuf, BorrowedCursor}; +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "alloc_io", issue = "154046")] pub use core::io::{ Chain, Cursor, Empty, Error, ErrorKind, IoSlice, IoSliceMut, Repeat, Result, Seek, SeekFrom, @@ -209,6 +211,8 @@ use core::io::{ use self::read::{append_to_string, default_read_buf_exact, default_read_exact}; use self::util::{bytes, lines, split, uninlined_slow_read_byte}; +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "alloc_io", issue = "154046")] pub use self::{ buf_read::BufRead, diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index 4c86d7e06ae44..c3f455619451f 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -17,11 +17,15 @@ pub use core::str::SplitAsciiWhitespace; #[stable(feature = "split_inclusive", since = "1.51.0")] pub use core::str::SplitInclusive; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::str::SplitWhitespace; #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::pattern; use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher, Utf8Pattern}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::str::{Bytes, CharIndices, Chars, from_utf8, from_utf8_mut}; #[stable(feature = "str_escape", since = "1.34.0")] pub use core::str::{EscapeDebug, EscapeDefault, EscapeUnicode}; @@ -31,10 +35,16 @@ pub use core::str::{FromStr, Utf8Error}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::{Lines, LinesAny}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::str::{MatchIndices, RMatchIndices}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::str::{Matches, RMatches}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use core::str::{ParseBoolError, from_utf8_unchecked, from_utf8_unchecked_mut}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::{RSplit, Split}; diff --git a/library/core/src/arch.rs b/library/core/src/arch.rs index 737a643ef8659..659e753cccce7 100644 --- a/library/core/src/arch.rs +++ b/library/core/src/arch.rs @@ -10,6 +10,9 @@ unreachable_pub )] #[stable(feature = "simd_arch", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// Keep the facade's stability. pub use crate::core_arch::arch::*; /// Inline assembly. diff --git a/library/core/src/io/mod.rs b/library/core/src/io/mod.rs index a44d271535a9e..6a916bbbd8d6f 100644 --- a/library/core/src/io/mod.rs +++ b/library/core/src/io/mod.rs @@ -20,6 +20,8 @@ pub use self::error::RawOsError; pub use self::error::SimpleMessage; #[unstable(feature = "io_const_error", issue = "133448")] pub use self::error::const_error; +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "core_io", issue = "154046")] pub use self::{ cursor::Cursor, diff --git a/library/core/src/iter/mod.rs b/library/core/src/iter/mod.rs index 9ddafd47807f2..0b32db8765685 100644 --- a/library/core/src/iter/mod.rs +++ b/library/core/src/iter/mod.rs @@ -459,6 +459,8 @@ pub use self::traits::TrustedLen; #[unstable(feature = "trusted_step", issue = "85731")] pub use self::traits::TrustedStep; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use self::traits::{ DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator, IntoIterator, Product, Sum, }; diff --git a/library/core/src/iter/traits/mod.rs b/library/core/src/iter/traits/mod.rs index 7639704d5799c..8cbf8a78dbea3 100644 --- a/library/core/src/iter/traits/mod.rs +++ b/library/core/src/iter/traits/mod.rs @@ -12,6 +12,8 @@ pub use self::marker::TrustedFused; #[unstable(feature = "trusted_step", issue = "85731")] pub use self::marker::TrustedStep; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use self::{ accum::{Product, Sum}, collect::{Extend, FromIterator, IntoIterator}, diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index f026434acbbc1..e03c2f26906d0 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -227,6 +227,8 @@ pub mod offload; #[unstable(feature = "contracts", issue = "128044")] pub mod contracts; +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "derive_macro_global_path", issue = "154645")] pub use crate::macros::builtin::derive; #[stable(feature = "cfg_select", since = "1.95.0")] diff --git a/library/core/src/net/mod.rs b/library/core/src/net/mod.rs index 0786165fe9e76..14bdb2c0309e6 100644 --- a/library/core/src/net/mod.rs +++ b/library/core/src/net/mod.rs @@ -12,6 +12,8 @@ #![stable(feature = "ip_in_core", since = "1.77.0")] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use self::ip_addr::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::parser::AddrParseError; diff --git a/library/core/src/ops/mod.rs b/library/core/src/ops/mod.rs index 6fa96c242fa76..b355a75714f11 100644 --- a/library/core/src/ops/mod.rs +++ b/library/core/src/ops/mod.rs @@ -156,6 +156,8 @@ mod unsize; pub use self::arith::{Add, Div, Mul, Neg, Rem, Sub}; #[stable(feature = "op_assign_traits", since = "1.8.0")] pub use self::arith::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "async_fn_traits", issue = "none")] pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce}; #[stable(feature = "rust1", since = "1.0.0")] @@ -186,6 +188,8 @@ pub(crate) use self::index_range::IndexRange; #[unstable(feature = "range_into_bounds", issue = "136903")] pub use self::range::IntoBounds; #[stable(feature = "inclusive_range", since = "1.26.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; #[unstable(feature = "one_sided_range", issue = "69780")] pub use self::range::{OneSidedRange, OneSidedRangeBound}; diff --git a/library/core/src/prelude/mod.rs b/library/core/src/prelude/mod.rs index 8d867a269a21a..60c8202ec71a3 100644 --- a/library/core/src/prelude/mod.rs +++ b/library/core/src/prelude/mod.rs @@ -18,6 +18,8 @@ pub mod v1; pub mod rust_2015 { #[stable(feature = "prelude_2015", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; } @@ -28,6 +30,8 @@ pub mod rust_2015 { pub mod rust_2018 { #[stable(feature = "prelude_2018", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; } @@ -38,14 +42,20 @@ pub mod rust_2018 { pub mod rust_2021 { #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::iter::FromIterator; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::convert::{TryFrom, TryInto}; } @@ -56,18 +66,26 @@ pub mod rust_2021 { pub mod rust_2024 { #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::iter::FromIterator; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::convert::{TryFrom, TryInto}; #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::future::{Future, IntoFuture}; } @@ -79,17 +97,25 @@ pub mod rust_2024 { pub mod rust_future { #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::iter::FromIterator; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::convert::{TryFrom, TryInto}; #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::future::{Future, IntoFuture}; } diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 6122ab12ec351..019f86daef223 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -6,13 +6,16 @@ // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] - // Re-exported core operators #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::marker::{Copy, Send, Sized, Sync, Unpin}; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::ops::{Drop, Fn, FnMut, FnOnce}; #[stable(feature = "async_closure", since = "1.85.0")] #[doc(no_inline)] @@ -21,32 +24,50 @@ pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; // Re-exported functions #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::mem::drop; #[stable(feature = "size_of_prelude", since = "1.80.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::mem::{align_of, align_of_val, size_of, size_of_val}; // Re-exported types and traits #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::clone::Clone; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::cmp::{Eq, Ord, PartialEq, PartialOrd}; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::convert::{AsMut, AsRef, From, Into}; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::default::Default; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::iter::{DoubleEndedIterator, ExactSizeIterator, Extend, IntoIterator, Iterator}; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::option::Option::{self, None, Some}; #[stable(feature = "core_prelude", since = "1.4.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::result::Result::{self, Err, Ok}; // Re-exported built-in macros @@ -60,6 +81,8 @@ pub use crate::hash::macros::Hash; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] #[expect(deprecated)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::{ assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, file, format_args, include, include_bytes, include_str, line, matches, @@ -74,10 +97,14 @@ mod ambiguous_macros_only { #[expect(hidden_glob_reexports)] mod panic {} #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::*; } #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use self::ambiguous_macros_only::{env, panic}; #[stable(feature = "cfg_select", since = "1.95.0")] @@ -119,12 +146,16 @@ pub use crate::trace_macros; // Do not `doc(no_inline)` so that they become doc items on their own // (no public module for them to be re-exported from). #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::macros::builtin::{ alloc_error_handler, bench, global_allocator, test, test_case, }; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::macros::builtin::derive; #[unstable(feature = "derive_const", issue = "118304")] diff --git a/library/core/src/range.rs b/library/core/src/range.rs index 557587b4e9a88..e71330badc3e0 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -41,6 +41,8 @@ use crate::iter::Step; use crate::ops::{IntoBounds, OneSidedRange, OneSidedRangeBound, RangeBounds}; #[doc(inline)] #[stable(feature = "new_range_api_exports", since = "1.98.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use crate::ops::{RangeFull, RangeTo}; /// A (half-open) range bounded inclusively below and exclusively above. diff --git a/library/core/src/range/legacy.rs b/library/core/src/range/legacy.rs index c1bac705f80b3..40ed359ef1161 100644 --- a/library/core/src/range/legacy.rs +++ b/library/core/src/range/legacy.rs @@ -8,4 +8,6 @@ #[doc(inline)] #[stable(feature = "new_range_api_legacy", since = "1.98.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use crate::ops::{Range, RangeFrom, RangeInclusive, RangeToInclusive}; diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index b3b4658645b9f..4e3ad405b1393 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -42,6 +42,8 @@ pub use iter::SplitAsciiWhitespace; #[stable(feature = "split_inclusive", since = "1.51.0")] pub use iter::SplitInclusive; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Path stability is tracked separately. pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace}; #[stable(feature = "str_escape", since = "1.34.0")] pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode}; diff --git a/library/core/src/ub_checks.rs b/library/core/src/ub_checks.rs index f25781ea8ce5a..6c9ccd7ad82dc 100644 --- a/library/core/src/ub_checks.rs +++ b/library/core/src/ub_checks.rs @@ -85,6 +85,9 @@ pub use assert_unsafe_precondition; /// Checking library UB is always enabled when UB-checking is done /// (and we use a reexport so that there is no unnecessary wrapper function). #[unstable(feature = "ub_checks", issue = "none")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// Public alias intentionally uses the `ub_checks` feature. pub use intrinsics::ub_checks as check_library_ub; /// Determines whether we should check for language UB. diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 2f026fb81ee1b..87fa22d38382a 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -372,6 +372,9 @@ impl Default for TokenStream { } #[unstable(feature = "proc_macro_quote", issue = "54722")] +#[cfg_attr(not(bootstrap), allow(clippy::useless_attribute))] +#[cfg_attr(not(bootstrap), allow(incompatible_reexport_stability))] +// These helpers are exposed through this unstable API. pub use quote::{HasIterator, RepInterp, ThereIsNoIteratorInRepetition, ext, quote, quote_span}; fn tree_to_bridge_tree( diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 558ab0f2fc66d..36e2bb283b99f 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -70,6 +70,9 @@ #[stable(feature = "alloc_module", since = "1.28.0")] #[doc(inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use alloc_crate::alloc::*; use crate::ptr::NonNull; diff --git a/library/std/src/collections/mod.rs b/library/std/src/collections/mod.rs index 460deb490ef0b..1452c373bc9ce 100644 --- a/library/std/src/collections/mod.rs +++ b/library/std/src/collections/mod.rs @@ -436,6 +436,9 @@ pub use self::hash_set::HashSet; // FIXME(#82080) The deprecation here is only theoretical, and does not actually produce a warning. #[deprecated(note = "moved to `std::ops::Bound`", since = "1.26.0")] #[doc(hidden)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use crate::ops::Bound; mod hash; @@ -444,6 +447,9 @@ mod hash; pub mod hash_map { //! A hash map implemented with quadratic probing and SIMD lookup. #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::hash::map::*; #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] pub use crate::hash::random::DefaultHasher; @@ -455,5 +461,8 @@ pub mod hash_map { pub mod hash_set { //! A hash set implemented as a `HashMap` where the value is `()`. #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::hash::set::*; } diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index cb0ca5d1376ea..12c4a694ef274 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -1,14 +1,29 @@ //! [`CStr`], [`CString`], and related types. #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use alloc::ffi::c_str::FromVecWithNulError; #[stable(feature = "cstring_into", since = "1.7.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use alloc::ffi::c_str::IntoStringError; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use alloc::ffi::c_str::{CString, NulError}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::ffi::c_str::CStr; #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use core::ffi::c_str::FromBytesUntilNulError; #[stable(feature = "cstr_from_bytes", since = "1.10.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::ffi::c_str::FromBytesWithNulError; diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs index b339a80f45397..1bc9f533f702b 100644 --- a/library/std/src/ffi/mod.rs +++ b/library/std/src/ffi/mod.rs @@ -181,18 +181,33 @@ pub use core::ffi::{c_ptrdiff_t, c_size_t, c_ssize_t}; pub use self::c_str::FromBytesUntilNulError; #[doc(inline)] #[stable(feature = "cstr_from_bytes", since = "1.10.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::c_str::FromBytesWithNulError; #[doc(inline)] #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::c_str::FromVecWithNulError; #[doc(inline)] #[stable(feature = "cstring_into", since = "1.7.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::c_str::IntoStringError; #[doc(inline)] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::c_str::NulError; #[doc(inline)] #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::c_str::{CStr, CString}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(inline)] diff --git a/library/std/src/hash/mod.rs b/library/std/src/hash/mod.rs index e5ef9e3359736..80ee59fad50e0 100644 --- a/library/std/src/hash/mod.rs +++ b/library/std/src/hash/mod.rs @@ -85,7 +85,13 @@ pub(crate) mod random; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::hash::*; #[stable(feature = "std_hash_exports", since = "1.76.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::random::{DefaultHasher, RandomState}; diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index c0ed06d5311bc..e10991e8815cd 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -307,6 +307,9 @@ pub use alloc_crate::io::const_error; #[stable(feature = "io_read_to_string", since = "1.65.0")] pub use alloc_crate::io::read_to_string; #[unstable(feature = "read_buf", issue = "78485")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use alloc_crate::io::{BorrowedBuf, BorrowedCursor}; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::io::{ diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 980ec4416f04a..1996f92a17201 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -573,6 +573,9 @@ pub use core::pin; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ptr; #[stable(feature = "new_range_api", since = "1.96.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::range; #[stable(feature = "rust1", since = "1.0.0")] pub use core::result; @@ -694,6 +697,9 @@ pub mod task { pub use alloc::task::*; #[doc(inline)] #[stable(feature = "futures_api", since = "1.36.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use core::task::*; } @@ -706,14 +712,21 @@ pub mod arch { // See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for // more information. #[doc(no_inline)] // Note (#82861): required for correct documentation + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use core::arch::*; #[stable(feature = "simd_aarch64", since = "1.60.0")] pub use std_detect::is_aarch64_feature_detected; #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] pub use std_detect::is_arm_feature_detected; + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "is_loongarch_feature_detected", issue = "117425")] pub use std_detect::is_loongarch_feature_detected; + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "is_riscv_feature_detected", issue = "111192")] pub use std_detect::is_riscv_feature_detected; #[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")] @@ -750,6 +763,8 @@ pub use core::cfg_select; reason = "`concat_bytes` is not stable enough for use and is subject to change" )] pub use core::concat_bytes; +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "derive_macro_global_path", issue = "154645")] pub use core::derive; #[stable(feature = "matches_macro", since = "1.42.0")] @@ -762,6 +777,9 @@ pub use core::primitive; pub use core::todo; // Re-export built-in macros defined through core. #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::{ assert, cfg, column, compile_error, concat, const_format_args, env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env, @@ -770,6 +788,9 @@ pub use core::{ // Re-export macros defined in core. #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::{ assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, r#try, unimplemented, unreachable, write, writeln, diff --git a/library/std/src/net/mod.rs b/library/std/src/net/mod.rs index 1b1096925dd4a..3ea07d4315610 100644 --- a/library/std/src/net/mod.rs +++ b/library/std/src/net/mod.rs @@ -28,6 +28,9 @@ pub use core::net::AddrParseError; #[unstable(feature = "gethostname", issue = "135142")] pub use self::hostname::hostname; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use self::ip_addr::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::socket_addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}; diff --git a/library/std/src/num/mod.rs b/library/std/src/num/mod.rs index 5aa6c1492ec65..465867e4cc4e5 100644 --- a/library/std/src/num/mod.rs +++ b/library/std/src/num/mod.rs @@ -23,6 +23,9 @@ pub use core::num::Wrapping; )] pub use core::num::ZeroablePrimitive; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}; #[stable(feature = "signed_nonzero", since = "1.34.0")] pub use core::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize}; diff --git a/library/std/src/os/fd/mod.rs b/library/std/src/os/fd/mod.rs index 735f1cf8925fb..6f043efbaeff5 100644 --- a/library/std/src/os/fd/mod.rs +++ b/library/std/src/os/fd/mod.rs @@ -25,8 +25,14 @@ mod tests; // Export the types and traits for the public API. #[stable(feature = "os_fd", since = "1.66.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use owned::*; #[stable(feature = "os_fd", since = "1.66.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use raw::*; #[unstable(feature = "stdio_fd_consts", issue = "150836")] pub use stdio::*; diff --git a/library/std/src/os/macos/mod.rs b/library/std/src/os/macos/mod.rs index 0681c9b714816..bf23554170496 100644 --- a/library/std/src/os/macos/mod.rs +++ b/library/std/src/os/macos/mod.rs @@ -23,5 +23,8 @@ pub mod fs { pub mod raw { #[doc(inline)] #[stable(feature = "raw_ext", since = "1.1.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use crate::os::darwin::raw::*; } diff --git a/library/std/src/os/unix/io/mod.rs b/library/std/src/os/unix/io/mod.rs index 4afb8ffa71017..dc046dfd12648 100644 --- a/library/std/src/os/unix/io/mod.rs +++ b/library/std/src/os/unix/io/mod.rs @@ -94,6 +94,9 @@ use crate::io::{self, Stderr, StderrLock, Stdin, StdinLock, Stdout, StdoutLock, Write}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use crate::os::fd::*; #[allow(unused_imports)] // not used on all targets use crate::sys::cvt; diff --git a/library/std/src/os/unix/mod.rs b/library/std/src/os/unix/mod.rs index c994174b744dd..db00f165c644f 100644 --- a/library/std/src/os/unix/mod.rs +++ b/library/std/src/os/unix/mod.rs @@ -107,15 +107,24 @@ pub mod prelude { pub use super::ffi::{OsStrExt, OsStringExt}; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::fs::DirEntryExt; #[doc(no_inline)] #[stable(feature = "file_offset", since = "1.15.0")] pub use super::fs::FileExt; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::fs::{FileTypeExt, MetadataExt, OpenOptionsExt, PermissionsExt}; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; #[doc(no_inline)] #[unstable(feature = "unix_send_signal", issue = "141975")] @@ -125,5 +134,8 @@ pub mod prelude { pub use super::process::{CommandExt, ExitStatusExt}; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::thread::JoinHandleExt; } diff --git a/library/std/src/os/wasi/io/mod.rs b/library/std/src/os/wasi/io/mod.rs index 5f9a735db085e..e61061101d81e 100644 --- a/library/std/src/os/wasi/io/mod.rs +++ b/library/std/src/os/wasi/io/mod.rs @@ -3,6 +3,9 @@ #![stable(feature = "io_safety_wasi", since = "1.65.0")] #[stable(feature = "io_safety_wasi", since = "1.65.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use crate::os::fd::*; // Tests for this module diff --git a/library/std/src/os/wasi/mod.rs b/library/std/src/os/wasi/mod.rs index 1db9ec906726f..f89c8fdb69983 100644 --- a/library/std/src/os/wasi/mod.rs +++ b/library/std/src/os/wasi/mod.rs @@ -57,5 +57,8 @@ pub mod prelude { pub use super::fs::{DirEntryExt, FileExt, MetadataExt, OpenOptionsExt}; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // This re-export has its own stability. pub use super::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; } diff --git a/library/std/src/os/windows/io/mod.rs b/library/std/src/os/windows/io/mod.rs index bf0605aa08a95..731107c31ce5d 100644 --- a/library/std/src/os/windows/io/mod.rs +++ b/library/std/src/os/windows/io/mod.rs @@ -61,6 +61,9 @@ mod socket; #[stable(feature = "io_safety", since = "1.63.0")] pub use handle::*; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use raw::*; #[stable(feature = "io_safety", since = "1.63.0")] pub use socket::*; diff --git a/library/std/src/os/windows/mod.rs b/library/std/src/os/windows/mod.rs index a7e032dbf4d4d..bf36c063a8cc4 100644 --- a/library/std/src/os/windows/mod.rs +++ b/library/std/src/os/windows/mod.rs @@ -49,9 +49,15 @@ pub mod prelude { pub use super::fs::FileExt; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // Prelude stability differs here. pub use super::fs::{MetadataExt, OpenOptionsExt}; #[doc(no_inline)] #[stable(feature = "rust1", since = "1.0.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] + // Prelude stability differs here. pub use super::io::{ AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, FromRawHandle, FromRawSocket, HandleOrInvalid, IntoRawHandle, IntoRawSocket, OwnedHandle, OwnedSocket, diff --git a/library/std/src/prelude/mod.rs b/library/std/src/prelude/mod.rs index 78eb79ac666a2..9766b7a6fdbc7 100644 --- a/library/std/src/prelude/mod.rs +++ b/library/std/src/prelude/mod.rs @@ -120,6 +120,8 @@ pub mod v1; pub mod rust_2015 { #[stable(feature = "prelude_2015", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; } @@ -130,6 +132,8 @@ pub mod rust_2015 { pub mod rust_2018 { #[stable(feature = "prelude_2018", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; } @@ -140,15 +144,21 @@ pub mod rust_2018 { pub mod rust_2021 { #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use core::prelude::rust_2021::*; // There are two different panic macros, one in `core` and one in `std`. They are slightly // different. For `std` we explicitly want the one defined in `std`. #[stable(feature = "prelude_2021", since = "1.55.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::panic; } @@ -159,15 +169,21 @@ pub mod rust_2021 { pub mod rust_2024 { #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use core::prelude::rust_2024::*; // There are two different panic macros, one in `core` and one in `std`. They are slightly // different. For `std` we explicitly want the one defined in `std`. #[stable(feature = "prelude_2024", since = "1.85.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::panic; } @@ -179,14 +195,20 @@ pub mod rust_2024 { pub mod rust_future { #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use super::v1::*; + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "prelude_next", issue = "none")] #[doc(no_inline)] pub use core::prelude::rust_future::*; // There are two different panic macros, one in `core` and one in `std`. They are slightly // different. For `std` we explicitly want the one defined in `std`. + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // FIXME(#161153) #[unstable(feature = "prelude_next", issue = "none")] pub use super::v1::panic; } diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index aeefec8b9e084..76f9d001824d8 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -6,10 +6,11 @@ // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] - // Re-exported core operators #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::marker::{Send, Sized, Sync, Unpin}; #[stable(feature = "rust1", since = "1.0.0")] #[doc(no_inline)] @@ -24,6 +25,8 @@ pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; pub use crate::mem::drop; #[stable(feature = "size_of_prelude", since = "1.80.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::mem::{align_of, align_of_val, size_of, size_of_val}; // Re-exported types and traits @@ -47,6 +50,8 @@ pub use crate::result::Result::{self, Err, Ok}; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] #[expect(deprecated)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use core::prelude::v1::{ assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, @@ -56,6 +61,8 @@ pub use core::prelude::v1::{ #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::{ dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local }; @@ -73,10 +80,13 @@ mod ambiguous_macros_only { #[expect(clippy::useless_attribute)] #[expect(exported_private_dependencies)] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] + #[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use crate::*; } #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use self::ambiguous_macros_only::{vec, panic}; #[stable(feature = "cfg_select", since = "1.95.0")] @@ -114,12 +124,16 @@ pub use core::prelude::v1::trace_macros; // Do not `doc(no_inline)` so that they become doc items on their own // (no public module for them to be re-exported from). #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use core::prelude::v1::{ alloc_error_handler, bench, global_allocator, test, test_case, }; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Prelude stability differs here. pub use core::prelude::v1::derive; #[unstable(feature = "derive_const", issue = "118304")] diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index 9426d9a684ef6..374e94d8ee01f 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -187,6 +187,8 @@ pub use core::sync::atomic; #[unstable(feature = "unique_rc_arc", issue = "112566")] pub use alloc_crate::sync::UniqueArc; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use alloc_crate::sync::{Arc, Weak}; #[unstable(feature = "mpmc_channel", issue = "126840")] @@ -198,6 +200,8 @@ pub mod oneshot; pub(crate) mod once; // `pub(crate)` for the `sys::sync::once` implementations and `LazyLock`. #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // This re-export has its own stability. pub use self::once::{Once, OnceState}; #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 955d1f61e7535..c9dc32d0622f7 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -200,6 +200,9 @@ pub use id::ThreadId; pub use join_handle::JoinHandle; pub(crate) use lifecycle::ThreadInit; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use local::{AccessError, LocalKey}; #[stable(feature = "scoped_threads", since = "1.63.0")] pub use scoped::{Scope, ScopedJoinHandle, scope}; diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 5566c497e06cb..dc6a927d43d20 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -32,6 +32,9 @@ #![stable(feature = "time", since = "1.3.0")] #[stable(feature = "time", since = "1.3.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] +// This re-export has its own stability. pub use core::time::Duration; #[stable(feature = "duration_checked_float", since = "1.66.0")] pub use core::time::TryFromFloatSecsError; diff --git a/library/stdarch/crates/core_arch/src/aarch64/mod.rs b/library/stdarch/crates/core_arch/src/aarch64/mod.rs index 1f07f024721dc..744a6273850b4 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/mod.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/mod.rs @@ -23,6 +23,8 @@ pub use self::rand::*; mod neon; #[stable(feature = "neon_intrinsics", since = "1.59.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::neon::*; // The rest of `core_arch::aarch64` is available on `arm64ec` but SVE is not supported on `arm64ec`. @@ -44,6 +46,8 @@ mod prefetch; pub use self::prefetch::*; #[stable(feature = "neon_intrinsics", since = "1.59.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use super::arm_shared::*; #[cfg(test)] diff --git a/library/stdarch/crates/core_arch/src/aarch64/neon/mod.rs b/library/stdarch/crates/core_arch/src/aarch64/neon/mod.rs index c66702814cfb2..ff60284ad4590 100644 --- a/library/stdarch/crates/core_arch/src/aarch64/neon/mod.rs +++ b/library/stdarch/crates/core_arch/src/aarch64/neon/mod.rs @@ -6,6 +6,8 @@ mod generated; #[rustfmt::skip] #[stable(feature = "neon_intrinsics", since = "1.59.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::generated::*; // FIXME: replace neon with asimd diff --git a/library/stdarch/crates/core_arch/src/arm_shared/mod.rs b/library/stdarch/crates/core_arch/src/arm_shared/mod.rs index 8074648a28a28..96cf981c83c46 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/mod.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/mod.rs @@ -88,6 +88,8 @@ pub(crate) mod neon; target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800") )] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::neon::*; #[cfg(test)] diff --git a/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs b/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs index 3af59b1dfb7cb..5b40764c47eb7 100644 --- a/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs +++ b/library/stdarch/crates/core_arch/src/arm_shared/neon/mod.rs @@ -5,6 +5,8 @@ mod generated; #[rustfmt::skip] #[cfg_attr(not(target_arch = "arm"), stable(feature = "neon_intrinsics", since = "1.59.0"))] #[cfg_attr(target_arch = "arm", unstable(feature = "stdarch_arm_neon_intrinsics", issue = "111800"))] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::generated::*; use crate::{core_arch::simd::*, intrinsics::simd::*, mem::transmute}; diff --git a/library/stdarch/crates/core_arch/src/mod.rs b/library/stdarch/crates/core_arch/src/mod.rs index 2483d07b230f9..b49d9bb27c0f5 100644 --- a/library/stdarch/crates/core_arch/src/mod.rs +++ b/library/stdarch/crates/core_arch/src/mod.rs @@ -37,6 +37,8 @@ pub mod arch { #[stable(feature = "simd_x86", since = "1.27.0")] pub mod x86 { #[stable(feature = "simd_x86", since = "1.27.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::x86::*; } @@ -48,8 +50,12 @@ pub mod arch { #[stable(feature = "simd_x86", since = "1.27.0")] pub mod x86_64 { #[stable(feature = "simd_x86", since = "1.27.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::x86::*; #[stable(feature = "simd_x86", since = "1.27.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::x86_64::*; } @@ -72,6 +78,8 @@ pub mod arch { #[stable(feature = "neon_intrinsics", since = "1.59.0")] pub mod aarch64 { #[stable(feature = "neon_intrinsics", since = "1.59.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::aarch64::*; } @@ -204,6 +212,8 @@ pub mod arch { #[stable(feature = "simd_wasm32", since = "1.33.0")] pub mod wasm32 { #[stable(feature = "simd_wasm32", since = "1.33.0")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::wasm32::*; } @@ -215,6 +225,8 @@ pub mod arch { #[unstable(feature = "simd_wasm64", issue = "90599")] pub mod wasm64 { #[unstable(feature = "simd_wasm64", issue = "90599")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::wasm32::*; } @@ -226,6 +238,8 @@ pub mod arch { #[unstable(feature = "simd_wasm64", issue = "90599")] pub mod wasm { #[unstable(feature = "simd_wasm64", issue = "90599")] + #[allow(clippy::useless_attribute)] + #[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use crate::core_arch::wasm32::*; } diff --git a/library/stdarch/crates/core_arch/src/s390x/mod.rs b/library/stdarch/crates/core_arch/src/s390x/mod.rs index 5b85020072d87..d136597f6c247 100644 --- a/library/stdarch/crates/core_arch/src/s390x/mod.rs +++ b/library/stdarch/crates/core_arch/src/s390x/mod.rs @@ -8,5 +8,5 @@ pub(crate) mod macros; #[cfg(not(target_abi = "softfloat"))] mod vector; #[cfg(not(target_abi = "softfloat"))] -#[unstable(feature = "stdarch_s390x", issue = "130869")] +#[unstable(feature = "stdarch_s390x", issue = "135681")] pub use self::vector::*; diff --git a/library/stdarch/crates/core_arch/src/x86/mod.rs b/library/stdarch/crates/core_arch/src/x86/mod.rs index e6875a628fbf0..2b2ead06181c8 100644 --- a/library/stdarch/crates/core_arch/src/x86/mod.rs +++ b/library/stdarch/crates/core_arch/src/x86/mod.rs @@ -636,6 +636,8 @@ mod sse; pub use self::sse::*; mod sse2; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::sse2::*; mod sse3; #[stable(feature = "simd_x86", since = "1.27.0")] @@ -645,6 +647,8 @@ mod ssse3; pub use self::ssse3::*; mod sse41; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::sse41::*; mod sse42; #[stable(feature = "simd_x86", since = "1.27.0")] @@ -654,6 +658,8 @@ mod avx; pub use self::avx::*; mod avx2; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::avx2::*; mod fma; #[stable(feature = "simd_x86", since = "1.27.0")] @@ -664,6 +670,8 @@ mod abm; pub use self::abm::*; mod bmi1; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::bmi1::*; mod bmi2; @@ -672,10 +680,14 @@ pub use self::bmi2::*; mod sse4a; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::sse4a::*; mod tbm; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::tbm::*; mod pclmulqdq; @@ -692,6 +704,8 @@ pub use self::rdrand::*; mod sha; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::sha::*; mod adx; @@ -775,6 +789,8 @@ pub use self::avx512bf16::*; mod avxneconvert; #[stable(feature = "stdarch_x86_avx512", since = "1.89")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::avxneconvert::*; mod avx512fp16; diff --git a/library/stdarch/crates/core_arch/src/x86_64/mod.rs b/library/stdarch/crates/core_arch/src/x86_64/mod.rs index 6f1177ad94636..04d3cca1b6292 100644 --- a/library/stdarch/crates/core_arch/src/x86_64/mod.rs +++ b/library/stdarch/crates/core_arch/src/x86_64/mod.rs @@ -81,6 +81,8 @@ pub use self::bmi2::*; mod tbm; #[stable(feature = "simd_x86", since = "1.27.0")] +#[allow(clippy::useless_attribute)] +#[allow(incompatible_reexport_stability)] // Keep the facade's stability. pub use self::tbm::*; mod avx512f; diff --git a/tests/ui/feature-gates/feature-gate-incompatible_reexport_stability.rs b/tests/ui/feature-gates/feature-gate-incompatible_reexport_stability.rs new file mode 100644 index 0000000000000..009630d8a39b8 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-incompatible_reexport_stability.rs @@ -0,0 +1,7 @@ +//@ check-pass +//@ normalize-stderr: "(\n)\n$" -> "$1" +// This lint is only available with `staged_api`. +#![allow(incompatible_reexport_stability)] +//~^ WARNING unknown lint: `incompatible_reexport_stability` + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-incompatible_reexport_stability.stderr b/tests/ui/feature-gates/feature-gate-incompatible_reexport_stability.stderr new file mode 100644 index 0000000000000..676496bd9e91f --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-incompatible_reexport_stability.stderr @@ -0,0 +1,10 @@ +warning: unknown lint: `incompatible_reexport_stability` + --> $DIR/feature-gate-incompatible_reexport_stability.rs:4:10 + | +LL | #![allow(incompatible_reexport_stability)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the `incompatible_reexport_stability` lint is unstable + = note: `#[warn(unknown_lints)]` on by default + +warning: 1 warning emitted diff --git a/tests/ui/stability-attribute/auxiliary/stable-glob-source.rs b/tests/ui/stability-attribute/auxiliary/stable-glob-source.rs new file mode 100644 index 0000000000000..3d5bc44bc7862 --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/stable-glob-source.rs @@ -0,0 +1,10 @@ +#![crate_type = "lib"] +#![crate_name = "stable_glob_source"] +#![feature(staged_api)] +#![stable(feature = "stable_glob_source", since = "1.0.0")] + +#[stable(feature = "stable_glob_source", since = "1.0.0")] +pub fn stable_a() {} + +#[stable(feature = "stable_glob_source", since = "1.0.0")] +pub fn stable_b() {} diff --git a/tests/ui/stability-attribute/auxiliary/unstable-glob-source.rs b/tests/ui/stability-attribute/auxiliary/unstable-glob-source.rs new file mode 100644 index 0000000000000..3fd19a7aeb50b --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/unstable-glob-source.rs @@ -0,0 +1,13 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "unstable_glob_source_crate", since = "1.0.0")] + +#[unstable(feature = "unstable_glob_source", issue = "none")] +pub fn unstable_a() {} + +#[unstable( + feature = "unstable_glob_source", + reason = "different reason", + issue = "none" +)] +pub fn unstable_b() {} diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability-glob.rs b/tests/ui/stability-attribute/incompatible-reexport-stability-glob.rs new file mode 100644 index 0000000000000..60b80d5e5dfbd --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability-glob.rs @@ -0,0 +1,20 @@ +//@ aux-build:stable-glob-source.rs +//@ aux-build:unstable-glob-source.rs +//@ normalize-stderr: "(\n)\n$" -> "$1" + +#![crate_type = "lib"] +#![feature(staged_api)] +#![deny(incompatible_reexport_stability)] +#![stable(feature = "reexport_test", since = "1.0.0")] + +extern crate stable_glob_source; +extern crate unstable_glob_source; + +// An unstable annotation does not match these stable items. +#[unstable(feature = "stable_glob_reexport", issue = "none")] +pub use stable_glob_source::*; +//~^ ERROR stability annotation on this re-export does not match the re-exported item + +// Same feature and issue; `reason` does not matter. +#[unstable(feature = "unstable_glob_source", issue = "none")] +pub use unstable_glob_source::*; diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability-glob.stderr b/tests/ui/stability-attribute/incompatible-reexport-stability-glob.stderr new file mode 100644 index 0000000000000..27c3223c7d092 --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability-glob.stderr @@ -0,0 +1,13 @@ +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability-glob.rs:15:9 + | +LL | pub use stable_glob_source::*; + | ^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/incompatible-reexport-stability-glob.rs:7:9 + | +LL | #![deny(incompatible_reexport_stability)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability-grouped.rs b/tests/ui/stability-attribute/incompatible-reexport-stability-grouped.rs new file mode 100644 index 0000000000000..a7e8c276c05fd --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability-grouped.rs @@ -0,0 +1,40 @@ +//@ aux-build:lint-stability.rs +//@ normalize-stderr: "(\n)\n$" -> "$1" + +#![crate_type = "lib"] +#![feature(staged_api)] +#![deny(incompatible_reexport_stability)] +#![stable(feature = "reexport_test", since = "1.0.0")] + +extern crate lint_stability; + +// An unstable annotation does not match these stable items. +#[unstable(feature = "grouped_stable", issue = "none")] +pub use lint_stability::{ + stable as grouped_stable_a, + stable_text as grouped_stable_b, +}; +//~^^^ ERROR stability annotation on this re-export does not match the re-exported item + +// The annotation must match every item. +#[unstable(feature = "grouped_mixed", issue = "none")] +pub use lint_stability::{ + stable as grouped_mixed_stable, + unstable as grouped_mixed_unstable, +}; +//~^^^ ERROR stability annotation on this re-export does not match the re-exported item + +// Make sure we point at the later mismatch. +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub use lint_stability::{ + unstable as grouped_matching_first, + stable as grouped_mismatching_second, + //~^ ERROR stability annotation on this re-export does not match the re-exported item +}; + +// Same feature and issue; `reason` does not matter. +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub use lint_stability::{ + unstable as grouped_unstable_a, + unstable_text as grouped_unstable_b, +}; diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability-grouped.stderr b/tests/ui/stability-attribute/incompatible-reexport-stability-grouped.stderr new file mode 100644 index 0000000000000..8a9e49a546323 --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability-grouped.stderr @@ -0,0 +1,25 @@ +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability-grouped.rs:14:5 + | +LL | stable as grouped_stable_a, + | ^^^^^^ + | +note: the lint level is defined here + --> $DIR/incompatible-reexport-stability-grouped.rs:6:9 + | +LL | #![deny(incompatible_reexport_stability)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability-grouped.rs:22:5 + | +LL | stable as grouped_mixed_stable, + | ^^^^^^ + +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability-grouped.rs:31:5 + | +LL | stable as grouped_mismatching_second, + | ^^^^^^ + +error: aborting due to 3 previous errors diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability-since.rs b/tests/ui/stability-attribute/incompatible-reexport-stability-since.rs new file mode 100644 index 0000000000000..51ac7c8c6ebc5 --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability-since.rs @@ -0,0 +1,14 @@ +//@ aux-build:lint-stability.rs +//@ normalize-stderr: "(\n)\n$" -> "$1" + +#![crate_type = "lib"] +#![feature(staged_api)] +#![deny(incompatible_reexport_stability)] +#![stable(feature = "reexport_since_test", since = "1.0.0")] + +extern crate lint_stability; + +// Same feature, different `since`. +#[stable(feature = "rust1", since = "1.1.0")] +pub use lint_stability::stable as different_stable_since; +//~^ ERROR stability annotation on this re-export does not match the re-exported item diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability-since.stderr b/tests/ui/stability-attribute/incompatible-reexport-stability-since.stderr new file mode 100644 index 0000000000000..7a9be1467e17f --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability-since.stderr @@ -0,0 +1,13 @@ +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability-since.rs:13:9 + | +LL | pub use lint_stability::stable as different_stable_since; + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/incompatible-reexport-stability-since.rs:6:9 + | +LL | #![deny(incompatible_reexport_stability)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability.rs b/tests/ui/stability-attribute/incompatible-reexport-stability.rs new file mode 100644 index 0000000000000..a21f72c4fb16e --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability.rs @@ -0,0 +1,43 @@ +//@ aux-build:lint-stability.rs +//@ normalize-stderr: "(\n)\n$" -> "$1" + +#![crate_type = "lib"] +#![feature(staged_api)] +#![deny(incompatible_reexport_stability)] +#![stable(feature = "reexport_test", since = "1.0.0")] + +extern crate core; +extern crate lint_stability; + +// An unstable annotation cannot make a stable item unstable through a re-export. +#[unstable(feature = "reexport_test_unstable", issue = "none")] +pub use lint_stability::stable as supposedly_unstable; +//~^ ERROR stability annotation on this re-export does not match the re-exported item + +// Repeating the target's stable metadata is fine. +#[stable(feature = "rust1", since = "1.0.0")] +pub use lint_stability::stable as matching_stable; + +// A stable re-export must use the same stability feature. +#[stable(feature = "different_stable_feature", since = "1.0.0")] +pub use lint_stability::stable as different_stable_feature; +//~^ ERROR stability annotation on this re-export does not match the re-exported item + +// Repeating the target's unstable feature and issue is fine. +#[unstable(feature = "unstable_test_feature", issue = "none")] +pub use lint_stability::unstable as matching_unstable; + +// An unstable re-export must use the same feature. +#[unstable(feature = "different_unstable_feature", issue = "none")] +pub use lint_stability::unstable as different_unstable_feature; +//~^ ERROR stability annotation on this re-export does not match the re-exported item + +// An unstable re-export must use the same tracking issue. +#[unstable(feature = "unstable_test_feature", issue = "12345")] +pub use lint_stability::unstable as different_unstable_issue; +//~^ ERROR stability annotation on this re-export does not match the re-exported item + +// Primitive re-exports have no DefId, but primitives themselves are stable. +#[unstable(feature = "primitive_reexport", issue = "none")] +pub use core::primitive::bool as supposedly_unstable_bool; +//~^ ERROR stability annotation on this re-export does not match the re-exported item diff --git a/tests/ui/stability-attribute/incompatible-reexport-stability.stderr b/tests/ui/stability-attribute/incompatible-reexport-stability.stderr new file mode 100644 index 0000000000000..97e1be3249a16 --- /dev/null +++ b/tests/ui/stability-attribute/incompatible-reexport-stability.stderr @@ -0,0 +1,37 @@ +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability.rs:14:9 + | +LL | pub use lint_stability::stable as supposedly_unstable; + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/incompatible-reexport-stability.rs:6:9 + | +LL | #![deny(incompatible_reexport_stability)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability.rs:23:9 + | +LL | pub use lint_stability::stable as different_stable_feature; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability.rs:32:9 + | +LL | pub use lint_stability::unstable as different_unstable_feature; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability.rs:37:9 + | +LL | pub use lint_stability::unstable as different_unstable_issue; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: stability annotation on this re-export does not match the re-exported item + --> $DIR/incompatible-reexport-stability.rs:42:9 + | +LL | pub use core::primitive::bool as supposedly_unstable_bool; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors