forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#135195 - oli-obk:push-toyoyrupruko, r=lcnr Make `lit_to_mir_constant` and `lit_to_const` infallible My motivation for this change is just that it's annoying to check everywhere, especially since all but one call site was just ICEing on errors anyway right there. They can still fail, but now just return an error constant instead of having the caller handle the error. fixes rust-lang#114317 fixes rust-lang#126182
- Loading branch information
Showing
15 changed files
with
143 additions
and
175 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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.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,22 @@ | ||
//! ICE regression test for #114317 and #126182 | ||
//! Type mismatches of literals cause errors int typeck, | ||
//! but those errors cannot be propagated to the various | ||
//! `lit_to_const` call sites. Now `lit_to_const` just delays | ||
//! a bug and produces an error constant on its own. | ||
#![feature(adt_const_params)] | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
struct A<const B: () = 1, C>(C); | ||
//~^ ERROR: generic parameters with a default must be trailing | ||
//~| ERROR: mismatched types | ||
|
||
struct Cond<const B: bool>; | ||
|
||
struct Thing<T = Cond<0>>(T); | ||
//~^ ERROR: mismatched types | ||
|
||
impl Thing {} | ||
|
||
fn main() {} |
21 changes: 21 additions & 0 deletions
21
tests/ui/const-generics/generic_const_exprs/lit_type_mismatch.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,21 @@ | ||
error: generic parameters with a default must be trailing | ||
--> $DIR/lit_type_mismatch.rs:11:16 | ||
| | ||
LL | struct A<const B: () = 1, C>(C); | ||
| ^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/lit_type_mismatch.rs:11:24 | ||
| | ||
LL | struct A<const B: () = 1, C>(C); | ||
| ^ expected `()`, found integer | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/lit_type_mismatch.rs:17:23 | ||
| | ||
LL | struct Thing<T = Cond<0>>(T); | ||
| ^ expected `bool`, found integer | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Oops, something went wrong.