Skip to content

Commit

Permalink
librustc_passes: use bug!(), span_bug!()
Browse files Browse the repository at this point in the history
  • Loading branch information
ben0x539 committed Mar 31, 2016
1 parent 0305537 commit 676f6c3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/librustc_passes/const_fn.rs
Expand Up @@ -44,13 +44,13 @@ impl<'a, 'v> Visitor<'v> for CheckBlock<'a> {
visit::walk_expr(self, e);
}
}
fn visit_item(&mut self, _i: &'v ast::Item) { panic!("should be handled in CheckConstFn") }
fn visit_item(&mut self, _i: &'v ast::Item) { bug!("should be handled in CheckConstFn") }
fn visit_fn(&mut self,
_fk: FnKind<'v>,
_fd: &'v ast::FnDecl,
_b: &'v ast::Block,
_s: Span,
_fn_id: ast::NodeId) { panic!("should be handled in CheckConstFn") }
_fn_id: ast::NodeId) { bug!("should be handled in CheckConstFn") }
}

fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) {
Expand All @@ -67,7 +67,7 @@ fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) {
}
ast::StmtKind::Expr(ref expr, _) => expr.span,
ast::StmtKind::Semi(ref semi, _) => semi.span,
ast::StmtKind::Mac(..) => unreachable!(),
ast::StmtKind::Mac(..) => bug!(),
};
span_err!(sess, span, E0016,
"blocks in {}s are limited to items and tail expressions", kind);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_passes/consts.rs
Expand Up @@ -229,7 +229,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
Mode::Const => "constant",
Mode::ConstFn => "constant function",
Mode::StaticMut | Mode::Static => "static",
Mode::Var => unreachable!(),
Mode::Var => bug!(),
}
}

Expand Down Expand Up @@ -400,7 +400,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
// The count is checked elsewhere (typeck).
let count = match node_ty.sty {
ty::TyArray(_, n) => n,
_ => unreachable!()
_ => bug!()
};
// [element; 0] is always zero-sized.
if count == 0 {
Expand Down Expand Up @@ -570,7 +570,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
hir::ExprCast(ref from, _) => {
debug!("Checking const cast(id={})", from.id);
match v.tcx.cast_kinds.borrow().get(&from.id) {
None => v.tcx.sess.span_bug(e.span, "no kind for cast"),
None => span_bug!(e.span, "no kind for cast"),
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
v.add_qualif(ConstQualif::NOT_CONST);
if v.mode != Mode::Var {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/lib.rs
Expand Up @@ -28,7 +28,7 @@
#![feature(rustc_private)]

extern crate core;
extern crate rustc;
#[macro_use] extern crate rustc;
extern crate rustc_front;
extern crate rustc_const_eval;

Expand Down
18 changes: 9 additions & 9 deletions src/librustc_passes/static_recursion.rs
Expand Up @@ -218,9 +218,9 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
// borrow fall out of scope, so that we can reborrow farther down.
maybe_expr = (*get_expr).clone();
} else {
self.sess.span_bug(variant.span,
"`check_static_recursion` attempted to visit \
variant with unknown discriminant")
span_bug!(variant.span,
"`check_static_recursion` attempted to visit \
variant with unknown discriminant")
}
// If `maybe_expr` is `None`, that's because no discriminant is
// specified that affects this variant. Thus, no risk of recursion.
Expand Down Expand Up @@ -254,10 +254,10 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
self.visit_impl_item(item),
ast_map::NodeForeignItem(_) => {},
_ => {
self.sess.span_bug(
span_bug!(
e.span,
&format!("expected item, found {}",
self.ast_map.node_to_string(node_id)));
"expected item, found {}",
self.ast_map.node_to_string(node_id));
}
}
}
Expand All @@ -277,9 +277,9 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckItemRecursionVisitor<'a, 'ast> {
let variant = self.ast_map.expect_variant(variant_id);
self.visit_variant(variant, generics, enum_id);
} else {
self.sess.span_bug(e.span,
"`check_static_recursion` found \
non-enum in Def::Variant");
span_bug!(e.span,
"`check_static_recursion` found \
non-enum in Def::Variant");
}
}
}
Expand Down

0 comments on commit 676f6c3

Please sign in to comment.