Skip to content

Commit 21cd27f

Browse files
committed
---
yaml --- r: 272221 b: refs/heads/auto c: 37f8429 h: refs/heads/master i: 272219: aad1cf5
1 parent 86ec473 commit 21cd27f

File tree

5 files changed

+64
-72
lines changed

5 files changed

+64
-72
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: d05f726eed5a977d546a92d64d2402cb049e505e
11+
refs/heads/auto: 37f8429f3d396c4d815f95c7dd49085ff4d8bdbe
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc_save_analysis/data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use syntax::codemap::Span;
2222

2323
#[macro_export]
2424
macro_rules! down_cast_data {
25-
($id:ident, $kind:ident, $this:ident, $sp:expr) => {
25+
($id:ident, $kind:ident, $sp:expr) => {
2626
let $id = if let super::Data::$kind(data) = $id {
2727
data
2828
} else {
29-
$this.sess.span_bug($sp, &format!("unexpected data kind: {:?}", $id));
29+
span_bug!($sp, "unexpected data kind: {:?}", $id);
3030
}
3131
};
3232
}

branches/auto/src/librustc_save_analysis/dump_visitor.rs

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ use super::span_utils::SpanUtils;
5151
use super::recorder;
5252

5353
macro_rules! down_cast_data {
54-
($id:ident, $kind:ident, $this:ident, $sp:expr) => {
54+
($id:ident, $kind:ident, $sp:expr) => {
5555
let $id = if let super::Data::$kind(data) = $id {
5656
data
5757
} else {
58-
$this.sess.span_bug($sp, &format!("unexpected data kind: {:?}", $id));
58+
span_bug!($sp, "unexpected data kind: {:?}", $id);
5959
}
6060
};
6161
}
@@ -271,8 +271,7 @@ where D: Dump
271271
// looks up anything, not just a type
272272
fn lookup_type_ref(&self, ref_id: NodeId) -> Option<DefId> {
273273
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
274-
self.sess.bug(&format!("def_map has no key for {} in lookup_type_ref",
275-
ref_id));
274+
bug!("def_map has no key for {} in lookup_type_ref", ref_id);
276275
}
277276
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
278277
match def {
@@ -294,9 +293,9 @@ where D: Dump
294293

295294
let def_map = self.tcx.def_map.borrow();
296295
if !def_map.contains_key(&ref_id) {
297-
self.sess.span_bug(span,
298-
&format!("def_map has no key for {} in lookup_def_kind",
299-
ref_id));
296+
span_bug!(span,
297+
"def_map has no key for {} in lookup_def_kind",
298+
ref_id);
300299
}
301300
let def = def_map.get(&ref_id).unwrap().full_def();
302301
match def {
@@ -347,8 +346,9 @@ where D: Dump
347346
Def::Method(..) |
348347
Def::PrimTy(_) |
349348
Def::Err => {
350-
self.sess.span_bug(span,
351-
&format!("process_def_kind for unexpected item: {:?}", def));
349+
span_bug!(span,
350+
"process_def_kind for unexpected item: {:?}",
351+
def);
352352
}
353353
}
354354
}
@@ -480,7 +480,7 @@ where D: Dump
480480
ty_params: &ast::Generics,
481481
body: &ast::Block) {
482482
if let Some(fn_data) = self.save_ctxt.get_item_data(item) {
483-
down_cast_data!(fn_data, FunctionData, self, item.span);
483+
down_cast_data!(fn_data, FunctionData, item.span);
484484
if !self.span.filter_generated(Some(fn_data.span), item.span) {
485485
self.dumper.function(item.span, fn_data.clone().normalize(&self.tcx));
486486
}
@@ -502,7 +502,7 @@ where D: Dump
502502

503503
fn process_static_or_const_item(&mut self, item: &ast::Item, typ: &ast::Ty, expr: &ast::Expr) {
504504
if let Some(var_data) = self.save_ctxt.get_item_data(item) {
505-
down_cast_data!(var_data, VariableData, self, item.span);
505+
down_cast_data!(var_data, VariableData, item.span);
506506
if !self.span.filter_generated(Some(var_data.span), item.span) {
507507
let mut var_data = var_data;
508508
var_data.scope = normalize_node_id(&self.tcx, var_data.scope) as u32;
@@ -578,7 +578,7 @@ where D: Dump
578578
None => return,
579579
Some(data) => data,
580580
};
581-
down_cast_data!(enum_data, EnumData, self, item.span);
581+
down_cast_data!(enum_data, EnumData, item.span);
582582
let normalized = enum_data.clone().normalize(&self.tcx);
583583
if !self.span.filter_generated(Some(normalized.span), item.span) {
584584
self.dumper.enum_data(item.span, normalized);
@@ -638,7 +638,7 @@ where D: Dump
638638
impl_items: &[ast::ImplItem]) {
639639
let mut has_self_ref = false;
640640
if let Some(impl_data) = self.save_ctxt.get_item_data(item) {
641-
down_cast_data!(impl_data, ImplData, self, item.span);
641+
down_cast_data!(impl_data, ImplData, item.span);
642642
if let Some(ref self_ref) = impl_data.self_ref {
643643
has_self_ref = true;
644644
if !self.span.filter_generated(Some(self_ref.span), item.span) {
@@ -734,7 +734,7 @@ where D: Dump
734734
// `item` is the module in question, represented as an item.
735735
fn process_mod(&mut self, item: &ast::Item) {
736736
if let Some(mod_data) = self.save_ctxt.get_item_data(item) {
737-
down_cast_data!(mod_data, ModData, self, item.span);
737+
down_cast_data!(mod_data, ModData, item.span);
738738
if !self.span.filter_generated(Some(mod_data.span), item.span) {
739739
self.dumper.mod_data(mod_data.normalize(&self.tcx));
740740
}
@@ -750,10 +750,9 @@ where D: Dump
750750
let path_data = match path_data {
751751
Some(pd) => pd,
752752
None => {
753-
self.tcx.sess.span_bug(path.span,
754-
&format!("Unexpected def kind while looking up path in \
755-
`{}`",
756-
self.span.snippet(path.span)))
753+
span_bug!(path.span,
754+
"Unexpected def kind while looking up path in `{}`",
755+
self.span.snippet(path.span))
757756
}
758757
};
759758

@@ -807,8 +806,7 @@ where D: Dump
807806
}
808807
}
809808
_ => {
810-
self.sess.span_bug(path.span,
811-
&format!("Unexpected data: {:?}", path_data));
809+
span_bug!(path.span, "Unexpected data: {:?}", path_data);
812810
}
813811
}
814812

@@ -844,7 +842,7 @@ where D: Dump
844842
self.write_sub_paths_truncated(path, false);
845843

846844
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
847-
down_cast_data!(struct_lit_data, TypeRefData, self, ex.span);
845+
down_cast_data!(struct_lit_data, TypeRefData, ex.span);
848846
if !self.span.filter_generated(Some(struct_lit_data.span), ex.span) {
849847
self.dumper.type_ref(ex.span, struct_lit_data.normalize(&self.tcx));
850848
}
@@ -869,7 +867,7 @@ where D: Dump
869867

870868
fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec<P<ast::Expr>>) {
871869
if let Some(mcd) = self.save_ctxt.get_expr_data(ex) {
872-
down_cast_data!(mcd, MethodCallData, self, ex.span);
870+
down_cast_data!(mcd, MethodCallData, ex.span);
873871
if !self.span.filter_generated(Some(mcd.span), ex.span) {
874872
self.dumper.method_call(ex.span, mcd.normalize(&self.tcx));
875873
}
@@ -1234,7 +1232,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
12341232
self.visit_expr(&sub_ex);
12351233

12361234
if let Some(field_data) = self.save_ctxt.get_expr_data(ex) {
1237-
down_cast_data!(field_data, VariableRefData, self, ex.span);
1235+
down_cast_data!(field_data, VariableRefData, ex.span);
12381236
if !self.span.filter_generated(Some(field_data.span), ex.span) {
12391237
self.dumper.variable_ref(ex.span, field_data.normalize(&self.tcx));
12401238
}
@@ -1258,9 +1256,9 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
12581256
}
12591257
}
12601258
ty::TyTuple(_) => {}
1261-
_ => self.sess.span_bug(ex.span,
1262-
&format!("Expected struct or tuple type, found {:?}",
1263-
ty)),
1259+
_ => span_bug!(ex.span,
1260+
"Expected struct or tuple type, found {:?}",
1261+
ty),
12641262
}
12651263
}
12661264
ast::ExprKind::Closure(_, ref decl, ref body) => {
@@ -1302,7 +1300,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
13021300

13031301
fn visit_mac(&mut self, mac: &ast::Mac) {
13041302
// These shouldn't exist in the AST at this point, log a span bug.
1305-
self.sess.span_bug(mac.span, "macro invocation should have been expanded out of AST");
1303+
span_bug!(mac.span, "macro invocation should have been expanded out of AST");
13061304
}
13071305

13081306
fn visit_pat(&mut self, p: &ast::Pat) {
@@ -1325,8 +1323,7 @@ impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
13251323
for &(id, ref p, immut, ref_kind) in &collector.collected_paths {
13261324
let def_map = self.tcx.def_map.borrow();
13271325
if !def_map.contains_key(&id) {
1328-
self.sess.span_bug(p.span,
1329-
&format!("def_map has no key for {} in visit_arm", id));
1326+
span_bug!(p.span, "def_map has no key for {} in visit_arm", id);
13301327
}
13311328
let def = def_map.get(&id).unwrap().full_def();
13321329
match def {

branches/auto/src/librustc_save_analysis/lib.rs

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#![feature(rustc_private)]
2323
#![feature(staged_api)]
2424

25-
extern crate rustc;
25+
#[macro_use] extern crate rustc;
2626
extern crate rustc_front;
2727

2828
#[macro_use] extern crate log;
@@ -240,7 +240,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
240240
}
241241
_ => {
242242
// FIXME
243-
unimplemented!();
243+
bug!();
244244
}
245245
}
246246
}
@@ -292,21 +292,19 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
292292
result
293293
}
294294
_ => {
295-
self.tcx.sess.span_bug(span,
296-
&format!("Container {:?} for method {} not \
297-
an impl?",
298-
impl_id,
299-
id));
295+
span_bug!(span,
296+
"Container {:?} for method {} not an impl?",
297+
impl_id,
298+
id);
300299
}
301300
}
302301
}
303302
r => {
304-
self.tcx.sess.span_bug(span,
305-
&format!("Container {:?} for method {} is not a node \
306-
item {:?}",
307-
impl_id,
308-
id,
309-
r));
303+
span_bug!(span,
304+
"Container {:?} for method {} is not a node item {:?}",
305+
impl_id,
306+
id,
307+
r);
310308
}
311309
},
312310
None => match self.tcx.trait_of_item(self.tcx.map.local_def_id(id)) {
@@ -316,18 +314,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
316314
format!("::{}", self.tcx.item_path_str(def_id))
317315
}
318316
r => {
319-
self.tcx.sess.span_bug(span,
320-
&format!("Could not find container {:?} for \
321-
method {}, got {:?}",
322-
def_id,
323-
id,
324-
r));
317+
span_bug!(span,
318+
"Could not find container {:?} for \
319+
method {}, got {:?}",
320+
def_id,
321+
id,
322+
r);
325323
}
326324
}
327325
}
328326
None => {
329-
self.tcx.sess.span_bug(span,
330-
&format!("Could not find container for method {}", id));
327+
span_bug!(span, "Could not find container for method {}", id);
331328
}
332329
},
333330
};
@@ -443,16 +440,15 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
443440
}
444441
_ => {
445442
// FIXME
446-
unimplemented!();
443+
bug!();
447444
}
448445
}
449446
}
450447

