Skip to content

Commit

Permalink
librustc: replace tcx.sess.bug calls with bug!()
Browse files Browse the repository at this point in the history
  • Loading branch information
ben0x539 committed Mar 31, 2016
1 parent fc7ec6b commit 859b5a1
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 132 deletions.
9 changes: 4 additions & 5 deletions src/librustc/infer/freshen.rs
Expand Up @@ -140,11 +140,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
ty::TyInfer(ty::FreshIntTy(c)) |
ty::TyInfer(ty::FreshFloatTy(c)) => {
if c >= self.freshen_count {
tcx.sess.bug(
&format!("Encountered a freshend type with id {} \
but our counter is only at {}",
c,
self.freshen_count));
bug!("Encountered a freshend type with id {} \
but our counter is only at {}",
c,
self.freshen_count);
}
t
}
Expand Down
9 changes: 4 additions & 5 deletions src/librustc/infer/mod.rs
Expand Up @@ -471,7 +471,7 @@ pub fn mk_eq_impl_headers<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
match (a.trait_ref, b.trait_ref) {
(Some(a_ref), Some(b_ref)) => mk_eq_trait_refs(cx, a_is_expected, origin, a_ref, b_ref),
(None, None) => mk_eqty(cx, a_is_expected, origin, a.self_ty, b.self_ty),
_ => cx.tcx.sess.bug("mk_eq_impl_headers given mismatched impl kinds"),
_ => bug!("mk_eq_impl_headers given mismatched impl kinds"),
}
}

