-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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 |
…h-unstable-modules-is-a-deprecation-flag, r=GuillaumeGomez rustdoc: treat `allowed_through_unstable_modules` as deprecation This ensures `std::intrinsics::transmute` is deemphasized in the search engine and other UI, by cleaning it into a deprecation without propagating it through reexports when the parent module is stable. Fixes rust-lang#131676 Related to rust-lang#135003 r? `@GuillaumeGomez` `@RalfJung` `@workingjubilee`
…h-unstable-modules-is-a-deprecation-flag, r=GuillaumeGomez rustdoc: treat `allowed_through_unstable_modules` as deprecation This ensures `std::intrinsics::transmute` is deemphasized in the search engine and other UI, by cleaning it into a deprecation without propagating it through reexports when the parent module is stable. Fixes rust-lang#131676 Related to rust-lang#135003 r? ``@GuillaumeGomez`` ``@RalfJung`` ``@workingjubilee``
Rollup merge of rust-lang#135043 - notriddle:notriddle/allowed-through-unstable-modules-is-a-deprecation-flag, r=GuillaumeGomez rustdoc: treat `allowed_through_unstable_modules` as deprecation This ensures `std::intrinsics::transmute` is deemphasized in the search engine and other UI, by cleaning it into a deprecation without propagating it through reexports when the parent module is stable. Fixes rust-lang#131676 Related to rust-lang#135003 r? ``@GuillaumeGomez`` ``@RalfJung`` ``@workingjubilee``
#[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 |
…-unstable, r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead 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.
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#131806 (Treat other items as functions for the purpose of type-based search) - rust-lang#132654 (std: lazily allocate the main thread handle) - rust-lang#135003 (deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead) - rust-lang#135428 (rustdoc: Remove `AttributesExt` trait magic that added needless complexity) - rust-lang#135498 (Prefer lower `TraitUpcasting` candidates in selection) - rust-lang#135529 (remove outdated FIXME) r? `@ghost` `@rustbot` modify labels: rollup
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#132654 (std: lazily allocate the main thread handle) - rust-lang#135003 (deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead) - rust-lang#135428 (rustdoc: Remove `AttributesExt` trait magic that added needless complexity) - rust-lang#135498 (Prefer lower `TraitUpcasting` candidates in selection) - rust-lang#135507 (TRPL: incorporate all backward-compatible Edition changes) - rust-lang#135529 (remove outdated FIXME) r? `@ghost` `@rustbot` modify labels: rollup
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_modules
attribute lets users callstd::mem::transmute
asstd::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 instd::intrinsics
that carry the attribute.I assume this will need @rust-lang/libs-api FCP.