451448
pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option<Data> {
452449
let def_map = self.tcx.def_map.borrow();
453450
if !def_map.contains_key(&id) {
454-
self.tcx.sess.span_bug(path.span,
455-
&format!("def_map has no key for {} in visit_expr", id));
451+
span_bug!(path.span, "def_map has no key for {} in visit_expr", id);
456452
}
457453
let def = def_map.get(&id).unwrap().full_def();
458454
let sub_span = self.span_utils.span_for_last_ident(path.span);
@@ -618,13 +614,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
618614

619615
pub fn get_data_for_id(&self, _id: &NodeId) -> Data {
620616
// FIXME
621-
unimplemented!();
617+
bug!();
622618
}
623619

624620
fn lookup_ref_id(&self, ref_id: NodeId) -> Option<DefId> {
625621
if !self.tcx.def_map.borrow().contains_key(&ref_id) {
626-
self.tcx.sess.bug(&format!("def_map has no key for {} in lookup_type_ref",
627-
ref_id));
622+
bug!("def_map has no key for {} in lookup_type_ref", ref_id);
628623
}
629624
let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def();
630625
match def {

branches/auto/src/librustc_save_analysis/span_utils.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ impl<'a> SpanUtils<'a> {
223223
}
224224
if bracket_count != 0 {
225225
let loc = self.sess.codemap().lookup_char_pos(span.lo);
226-
self.sess.span_bug(span,
227-
&format!("Mis-counted brackets when breaking path? Parsing '{}' \
228-
in {}, line {}",
229-
self.snippet(span),
230-
loc.file.name,
231-
loc.line));
226+
span_bug!(span,
227+
"Mis-counted brackets when breaking path? Parsing '{}' \
228+
in {}, line {}",
229+
self.snippet(span),
230+
loc.file.name,
231+
loc.line);
232232
}
233233
if result.is_none() && prev.tok.is_ident() && bracket_count == 0 {
234234
return self.make_sub_span(span, Some(prev.sp));
@@ -256,12 +256,12 @@ impl<'a> SpanUtils<'a> {
256256
return vec!();
257257
}
258258
let loc = self.sess.codemap().lookup_char_pos(span.lo);
259-
self.sess.span_bug(span,
260-
&format!("Mis-counted brackets when breaking path? \
261-
Parsing '{}' in {}, line {}",
262-
self.snippet(span),
263-
loc.file.name,
264-
loc.line));
259+
span_bug!(span,
260+
"Mis-counted brackets when breaking path? \
261+
Parsing '{}' in {}, line {}",
262+
self.snippet(span),
263+
loc.file.name,
264+
loc.line);
265265
}
266266
return result
267267
}
@@ -374,7 +374,7 @@ impl<'a> SpanUtils<'a> {
374374
loc.line);
375375
self.err_count.set(self.err_count.get() + 1);
376376
if self.err_count.get() > 1000 {
377-
self.sess.bug("span errors reached 1000, giving up");
377+
bug!("span errors reached 1000, giving up");
378378
}
379379
}
380380

0 commit comments

Comments
 (0)