Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ICE when encountering ConstKind::Error in RequiredConstsVisitor #104233

Merged
merged 1 commit into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remotely know how this works, but shouldn't this be changed too, since the above now allows another kind?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an error message, so I don't think it really needs to be changed -- Error isn't really expected here, we just silently swallow it.

},
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