Skip to content

Commit 859b5a1

Browse files
committed
librustc: replace tcx.sess.bug calls with bug!()
1 parent fc7ec6b commit 859b5a1

File tree

24 files changed

+95
-132
lines changed

24 files changed

+95
-132
lines changed

src/librustc/infer/freshen.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
140140
ty::TyInfer(ty::FreshIntTy(c)) |
141141
ty::TyInfer(ty::FreshFloatTy(c)) => {
142142
if c >= self.freshen_count {
143-
tcx.sess.bug(
144-
&format!("Encountered a freshend type with id {} \
145-
but our counter is only at {}",
146-
c,
147-
self.freshen_count));
143+
bug!("Encountered a freshend type with id {} \
144+
but our counter is only at {}",
145+
c,
146+
self.freshen_count);
148147
}
149148
t
150149
}

src/librustc/infer/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ pub fn mk_eq_impl_headers<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
471471
match (a.trait_ref, b.trait_ref) {
472472
(Some(a_ref), Some(b_ref)) => mk_eq_trait_refs(cx, a_is_expected, origin, a_ref, b_ref),
473473
(None, None) => mk_eqty(cx, a_is_expected, origin, a.self_ty, b.self_ty),
474-
_ => cx.tcx.sess.bug("mk_eq_impl_headers given mismatched impl kinds"),
474+
_ => bug!("mk_eq_impl_headers given mismatched impl kinds"),
475475
}
476476
}
477477

@@ -1114,9 +1114,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11141114
None if self.errors_since_creation() =>
11151115
self.tcx.types.err,
11161116
None => {
1117-
self.tcx.sess.bug(
1118-
&format!("no type for node {}: {} in fcx",
1119-
id, self.tcx.map.node_to_string(id)));
1117+
bug!("no type for node {}: {} in fcx",
1118+
id, self.tcx.map.node_to_string(id));
11201119
}
11211120
}
11221121
}
@@ -1125,7 +1124,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11251124
match self.tables.borrow().node_types.get(&ex.id) {
11261125
Some(&t) => t,
11271126
None => {
1128-
self.tcx.sess.bug("no type for expr in fcx");
1127+
bug!("no type for expr in fcx");
11291128
}
11301129
}
11311130
}

src/librustc/infer/region_inference/graphviz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
9090
};
9191

9292
if output_template.is_empty() {
93-
tcx.sess.bug("empty string provided as RUST_REGION_GRAPH");
93+
bug!("empty string provided as RUST_REGION_GRAPH");
9494
}
9595

9696
if output_template.contains('%') {

src/librustc/infer/region_inference/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
413413
self.bound_count.set(sc + 1);
414414

415415
if sc >= self.bound_count.get() {
416-
self.tcx.sess.bug("rollover in RegionInference new_bound()");
416+
bug!("rollover in RegionInference new_bound()");
417417
}
418418

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

739739
(ReStatic, _) | (_, ReStatic) => {

src/librustc/infer/resolve.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ impl<'a, 'tcx> ty::fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
127127
self.tcx().types.err
128128
}
129129
ty::TyInfer(_) => {
130-
self.infcx.tcx.sess.bug(
131-
&format!("Unexpected type in full type resolver: {:?}",
132-
t));
130+
bug!("Unexpected type in full type resolver: {:?}", t);
133131
}
134132
_ => {
135133
t.super_fold_with(self)

src/librustc/lint/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl LintStore {
183183
// We load builtin lints first, so a duplicate is a compiler bug.
184184
// Use early_error when handling -W help with no crate.
185185
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
186-
(Some(sess), false) => sess.bug(&msg[..]),
186+
(Some(_), false) => bug!("{}", msg),
187187

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

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

453453
// Check for future incompatibility lints and issue a stronger warning.

src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl OverloadedCallType {
224224
}
225225
}
226226

227-
tcx.sess.bug("overloaded call didn't map to known function trait")
227+
bug!("overloaded call didn't map to known function trait")
228228
}
229229

230230
fn from_method_id(tcx: &TyCtxt, method_id: DefId)

src/librustc/middle/free_region.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl FreeRegionMap {
4949
}
5050

5151
pub fn relate_free_regions_from_predicates<'tcx>(&mut self,
52-
tcx: &TyCtxt<'tcx>,
52+
_tcx: &TyCtxt<'tcx>,
5353
predicates: &[ty::Predicate<'tcx>]) {
5454
debug!("relate_free_regions_from_predicates(predicates={:?})", predicates);
5555
for predicate in predicates {
@@ -72,10 +72,9 @@ impl FreeRegionMap {
7272
}
7373
_ => {
7474
// All named regions are instantiated with free regions.
75-
tcx.sess.bug(
76-
&format!("record_region_bounds: non free region: {:?} / {:?}",
77-
r_a,
78-
r_b));
75+
bug!("record_region_bounds: non free region: {:?} / {:?}",
76+
r_a,
77+
r_b);
7978
}
8079
}
8180
}

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> {
10441044
mutbl:m,
10451045
ty: match base_cmt.ty.builtin_deref(false, ty::NoPreference) {
10461046
Some(mt) => mt.ty,
1047-
None => self.tcx().sess.bug("Found non-derefable type")
1047+
None => bug!("Found non-derefable type")
10481048
},
10491049
note: NoteNone
10501050
})

src/librustc/middle/reachable.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
312312
ast_map::NodeVariant(_) |
313313
ast_map::NodeStructCtor(_) => {}
314314
_ => {
315-
self.tcx
316-
.sess
317-
.bug(&format!("found unexpected thingy in worklist: {}",
318-
self.tcx
319-
.map
320-
.node_to_string(search_item)))
315+
bug!("found unexpected thingy in worklist: {}",
316+
self.tcx.map.node_to_string(search_item))
321317
}
322318
}
323319
}

0 commit comments

Comments
 (0)