-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
6 changed files
with
74 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
src/test/ui/const-generics/cannot-infer-type-for-const-param.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 1 addition & 20 deletions
21
src/test/ui/const-generics/cannot-infer-type-for-const-param.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
10 changes: 10 additions & 0 deletions
10
src/test/ui/const-generics/issue-60818-struct-constructors.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/test/ui/const-generics/issue-60818-struct-constructors.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)] | ||
| ^^^^^^^^^^^^^^ | ||
|