Skip to content

remove remaining rustc_allowed_through_unstable_modules - #157082

Closed
RalfJung wants to merge 1 commit into
rust-lang:mainfrom
RalfJung:dont_allow_through_unstable_modules
Closed

RalfJung wants to merge 1 commit into
rust-lang:mainfrom
RalfJung:dont_allow_through_unstable_modules

Conversation

@RalfJung

@RalfJung RalfJung commented May 28, 2026 •

Copy link
Copy Markdown
Member

Let's see if we can actually fully undo this accidental stabilization. Would be nice to be able to get rid of this hack in the compiler.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 28, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request May 28, 2026
… r=<try>

remove remaining rustc_allowed_through_unstable_modules
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/stability-attribute/accidental-stable-in-unstable/accidental-stable-in-unstable.stderr`
diff of stderr:

7    = help: add `#![feature(unicode_internals)]` to the crate attributes to enable
8    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
9 
- warning: use of deprecated module `std::intrinsics`: import this function via `std::mem` instead
-   --> $DIR/accidental-stable-in-unstable.rs:10:23
+ error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
+   --> $DIR/accidental-stable-in-unstable.rs:10:5
12    |
13 LL | use core::intrinsics::transmute; // depended upon by rand_core
-    |                       ^^^^^^^^^
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
15    |
-    = note: `#[warn(deprecated)]` on by default
+    = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
17 
- error: aborting due to 1 previous error; 1 warning emitted
+ error: aborting due to 2 previous errors
19 
20 For more information about this error, try `rustc --explain E0658`.
21 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/stability-attribute/accidental-stable-in-unstable.rs:10:5
+ error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
+   --> $DIR/accidental-stable-in-unstable.rs:10:5
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+    = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
+    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+ error: aborting due to 2 previous errors


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args stability-attribute/accidental-stable-in-unstable.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/stability-attribute/accidental-stable-in-unstable.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/stability-attribute/accidental-stable-in-unstable" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0658]: use of unstable library feature `unicode_internals`
##[error]  --> /checkout/tests/ui/stability-attribute/accidental-stable-in-unstable.rs:6:5
   |
LL | use core::unicode::UNICODE_VERSION; //~ ERROR use of unstable library feature `unicode_internals`
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/accidental-stable-in-unstable.rs:10:5
   |
LL | use core::intrinsics::transmute; // depended upon by rand_core
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
------------------------------------------

---- [ui] tests/ui/stability-attribute/accidental-stable-in-unstable.rs stdout end ----
---- [ui] tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs stdout ----

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/stability-attribute/issue-99286-stable-intrinsics" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs:11:5
   |
LL | use std::intrinsics::copy_nonoverlapping as _;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs:12:5
   |
LL | use std::intrinsics::copy as _;
   |     ^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs:13:5
   |
LL | use std::intrinsics::write_bytes as _;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs:14:23
   |
LL | use std::intrinsics::{copy_nonoverlapping, copy, write_bytes};
   |                       ^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs:14:44
   |
LL | use std::intrinsics::{copy_nonoverlapping, copy, write_bytes};
   |                                            ^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `core_intrinsics`: intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
##[error]  --> /checkout/tests/ui/stability-attribute/issue-99286-stable-intrinsics.rs:14:50
   |
