-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
Given code using const
arguments to constraint the applicability of an impl
, we currently give a type error that completely ignores where the bound obligations came from:
error[E0308]: mismatched types
--> src/main.rs:37:24
|
37 | println!("{:?}", x + y);
| ^ expected `false`, found `true`
|
= note: expected type `false`
found type `true`
This output should be pointing at the obligation chain, closer to what you get if the failure isn't in a const arg:
error[E0277]: the trait bound `I32<{ 2..4 }>: IsTrue` is not satisfied
--> src/main.rs:35:24
|
35 | println!("{:?}", x + y);
| ^ the trait `IsTrue` is not implemented for `I32<{ 2..4 }>`
|
note: required because of the requirements on the impl of `Add<I32<{ 2..4 }>>` for `I32<{ 0..3 }>`
--> src/main.rs:23:31
|
23 | impl<T, const R1: Range<i32>> Add<T> for I32<R1>
| ^^^^^^ ^^^^^^^
jplattejonhoo, PotHix and YohDeadfall
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.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.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.