-
Notifications
You must be signed in to change notification settings - Fork 14k
deprecate std::intrinsics::transmute etc, use std::mem::* instead
#135003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deprecate std::intrinsics::transmute etc, use std::mem::* instead
#135003
Conversation
|
rustbot has assigned @petrochenkov. Use |
|
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval |
| // 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() { |
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
ed11ebe to
59c0265
Compare
|
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; | ||
| } |
There was a problem hiding this comment.
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.
This comment has been minimized.
This comment has been minimized.
59c0265 to
722a4b8
Compare
This comment has been minimized.
This comment has been minimized.
722a4b8 to
9d035c7
Compare
std::intrinsics::transmute etc, use std::mem::* instead
|
r? compiler |
| #[cfg_attr( | ||
| not(bootstrap), | ||
| rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead" | ||
| )] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #[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") | |
| )] |
There was a problem hiding this comment.
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.
This comment was marked as duplicate.
This comment was marked as duplicate.
9a80eff to
ff97579
Compare
ff97579 to
7ae494a
Compare
|
@bors r=davidtwco |
|
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. |
|
I think rustbot has some auto labeling support based on which folders a PR changes. That sounds easier than relying on every PR author or reviewer to remember this.
|
|
it does, we just enabled that haha #136643 |
The
rustc_allowed_through_unstable_modulesattribute lets users callstd::mem::transmuteasstd::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::transmuteis 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 instd::intrinsicsthat carry the attribute.I assume this will need @rust-lang/libs-api FCP.