librustc: replace span_bug calls with span_bug!()

This commit is contained in:
Benjamin Herr 2016-03-25 18:31:27 +01:00
parent 859b5a141c
commit bcdaccfbbe
21 changed files with 162 additions and 176 deletions

View file

@ -67,8 +67,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &TyCtxt<'tcx>, ast_ty: &ast::Ty)
if let ast::TyPath(None, ref path) = ast_ty.node {
let def = match tcx.def_map.borrow().get(&ast_ty.id) {
None => {
tcx.sess.span_bug(ast_ty.span,
&format!("unbound path {:?}", path))
span_bug!(ast_ty.span, "unbound path {:?}", path)
}
Some(d) => d.full_def()
};

View file

@ -125,7 +125,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
if let ty::TyStruct(def, _) = self.tcx.expr_ty_adjusted(lhs).sty {
self.insert_def_id(def.struct_variant().field_named(name).did);
} else {
self.tcx.sess.span_bug(lhs.span, "named field access on non-struct")
span_bug!(lhs.span, "named field access on non-struct")
}
}
@ -141,7 +141,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
let pat_ty = self.tcx.node_id_to_type(lhs.id);
let variant = match pat_ty.sty {
ty::TyStruct(adt, _) | ty::TyEnum(adt, _) => adt.variant_of_def(def),
_ => self.tcx.sess.span_bug(lhs.span, "non-ADT in struct pattern")
_ => span_bug!(lhs.span, "non-ADT in struct pattern")
};
for pat in pats {
if let PatKind::Wild = pat.node.pat.node {

View file

@ -564,9 +564,10 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
OverloadedCallType::from_method_id(self.tcx(), method_id)
}
None => {
self.tcx().sess.span_bug(
span_bug!(
callee.span,
&format!("unexpected callee type {}", callee_ty))
"unexpected callee type {}",
callee_ty)
}
};
match overloaded_call_type {
@ -683,7 +684,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
// may not. This will generate an error earlier in typeck,
// so we can just ignore it.
if !self.tcx().sess.has_errors() {
self.tcx().sess.span_bug(
span_bug!(
with_expr.span,
"with expression doesn't evaluate to a struct");
}
@ -750,9 +751,9 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
let (m, r) = match self_ty.sty {
ty::TyRef(r, ref m) => (m.mutbl, r),
_ => self.tcx().sess.span_bug(expr.span,
&format!("bad overloaded deref type {:?}",
method_ty))
_ => span_bug!(expr.span,
"bad overloaded deref type {:?}",
method_ty)
};
let bk = ty::BorrowKind::from_mutbl(m);
self.delegate.borrow(expr.id, expr.span, cmt,
@ -934,7 +935,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr,
pat);
return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| {
let tcx = self.tcx();
let def_map = &self.tcx().def_map;
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
match pat.node {
@ -947,7 +947,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
}
}
_ => {
tcx.sess.span_bug(
span_bug!(
pat.span,
"binding pattern not an identifier");
}
@ -972,8 +972,6 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
let delegate = &mut self.delegate;
return_if_err!(mc.cat_pattern(cmt_discr.clone(), pat, |mc, cmt_pat, pat| {
if pat_util::pat_is_binding(&def_map.borrow(), pat) {
let tcx = typer.tcx;
debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}",
cmt_pat,
pat,
@ -1007,7 +1005,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
delegate.consume_pat(pat, cmt_pat, mode);
}
_ => {
tcx.sess.span_bug(
span_bug!(
pat.span,
"binding pattern not an identifier");
}
@ -1117,10 +1115,10 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
// reported.
if !tcx.sess.has_errors() {
let msg = format!("Pattern has unexpected def: {:?} and type {:?}",
def,
cmt_pat.ty);
tcx.sess.span_bug(pat.span, &msg[..])
span_bug!(pat.span,
"Pattern has unexpected def: {:?} and type {:?}",
def,
cmt_pat.ty);
}
}
}

View file

@ -66,7 +66,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> {
let param_env = match self.param_envs.last() {
Some(p) => p,
None => {
self.tcx.sess.span_bug(
span_bug!(
span,
"transmute encountered outside of any fn");
}
@ -245,9 +245,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> {
}
}
_ => {
self.tcx
.sess
.span_bug(expr.span, "transmute wasn't a bare fn?!");
span_bug!(expr.span, "transmute wasn't a bare fn?!");
}
}
}

View file

@ -325,13 +325,10 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
fn variable(&self, node_id: NodeId, span: Span) -> Variable {
match self.variable_map.get(&node_id) {
Some(&var) => var,
None => {
self.tcx
.sess
.span_bug(span, &format!("no variable registered for id {}",
node_id));
}
Some(&var) => var,
None => {
span_bug!(span, "no variable registered for id {}", node_id);
}
}
}
@ -578,10 +575,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// above and the propagation code below; the two sets of
// code have to agree about which AST nodes are worth
// creating liveness nodes for.
self.ir.tcx.sess.span_bug(
span_bug!(
span,
&format!("no live node registered for node {}",
node_id));
"no live node registered for node {}",
node_id);
}
}
}
@ -703,15 +700,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// to find with one
match self.ir.tcx.def_map.borrow().get(&id).map(|d| d.full_def()) {
Some(Def::Label(loop_id)) => loop_id,
_ => self.ir.tcx.sess.span_bug(sp, "label on break/loop \
doesn't refer to a loop")
_ => span_bug!(sp, "label on break/loop \
doesn't refer to a loop")
}
}
None => {
// Vanilla 'break' or 'loop', so use the enclosing
// loop scope
if self.loop_scope.is_empty() {
self.ir.tcx.sess.span_bug(sp, "break outside loop");
span_bug!(sp, "break outside loop");
} else {
*self.loop_scope.last().unwrap()
}
@ -967,7 +964,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let caps = match this.ir.capture_info_map.get(&expr.id) {
Some(caps) => caps.clone(),
None => {
this.ir.tcx.sess.span_bug(expr.span, "no registered caps");
span_bug!(expr.span, "no registered caps");
}
};
caps.iter().rev().fold(succ, |succ, cap| {
@ -1061,8 +1058,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
match self.break_ln.get(&sc) {
Some(&b) => b,
None => self.ir.tcx.sess.span_bug(expr.span,
"break to unknown label")
None => span_bug!(expr.span, "break to unknown label")
}
}
@ -1075,8 +1071,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
match self.cont_ln.get(&sc) {
Some(&b) => b,
None => self.ir.tcx.sess.span_bug(expr.span,
"loop to unknown label")
None => span_bug!(expr.span, "loop to unknown label")
}
}

View file

@ -312,9 +312,9 @@ impl MutabilityCategory {
McImmutable
}
}
_ => tcx.sess.span_bug(p.span, "expected identifier pattern")
_ => span_bug!(p.span, "expected identifier pattern")
},
_ => tcx.sess.span_bug(tcx.map.span(id), "expected identifier pattern")
_ => span_bug!(tcx.map.span(id), "expected identifier pattern")
};
debug!("MutabilityCategory::{}(tcx, id={:?}) => {:?}",
"from_local", id, ret);
@ -559,8 +559,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
Def::TyParam(..) |
Def::Label(_) | Def::SelfTy(..) |
Def::AssociatedTy(..) => {
self.tcx().sess.span_bug(span, &format!("Unexpected definition in \
memory categorization: {:?}", def));
span_bug!(span, "Unexpected definition in \
memory categorization: {:?}", def);
}
Def::Static(_, mutbl) => {
@ -583,18 +583,19 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
self.cat_upvar(id, span, var_id, fn_node_id, kind)
}
None => {
self.tcx().sess.span_bug(
span_bug!(
span,
&format!("No closure kind for {:?}", closure_id));
"No closure kind for {:?}",
closure_id);
}
}
}
_ => {
self.tcx().sess.span_bug(
span_bug!(
span,
&format!("Upvar of non-closure {} - {:?}",
fn_node_id,
ty));
"Upvar of non-closure {} - {:?}",
fn_node_id,
ty);
}
}
}
@ -926,7 +927,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
let ptr = if implicit {
match ptr {
BorrowedPtr(bk, r) => Implicit(bk, r),
_ => self.tcx().sess.span_bug(node.span(),
_ => span_bug!(node.span(),
"Implicit deref of non-borrowed pointer")
}
} else {
@ -1092,8 +1093,8 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
},
_ => {
tcx.sess.span_bug(pat.span,
"type of slice pattern is not a slice");
span_bug!(pat.span,
"type of slice pattern is not a slice");
}
}
}
@ -1261,9 +1262,10 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
}
}
_ => {
self.tcx().sess.span_bug(
span_bug!(
pat.span,
&format!("enum pattern didn't resolve to enum or struct {:?}", opt_def));
"enum pattern didn't resolve to enum or struct {:?}",
opt_def);
}
}
}

