librustc_passes: use bug!(), span_bug!()
This commit is contained in:
parent
0305537652
commit
676f6c3116
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
|
|
@ -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!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue