add suggestion for rustc_allowed_through_unstable_modules attribute - #162155
add suggestion for rustc_allowed_through_unstable_modules attribute#162155mejrs wants to merge 1 commit into
rustc_allowed_through_unstable_modules attribute#162155Conversation
|
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred in compiler/rustc_attr_ir cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_attr_parsing |
|
r? @davidtwco rustbot has assigned @davidtwco. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| use core::intrinsics::{ | ||
| transmute as _, | ||
| //~^ ERROR use of deprecated import through accidentally stabilized module `intrinsics` | ||
| }; |
There was a problem hiding this comment.
Rustfix doesn't like duplicate fixes (this impl would emit it twice for e.g. use std::intrinsics::{copy, copy_nonoverlapping};, but there are only 16 crates in Ralf's crater run that do this so I don't care
There was a problem hiding this comment.
if you run ci rustfix on e.g. use core::intrinsics::{transmute, copy}; then compiletest panics with
thread '[ui] tests\ui\stability-attribute\accidentally-stable-intrinsics.rs' panicked at
src\tools\compiletest\src\runtest\ui.rs:99:17:
failed to apply suggestions for "C:\\Users\\bruno\\Rust\\rust\\tests\\ui\\stability-attribute\\accidentally-stable-intrinsics.rs"
with rustfix: cannot replace slice of data that was already replaced
So I think it still works, I just can't write a test for it without complicating the implementation significantly.
There was a problem hiding this comment.
What does cargo fix do with such replacements?
There was a problem hiding this comment.
Hm, per the docs: https://doc.rust-lang.org/nightly/nightly-rustc/rustfix/fn.apply_suggestions.html
If a replacement in a suggestion exactly matches a replacement of a previously applied solution, that entire suggestion will be skipped without generating an error. This is currently done to alleviate issues like #51211, although it may be removed if that’s fixed deeper in the compiler.
So that means it doesn't do anything? I don't think it's worth fixing - these imports are very rare and having to keep track of already emitted lints would be a bit annoying. It should be easier to do once #161349 lands though.
There was a problem hiding this comment.
I want to avoid us emitting diagnostics that cause cargo fix to ICE or do something wrong. That would be worth fixing. If cargo fix just ignores some of the fixes, that's not great but less concerning.
There was a problem hiding this comment.
Ah, I figured out what exactly the problem was. It is because if you have
use core::intrinsics::{transmute, copy}; then one lint will suggest replacing it with mem but the other with ptr.
In that case rustfix will just do nothing. In principle that could be fixed, but it is hard because ast lowering flattens the import structure, so we don't really know multiple imports came from a single tree. #161349 possibly might make that easier. But given that there are no such cases in the crater run (I only see import tree combinations of copy/copy_nonoverlapping/write_bytes) I don't think it's worth complicating the implementation or waiting for that pr.
There was a problem hiding this comment.
Both suggestions are wrong though. I don't mind duplicate suggestions that much, but incorrect suggestions are a bug. Is that a good way to just not have a suggestion in this case?
There was a problem hiding this comment.
Not really. I guess we could, rather than emitting the lint immediately, collect all lints and at the end of the pass try to guess by looking at spans which imports came from the same use tree and not emit those suggestions. There are probably corner cases with that approach too.
So that's a decent implementation effort/complexity for something that ~never happens (no such cases in the crater run). And then Oli gets to rip it all out when he gets to implementing the unflattening of hir use trees.
I will not be wasting my time implementing that.
This comment has been minimized.
This comment has been minimized.
260bc7c to
11abd8d
Compare
This comment has been minimized.
This comment has been minimized.
11abd8d to
4badc23
Compare
4badc23 to
8f316d4
Compare
|
@bors r+ rollup |
…le_modules, r=davidtwco add suggestion for `rustc_allowed_through_unstable_modules` attribute
…le_modules, r=davidtwco add suggestion for `rustc_allowed_through_unstable_modules` attribute
Rollup of 25 pull requests Successful merges: - #159074 ([PAC] FnAbi, llvm.ptrauth.resign and Session API change (2/8)) - #159792 (A more readable debug map for IndexMaps) - #161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment) - #161900 (bootstrap: Include feature-gated items in bootstrap tool docs) - #161940 (Promote `wasm32-wasip3` to a tier 2 target) - #162072 (Add new Tier-3 target: `powerpc64-sony-ps3`) - #162179 (type system const items via direct rhs) - #162277 (Introduce `rustc_middle::middel::resolve`) - #162285 (box: fixup map/try_map deallocate calls) - #162286 (string: don't unwind prematurely) - #162289 (alloc: a bunch of safety comments) - #162292 (Update `askama` version to `0.16.1`) - #160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`) - #160906 (Suggest usize instead of placeholder type for array length constants) - #160936 (traits: Represent live alias arguments as bitsets) - #161400 (Improve diagnostics for references to closures) - #161656 (Suggest mutable references for FnMut closure arguments) - #161711 (Add more splat fn type tests) - #161786 (Make `tcx.def_id_partial_cmp` public) - #161953 (sanitizers: Implicitly disable mutually exclusive sanitizers) - #162155 (add suggestion for `rustc_allowed_through_unstable_modules` attribute) - #162212 (Implement `Rng` for `Box`) - #162246 (Fix incorrect meta span) - #162266 (std: fix typo) - #162291 (Add regression test from 1.98.1)
…le_modules, r=davidtwco add suggestion for `rustc_allowed_through_unstable_modules` attribute
Rollup of 25 pull requests Successful merges: - #159074 ([PAC] FnAbi, llvm.ptrauth.resign and Session API change (2/8)) - #159792 (A more readable debug map for IndexMaps) - #160745 (make closures act like MaybeDangling) - #161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment) - #161940 (Promote `wasm32-wasip3` to a tier 2 target) - #162072 (Add new Tier-3 target: `powerpc64-sony-ps3`) - #162179 (type system const items via direct rhs) - #162277 (Introduce `rustc_middle::middel::resolve`) - #162285 (box: fixup map/try_map deallocate calls) - #162286 (string: don't unwind prematurely) - #162289 (alloc: a bunch of safety comments) - #162292 (Update `askama` version to `0.16.1`) - #160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`) - #160906 (Suggest usize instead of placeholder type for array length constants) - #160936 (traits: Represent live alias arguments as bitsets) - #161400 (Improve diagnostics for references to closures) - #161656 (Suggest mutable references for FnMut closure arguments) - #161711 (Add more splat fn type tests) - #161786 (Make `tcx.def_id_partial_cmp` public) - #161953 (sanitizers: Implicitly disable mutually exclusive sanitizers) - #162155 (add suggestion for `rustc_allowed_through_unstable_modules` attribute) - #162212 (Implement `Rng` for `Box`) - #162246 (Fix incorrect meta span) - #162266 (std: fix typo) - #162291 (Add regression test from 1.98.1)
…le_modules, r=davidtwco add suggestion for `rustc_allowed_through_unstable_modules` attribute
…le_modules, r=davidtwco add suggestion for `rustc_allowed_through_unstable_modules` attribute
Rollup of 27 pull requests Successful merges: - #159074 ([PAC] FnAbi, llvm.ptrauth.resign and Session API change (2/8)) - #159792 (A more readable debug map for IndexMaps) - #160745 (make closures act like MaybeDangling) - #161940 (Promote `wasm32-wasip3` to a tier 2 target) - #162030 (Prevent `--test` to be used in `rustdoc-html` testsuite) - #162072 (Add new Tier-3 target: `powerpc64-sony-ps3`) - #162179 (type system const items via direct rhs) - #162262 (Avoid manually instantiating some binders in error reporting with `-Znext-solver`) - #162277 (Introduce `rustc_middle::middel::resolve`) - #162285 (box: fixup map/try_map deallocate calls) - #162286 (string: don't unwind prematurely) - #162289 (alloc: a bunch of safety comments) - #162290 (abby test DSL: AliasTyOutlivesViaEnv) - #162292 (Update `askama` version to `0.16.1`) - #160509 (Remove `RegionExt`; move methods to `Region` in `rustc_type_ir`) - #160906 (Suggest usize instead of placeholder type for array length constants) - #160936 (traits: Represent live alias arguments as bitsets) - #161400 (Improve diagnostics for references to closures) - #161656 (Suggest mutable references for FnMut closure arguments) - #161711 (Add more splat fn type tests) - #161786 (Make `tcx.def_id_partial_cmp` public) - #161953 (sanitizers: Implicitly disable mutually exclusive sanitizers) - #162155 (add suggestion for `rustc_allowed_through_unstable_modules` attribute) - #162212 (Implement `Rng` for `Box`) - #162246 (Fix incorrect meta span) - #162266 (std: fix typo) - #162291 (Add regression test from 1.98.1)
…le_modules, r=davidtwco add suggestion for `rustc_allowed_through_unstable_modules` attribute
No description provided.