Skip to content

Commit 5c202ab

Browse files
committed
---
yaml --- r: 272217 b: refs/heads/auto c: 0305537 h: refs/heads/master i: 272215: 2e91f01
1 parent 7af2e88 commit 5c202ab

File tree

9 files changed

+63
-75
lines changed

9 files changed

+63
-75
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: 8aaf6eee2fee2ffd6d8eeba1542916fcbd7c6dad
11+
refs/heads/auto: 0305537652821c86cfb073901d1ecd93378e3382
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc_metadata/astencode.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
991991
region: this.read_enum_variant_arg(1,
992992
|this| Ok(this.read_region(dcx))).unwrap()
993993
}),
994-
_ => panic!("bad enum variant for ty::UpvarCapture")
994+
_ => bug!("bad enum variant for ty::UpvarCapture")
995995
})
996996
})
997997
}).unwrap()
@@ -1013,7 +1013,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
10131013

10141014
adjustment::AdjustDerefRef(auto_deref_ref)
10151015
}
1016-
_ => panic!("bad enum variant for adjustment::AutoAdjustment")
1016+
_ => bug!("bad enum variant for adjustment::AutoAdjustment")
10171017
})
10181018
})
10191019
}).unwrap()
@@ -1072,7 +1072,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
10721072

10731073
adjustment::AutoUnsafe(m)
10741074
}
1075-
_ => panic!("bad enum variant for adjustment::AutoRef")
1075+
_ => bug!("bad enum variant for adjustment::AutoRef")
10761076
})
10771077
})
10781078
}).unwrap()
@@ -1140,9 +1140,7 @@ fn decode_side_tables(dcx: &DecodeContext,
11401140
let decoded_tag: Option<c::astencode_tag> = c::astencode_tag::from_u32(tag);
11411141
match decoded_tag {
11421142
None => {
1143-
dcx.tcx.sess.bug(
1144-
&format!("unknown tag found in side tables: {:x}",
1145-
tag));
1143+
bug!("unknown tag found in side tables: {:x}", tag);
11461144
}
11471145
Some(value) => {
11481146
let val_dsr = &mut entry_dsr;
@@ -1206,9 +1204,7 @@ fn decode_side_tables(dcx: &DecodeContext,
12061204
dcx.tcx.const_qualif_map.borrow_mut().insert(id, qualif);
12071205
}
12081206
_ => {
1209-
dcx.tcx.sess.bug(
1210-
&format!("unknown tag found in side tables: {:x}",
1211-
tag));
1207+
bug!("unknown tag found in side tables: {:x}", tag);
12121208
}
12131209
}
12141210
}
@@ -1404,6 +1400,6 @@ fn test_simplification() {
14041400
assert!(pprust::item_to_string(&item_out) ==
14051401
pprust::item_to_string(&item_exp));
14061402
}
1407-
_ => panic!()
1403+
_ => bug!()
14081404
}
14091405
}

branches/auto/src/librustc_metadata/creader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use syntax::codemap::{self, Span, mk_sp, Pos};
3636
use syntax::parse;
3737
use syntax::attr;
3838
use syntax::attr::AttrMetaMethods;
39-
use syntax::errors::FatalError;
4039
use syntax::parse::token::InternedString;
4140
use rustc_front::intravisit::Visitor;
4241
use rustc_front::hir;
@@ -527,7 +526,7 @@ impl<'a> CrateReader<'a> {
527526
load_ctxt.filesearch = self.sess.target_filesearch(PathKind::Crate);
528527
load_ctxt.load_library_crate()
529528
}
530-
None => { load_ctxt.report_load_errs(); unreachable!() },
529+
None => { load_ctxt.report_load_errs(); },
531530
};
532531

533532
let dylib = library.dylib.clone();
@@ -573,7 +572,8 @@ impl<'a> CrateReader<'a> {
573572
Ok(body) => body,
574573
Err(mut err) => {
575574
err.emit();
576-
panic!(FatalError);
575+
self.sess.abort_if_errors();
576+
unreachable!();
577577
}
578578
};
579579
let local_span = mk_sp(lo, p.last_span.hi);

branches/auto/src/librustc_metadata/decoder.rs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl crate_metadata {
7070

7171
fn lookup_item(&self, item_id: DefIndex) -> rbml::Doc {
7272
match self.get_item(item_id) {
73-
None => panic!("lookup_item: id not found: {:?}", item_id),
73+
None => bug!("lookup_item: id not found: {:?}", item_id),
7474
Some(d) => d
7575
}
7676
}
@@ -136,7 +136,7 @@ fn item_family(item: rbml::Doc) -> Family {
136136
'u' => Struct(VariantKind::Unit),
137137
'g' => PublicField,
138138
'N' => InheritedField,
139-
c => panic!("unexpected family char: {}", c)
139+
c => bug!("unexpected family char: {}", c)
140140
}
141141
}
142142

@@ -147,7 +147,7 @@ fn item_visibility(item: rbml::Doc) -> hir::Visibility {
147147
match reader::doc_as_u8(visibility_doc) as char {
148148
'y' => hir::Public,
149149
'i' => hir::Inherited,
150-
_ => panic!("unknown visibility character")
150+
_ => bug!("unknown visibility character")
151151
}
152152
}
153153
}
@@ -160,7 +160,7 @@ fn fn_constness(item: rbml::Doc) -> hir::Constness {
160160
match reader::doc_as_u8(constness_doc) as char {
161161
'c' => hir::Constness::Const,
162162
'n' => hir::Constness::NotConst,
163-
_ => panic!("unknown constness character")
163+
_ => bug!("unknown constness character")
164164
}
165165
}
166166
}
@@ -173,7 +173,7 @@ fn item_defaultness(item: rbml::Doc) -> hir::Defaultness {
173173
match reader::doc_as_u8(defaultness_doc) as char {
174174
'd' => hir::Defaultness::Default,
175175
'f' => hir::Defaultness::Final,
176-
_ => panic!("unknown defaultness character")
176+
_ => bug!("unknown defaultness character")
177177
}
178178
}
179179
}
@@ -387,16 +387,15 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
387387
item_id: DefIndex,
388388
tcx: &TyCtxt<'tcx>) -> ty::AdtDefMaster<'tcx>
389389
{
390-
fn expect_variant_kind<'tcx>(family: Family, tcx: &TyCtxt<'tcx>) -> ty::VariantKind {
390+
fn expect_variant_kind(family: Family) -> ty::VariantKind {
391391
match family_to_variant_kind(family) {
392392
Some(kind) => kind,
393-
_ => tcx.sess.bug(&format!("unexpected family: {:?}", family)),
393+
_ => bug!("unexpected family: {:?}", family),
394394
}
395395
}
396396
fn get_enum_variants<'tcx>(intr: &IdentInterner,
397397
cdata: Cmd,
398-
doc: rbml::Doc,
399-
tcx: &TyCtxt<'tcx>) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
398+
doc: rbml::Doc) -> Vec<ty::VariantDefData<'tcx, 'tcx>> {
400399
let mut disr_val = 0;
401400
reader::tagged_docs(doc, tag_items_data_item_variant).map(|p| {
402401
let did = translated_def_id(cdata, p);
@@ -411,22 +410,21 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
411410
ty::VariantDefData {
412411
did: did,
413412
name: item_name(intr, item),
414-
fields: get_variant_fields(intr, cdata, item, tcx),
413+
fields: get_variant_fields(intr, cdata, item),
415414
disr_val: ConstInt::Infer(disr),
416-
kind: expect_variant_kind(item_family(item), tcx),
415+
kind: expect_variant_kind(item_family(item)),
417416
}
418417
}).collect()
419418
}
420419
fn get_variant_fields<'tcx>(intr: &IdentInterner,
421420
cdata: Cmd,
422-
doc: rbml::Doc,
423-
tcx: &TyCtxt<'tcx>) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
421+
doc: rbml::Doc) -> Vec<ty::FieldDefData<'tcx, 'tcx>> {
424422
let mut index = 0;
425423
reader::tagged_docs(doc, tag_item_field).map(|f| {
426424
let ff = item_family(f);
427425
match ff {
428426
PublicField | InheritedField => {},
429-
_ => tcx.sess.bug(&format!("expected field, found {:?}", ff))
427+
_ => bug!("expected field, found {:?}", ff)
430428
};
431429
ty::FieldDefData::new(item_def_id(f, cdata),
432430
item_name(intr, f),
@@ -442,14 +440,13 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
442440
fn get_struct_variant<'tcx>(intr: &IdentInterner,
443441
cdata: Cmd,
444442
doc: rbml::Doc,
445-
did: DefId,
446-
tcx: &TyCtxt<'tcx>) -> ty::VariantDefData<'tcx, 'tcx> {
443+
did: DefId) -> ty::VariantDefData<'tcx, 'tcx> {
447444
ty::VariantDefData {
448445
did: did,
449446
name: item_name(intr, doc),
450-
fields: get_variant_fields(intr, cdata, doc, tcx),
447+
fields: get_variant_fields(intr, cdata, doc),
451448
disr_val: ConstInt::Infer(0),
452-
kind: expect_variant_kind(item_family(doc), tcx),
449+
kind: expect_variant_kind(item_family(doc)),
453450
}
454451
}
455452

@@ -458,18 +455,17 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
458455
let (kind, variants) = match item_family(doc) {
459456
Enum => {
460457
(ty::AdtKind::Enum,
461-
get_enum_variants(intr, cdata, doc, tcx))
458+
get_enum_variants(intr, cdata, doc))
462459
}
463460
Struct(..) => {
464461
let ctor_did =
465462
reader::maybe_get_doc(doc, tag_items_data_item_struct_ctor).
466463
map_or(did, |ctor_doc| translated_def_id(cdata, ctor_doc));
467464
(ty::AdtKind::Struct,
468-
vec![get_struct_variant(intr, cdata, doc, ctor_did, tcx)])
465+
vec![get_struct_variant(intr, cdata, doc, ctor_did)])
469466
}
470-
_ => tcx.sess.bug(
471-
&format!("get_adt_def called on a non-ADT {:?} - {:?}",
472-
item_family(doc), did))
467+
_ => bug!("get_adt_def called on a non-ADT {:?} - {:?}",
468+
item_family(doc), did)
473469
};
474470

475471
let adt = tcx.intern_adt_def(did, kind, variants);
@@ -495,7 +491,7 @@ pub fn get_adt_def<'tcx>(intr: &IdentInterner,
495491
assert!(!inputs.has_escaping_regions());
496492
inputs
497493
},
498-
_ => tcx.sess.bug("tuple-variant ctor is not an ADT")
494+
_ => bug!("tuple-variant ctor is not an ADT")
499495
};
500496
for (field, &ty) in variant.fields.iter().zip(field_tys.iter()) {
501497
field.fulfill_ty(ty);
@@ -915,7 +911,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
915911
match ch as char {
916912
'i' => hir::MutImmutable,
917913
'm' => hir::MutMutable,
918-
_ => panic!("unknown mutability character: `{}`", ch as char),
914+
_ => bug!("unknown mutability character: `{}`", ch as char),
919915
}
920916
}
921917

