-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Wrong suggestion for const well-formedness of bool #122395
Labels
A-const-generics
Area: const generics (parameters and arguments)
A-diagnostics
Area: Messages for errors, warnings, and lints
const-generics-bad-diagnostics
An error is correctly emitted, but is confusing, for `min_const_generics`.
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
slanterns
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Mar 12, 2024
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
rustbot
added
A-const-generics
Area: const generics (parameters and arguments)
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
labels
Mar 12, 2024
compiler-errors
added
the
const-generics-bad-diagnostics
An error is correctly emitted, but is confusing, for `min_const_generics`.
label
Mar 12, 2024
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 25, 2024
…st, r=Nadrieril Provide structured suggestion for unconstrained generic constant ``` error: unconstrained generic constant --> $DIR/const-argument-if-length.rs:18:10 | LL | pad: [u8; is_zst::<T>()], | ^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: { | ++++++++++++++++++++++++++ ``` Detect when the constant expression isn't `usize` and suggest casting: ``` error: unconstrained generic constant --> f300.rs:6:10 | 6 | bb::<{!N}>(); | ^^^^ -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36 | help: try adding a `where` bound | 5 | fn b<const N: bool>() where [(); {!N} as usize]: { | ++++++++++++++++++++++++++ ``` Fix rust-lang#122395.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 25, 2024
…st, r=Nadrieril Provide structured suggestion for unconstrained generic constant ``` error: unconstrained generic constant --> $DIR/const-argument-if-length.rs:18:10 | LL | pad: [u8; is_zst::<T>()], | ^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: { | ++++++++++++++++++++++++++ ``` Detect when the constant expression isn't `usize` and suggest casting: ``` error: unconstrained generic constant --> f300.rs:6:10 | 6 | bb::<{!N}>(); | ^^^^ -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36 | help: try adding a `where` bound | 5 | fn b<const N: bool>() where [(); {!N} as usize]: { | ++++++++++++++++++++++++++ ``` Fix rust-lang#122395.
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 25, 2024
…, r=Nadrieril Provide structured suggestion for unconstrained generic constant ``` error: unconstrained generic constant --> $DIR/const-argument-if-length.rs:18:10 | LL | pad: [u8; is_zst::<T>()], | ^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | LL | pub struct AtLeastByte<T: ?Sized> where [(); is_zst::<T>()]: { | ++++++++++++++++++++++++++ ``` Detect when the constant expression isn't `usize` and suggest casting: ``` error: unconstrained generic constant --> f300.rs:6:10 | 6 | bb::<{!N}>(); | ^^^^ -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs:3539:36 | help: try adding a `where` bound | 5 | fn b<const N: bool>() where [(); {!N} as usize]: { | ++++++++++++++++++++++++++ ``` Fix rust-lang#122395.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-const-generics
Area: const generics (parameters and arguments)
A-diagnostics
Area: Messages for errors, warnings, and lints
const-generics-bad-diagnostics
An error is correctly emitted, but is confusing, for `min_const_generics`.
F-generic_const_exprs
`#![feature(generic_const_exprs)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=6c33a1495d719fbc2d8efe30177c3ca4
Current output
Desired output
`where [(); !N as usize]:`
Rationale and extra context
The well-formedness shouldn't be written as
where [(); {!N}]:
when!N
is a bool, which doesn't compile. Should cast it to an integral type.Other cases
No response
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: