Repository navigation
rustc should not suggest #![feature(core_intrinsics)] #97501
Description
Activity
- addedC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on May 28, 2022 searched nightlies: from nightly-2022-03-01 to nightly-2022-05-28
regressed nightly: nightly-2022-04-13
searched commit range: 90ca447...52ca603
regressed commit: 2a83fbcbisected with cargo-bisect-rustc v0.6.2
Host triple: x86_64-unknown-linux-gnu
Reproduce with:cargo bisect-rustc --start=2022-03-01 --end=2022-05-28 --regress=ice
Makes sense to fail in #95320, cc @JakobDegen. Maybe this should be a hard error instead of a delayed bug?
Thanks for the report!
Before that PR, this:
#![feature(core_intrinsics)] pub fn add(a: bool, b: bool) -> bool { std::intrinsics::wrapping_add(a, b) }
just happily compiled, and this:
#![feature(core_intrinsics)] use std::intrinsics::wrapping_add; #[derive(Clone, Copy)] struct WrapInt8 { value: u8, value2: u16, } impl std::ops::Add for WrapInt8 { type Output = WrapInt8; fn add(self, other: WrapInt8) -> WrapInt8 { wrapping_add(self, other) } } fn main() { let p = WrapInt8 { value: 1, value2: 2 }; let q = WrapInt8 { value: 3, value2: 4 }; println!("{}", (p + q).value); }
already ICEd, so I don't think this is a regression. I'm tempted to say that we shouldn't bother trying to fix this, and that
#![feature(core_intrinsics)]is not "supported" in the sense that this bug wants it to be. I'm not sure what the procedure is for making a decision on this though.Edit: Maybe the actual bug here is that we recommend
#![feature(core_intrinsics)]in diagnostics?Reacted by Michael Goulet and Andrew KayMaybe the actual bug here is that we recommend
#![feature(core_intrinsics)]in diagnostics?I would agree with this. It probably makes sense to exclude
std::intrinsicsandcore::intrinsicsfrom suggested fixes, too.- addedglacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
on May 29, 2022 I agree that ICEing for this is actually pretty expected -- intrinsics are super-internal, and ICEing for misuse is basically fine.
👍 to seeing if we can make sure not to suggest
core_intrinsicsthe feature, or really anything with theextern "rust-intrinsic"ABI called via theintrinsicsmodule. (Sadly there are some stable things with that ABI.)Maybe for the things that are stable we can have them emit warnings/errors pointing to the stable versions? Since this example really wants
u8::wrapping_add, not the intrinsic. (Well, really it wantsnum::Wrapping<u8>, but we're probably not able to be that smart about it.)We might also want to change this message if the crate uses the
core_intrinsicfeature:note: the compiler unexpectedly panicked. this is a bug.
ICEs are not always bugs when intrinsics are used directly.
Reacted by scottmcm, Jakob Degen and Andrew KayReacted by scottmcm and Jubilee- addedA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-intrinsicsArea: IntrinsicsArea: IntrinsicsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.
on Mar 11, 2023 🤔
note: the compiler expectedly panicked. this is not a bug.
Unfortunately there's no label for "inviting Rust programmers to see a cask of Amontillado".
- changed the title
[-]Internal compiler errors using std::intrinsics::wrapping_add on Playground[/-][+]rustc should not suggest `#![feature(core_intrinsics)]`[/+]on Mar 11, 2023 - addedF-core_intrinsicsIssue in the "core intrinsics" for internal usage only.Issue in the "core intrinsics" for internal usage only.
on Mar 14, 2023 - addedS-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.Status: This bug is tracked inside the repo by a `known-bug` test.
on Apr 15, 2024 - added a commit that references this issue
on Jul 25, 2024 Reopening, since
Maybe the actual bug here is that we recommend #![feature(core_intrinsics)] in diagnostics?
Though... on playground I do find this recommendation quite handy, when I have to craft some code that actually wants to call intrinsics. And we do emit this now:
warning: the feature `core_intrinsics` is internal to the compiler or standard library --> src/main.rs:1:12 | 1 | #![feature(core_intrinsics)] | ^^^^^^^^^^^^^^^ | = note: using it is strongly discouraged = note: `#[warn(internal_features)]` on by defaultBut we also still say this, which we probably shouldn't:
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md- added a commit that references this issue
on Jul 29, 2024 - added a commit that references this issue
on Jul 29, 2024
Rust beginner here. I was trying something out on the Playground, turns out I didn't understand how to use
wrapping_addcorrectly; but following a sequence of suggested fixes from the compiler I arrived at the below, which gives two internal compiler errors. I asked on Discord and was told it is worth reporting it here, even though this code is incorrect and uses an unstable library feature.Code
Meta
This occurred on the Playground, using the current nightly build (1.63.0-nightly, 2022-05-27 ebbcbfc).
Error output