Const generic is incorrectly inferred #133390
Labels
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen:
I expect the code to compile with no errors and no warnings.
Both functions have a const generic parameter with the same constraint applied, but these parameters should be completely independent. I made sure to given them different names (
N
andD
) to make the distinction more obvious.I expect the
get_array
call insideweird
to inferD=1
, no matter whatN
is monomorphized to.Instead, this happened:
Note that the error disappears if any single one of these changes is applied:
[f32; N]: SomeArray
constraint onweird
is removed[f32; D]: SomeArray
constraint onget_array
is removedget_array()
is turbofished toget_array::<1>()
Meta
rustc --version --verbose
:The behaviour on nightly 2024-11-22 is the same as on 1.82.0
RUST_BACKTRACE=1
has no effect on the compiler output.The text was updated successfully, but these errors were encountered: