Fix ICE with struct ctors and const generics.
This commit fixes a ICE where struct constructors were resulting in an ICE with const generics. Previously, a `match` in `type_of` did not have an arm for the `DefKind::Ctor` resolutions and therefore would assume that the type did not have generics.
This commit is contained in:
parent
4b9d80325a
commit
41aaf7bc46
6 changed files with 74 additions and 73 deletions
|
|
@ -1,8 +1,9 @@
|
|||
// compile-pass
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
// We should probably be able to infer the types here. However, this test is checking that we don't
|
||||
// get an ICE in this case. It may be modified later to not be an error.
|
||||
// This test confirms that the types can be inferred correctly for this example with const
|
||||
// generics. Previously this would ICE, and more recently error.
|
||||
|
||||
struct Foo<const NUM_BYTES: usize>(pub [u8; NUM_BYTES]);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,6 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/cannot-infer-type-for-const-param.rs:1:12
|
||||
--> $DIR/cannot-infer-type-for-const-param.rs:2:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/cannot-infer-type-for-const-param.rs:10:19
|
||||
|
|
||||
LL | let _ = Foo::<3>([1, 2, 3]);
|
||||
| ^ cannot infer type for `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/cannot-infer-type-for-const-param.rs:10:22
|
||||
|
|
||||
LL | let _ = Foo::<3>([1, 2, 3]);
|
||||
| ^^^^^^^^^ expected `3`, found `3usize`
|
||||
|
|
||||
= note: expected type `[u8; _]`
|
||||
found type `[u8; 3]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0308.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
// compile-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
|
||||
struct Generic<const V: usize>;
|
||||
|
||||
fn main() {
|
||||
let _ = Generic::<0>;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/issue-60818-struct-constructors.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue