lowering: bug! -> panic!

This commit is contained in:
Mazdak Farrokhzad 2020-03-21 02:38:48 +01:00
parent 0f68ab03c3
commit e0403bcde3
4 changed files with 17 additions and 18 deletions

View File

@ -1,6 +1,5 @@
use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
use rustc::bug;
use rustc_ast::ast::*;
use rustc_ast::attr;
use rustc_ast::ptr::P as AstP;
@ -757,7 +756,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
Some(movability)
}
Some(hir::GeneratorKind::Async(_)) => {
bug!("non-`async` closure body turned `async` during lowering");
panic!("non-`async` closure body turned `async` during lowering");
}
None => {
if movability == Movability::Static {

View File

@ -2,7 +2,6 @@ use super::{AnonymousLifetimeMode, LoweringContext, ParamMode};
use super::{ImplTraitContext, ImplTraitPosition, ImplTraitTypeIdVisitor};
use crate::Arena;
use rustc::bug;
use rustc_ast::ast::*;
use rustc_ast::attr;
use rustc_ast::node_id::NodeMap;
@ -432,7 +431,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
),
ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
bug!("`TyMac` should have been expanded by now")
panic!("`TyMac` should have been expanded by now")
}
}
@ -784,7 +783,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(generics, kind)
}
AssocItemKind::MacCall(..) => bug!("macro item shouldn't exist at this point"),
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
};
hir::TraitItem {
@ -865,7 +864,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
};
(generics, kind)
}
AssocItemKind::MacCall(..) => bug!("`TyMac` should have been expanded by now"),
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
};
hir::ImplItem {

View File

@ -38,7 +38,6 @@
use rustc::dep_graph::DepGraph;
use rustc::hir::map::definitions::{DefKey, DefPathData, Definitions};
use rustc::{bug, span_bug};
use rustc_ast::ast;
use rustc_ast::ast::*;
use rustc_ast::attr;
@ -675,7 +674,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
self.resolver.get_partial_res(id).map_or(Res::Err, |pr| {
if pr.unresolved_segments() != 0 {
bug!("path not fully resolved: {:?}", pr);
panic!("path not fully resolved: {:?}", pr);
}
pr.base_res()
})
@ -1343,7 +1342,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
}
}
TyKind::MacCall(_) => bug!("`TyKind::MacCall` should have been expanded by now"),
TyKind::MacCall(_) => panic!("`TyKind::MacCall` should have been expanded by now"),
TyKind::CVarArgs => {
self.sess.delay_span_bug(
t.span,
@ -1578,7 +1577,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::LifetimeName::Param(param_name) => {
(param_name, hir::LifetimeParamKind::Explicit)
}
_ => bug!("expected `LifetimeName::Param` or `ParamName::Plain`"),
_ => panic!("expected `LifetimeName::Param` or `ParamName::Plain`"),
};
self.output_lifetime_params.push(hir::GenericParam {
@ -2099,7 +2098,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
| hir::LifetimeName::Underscore
| hir::LifetimeName::Static => hir::ParamName::Plain(lt.name.ident()),
hir::LifetimeName::ImplicitObjectLifetimeDefault => {
span_bug!(
self.sess.diagnostic().span_bug(
param.ident.span,
"object-lifetime-default should not occur here",
);
@ -2166,7 +2165,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
) -> hir::TraitRef<'hir> {
let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
hir::QPath::Resolved(None, path) => path,
qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
};
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
}

View File

@ -1,7 +1,6 @@
use super::{AnonymousLifetimeMode, ImplTraitContext, LoweringContext, ParamMode};
use super::{GenericArgsCtor, ParenthesizedGenericArgs};
use rustc::span_bug;
use rustc_ast::ast::{self, *};
use rustc_errors::{struct_span_err, Applicability};
use rustc_hir as hir;
@ -163,12 +162,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
// We should've returned in the for loop above.
span_bug!(
self.sess.diagnostic().span_bug(
p.span,
"lower_qpath: no final extension segment in {}..{}",
proj_start,
p.segments.len()
)
&format!(
"lower_qpath: no final extension segment in {}..{}",
proj_start,
p.segments.len()
),
);
}
crate fn lower_path_extra(