From f296fdf92ad3252d0d33e8e4a06a5ca0cb2c5d31 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Sat, 3 Oct 2026 20:07:41 +0200 Subject: [PATCH] implement FCW for `rustc_allowed_through_unstable_modules` items --- compiler/rustc_lint_defs/src/builtin.rs | 26 ++ compiler/rustc_passes/src/stability.rs | 6 +- .../clippy/tests/ui/std_instead_of_core.fixed | 2 +- .../clippy/tests/ui/std_instead_of_core.rs | 2 +- .../tests/ui/std_instead_of_core.stderr | 26 +- .../accidental-stable-in-unstable.rs | 3 +- .../accidental-stable-in-unstable.stderr | 24 +- .../accidentally-stable-intrinsics.fixed | 12 +- .../accidentally-stable-intrinsics.rs | 12 +- .../accidentally-stable-intrinsics.stderr | 224 ++++++++++++++++-- .../allowed-through-unstable.rs | 3 +- .../allowed-through-unstable.stderr | 30 ++- .../issue-99286-stable-intrinsics.rs | 2 +- .../issue-99286-stable-intrinsics.stderr | 90 +++++++ 14 files changed, 419 insertions(+), 43 deletions(-) create mode 100644 tests/ui/stability-attribute/issue-99286-stable-intrinsics.stderr diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a722f0e103ea1..34c7e3f19a631 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -137,6 +137,7 @@ pub mod hardwired { UNREACHABLE_PATTERNS, UNSAFE_ATTR_OUTSIDE_UNSAFE, UNSAFE_OP_IN_UNSAFE_FN, + UNSTABLE_IMPORTS, UNSTABLE_NAME_COLLISIONS, UNSTABLE_SYNTAX_PRE_EXPANSION, UNSUPPORTED_CALLING_CONVENTIONS, @@ -5857,3 +5858,28 @@ declare_lint! { "`repr(C, align)` types nested inside `repr(C, packed)` types \ do not always have a C-compatible layout", } + +declare_lint! { + /// The `unstable_imports` lints detects imports that go through unstable modules. + /// + /// ### Example + /// + /// ```rust + /// use core::intrinsics::transmute; + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Previous versions of Rust accidentally allowed certain imports through unstable modules + /// because stability information of modules was not correctly accounted for if the imported + /// item was stable itself. + pub UNSTABLE_IMPORTS, + Deny, + "lints on accidentally allowed unstable imports", + @future_incompatible = FutureIncompatibleInfo { + reason: fcw!(FutureReleaseError # 163160), + report_in_deps: true, + }; +} diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index d607d929b0db6..162914c95c0e5 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -19,8 +19,8 @@ use rustc_hir::{ UsePath, Variant, }; use rustc_lint_defs::builtin::{ - DEPRECATED, DUPLICATE_FEATURES, INEFFECTIVE_UNSTABLE_REEXPORTS, - INEFFECTIVE_UNSTABLE_TRAIT_IMPL, STABLE_FEATURES, + DUPLICATE_FEATURES, INEFFECTIVE_UNSTABLE_REEXPORTS, INEFFECTIVE_UNSTABLE_TRAIT_IMPL, + STABLE_FEATURES, UNSTABLE_IMPORTS, }; use rustc_middle::hir::nested_filter; use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures}; @@ -1079,7 +1079,7 @@ impl<'tcx> Checker<'tcx> { suggestion, }; self.tcx.emit_node_span_lint( - DEPRECATED, + UNSTABLE_IMPORTS, id, method_span.unwrap_or(span), diag, diff --git a/src/tools/clippy/tests/ui/std_instead_of_core.fixed b/src/tools/clippy/tests/ui/std_instead_of_core.fixed index c162dcb0451e2..208678a71cf35 100644 --- a/src/tools/clippy/tests/ui/std_instead_of_core.fixed +++ b/src/tools/clippy/tests/ui/std_instead_of_core.fixed @@ -1,7 +1,6 @@ //@aux-build:proc_macro_derive.rs #![warn(clippy::std_instead_of_core)] -#![expect(deprecated)] extern crate alloc; @@ -77,6 +76,7 @@ mod std_in_proc_macro_derive { // replacing std -> core fn intrinsic(a: *mut u8, b: *mut u8) { unsafe { + #[expect(unstable_imports)] core::intrinsics::copy(a, b, 1); //~^ std_instead_of_core } diff --git a/src/tools/clippy/tests/ui/std_instead_of_core.rs b/src/tools/clippy/tests/ui/std_instead_of_core.rs index 6769af11def6f..8c27c1926fae4 100644 --- a/src/tools/clippy/tests/ui/std_instead_of_core.rs +++ b/src/tools/clippy/tests/ui/std_instead_of_core.rs @@ -1,7 +1,6 @@ //@aux-build:proc_macro_derive.rs #![warn(clippy::std_instead_of_core)] -#![expect(deprecated)] extern crate alloc; @@ -77,6 +76,7 @@ mod std_in_proc_macro_derive { // replacing std -> core fn intrinsic(a: *mut u8, b: *mut u8) { unsafe { + #[expect(unstable_imports)] std::intrinsics::copy(a, b, 1); //~^ std_instead_of_core } diff --git a/src/tools/clippy/tests/ui/std_instead_of_core.stderr b/src/tools/clippy/tests/ui/std_instead_of_core.stderr index ae0783863fbc2..c18f976412611 100644 --- a/src/tools/clippy/tests/ui/std_instead_of_core.stderr +++ b/src/tools/clippy/tests/ui/std_instead_of_core.stderr @@ -1,5 +1,5 @@ error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:13:9 + --> tests/ui/std_instead_of_core.rs:12:9 | LL | use std::hash::Hasher; | ^^^ help: consider importing the item from `core`: `core` @@ -8,61 +8,61 @@ LL | use std::hash::Hasher; = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_core)]` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:16:11 + --> tests/ui/std_instead_of_core.rs:15:11 | LL | use ::std::hash::Hash; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:22:9 + --> tests/ui/std_instead_of_core.rs:21:9 | LL | use std::fmt::{Debug, Result}; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:27:9 + --> tests/ui/std_instead_of_core.rs:26:9 | LL | use std::{ | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:34:15 + --> tests/ui/std_instead_of_core.rs:33:15 | LL | let ptr = std::ptr::null::(); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:36:21 + --> tests/ui/std_instead_of_core.rs:35:21 | LL | let ptr_mut = ::std::ptr::null_mut::(); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:40:16 + --> tests/ui/std_instead_of_core.rs:39:16 | LL | let cell = std::cell::Cell::new(8u32); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:42:27 + --> tests/ui/std_instead_of_core.rs:41:27 | LL | let cell_absolute = ::std::cell::Cell::new(8u32); | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:47:9 + --> tests/ui/std_instead_of_core.rs:46:9 | LL | use std::error::Error; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `core` - --> tests/ui/std_instead_of_core.rs:51:9 + --> tests/ui/std_instead_of_core.rs:50:9 | LL | use std::iter::Iterator; | ^^^ help: consider importing the item from `core`: `core` error: used import from `std` instead of `alloc` - --> tests/ui/std_instead_of_core.rs:58:9 + --> tests/ui/std_instead_of_core.rs:57:9 | LL | use std::vec; | ^^^ help: consider importing the item from `alloc`: `alloc` @@ -71,13 +71,13 @@ LL | use std::vec; = help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]` error: used import from `std` instead of `alloc` - --> tests/ui/std_instead_of_core.rs:60:9 + --> tests/ui/std_instead_of_core.rs:59:9 | LL | use std::vec::Vec; | ^^^ help: consider importing the item from `alloc`: `alloc` error: used import from `alloc` instead of `core` - --> tests/ui/std_instead_of_core.rs:66:9 + --> tests/ui/std_instead_of_core.rs:65:9 | LL | use alloc::slice::from_ref; | ^^^^^ help: consider importing the item from `core`: `core` diff --git a/tests/ui/stability-attribute/accidental-stable-in-unstable.rs b/tests/ui/stability-attribute/accidental-stable-in-unstable.rs index a36a78ee442ce..b52912938539e 100644 --- a/tests/ui/stability-attribute/accidental-stable-in-unstable.rs +++ b/tests/ui/stability-attribute/accidental-stable-in-unstable.rs @@ -8,4 +8,5 @@ use core::unicode::UNICODE_VERSION; //~ ERROR use of unstable library feature `u // Known accidental stabilizations with known users // fully stable @ core::mem::transmute use core::intrinsics::transmute; // depended upon by rand_core -//~^WARN deprecated +//~^ERROR use of deprecated import through accidentally stabilized module +//~| WARN previously accepted diff --git a/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr b/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr index b0b1f78cb28b2..b2e8072101759 100644 --- a/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr +++ b/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr @@ -7,19 +7,37 @@ LL | use core::unicode::UNICODE_VERSION; = help: add `#![feature(unicode_internals)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -warning: use of deprecated import through accidentally stabilized module `intrinsics` +error: use of deprecated import through accidentally stabilized module `intrinsics` --> $DIR/accidental-stable-in-unstable.rs:10:5 | LL | use core::intrinsics::transmute; // depended upon by rand_core | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(deprecated)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default help: import this function via the `mem` module instead | LL - use core::intrinsics::transmute; // depended upon by rand_core LL + use core::mem::transmute; // depended upon by rand_core | -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. +Future incompatibility report: Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidental-stable-in-unstable.rs:10:5 + | +LL | use core::intrinsics::transmute; // depended upon by rand_core + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `mem` module instead + | +LL - use core::intrinsics::transmute; // depended upon by rand_core +LL + use core::mem::transmute; // depended upon by rand_core + | + diff --git a/tests/ui/stability-attribute/accidentally-stable-intrinsics.fixed b/tests/ui/stability-attribute/accidentally-stable-intrinsics.fixed index 41917c65f5215..47e42c13a4589 100644 --- a/tests/ui/stability-attribute/accidentally-stable-intrinsics.fixed +++ b/tests/ui/stability-attribute/accidentally-stable-intrinsics.fixed @@ -1,26 +1,32 @@ //@ run-rustfix #![crate_type = "lib"] #![allow(unnecessary_transmutes, unused_imports)] -#![deny(deprecated)] extern crate core; use std::mem::transmute as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use core::ptr::copy as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use std::ptr::copy_nonoverlapping as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use core::ptr::write_bytes as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use core::ptr::{ copy as _, //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted copy_nonoverlapping as _, //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted write_bytes as _, //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted }; pub fn what() { @@ -29,11 +35,15 @@ pub fn what() { let mut dst = 0; let _ = std::mem::transmute::(value); //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted core::ptr::copy(&value, &mut dst, 1); //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted core::ptr::copy_nonoverlapping(&value, &mut dst, 1); //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted std::ptr::write_bytes(&mut dst, value, 1) //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted } } diff --git a/tests/ui/stability-attribute/accidentally-stable-intrinsics.rs b/tests/ui/stability-attribute/accidentally-stable-intrinsics.rs index 189927e9e8989..f3d9bd14cf62f 100644 --- a/tests/ui/stability-attribute/accidentally-stable-intrinsics.rs +++ b/tests/ui/stability-attribute/accidentally-stable-intrinsics.rs @@ -1,26 +1,32 @@ //@ run-rustfix #![crate_type = "lib"] #![allow(unnecessary_transmutes, unused_imports)] -#![deny(deprecated)] extern crate core; use std::intrinsics::transmute as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use core::intrinsics::copy as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use std::intrinsics::copy_nonoverlapping as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use core::intrinsics::write_bytes as _; //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` +//~| WARN previously accepted use core::intrinsics::{ copy as _, //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted copy_nonoverlapping as _, //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted write_bytes as _, //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted }; pub fn what() { @@ -29,11 +35,15 @@ pub fn what() { let mut dst = 0; let _ = std::intrinsics::transmute::(value); //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted core::intrinsics::copy(&value, &mut dst, 1); //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted core::intrinsics::copy_nonoverlapping(&value, &mut dst, 1); //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted std::intrinsics::write_bytes(&mut dst, value, 1) //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` + //~| WARN previously accepted } } diff --git a/tests/ui/stability-attribute/accidentally-stable-intrinsics.stderr b/tests/ui/stability-attribute/accidentally-stable-intrinsics.stderr index 645437a306f74..96f56043af189 100644 --- a/tests/ui/stability-attribute/accidentally-stable-intrinsics.stderr +++ b/tests/ui/stability-attribute/accidentally-stable-intrinsics.stderr @@ -1,14 +1,12 @@ error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:8:5 + --> $DIR/accidentally-stable-intrinsics.rs:7:5 | LL | use std::intrinsics::transmute as _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: the lint level is defined here - --> $DIR/accidentally-stable-intrinsics.rs:4:9 - | -LL | #![deny(deprecated)] - | ^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default help: import this function via the `mem` module instead | LL - use std::intrinsics::transmute as _; @@ -21,6 +19,8 @@ error: use of deprecated import through accidentally stabilized module `intrinsi LL | use core::intrinsics::copy as _; | ^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - use core::intrinsics::copy as _; @@ -28,11 +28,13 @@ LL + use core::ptr::copy as _; | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:12:5 + --> $DIR/accidentally-stable-intrinsics.rs:13:5 | LL | use std::intrinsics::copy_nonoverlapping as _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - use std::intrinsics::copy_nonoverlapping as _; @@ -40,11 +42,13 @@ LL + use std::ptr::copy_nonoverlapping as _; | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:14:5 + --> $DIR/accidentally-stable-intrinsics.rs:16:5 | LL | use core::intrinsics::write_bytes as _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - use core::intrinsics::write_bytes as _; @@ -52,11 +56,13 @@ LL + use core::ptr::write_bytes as _; | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:18:5 + --> $DIR/accidentally-stable-intrinsics.rs:21:5 | LL | copy as _, | ^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - use core::intrinsics::{ @@ -64,11 +70,13 @@ LL + use core::ptr::{ | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:20:5 + --> $DIR/accidentally-stable-intrinsics.rs:24:5 | LL | copy_nonoverlapping as _, | ^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - use core::intrinsics::{ @@ -76,11 +84,13 @@ LL + use core::ptr::{ | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:22:5 + --> $DIR/accidentally-stable-intrinsics.rs:27:5 | LL | write_bytes as _, | ^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - use core::intrinsics::{ @@ -88,11 +98,13 @@ LL + use core::ptr::{ | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:30:17 + --> $DIR/accidentally-stable-intrinsics.rs:36:17 | LL | let _ = std::intrinsics::transmute::(value); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `mem` module instead | LL - let _ = std::intrinsics::transmute::(value); @@ -100,11 +112,13 @@ LL + let _ = std::mem::transmute::(value); | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:32:9 + --> $DIR/accidentally-stable-intrinsics.rs:39:9 | LL | core::intrinsics::copy(&value, &mut dst, 1); | ^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - core::intrinsics::copy(&value, &mut dst, 1); @@ -112,11 +126,13 @@ LL + core::ptr::copy(&value, &mut dst, 1); | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:34:9 + --> $DIR/accidentally-stable-intrinsics.rs:42:9 | LL | core::intrinsics::copy_nonoverlapping(&value, &mut dst, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - core::intrinsics::copy_nonoverlapping(&value, &mut dst, 1); @@ -124,11 +140,13 @@ LL + core::ptr::copy_nonoverlapping(&value, &mut dst, 1); | error: use of deprecated import through accidentally stabilized module `intrinsics` - --> $DIR/accidentally-stable-intrinsics.rs:36:9 + --> $DIR/accidentally-stable-intrinsics.rs:45:9 | LL | std::intrinsics::write_bytes(&mut dst, value, 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 help: import this function via the `ptr` module instead | LL - std::intrinsics::write_bytes(&mut dst, value, 1) @@ -137,3 +155,179 @@ LL + std::ptr::write_bytes(&mut dst, value, 1) error: aborting due to 11 previous errors +Future incompatibility report: Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:7:5 + | +LL | use std::intrinsics::transmute as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `mem` module instead + | +LL - use std::intrinsics::transmute as _; +LL + use std::mem::transmute as _; + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:10:5 + | +LL | use core::intrinsics::copy as _; + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - use core::intrinsics::copy as _; +LL + use core::ptr::copy as _; + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:13:5 + | +LL | use std::intrinsics::copy_nonoverlapping as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::copy_nonoverlapping as _; +LL + use std::ptr::copy_nonoverlapping as _; + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:16:5 + | +LL | use core::intrinsics::write_bytes as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - use core::intrinsics::write_bytes as _; +LL + use core::ptr::write_bytes as _; + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:21:5 + | +LL | copy as _, + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - use core::intrinsics::{ +LL + use core::ptr::{ + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:24:5 + | +LL | copy_nonoverlapping as _, + | ^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - use core::intrinsics::{ +LL + use core::ptr::{ + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:27:5 + | +LL | write_bytes as _, + | ^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - use core::intrinsics::{ +LL + use core::ptr::{ + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:36:17 + | +LL | let _ = std::intrinsics::transmute::(value); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `mem` module instead + | +LL - let _ = std::intrinsics::transmute::(value); +LL + let _ = std::mem::transmute::(value); + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:39:9 + | +LL | core::intrinsics::copy(&value, &mut dst, 1); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - core::intrinsics::copy(&value, &mut dst, 1); +LL + core::ptr::copy(&value, &mut dst, 1); + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:42:9 + | +LL | core::intrinsics::copy_nonoverlapping(&value, &mut dst, 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - core::intrinsics::copy_nonoverlapping(&value, &mut dst, 1); +LL + core::ptr::copy_nonoverlapping(&value, &mut dst, 1); + | + +Future breakage diagnostic: +error: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/accidentally-stable-intrinsics.rs:45:9 + | +LL | std::intrinsics::write_bytes(&mut dst, value, 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 + = note: `#[deny(unstable_imports)]` (part of `#[deny(future_incompatible)]`) on by default +help: import this function via the `ptr` module instead + | +LL - std::intrinsics::write_bytes(&mut dst, value, 1) +LL + std::ptr::write_bytes(&mut dst, value, 1) + | + diff --git a/tests/ui/stability-attribute/allowed-through-unstable.rs b/tests/ui/stability-attribute/allowed-through-unstable.rs index eaa3ad9b830b4..4af64189dbfe3 100644 --- a/tests/ui/stability-attribute/allowed-through-unstable.rs +++ b/tests/ui/stability-attribute/allowed-through-unstable.rs @@ -2,8 +2,9 @@ // //@ aux-build:allowed-through-unstable-core.rs #![crate_type = "lib"] - +#![warn(unstable_imports)] extern crate allowed_through_unstable_core; use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; //~WARN use of deprecated import through accidentally stabilized module `unstable_module` +//~| WARN previously accepted use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowedThroughUnstable; //~ ERROR use of unstable library feature `unstable_test_feature` diff --git a/tests/ui/stability-attribute/allowed-through-unstable.stderr b/tests/ui/stability-attribute/allowed-through-unstable.stderr index 160dd4d4babff..6f2e0bf7a1fe9 100644 --- a/tests/ui/stability-attribute/allowed-through-unstable.stderr +++ b/tests/ui/stability-attribute/allowed-through-unstable.stderr @@ -4,7 +4,13 @@ warning: use of deprecated import through accidentally stabilized module `unstab LL | use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(deprecated)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +note: the lint level is defined here + --> $DIR/allowed-through-unstable.rs:5:9 + | +LL | #![warn(unstable_imports)] + | ^^^^^^^^^^^^^^^^ help: use the new path instead | LL - use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; @@ -12,7 +18,7 @@ LL + use allowed_through_unstable_core::stable::OldStableTraitAllowedThoughUnsta | error[E0658]: use of unstable library feature `unstable_test_feature` - --> $DIR/allowed-through-unstable.rs:9:36 + --> $DIR/allowed-through-unstable.rs:10:36 | LL | use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowedThroughUnstable; | ^^^^^^^^^^^^^^^ @@ -24,3 +30,23 @@ LL | use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowe error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0658`. +Future incompatibility report: Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `unstable_module` + --> $DIR/allowed-through-unstable.rs:8:5 + | +LL | use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +note: the lint level is defined here + --> $DIR/allowed-through-unstable.rs:5:9 + | +LL | #![warn(unstable_imports)] + | ^^^^^^^^^^^^^^^^ +help: use the new path instead + | +LL - use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; +LL + use allowed_through_unstable_core::stable::OldStableTraitAllowedThoughUnstable; + | + diff --git a/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs b/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs index d9e810362f2e9..9af880b63042b 100644 --- a/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs +++ b/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs @@ -6,7 +6,7 @@ // is unstable. #![allow(unused_imports)] -#![allow(deprecated)] +#![allow(unstable_imports)] use std::intrinsics::copy_nonoverlapping as _; use std::intrinsics::copy as _; diff --git a/tests/ui/stability-attribute/issue-99286-stable-intrinsics.stderr b/tests/ui/stability-attribute/issue-99286-stable-intrinsics.stderr new file mode 100644 index 0000000000000..5391a1a43889d --- /dev/null +++ b/tests/ui/stability-attribute/issue-99286-stable-intrinsics.stderr @@ -0,0 +1,90 @@ +Future incompatibility report: Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/issue-99286-stable-intrinsics.rs:11:5 + | +LL | use std::intrinsics::copy_nonoverlapping as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::copy_nonoverlapping as _; +LL + use std::ptr::copy_nonoverlapping as _; + | + +Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/issue-99286-stable-intrinsics.rs:12:5 + | +LL | use std::intrinsics::copy as _; + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::copy as _; +LL + use std::ptr::copy as _; + | + +Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/issue-99286-stable-intrinsics.rs:13:5 + | +LL | use std::intrinsics::write_bytes as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::write_bytes as _; +LL + use std::ptr::write_bytes as _; + | + +Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/issue-99286-stable-intrinsics.rs:14:23 + | +LL | use std::intrinsics::{copy_nonoverlapping, copy, write_bytes}; + | ^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::{copy_nonoverlapping, copy, write_bytes}; +LL + use std::ptr::{copy_nonoverlapping, copy, write_bytes}; + | + +Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/issue-99286-stable-intrinsics.rs:14:44 + | +LL | use std::intrinsics::{copy_nonoverlapping, copy, write_bytes}; + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::{copy_nonoverlapping, copy, write_bytes}; +LL + use std::ptr::{copy_nonoverlapping, copy, write_bytes}; + | + +Future breakage diagnostic: +warning: use of deprecated import through accidentally stabilized module `intrinsics` + --> $DIR/issue-99286-stable-intrinsics.rs:14:50 + | +LL | use std::intrinsics::{copy_nonoverlapping, copy, write_bytes}; + | ^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163160 +help: import this function via the `ptr` module instead + | +LL - use std::intrinsics::{copy_nonoverlapping, copy, write_bytes}; +LL + use std::ptr::{copy_nonoverlapping, copy, write_bytes}; + | +