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

replace all unreachable! and panic! calls with bug! #47

Merged
merged 6 commits into from
Sep 7, 2016
Merged

replace all unreachable! and panic! calls with bug! #47

merged 6 commits into from
Sep 7, 2016

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Sep 6, 2016

fixes #32

I didn't touch the unimplemented!, since these probably need to go away by being implememented before moving miri into rustc.

@@ -44,22 +44,25 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
fn extract_str(lit: &syntax::ast::Lit) -> syntax::parse::token::InternedString {
match lit.node {
syntax::ast::LitKind::Str(ref s, _) => s.clone(),
_ => panic!("attribute values need to be strings"),
_ => bug!("attribute values need to be strings"),
Copy link
Member

Choose a reason for hiding this comment

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

This should actually be a span_err, because it is a miri user fault, not miri progrmmer fault.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the parser ever yields something other than a LitKind::Str. Rustc will error and abort long before we reach this.

Copy link
Member

Choose a reason for hiding this comment

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

#[memory_size=true] should give LitKind::Bool for the value.

Copy link
Member

Choose a reason for hiding this comment

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

@oli-obk It turns out this changed in a recent nightly. Beta still bails on non-string literals in attributes, but nightly accepts them if you use #![feature(attr_literals)].

@@ -49,8 +49,7 @@ pub fn binary_op<'tcx>(bin_op: mir::BinOp, left: PrimVal, right: PrimVal) -> Eva
BitOr => $v($l | $r),

// these have already been handled
Shl => bug!("`<<` operation should already have been handled"),
Shr => bug!("`>>` operation should already have been handled"),
Shl | Shr => bug!("`bin_op` operation should already have been handled", bin_op.to_hir_binop().as_str()),
Copy link
Member

Choose a reason for hiding this comment

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

s/bin_op/{}/

@solson solson merged commit be23dcd into rust-lang:master Sep 7, 2016
@oli-obk oli-obk deleted the unreachable_bugs branch September 7, 2016 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use rustc's compiler error macros.
4 participants