Skip to content

Conversation

@RalfJung
Copy link
Member

@RalfJung RalfJung commented Jan 1, 2025

The rustc_allowed_through_unstable_modules attribute lets users call std::mem::transmute as std::intrinsics::transmute. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, std::intrinsics::transmute is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in std::intrinsics that carry the attribute.

I assume this will need @rust-lang/libs-api FCP.

@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2025

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @rust-lang/wg-const-eval

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jan 1, 2025
@RalfJung RalfJung added the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jan 1, 2025
// our own kind of error.
let parents = path.segments.iter().rev().skip(1);
for path_segment in parents {
if let Some(def_id) = path_segment.res.opt_def_id() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unfortunate duplication of the loop above, but I didn't find a good way to deduplicate that code.

@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the deprecate-allowed-through-unstable branch from ed11ebe to 59c0265 Compare January 1, 2025 19:46
@rustbot
Copy link
Collaborator

rustbot commented Jan 1, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

// Skip all that work if the lint is allowed anyway.
if tcx.lint_level_at_node(lint, hir_id).0 == Level::Allow {
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This first commit is unrelated, it just moves some logic to what I think is a more sensible location. I thought I'd use that logic for this PR but in the end I did not. I can make this a separate PR if you prefer.

@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the deprecate-allowed-through-unstable branch from 59c0265 to 722a4b8 Compare January 1, 2025 20:56
@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the deprecate-allowed-through-unstable branch from 722a4b8 to 9d035c7 Compare January 1, 2025 21:25
@RalfJung RalfJung changed the title allowed_through_unstable_modules: support showing a deprecation message when the unstable module name is used deprecate std::intrinsics::transmute etc, use std::mem::* instead Jan 2, 2025
@petrochenkov
Copy link
Contributor

r? compiler

Comment on lines +4469 to +4444
#[cfg_attr(
not(bootstrap),
rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"
)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[cfg_attr(
not(bootstrap),
rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"
)]
#[cfg_attr(
not(bootstrap),
rustc_allowed_through_unstable_modules(deprecated = "import this function via `std::mem` instead")
)]

Copy link
Member Author

@RalfJung RalfJung Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how to implement that with reasonable effort, sorry. This is a rustc-internal attribute so it doesn't have to be super pretty.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 4, 2025
@fee1-dead

This comment was marked as duplicate.

@RalfJung RalfJung force-pushed the deprecate-allowed-through-unstable branch from 9a80eff to ff97579 Compare January 15, 2025 08:36
@RalfJung RalfJung force-pushed the deprecate-allowed-through-unstable branch from ff97579 to 7ae494a Compare January 15, 2025 08:41
@RalfJung
Copy link
Member Author

@bors r=davidtwco

@bors
Copy link
Collaborator

bors commented Jan 15, 2025

📌 Commit 7ae494a has been approved by davidtwco

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 15, 2025
@bors bors merged commit 369d135 into rust-lang:master Jan 15, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 15, 2025
@RalfJung RalfJung deleted the deprecate-allowed-through-unstable branch January 16, 2025 10:53
@jdonszelmann
Copy link
Contributor

for future reference I'd have appreciated it if this PR got the A-attributes label since it changed rustc_attr_parsing which is being reworked.

@RalfJung
Copy link
Member Author

RalfJung commented Feb 6, 2025 via email

@jdonszelmann
Copy link
Contributor

it does, we just enabled that haha #136643

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.