Skip to content

Commit 2270553

Browse files
authored
Rollup merge of #150554 - Dushyanthyadav:ice-issue-150409-regression-test, r=davidtwco
test: add regression cases for valtree hashing ICE This PR extends the existing regression test `printing_valtrees_supports_non_values.rs` to cover cases that previously caused an ICE in `const_kind.rs` due to hashing inference variables. It specifically adds: A case where an associated constant is used without the required trait bound. The `0: _` case as suggested in [Here](#150409 (comment)) Fixes #150409
2 parents f8b1d59 + 4ba73c3 commit 2270553

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ fn baz<T: Trait>() {
2525
}
2626

2727
fn main() {}
28+
29+
fn test_ice_missing_bound<T>() {
30+
foo::<{Option::Some::<u32>{0: <T as Trait>::ASSOC}}>();
31+
//~^ ERROR the trait bound `T: Trait` is not satisfied
32+
//~| ERROR the constant `Option::<u32>::Some(_)` is not of type `Foo`
33+
}
34+
35+
fn test_underscore_inference() {
36+
foo::<{ Option::Some::<u32> { 0: _ } }>();
37+
//~^ ERROR the constant `Option::<u32>::Some(_)` is not of type `Foo`
38+
}

tests/ui/const-generics/mgca/printing_valtrees_supports_non_values.stderr

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,41 @@ note: required by a const generic parameter in `foo`
2222
LL | fn foo<const N: Foo>() {}
2323
| ^^^^^^^^^^^^ required by this const generic parameter in `foo`
2424

25-
error: aborting due to 2 previous errors
25+
error[E0277]: the trait bound `T: Trait` is not satisfied
26+
--> $DIR/printing_valtrees_supports_non_values.rs:30:5
27+
|
28+
LL | foo::<{Option::Some::<u32>{0: <T as Trait>::ASSOC}}>();
29+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
30+
|
31+
help: consider restricting type parameter `T` with trait `Trait`
32+
|
33+
LL | fn test_ice_missing_bound<T: Trait>() {
34+
| +++++++
35+
36+
error: the constant `Option::<u32>::Some(_)` is not of type `Foo`
37+
--> $DIR/printing_valtrees_supports_non_values.rs:30:12
38+
|
39+
LL | foo::<{Option::Some::<u32>{0: <T as Trait>::ASSOC}}>();
40+
| ^^^^^^^^^^^^^^^^^^^ expected `Foo`, found `Option<u32>`
41+
|
42+
note: required by a const generic parameter in `foo`
43+
--> $DIR/printing_valtrees_supports_non_values.rs:15:8
44+
|
45+
LL | fn foo<const N: Foo>() {}
46+
| ^^^^^^^^^^^^ required by this const generic parameter in `foo`
47+
48+
error: the constant `Option::<u32>::Some(_)` is not of type `Foo`
49+
--> $DIR/printing_valtrees_supports_non_values.rs:36:13
50+
|
51+
LL | foo::<{ Option::Some::<u32> { 0: _ } }>();
52+
| ^^^^^^^^^^^^^^^^^^^ expected `Foo`, found `Option<u32>`
53+
|
54+
note: required by a const generic parameter in `foo`
55+
--> $DIR/printing_valtrees_supports_non_values.rs:15:8
56+
|
57+
LL | fn foo<const N: Foo>() {}
58+
| ^^^^^^^^^^^^ required by this const generic parameter in `foo`
59+
60+
error: aborting due to 5 previous errors
2661

62+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)