Skip to content

Commit

Permalink
Rollup merge of rust-lang#104233 - compiler-errors:issue-104209, r=lcnr
Browse files Browse the repository at this point in the history
Don't ICE when encountering `ConstKind::Error` in `RequiredConstsVisitor`

Fixes rust-lang#104209
  • Loading branch information
Manishearth authored Nov 10, 2022
2 parents c6595ea + 31157de commit 77fde5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/required_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl<'tcx> Visitor<'tcx> for RequiredConstsVisitor<'_, 'tcx> {
let literal = constant.literal;
match literal {
ConstantKind::Ty(c) => match c.kind() {
ConstKind::Param(_) => {}
ConstKind::Param(_) | ConstKind::Error(_) => {}
_ => bug!("only ConstKind::Param should be encountered here, got {:#?}", c),
},
ConstantKind::Unevaluated(..) => self.required_consts.push(*constant),
Expand Down
6 changes: 6 additions & 0 deletions src/test/ui/consts/invalid-const-in-body.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn f() -> impl Sized {
2.0E
//~^ ERROR expected at least one digit in exponent
}

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/consts/invalid-const-in-body.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected at least one digit in exponent
--> $DIR/invalid-const-in-body.rs:2:5
|
LL | 2.0E
| ^^^^

error: aborting due to previous error

0 comments on commit 77fde5d

Please sign in to comment.