Skip to content

Confusing error message when feature generic_const_exprs is used. #100414

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
timcryt opened this issue Aug 11, 2022 · 0 comments · Fixed by #100437
Closed

Confusing error message when feature generic_const_exprs is used. #100414

timcryt opened this issue Aug 11, 2022 · 0 comments · Fixed by #100437
Assignees
Labels
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.

Comments

@timcryt
Copy link

timcryt commented Aug 11, 2022

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=5c971999babd48f6d0b57e56450996f2

#![feature(generic_const_exprs)]

trait True {}

struct Is<const V: bool>;

impl True for Is<true> {}

fn g<T>()
    where Is<{ std::mem::size_of::<T>() == 0 }>: True
{ } 

fn main() {
    g::<usize>();
}

The current output is:

error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
  --> src/main.rs:14:5
   |
14 |     g::<usize>();
   |     ^^^^^^^^^^ expected `false`, found `true`
   |
   = note: expected type `false`
              found type `true`

For more information about this error, try `rustc --explain E0308`.

Due to something true and false are considered types, not values, also the error span is not any informative.

@timcryt timcryt 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 Aug 11, 2022
@compiler-errors compiler-errors self-assigned this Aug 11, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue Aug 12, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 23, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
compiler-errors added a commit to compiler-errors/rust that referenced this issue Aug 24, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 26, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 26, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 26, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 26, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 27, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 28, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 28, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Aug 28, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 28, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 28, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 28, 2022
…tch-err, r=oli-obk

Improve const mismatch `FulfillmentError`

Fixes rust-lang#100414
@bors bors closed this as completed in 26c86c6 Aug 29, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants