librustc_borrowck: use bug!(), span_bug!()
This commit is contained in:
parent
e3a7a66f1a
commit
065dcd0702
@ -27,7 +27,7 @@ use rustc::middle::mem_categorization as mc;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::codemap::{Span, DUMMY_SP};
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
@ -428,8 +428,8 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
||||
let tuple_idx = match *origin_field_name {
|
||||
mc::PositionalField(tuple_idx) => tuple_idx,
|
||||
mc::NamedField(_) =>
|
||||
panic!("tuple type {:?} should not have named fields.",
|
||||
parent_ty),
|
||||
bug!("tuple type {:?} should not have named fields.",
|
||||
parent_ty),
|
||||
};
|
||||
let tuple_len = v.len();
|
||||
for i in 0..tuple_len {
|
||||
@ -493,10 +493,11 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
|
||||
}
|
||||
|
||||
ref sty_and_variant_info => {
|
||||
let msg = format!("type {:?} ({:?}) is not fragmentable",
|
||||
parent_ty, sty_and_variant_info);
|
||||
let opt_span = origin_id.and_then(|id|tcx.map.opt_span(id));
|
||||
tcx.sess.opt_span_bug(opt_span, &msg[..])
|
||||
span_bug!(opt_span.unwrap_or(DUMMY_SP),
|
||||
"type {:?} ({:?}) is not fragmentable",
|
||||
parent_ty,
|
||||
sty_and_variant_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
LpDowncast(ref base_lp, _) =>
|
||||
move_data.add_variant_match(
|
||||
tcx, lp.clone(), move_pat.id, base_lp.clone(), mode),
|
||||
_ => panic!("should only call gather_match_variant \
|
||||
for cat_downcast cmt"),
|
||||
_ => bug!("should only call gather_match_variant \
|
||||
for cat_downcast cmt"),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
|
@ -378,10 +378,10 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
|
||||
ty::ReEarlyBound(..) |
|
||||
ty::ReVar(..) |
|
||||
ty::ReSkolemized(..) => {
|
||||
self.tcx().sess.span_bug(
|
||||
span_bug!(
|
||||
cmt.span,
|
||||
&format!("invalid borrow lifetime: {:?}",
|
||||
loan_region));
|
||||
"invalid borrow lifetime: {:?}",
|
||||
loan_region);
|
||||
}
|
||||
};
|
||||
debug!("loan_scope = {:?}", loan_scope);
|
||||
|
@ -134,8 +134,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
a non-copy fixed-size array",
|
||||
b.ty)
|
||||
} else {
|
||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
||||
unreachable!();
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,14 +149,12 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
b.ty)
|
||||
},
|
||||
_ => {
|
||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
||||
unreachable!();
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
bccx.span_bug(move_from.span, "this path should not cause illegal move");
|
||||
unreachable!();
|
||||
span_bug!(move_from.span, "this path should not cause illegal move");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ fn gather_moves<'tcx>(mir: &Mir<'tcx>, tcx: &TyCtxt<'tcx>) -> MoveData<'tcx> {
|
||||
Rvalue::InlineAsm { .. } => {}
|
||||
|
||||
Rvalue::Slice {..} => {
|
||||
bb_ctxt.tcx.sess.bug("cannot move out of slice");
|
||||
bug!("cannot move out of slice");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -420,10 +420,10 @@ pub fn closure_to_block(closure_id: ast::NodeId,
|
||||
block.id
|
||||
}
|
||||
_ => {
|
||||
panic!("encountered non-closure id: {}", closure_id)
|
||||
bug!("encountered non-closure id: {}", closure_id)
|
||||
}
|
||||
},
|
||||
_ => panic!("encountered non-expr id: {}", closure_id)
|
||||
_ => bug!("encountered non-expr id: {}", closure_id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -704,10 +704,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
||||
}
|
||||
r => {
|
||||
self.tcx.sess.bug(&format!("MoveExpr({}) maps to \
|
||||
{:?}, not Expr",
|
||||
the_move.id,
|
||||
r))
|
||||
bug!("MoveExpr({}) maps to {:?}, not Expr",
|
||||
the_move.id,
|
||||
r)
|
||||
}
|
||||
};
|
||||
let (suggestion, _) =
|
||||
@ -766,10 +765,9 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
(self.tcx.expr_ty_adjusted(&expr), expr.span)
|
||||
}
|
||||
r => {
|
||||
self.tcx.sess.bug(&format!("Captured({}) maps to \
|
||||
{:?}, not Expr",
|
||||
the_move.id,
|
||||
r))
|
||||
bug!("Captured({}) maps to {:?}, not Expr",
|
||||
the_move.id,
|
||||
r)
|
||||
}
|
||||
};
|
||||
let (suggestion, help) =
|
||||
@ -852,10 +850,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
self.tcx.sess.span_err_with_code(s, msg, code);
|
||||
}
|
||||
|
||||
pub fn span_bug(&self, s: Span, m: &str) {
|
||||
self.tcx.sess.span_bug(s, m);
|
||||
}
|
||||
|
||||
pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
|
||||
match err.code {
|
||||
err_mutbl => {
|
||||
@ -895,7 +889,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
format!("cannot borrow {} as mutable", descr)
|
||||
}
|
||||
BorrowViolation(euv::ClosureInvocation) => {
|
||||
self.tcx.sess.span_bug(err.span,
|
||||
span_bug!(err.span,
|
||||
"err_mutbl with a closure invocation");
|
||||
}
|
||||
}
|
||||
@ -1035,7 +1029,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
|
||||
// We need to determine which is the case here.
|
||||
let kind = match err.cmt.upvar().unwrap().cat {
|
||||
Categorization::Upvar(mc::Upvar { kind, .. }) => kind,
|
||||
_ => unreachable!()
|
||||
_ => bug!()
|
||||
};
|
||||
if kind == ty::ClosureKind::Fn {
|
||||
db.span_help(
|
||||
|
@ -515,7 +515,7 @@ impl<'tcx> MoveData<'tcx> {
|
||||
assignment_index);
|
||||
}
|
||||
LpExtend(..) => {
|
||||
tcx.sess.bug("var assignment for non var path");
|
||||
bug!("var assignment for non var path");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
|
||||
// refers to the borrowck-specific graphviz adapter traits.
|
||||
extern crate graphviz as dot;
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_mir;
|
||||
|
Loading…
x
Reference in New Issue
Block a user