Expand Down Expand Up @@ -1114,9 +1114,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
None if self.errors_since_creation() =>
self.tcx.types.err,
None => {
self.tcx.sess.bug(
&format!("no type for node {}: {} in fcx",
id, self.tcx.map.node_to_string(id)));
bug!("no type for node {}: {} in fcx",
id, self.tcx.map.node_to_string(id));
}
}
}
Expand All @@ -1125,7 +1124,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
match self.tables.borrow().node_types.get(&ex.id) {
Some(&t) => t,
None => {
self.tcx.sess.bug("no type for expr in fcx");
bug!("no type for expr in fcx");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/region_inference/graphviz.rs
Expand Up @@ -90,7 +90,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
};

if output_template.is_empty() {
tcx.sess.bug("empty string provided as RUST_REGION_GRAPH");
bug!("empty string provided as RUST_REGION_GRAPH");
}

if output_template.contains('%') {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/region_inference/mod.rs
Expand Up @@ -413,7 +413,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
self.bound_count.set(sc + 1);

if sc >= self.bound_count.get() {
self.tcx.sess.bug("rollover in RegionInference new_bound()");
bug!("rollover in RegionInference new_bound()");
}

ReLateBound(debruijn, BrFresh(sc))
Expand Down Expand Up @@ -733,7 +733,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
(_, ReLateBound(..)) |
(ReEarlyBound(..), _) |
(_, ReEarlyBound(..)) => {
self.tcx.sess.bug(&format!("cannot relate bound region: LUB({:?}, {:?})", a, b));
bug!("cannot relate bound region: LUB({:?}, {:?})", a, b);
}

(ReStatic, _) | (_, ReStatic) => {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/infer/resolve.rs
Expand Up @@ -127,9 +127,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
self.tcx().types.err
}
ty::TyInfer(_) => {
self.infcx.tcx.sess.bug(
&format!("Unexpected type in full type resolver: {:?}",
t));
bug!("Unexpected type in full type resolver: {:?}", t);
}
_ => {
t.super_fold_with(self)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/lint/context.rs
Expand Up @@ -183,7 +183,7 @@ impl LintStore {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),
(Some(_), false) => bug!("{}", msg),

// A duplicate name from a plugin is a user error.
(Some(sess), true) => sess.err(&msg[..]),
Expand Down Expand Up @@ -221,7 +221,7 @@ impl LintStore {
// We load builtin lints first, so a duplicate is a compiler bug.
// Use early_error when handling -W help with no crate.
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
(Some(sess), false) => sess.bug(&msg[..]),
(Some(_), false) => bug!("{}", msg),

// A duplicate name from a plugin is a user error.
(Some(sess), true) => sess.err(&msg[..]),
Expand Down Expand Up @@ -447,7 +447,7 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
(Warn, None) => sess.struct_warn(&msg[..]),
(Deny, Some(sp)) => sess.struct_span_err(sp, &msg[..]),
(Deny, None) => sess.struct_err(&msg[..]),
_ => sess.bug("impossible level in raw_emit_lint"),
_ => bug!("impossible level in raw_emit_lint"),
};

// Check for future incompatibility lints and issue a stronger warning.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/expr_use_visitor.rs
Expand Up @@ -224,7 +224,7 @@ impl OverloadedCallType {
}
}

tcx.sess.bug("overloaded call didn't map to known function trait")
bug!("overloaded call didn't map to known function trait")
}

fn from_method_id(tcx: &TyCtxt, method_id: DefId)
Expand Down
9 changes: 4 additions & 5 deletions src/librustc/middle/free_region.rs
Expand Up @@ -49,7 +49,7 @@ impl FreeRegionMap {
}

pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
tcx: &TyCtxt<'tcx>,
_tcx: &TyCtxt<'tcx>,
predicates: &[ty::Predicate<'tcx>]) {
debug!("relate_free_regions_from_predicates(predicates={:?})", predicates);
for predicate in predicates {
Expand All @@ -72,10 +72,9 @@ impl FreeRegionMap {
}
_ => {
// All named regions are instantiated with free regions.
tcx.sess.bug(
&format!("record_region_bounds: non free region: {:?} / {:?}",
r_a,
r_b));
bug!("record_region_bounds: non free region: {:?} / {:?}",
r_a,
r_b);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Expand Up @@ -1044,7 +1044,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
mutbl:m,
ty: match base_cmt.ty.builtin_deref(false, ty::NoPreference) {
Some(mt) => mt.ty,
None => self.tcx().sess.bug("Found non-derefable type")
None => bug!("Found non-derefable type")
},
note: NoteNone
})
Expand Down
8 changes: 2 additions & 6 deletions src/librustc/middle/reachable.rs
Expand Up @@ -312,12 +312,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
ast_map::NodeVariant(_) |
ast_map::NodeStructCtor(_) => {}
_ => {
self.tcx
.sess
.bug(&format!("found unexpected thingy in worklist: {}",
self.tcx
.map
.node_to_string(search_item)))
bug!("found unexpected thingy in worklist: {}",
self.tcx.map.node_to_string(search_item))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/tcx.rs
Expand Up @@ -70,7 +70,7 @@ impl<'tcx> LvalueTy<'tcx> {
variant_index: index }
}
_ => {
tcx.sess.bug(&format!("cannot downcast non-enum type: `{:?}`", self))
bug!("cannot downcast non-enum type: `{:?}`", self)
}
},
ProjectionElem::Field(_, fty) => LvalueTy::Ty { ty: fty }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Expand Up @@ -270,7 +270,7 @@ impl Session {

match id.checked_add(count) {
Some(next) => self.next_node_id.set(next),
None => self.bug("Input too large, ran out of node ids!")
None => bug!("Input too large, ran out of node ids!")
}

id
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/traits/coherence.rs
Expand Up @@ -291,9 +291,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &TyCtxt<'tcx>,
}

ty::TyClosure(..) => {
tcx.sess.bug(
&format!("ty_is_local invoked on unexpected type: {:?}",
ty))
bug!("ty_is_local invoked on unexpected type: {:?}", ty)
}
}
}
4 changes: 2 additions & 2 deletions src/librustc/traits/project.rs
Expand Up @@ -719,8 +719,8 @@ fn project_type<'cx,'tcx>(
// The essential problem here is that the projection fails,
// leaving two unnormalized types, which appear not to unify
// -- so the overlap check succeeds, when it should fail.
selcx.tcx().sess.bug("Tried to project an inherited associated type during \
coherence checking, which is currently not supported.");
bug!("Tried to project an inherited associated type during \
coherence checking, which is currently not supported.");
}
}
}
Expand Down
48 changes: 20 additions & 28 deletions src/librustc/traits/select.rs
Expand Up @@ -1601,7 +1601,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ObjectCandidate |
ParamCandidate(_) | ProjectionCandidate => match victim.candidate {
DefaultImplCandidate(..) => {
self.tcx().sess.bug(
bug!(
"default implementations shouldn't be recorded \
when there are other valid candidates");
}
Expand Down Expand Up @@ -1703,7 +1703,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::BoundSized => ok_if(Vec::new()),

ty::BoundSync | ty::BoundSend => {
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
bug!("Send/Sync shouldn't occur in builtin_bounds()");
}
}
}
Expand All @@ -1713,7 +1713,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::BoundCopy | ty::BoundSized => ok_if(Vec::new()),