@@ -933,7 +929,7 @@ fn get_explicit_self(item: rbml::Doc) -> ty::ExplicitSelfCategory {
933929
ty::ReEmpty,
934930
get_mutability(string.as_bytes()[1]))
935931
}
936-
_ => panic!("unknown self type code: `{}`", explicit_self_kind as char)
932+
_ => bug!("unknown self type code: `{}`", explicit_self_kind as char)
937933
}
938934
}
939935

@@ -946,7 +942,7 @@ pub fn get_impl_items(cdata: Cmd, impl_id: DefIndex)
946942
Some('C') | Some('c') => ty::ConstTraitItemId(def_id),
947943
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
948944
Some('t') => ty::TypeTraitItemId(def_id),
949-
_ => panic!("unknown impl item sort"),
945+
_ => bug!("unknown impl item sort"),
950946
}
951947
}).collect()
952948
}
@@ -1012,9 +1008,9 @@ pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
10121008
let ity = tcx.lookup_item_type(def_id).ty;
10131009
let fty = match ity.sty {
10141010
ty::TyFnDef(_, _, fty) => fty.clone(),
1015-
_ => tcx.sess.bug(&format!(
1011+
_ => bug!(
10161012
"the type {:?} of the method {:?} is not a function?",
1017-
ity, name))
1013+
ity, name)
10181014
};
10191015
let explicit_self = get_explicit_self(item_doc);
10201016

