librustc_resolve: use bug!(), span_bug!()

This commit is contained in:
Benjamin Herr 2016-03-28 23:11:50 +02:00
parent 487219ccb1
commit d05f726eed
2 changed files with 14 additions and 13 deletions

View File

@ -507,7 +507,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
Def::Label(..) | Def::Label(..) |
Def::SelfTy(..) | Def::SelfTy(..) |
Def::Err => { Def::Err => {
panic!("didn't expect `{:?}`", def); bug!("didn't expect `{:?}`", def);
} }
} }
} }

View File

@ -32,6 +32,7 @@ extern crate arena;
#[no_link] #[no_link]
extern crate rustc_bitflags; extern crate rustc_bitflags;
extern crate rustc_front; extern crate rustc_front;
#[macro_use]
extern crate rustc; extern crate rustc;
use self::PatternBindingMode::*; use self::PatternBindingMode::*;
@ -2375,7 +2376,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// The below shouldn't happen because all // The below shouldn't happen because all
// qualified paths should be in PatKind::QPath. // qualified paths should be in PatKind::QPath.
TypecheckRequired => TypecheckRequired =>
self.session.span_bug(path.span, span_bug!(path.span,
"resolve_possibly_assoc_item claimed that a path \ "resolve_possibly_assoc_item claimed that a path \
in PatKind::Path or PatKind::TupleStruct \ in PatKind::Path or PatKind::TupleStruct \
requires typecheck to resolve, but qualified \ requires typecheck to resolve, but qualified \
@ -2668,7 +2669,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let mut def = local_def.def; let mut def = local_def.def;
match def { match def {
Def::Upvar(..) => { Def::Upvar(..) => {
self.session.span_bug(span, &format!("unexpected {:?} in bindings", def)) span_bug!(span, "unexpected {:?} in bindings", def)
} }
Def::Local(_, node_id) => { Def::Local(_, node_id) => {
for rib in ribs { for rib in ribs {
@ -3189,7 +3190,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}) })
} }
Some(_) => { Some(_) => {
self.session.span_bug(expr.span, "label wasn't mapped to a label def!") span_bug!(expr.span, "label wasn't mapped to a label def!")
} }
} }
} }
@ -3346,7 +3347,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
paths.push(segm); paths.push(segm);
paths paths
} }
_ => unreachable!(), _ => bug!(),
}; };
if !in_module_is_extern || name_binding.is_public() { if !in_module_is_extern || name_binding.is_public() {
@ -3368,10 +3369,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
debug!("(recording def) recording {:?} for {}", resolution, node_id); debug!("(recording def) recording {:?} for {}", resolution, node_id);
if let Some(prev_res) = self.def_map.borrow_mut().insert(node_id, resolution) { if let Some(prev_res) = self.def_map.borrow_mut().insert(node_id, resolution) {
let span = self.ast_map.opt_span(node_id).unwrap_or(codemap::DUMMY_SP); let span = self.ast_map.opt_span(node_id).unwrap_or(codemap::DUMMY_SP);
self.session.span_bug(span, span_bug!(span,
&format!("path resolved multiple times ({:?} before, {:?} now)", "path resolved multiple times ({:?} before, {:?} now)",
prev_res, prev_res,
resolution)); resolution);
} }
} }