diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 56d9f5bf78577..2957dc39d6a6d 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -430,6 +430,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> { kind = AnnotationKind::DeprecationProhibited; const_stab_inherit = InheritConstStability::Yes; } + hir::ItemKind::Use(_, _) => { + kind = AnnotationKind::DeprecationProhibited; + } hir::ItemKind::Struct(_, _, ref sd) => { if let Some(ctor_def_id) = sd.ctor_def_id() { self.annotate( diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs index 9d608d5e83c40..5ac5c730cac03 100644 --- a/library/core/src/alloc/mod.rs +++ b/library/core/src/alloc/mod.rs @@ -10,11 +10,6 @@ pub use self::global::GlobalAlloc; #[stable(feature = "alloc_layout", since = "1.28.0")] pub use self::layout::Layout; #[stable(feature = "alloc_layout", since = "1.28.0")] -#[deprecated( - since = "1.52.0", - note = "Name does not follow std convention, use LayoutError", - suggestion = "LayoutError" -)] #[allow(deprecated, deprecated_in_future)] pub use self::layout::LayoutErr; #[stable(feature = "alloc_layout_error", since = "1.50.0")] diff --git a/library/std/src/collections/mod.rs b/library/std/src/collections/mod.rs index 889ed3c538035..ba57c5eb3530d 100644 --- a/library/std/src/collections/mod.rs +++ b/library/std/src/collections/mod.rs @@ -433,8 +433,7 @@ pub use self::hash_map::HashMap; #[doc(inline)] pub use self::hash_set::HashSet; #[stable(feature = "rust1", since = "1.0.0")] -// 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")] +// FIXME(#82080) This has moved but #[deprecated] on `use` is unsupported. #[doc(hidden)] pub use crate::ops::Bound; diff --git a/tests/ui/deprecation/deprecation-sanity.rs b/tests/ui/deprecation/deprecation-sanity.rs index 80198ab81968f..1e87cf0250e17 100644 --- a/tests/ui/deprecation/deprecation-sanity.rs +++ b/tests/ui/deprecation/deprecation-sanity.rs @@ -39,4 +39,13 @@ impl Default for X { } } +mod inner { + pub struct Y; +} + +// Deprecation does not work on re-exports, so let's be clear about that. +// https://github.com/rust-lang/rust/issues/142436 +#[deprecated] //~ ERROR this `#[deprecated]` annotation has no effect +pub use inner::Y; + fn main() { } diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index f1b4697485cfc..2474749dd0248 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -154,7 +154,13 @@ LL | #[deprecated = "hello"] | = note: `#[deny(useless_deprecated)]` on by default -error: aborting due to 10 previous errors +error: this `#[deprecated]` annotation has no effect + --> $DIR/deprecation-sanity.rs:48:1 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute + +error: aborting due to 11 previous errors Some errors have detailed explanations: E0538, E0539, E0541, E0565. For more information about an error, try `rustc --explain E0538`. diff --git a/tests/ui/imports/unused-import-issue-87973.fixed b/tests/ui/imports/unused-import.fixed similarity index 81% rename from tests/ui/imports/unused-import-issue-87973.fixed rename to tests/ui/imports/unused-import.fixed index d1167d7d4861a..402655e4fbc88 100644 --- a/tests/ui/imports/unused-import-issue-87973.fixed +++ b/tests/ui/imports/unused-import.fixed @@ -1,5 +1,6 @@ //@ run-rustfix #![deny(unused_imports)] +#![allow(useless_deprecated)] // Check that attributes get removed too. See #87973. //~^ ERROR unused import diff --git a/tests/ui/imports/unused-import-issue-87973.rs b/tests/ui/imports/unused-import.rs similarity index 87% rename from tests/ui/imports/unused-import-issue-87973.rs rename to tests/ui/imports/unused-import.rs index 1b016ff814c6b..0186ddd5ec75f 100644 --- a/tests/ui/imports/unused-import-issue-87973.rs +++ b/tests/ui/imports/unused-import.rs @@ -1,5 +1,6 @@ //@ run-rustfix #![deny(unused_imports)] +#![allow(useless_deprecated)] // Check that attributes get removed too. See #87973. #[deprecated] diff --git a/tests/ui/imports/unused-import-issue-87973.stderr b/tests/ui/imports/unused-import.stderr similarity index 71% rename from tests/ui/imports/unused-import-issue-87973.stderr rename to tests/ui/imports/unused-import.stderr index a43e92b145802..e29014b83ef9f 100644 --- a/tests/ui/imports/unused-import-issue-87973.stderr +++ b/tests/ui/imports/unused-import.stderr @@ -1,11 +1,11 @@ error: unused import: `std::fs` - --> $DIR/unused-import-issue-87973.rs:8:5 + --> $DIR/unused-import.rs:9:5 | LL | use std::fs; | ^^^^^^^ | note: the lint level is defined here - --> $DIR/unused-import-issue-87973.rs:2:9 + --> $DIR/unused-import.rs:2:9 | LL | #![deny(unused_imports)] | ^^^^^^^^^^^^^^