@@ -1052,7 +1048,7 @@ pub fn get_trait_item_def_ids(cdata: Cmd, id: DefIndex)
10521048
Some('C') | Some('c') => ty::ConstTraitItemId(def_id),
10531049
Some('r') | Some('p') => ty::MethodTraitItemId(def_id),
10541050
Some('t') => ty::TypeTraitItemId(def_id),
1055-
_ => panic!("unknown trait item sort"),
1051+
_ => bug!("unknown trait item sort"),
10561052
}
10571053
}).collect()
10581054
}
@@ -1172,7 +1168,7 @@ fn struct_field_family_to_visibility(family: Family) -> hir::Visibility {
11721168
match family {
11731169
PublicField => hir::Public,
11741170
InheritedField => hir::Inherited,
1175-
_ => panic!()
1171+
_ => bug!()
11761172
}
11771173
}
11781174

@@ -1354,7 +1350,7 @@ pub fn translate_def_id(cdata: Cmd, did: DefId) -> DefId {
13541350
index: did.index,
13551351
}
13561352
}
1357-
None => panic!("didn't find a crate in the cnum_map")
1353+
None => bug!("didn't find a crate in the cnum_map")
13581354
}
13591355
}
13601356

@@ -1544,7 +1540,7 @@ pub fn get_dylib_dependency_formats(cdata: Cmd)
15441540
let cnum: ast::CrateNum = cnum.parse().unwrap();
15451541
let cnum = match cdata.cnum_map.borrow().get(&cnum) {
15461542
Some(&n) => n,
1547-
None => panic!("didn't find a crate in the cnum_map")
1543+
None => bug!("didn't find a crate in the cnum_map")
15481544
};
15491545
result.push((cnum, if link == "d" {
15501546
LinkagePreference::RequireDynamic
@@ -1772,7 +1768,7 @@ pub fn def_key(cdata: Cmd, id: DefIndex) -> hir_map::DefKey {
17721768
hir_map::DefKey::decode(&mut decoder).unwrap()
17731769
}
17741770
None => {
1775-
panic!("failed to find block with tag {:?} for item with family {:?}",
1771+
bug!("failed to find block with tag {:?} for item with family {:?}",
17761772
tag_def_key,
17771773
item_family(item_doc))
17781774
}

branches/auto/src/librustc_metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn encode_symbol(ecx: &EncodeContext,
217217
rbml_w.wr_tagged_str(tag_items_data_item_symbol, x);
218218
}
219219
None => {
220-
ecx.diag.bug(&format!("encode_symbol: id not found {}", id));
220+
bug!("encode_symbol: id not found {}", id);
221221
}
222222
}
223223
}

branches/auto/src/librustc_metadata/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extern crate flate;
3333
extern crate rbml;
3434
extern crate serialize;
3535

36+
#[macro_use]
3637
extern crate rustc;
3738
extern crate rustc_back;
3839
extern crate rustc_front;

branches/auto/src/librustc_metadata/loader.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,10 @@ impl<'a> Context<'a> {
300300
}
301301

302302
pub fn load_library_crate(&mut self) -> Library {
303-
match self.find_library_crate() {
304-
Some(t) => t,
305-
None => {
306-
self.report_load_errs();
307-
unreachable!()
308-
}
309-
}
303+
self.find_library_crate().unwrap_or_else(|| self.report_load_errs())
310304
}
311305

312-
pub fn report_load_errs(&mut self) {
306+
pub fn report_load_errs(&mut self) -> ! {
313307
let add = match self.root {
314308
&None => String::new(),
315309
&Some(ref r) => format!(" which `{}` depends on",
@@ -374,6 +368,7 @@ impl<'a> Context<'a> {
374368

375369
err.emit();
376370
self.sess.abort_if_errors();
371+
unreachable!();
377372
}
378373

379374
fn find_library_crate(&mut self) -> Option<Library> {

0 commit comments

Comments
 (0)