Skip to content

Commit e0403bc

Browse files
committed
lowering: bug! -> panic!
1 parent 0f68ab0 commit e0403bc

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

src/librustc_ast_lowering/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
22

3-
use rustc::bug;
43
use rustc_ast::ast::*;
54
use rustc_ast::attr;
65
use rustc_ast::ptr::P as AstP;
@@ -757,7 +756,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
757756
Some(movability)
758757
}
759758
Some(hir::GeneratorKind::Async(_)) => {
760-
bug!("non-`async` closure body turned `async` during lowering");
759+
panic!("non-`async` closure body turned `async` during lowering");
761760
}
762761
None => {
763762
if movability == Movability::Static {

src/librustc_ast_lowering/item.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::{AnonymousLifetimeMode, LoweringContext, ParamMode};
22
use super::{ImplTraitContext, ImplTraitPosition, ImplTraitTypeIdVisitor};
33
use crate::Arena;
44

5-
use rustc::bug;
65
use rustc_ast::ast::*;
76
use rustc_ast::attr;
87
use rustc_ast::node_id::NodeMap;
@@ -432,7 +431,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
432431
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
433432
),
434433
ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
435-
bug!("`TyMac` should have been expanded by now")
434+
panic!("`TyMac` should have been expanded by now")
436435
}
437436
}
438437

@@ -784,7 +783,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
784783

785784
(generics, kind)
786785
}
787-
AssocItemKind::MacCall(..) => bug!("macro item shouldn't exist at this point"),
786+
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
788787
};
789788

790789
hir::TraitItem {
@@ -865,7 +864,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
865864
};
866865
(generics, kind)
867866
}
868-
AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"),
867+
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
869868
};
870869

871870
hir::ImplItem {

src/librustc_ast_lowering/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
use rustc::dep_graph::DepGraph;
4040
use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
41-
use rustc::{bug, span_bug};
4241
use rustc_ast::ast;
4342
use rustc_ast::ast::*;
4443
use rustc_ast::attr;
@@ -675,7 +674,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
675674
fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
676675
self.resolver.get_partial_res(id).map_or(Res::Err, |pr| {
677676
if pr.unresolved_segments() != 0 {
678-
bug!("path not fully resolved: {:?}", pr);
677+
panic!("path not fully resolved: {:?}", pr);
679678
}
680679
pr.base_res()
681680
})
@@ -1343,7 +1342,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13431342
}
13441343
}
13451344
}
1346-
TyKind::MacCall(_) => bug!("`TyKind::MacCall` should have been expanded by now"),
1345+
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
13471346
TyKind::CVarArgs => {
13481347
self.sess.delay_span_bug(
13491348
t.span,
@@ -1578,7 +1577,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15781577
hir::LifetimeName::Param(param_name) => {
15791578
(param_name, hir::LifetimeParamKind::Explicit)
15801579
}
1581-
_ => bug!("expected `LifetimeName::Param` or `ParamName::Plain`"),
1580+
_ => panic!("expected `LifetimeName::Param` or `ParamName::Plain`"),
15821581
};
15831582

15841583
self.output_lifetime_params.push(hir::GenericParam {
@@ -2099,7 +2098,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20992098
| hir::LifetimeName::Underscore
21002099
| hir::LifetimeName::Static => hir::ParamName::Plain(lt.name.ident()),
21012100
hir::LifetimeName::ImplicitObjectLifetimeDefault => {
2102-
span_bug!(
2101+
self.sess.diagnostic().span_bug(
21032102
param.ident.span,
21042103
"object-lifetime-default should not occur here",
21052104
);
@@ -2166,7 +2165,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21662165
) -> hir::TraitRef<'hir> {
21672166
let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
21682167
hir::QPath::Resolved(None, path) => path,
2169-
qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
2168+
qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
21702169
};
21712170
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
21722171
}

src/librustc_ast_lowering/path.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::{AnonymousLifetimeMode, ImplTraitContext, LoweringContext, ParamMode};
22
use super::{GenericArgsCtor, ParenthesizedGenericArgs};
33

4-
use rustc::span_bug;
54
use rustc_ast::ast::{self, *};
65
use rustc_errors::{struct_span_err, Applicability};
76
use rustc_hir as hir;
@@ -163,12 +162,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
163162
}
164163

165164
// We should've returned in the for loop above.
166-
span_bug!(
165+
166+
self.sess.diagnostic().span_bug(
167167
p.span,
168-
"lower_qpath: no final extension segment in {}..{}",
169-
proj_start,
170-
p.segments.len()
171-
)
168+
&format!(
169+
"lower_qpath: no final extension segment in {}..{}",
170+
proj_start,
171+
p.segments.len()
172+
),
173+
);
172174
}
173175

174176
crate fn lower_path_extra(

0 commit comments

Comments
 (0)