LL | use std::intrinsics::{copy_nonoverlapping, copy, write_bytes};
   |                                                  ^^^^^^^^^^^
   |
   = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0658`.
------------------------------------------

@rust-bors

rust-bors Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 901d6c1 (901d6c1c62d7c61e05469e996c297476078ee06b, parent: cced03bfd61a304243a34504618ecec86c17063f)

@RalfJung

Copy link
Copy Markdown
Member Author

@craterbot check

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-157082 created and queued.
🤖 Automatically detected try build 901d6c1
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 29, 2026
@theemathas theemathas mentioned this pull request Jun 12, 2026
@theemathas

Copy link
Copy Markdown
Contributor

@craterbot cancel

See #157814

@craterbot

Copy link
Copy Markdown
Collaborator

🗑️ Experiment pr-157082 deleted!

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jun 12, 2026
@theemathas

Copy link
Copy Markdown
Contributor

@craterbot

Copy link
Copy Markdown
Collaborator

👌 Experiment pr-157082 created and queued.
🤖 Automatically detected try build 901d6c1
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-crater Status: Waiting on a crater run to be completed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 16, 2026
@craterbot

Copy link
Copy Markdown
Collaborator

🚧 Experiment pr-157082 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot

Copy link
Copy Markdown
Collaborator

🎉 Experiment pr-157082 is completed!
📊 7859 regressed and 0 fixed (14695 total)
📊 588 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-157082/retry-regressed-list.txt ↩

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels Jun 18, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

Older versions of rand had a use core::intrinsics::transmute;...
There's also trim-in-place, which seems unmaintained, and old versions of wide.

So yeah we won't be able to remove these any time soon. We could possibly remove just some of them but that doesn't seem worth it.

@RalfJung

RalfJung commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

(There was a comment here that got removed apparently. Very confusing for everyone who's following along via email notifications. Please prefer editing comments over just removing them.)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 3, 2026
…, r=nnethercote,RalfJung

implement FCW for `rustc_allowed_through_unstable_modules` items

Back in rust-lang#95956 we changed how stability checking of paths works, by checking the stability of all segments rather than just the last item in it. This meant that several items in the (unstable) `std::intrinsics` module, which were stable and re-exported elsewhere, could not be imported on stable anymore. By doing so, this broke everyone who imported (one example) `transmute` through `std::intrinsics::transmute` rather than `std::mem::transmute`.
To fix this regression, it also introduced the `rustc_allowed_through_unstable_modules` attribute, which is a hack to allow stable imports through unstable paths.

 We have been emitting the `deprecated` lint for this since Rust 1.86 (in rust-lang#136434).

A recent [crater run](rust-lang#157082) showed that many crates still depend on this accidental stabilization:
- 7859 total regressions
- 5k+ in old `rand-core` versions, new fixed minor versions released 3 weeks ago (after the crater run) in rust-random/rand_core#82 (comment)
- 600 from `trim-in-place`, which has a new major (but not minor) fixed version  (magiclen/trim-in-place#6)
- 600 from `wide`, has a fixed minor version (errors were in wide-0.7.32, fix is in 0.7.33)

Note however that the number of root regressions is very low (<100); almost all regressions are in (outdated) dependencies. The deprecation warnings have gotten people to fix their own code, but they cannot know about issues in their dependencies.

However, supporting this hack in the compiler significantly complicates the implementation of stability checking. Thus I'd really like to be able to get rid of this hack. That can't happen with so many regressions, but a step towards that is to start linting more aggressively on it.  This PR turns the lint into an FCW.

Tracking issue:  rust-lang#163160

Zulip thread: [#t-lang > fcwing on rustc_allowed_through_unstable_modules imports @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/fcwing.20on.20rustc_allowed_through_unstable_modules.20imports/near/620474117)

I don't know whose territory this is - adding new lints is lang's, but what library imports are valid is up to libs?
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 3, 2026
…, r=nnethercote,RalfJung

implement FCW for `rustc_allowed_through_unstable_modules` items

Back in rust-lang#95956 we changed how stability checking of paths works, by checking the stability of all segments rather than just the last item in it. This meant that several items in the (unstable) `std::intrinsics` module, which were stable and re-exported elsewhere, could not be imported on stable anymore. By doing so, this broke everyone who imported (one example) `transmute` through `std::intrinsics::transmute` rather than `std::mem::transmute`.
To fix this regression, it also introduced the `rustc_allowed_through_unstable_modules` attribute, which is a hack to allow stable imports through unstable paths.

 We have been emitting the `deprecated` lint for this since Rust 1.86 (in rust-lang#136434).

A recent [crater run](rust-lang#157082) showed that many crates still depend on this accidental stabilization:
- 7859 total regressions
- 5k+ in old `rand-core` versions, new fixed minor versions released 3 weeks ago (after the crater run) in rust-random/rand_core#82 (comment)
- 600 from `trim-in-place`, which has a new major (but not minor) fixed version  (magiclen/trim-in-place#6)
- 600 from `wide`, has a fixed minor version (errors were in wide-0.7.32, fix is in 0.7.33)

Note however that the number of root regressions is very low (<100); almost all regressions are in (outdated) dependencies. The deprecation warnings have gotten people to fix their own code, but they cannot know about issues in their dependencies.

However, supporting this hack in the compiler significantly complicates the implementation of stability checking. Thus I'd really like to be able to get rid of this hack. That can't happen with so many regressions, but a step towards that is to start linting more aggressively on it.  This PR turns the lint into an FCW.

Tracking issue:  rust-lang#163160

Zulip thread: [#t-lang > fcwing on rustc_allowed_through_unstable_modules imports @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/fcwing.20on.20rustc_allowed_through_unstable_modules.20imports/near/620474117)

I don't know whose territory this is - adding new lints is lang's, but what library imports are valid is up to libs?
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 4, 2026
…, r=nnethercote,RalfJung

implement FCW for `rustc_allowed_through_unstable_modules` items

Back in rust-lang#95956 we changed how stability checking of paths works, by checking the stability of all segments rather than just the last item in it. This meant that several items in the (unstable) `std::intrinsics` module, which were stable and re-exported elsewhere, could not be imported on stable anymore. By doing so, this broke everyone who imported (one example) `transmute` through `std::intrinsics::transmute` rather than `std::mem::transmute`.
To fix this regression, it also introduced the `rustc_allowed_through_unstable_modules` attribute, which is a hack to allow stable imports through unstable paths.

 We have been emitting the `deprecated` lint for this since Rust 1.86 (in rust-lang#136434).

A recent [crater run](rust-lang#157082) showed that many crates still depend on this accidental stabilization:
- 7859 total regressions
- 5k+ in old `rand-core` versions, new fixed minor versions released 3 weeks ago (after the crater run) in rust-random/rand_core#82 (comment)
- 600 from `trim-in-place`, which has a new major (but not minor) fixed version  (magiclen/trim-in-place#6)
- 600 from `wide`, has a fixed minor version (errors were in wide-0.7.32, fix is in 0.7.33)

Note however that the number of root regressions is very low (<100); almost all regressions are in (outdated) dependencies. The deprecation warnings have gotten people to fix their own code, but they cannot know about issues in their dependencies.

However, supporting this hack in the compiler significantly complicates the implementation of stability checking. Thus I'd really like to be able to get rid of this hack. That can't happen with so many regressions, but a step towards that is to start linting more aggressively on it.  This PR turns the lint into an FCW.

Tracking issue:  rust-lang#163160

Zulip thread: [#t-lang > fcwing on rustc_allowed_through_unstable_modules imports @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/fcwing.20on.20rustc_allowed_through_unstable_modules.20imports/near/620474117)

I don't know whose territory this is - adding new lints is lang's, but what library imports are valid is up to libs?
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup merge of #163161 - mejrs:deprecated_intrinsic_imports, r=nnethercote,RalfJung

implement FCW for `rustc_allowed_through_unstable_modules` items

Back in #95956 we changed how stability checking of paths works, by checking the stability of all segments rather than just the last item in it. This meant that several items in the (unstable) `std::intrinsics` module, which were stable and re-exported elsewhere, could not be imported on stable anymore. By doing so, this broke everyone who imported (one example) `transmute` through `std::intrinsics::transmute` rather than `std::mem::transmute`.
To fix this regression, it also introduced the `rustc_allowed_through_unstable_modules` attribute, which is a hack to allow stable imports through unstable paths.

 We have been emitting the `deprecated` lint for this since Rust 1.86 (in #136434).

A recent [crater run](#157082) showed that many crates still depend on this accidental stabilization:
- 7859 total regressions
- 5k+ in old `rand-core` versions, new fixed minor versions released 3 weeks ago (after the crater run) in rust-random/rand_core#82 (comment)
- 600 from `trim-in-place`, which has a new major (but not minor) fixed version  (magiclen/trim-in-place#6)
- 600 from `wide`, has a fixed minor version (errors were in wide-0.7.32, fix is in 0.7.33)

Note however that the number of root regressions is very low (<100); almost all regressions are in (outdated) dependencies. The deprecation warnings have gotten people to fix their own code, but they cannot know about issues in their dependencies.

However, supporting this hack in the compiler significantly complicates the implementation of stability checking. Thus I'd really like to be able to get rid of this hack. That can't happen with so many regressions, but a step towards that is to start linting more aggressively on it.  This PR turns the lint into an FCW.

Tracking issue:  #163160

Zulip thread: [#t-lang > fcwing on rustc_allowed_through_unstable_modules imports @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/fcwing.20on.20rustc_allowed_through_unstable_modules.20imports/near/620474117)

I don't know whose territory this is - adding new lints is lang's, but what library imports are valid is up to libs?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants