Skip to content

Commit d05f726

Browse files
committed
librustc_resolve: use bug!(), span_bug!()
1 parent 487219c commit d05f726

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
507507
Def::Label(..) |
508508
Def::SelfTy(..) |
509509
Def::Err => {
510-
panic!("didn't expect `{:?}`", def);
510+
bug!("didn't expect `{:?}`", def);
511511
}
512512
}
513513
}

src/librustc_resolve/lib.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern crate arena;
3232
#[no_link]
3333
extern crate rustc_bitflags;
3434
extern crate rustc_front;
35+
#[macro_use]
3536
extern crate rustc;
3637

3738
use self::PatternBindingMode::*;
@@ -2375,11 +2376,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23752376
// The below shouldn't happen because all
23762377
// qualified paths should be in PatKind::QPath.
23772378
TypecheckRequired =>
2378-
self.session.span_bug(path.span,
2379-
"resolve_possibly_assoc_item claimed that a path \
2380-
in PatKind::Path or PatKind::TupleStruct \
2381-
requires typecheck to resolve, but qualified \
2382-
paths should be PatKind::QPath"),
2379+
span_bug!(path.span,
2380+
"resolve_possibly_assoc_item claimed that a path \
2381+
in PatKind::Path or PatKind::TupleStruct \
2382+
requires typecheck to resolve, but qualified \
2383+
paths should be PatKind::QPath"),
23832384
ResolveAttempt(resolution) => resolution,
23842385
};
23852386
if let Some(path_res) = resolution {
@@ -2668,7 +2669,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26682669
let mut def = local_def.def;
26692670
match def {
26702671
Def::Upvar(..) => {
2671-
self.session.span_bug(span, &format!("unexpected {:?} in bindings", def))
2672+
span_bug!(span, "unexpected {:?} in bindings", def)
26722673
}
26732674
Def::Local(_, node_id) => {
26742675
for rib in ribs {
@@ -3189,7 +3190,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31893190
})
31903191
}
31913192
Some(_) => {
3192-
self.session.span_bug(expr.span, "label wasn't mapped to a label def!")
3193+
span_bug!(expr.span, "label wasn't mapped to a label def!")
31933194
}
31943195
}
31953196
}
@@ -3346,7 +3347,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33463347
paths.push(segm);
33473348
paths
33483349
}
3349-
_ => unreachable!(),
3350+
_ => bug!(),
33503351
};
33513352

33523353
if !in_module_is_extern || name_binding.is_public() {
@@ -3368,10 +3369,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33683369
debug!("(recording def) recording {:?} for {}", resolution, node_id);
33693370
if let Some(prev_res) = self.def_map.borrow_mut().insert(node_id, resolution) {
33703371
let span = self.ast_map.opt_span(node_id).unwrap_or(codemap::DUMMY_SP);
3371-
self.session.span_bug(span,
3372-
&format!("path resolved multiple times ({:?} before, {:?} now)",
3373-
prev_res,
3374-
resolution));
3372+
span_bug!(span,
3373+
"path resolved multiple times ({:?} before, {:?} now)",
3374+
prev_res,
3375+
resolution);
33753376
}
33763377
}
33773378

0 commit comments

Comments
 (0)