View file

@ -67,10 +67,10 @@ fn method_might_be_inlined(tcx: &TyCtxt, sig: &hir::MethodSig,
Some(ast_map::NodeItem(item)) =>
item_might_be_inlined(&item),
Some(..) | None =>
tcx.sess.span_bug(impl_item.span, "impl did is not an item")
span_bug!(impl_item.span, "impl did is not an item")
}
} else {
tcx.sess.span_bug(impl_item.span, "found a foreign impl as a parent of a local method")
span_bug!(impl_item.span, "found a foreign impl as a parent of a local method")
}
}
@ -94,8 +94,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> {
let def = match self.tcx.def_map.borrow().get(&expr.id) {
Some(d) => d.full_def(),
None => {
self.tcx.sess.span_bug(expr.span,
"def ID not in def map?!")
span_bug!(expr.span, "def ID not in def map?!")
}
};

View file

@ -747,9 +747,9 @@ impl<'a> LifetimeContext<'a> {
lifetime_ref: &hir::Lifetime,
def: DefRegion) {
if lifetime_ref.id == ast::DUMMY_NODE_ID {
self.sess.span_bug(lifetime_ref.span,
"lifetime reference not renumbered, \
probably a bug in syntax::fold");
span_bug!(lifetime_ref.span,
"lifetime reference not renumbered, \
probably a bug in syntax::fold");
}
debug!("lifetime_ref={:?} id={:?} resolved to {:?}",

View file

@ -516,8 +516,8 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
span = field.span;
match tcx.expr_ty_adjusted(base_e).sty {
ty::TyStruct(def, _) => def.struct_variant().field_named(field.node).did,
_ => tcx.sess.span_bug(e.span,
"stability::check_expr: named field access on non-struct")
_ => span_bug!(e.span,
"stability::check_expr: named field access on non-struct")
}
}
hir::ExprTupField(ref base_e, ref field) => {
@ -525,9 +525,9 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
match tcx.expr_ty_adjusted(base_e).sty {
ty::TyStruct(def, _) => def.struct_variant().fields[field.node].did,
ty::TyTuple(..) => return,
_ => tcx.sess.span_bug(e.span,
"stability::check_expr: unnamed field access on \
something other than a tuple or struct")
_ => span_bug!(e.span,
"stability::check_expr: unnamed field access on \
something other than a tuple or struct")
}
}
hir::ExprStruct(_, ref expr_fields, _) => {
@ -551,10 +551,10 @@ pub fn check_expr(tcx: &TyCtxt, e: &hir::Expr,
// a bug to have construct one.
ty::TyEnum(..) => return,
_ => {
tcx.sess.span_bug(e.span,
&format!("stability::check_expr: struct construction \
of non-struct, type {:?}",
type_));
span_bug!(e.span,
"stability::check_expr: struct construction \
of non-struct, type {:?}",
type_);
}
}
}