ty::BoundSync | ty::BoundSend => {
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
bug!("Send/Sync shouldn't occur in builtin_bounds()");
}
}
}
Expand Down Expand Up @@ -1741,7 +1741,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
}
ty::BoundSync | ty::BoundSend => {
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
bug!("Send/Sync shouldn't occur in builtin_bounds()");
}
}
}
Expand All @@ -1762,7 +1762,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::BoundSized => ok_if(Vec::new()),

ty::BoundSync | ty::BoundSend => {
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
bug!("Send/Sync shouldn't occur in builtin_bounds()");
}
}
}
Expand All @@ -1773,15 +1773,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::BoundCopy => ok_if(vec![element_ty]),
ty::BoundSized => ok_if(Vec::new()),
ty::BoundSync | ty::BoundSend => {
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
bug!("Send/Sync shouldn't occur in builtin_bounds()");
}
}
}

ty::TyStr | ty::TySlice(_) => {
match bound {
ty::BoundSync | ty::BoundSend => {
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
bug!("Send/Sync shouldn't occur in builtin_bounds()");
}

ty::BoundCopy | ty::BoundSized => Err(Unimplemented),
Expand Down Expand Up @@ -1847,10 +1847,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::TyInfer(ty::FreshTy(_))
| ty::TyInfer(ty::FreshIntTy(_))
| ty::TyInfer(ty::FreshFloatTy(_)) => {
self.tcx().sess.bug(
&format!(
"asked to assemble builtin bounds of unexpected type: {:?}",
self_ty));
bug!("asked to assemble builtin bounds of unexpected type: {:?}",
self_ty);
}
};

Expand Down Expand Up @@ -1911,10 +1909,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::TyInfer(ty::FreshTy(_)) |
ty::TyInfer(ty::FreshIntTy(_)) |
ty::TyInfer(ty::FreshFloatTy(_)) => {
self.tcx().sess.bug(
&format!(
"asked to assemble constituent types of unexpected type: {:?}",
t));
bug!("asked to assemble constituent types of unexpected type: {:?}",
t);
}

ty::TyBox(referent_ty) => { // Box<T>
Expand Down Expand Up @@ -2135,10 +2131,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
match self.match_where_clause_trait_ref(obligation, param.clone()) {
Ok(obligations) => obligations,
Err(()) => {
self.tcx().sess.bug(
&format!("Where clause `{:?}` was applicable to `{:?}` but now is not",
param,
obligation));
bug!("Where clause `{:?}` was applicable to `{:?}` but now is not",
param,
obligation);
}
}
}
Expand Down Expand Up @@ -2175,7 +2170,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let trait_def = match self.tcx().lang_items.from_builtin_kind(bound) {
Ok(def_id) => def_id,
Err(_) => {
self.tcx().sess.bug("builtin trait definition not found");
bug!("builtin trait definition not found");
}
};

Expand Down Expand Up @@ -2238,10 +2233,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
self.vtable_default_impl(obligation, trait_def_id, all_types)
}
_ => {
self.tcx().sess.bug(
&format!(
"asked to confirm default object implementation for non-object type: {:?}",
self_ty));
bug!("asked to confirm default object implementation for non-object type: {:?}",
self_ty);
}
}
}
Expand Down Expand Up @@ -2692,10 +2685,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
match self.match_impl(impl_def_id, obligation, snapshot) {
Ok((substs, skol_map)) => (substs, skol_map),
Err(()) => {
self.tcx().sess.bug(
&format!("Impl {:?} was matchable against {:?} but now is not",
impl_def_id,
obligation));
bug!("Impl {:?} was matchable against {:?} but now is not",
impl_def_id,
obligation);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/librustc/traits/specialize/mod.rs
Expand Up @@ -93,10 +93,8 @@ pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
}

fulfill_implication(infcx, source_trait_ref, target_impl).unwrap_or_else(|_| {
infcx.tcx
.sess
.bug("When translating substitutions for specialization, the expected \
specializaiton failed to hold")
bug!("When translating substitutions for specialization, the expected \
specializaiton failed to hold")
})
}
specialization_graph::Node::Trait(..) => source_trait_ref.substs.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/util.rs
Expand Up @@ -481,8 +481,8 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &TyCtxt<'tcx>,
}
}

tcx.sess.bug(&format!("get_vtable_index_of_object_method: {:?} was not found",
method_def_id));
bug!("get_vtable_index_of_object_method: {:?} was not found",
method_def_id);
}

pub enum TupleArgumentsFlag { Yes, No }
Expand Down

0 comments on commit 859b5a1

Please sign in to comment.