Show the inline stack of MIR lints that only occur after inlining
This commit is contained in:
parent
4445e46518
commit
c8a866ea17
40 changed files with 378 additions and 353 deletions
|
@ -296,7 +296,7 @@ pub trait Emitter {
|
|||
|
||||
// Skip past non-macro entries, just in case there
|
||||
// are some which do actually involve macros.
|
||||
ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
|
||||
ExpnKind::Inlined | ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
|
||||
|
||||
ExpnKind::Macro(macro_kind, _) => Some(macro_kind),
|
||||
}
|
||||
|
@ -356,7 +356,9 @@ pub trait Emitter {
|
|||
continue;
|
||||
}
|
||||
|
||||
if always_backtrace {
|
||||
if matches!(trace.kind, ExpnKind::Inlined) {
|
||||
new_labels.push((trace.call_site, "in the inlined copy of this".to_string()));
|
||||
} else if always_backtrace {
|
||||
new_labels.push((
|
||||
trace.def_site,
|
||||
format!(
|
||||
|
|
|
@ -358,7 +358,9 @@ pub fn struct_lint_level<'s, 'd>(
|
|||
pub fn in_external_macro(sess: &Session, span: Span) -> bool {
|
||||
let expn_data = span.ctxt().outer_expn_data();
|
||||
match expn_data.kind {
|
||||
ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => false,
|
||||
ExpnKind::Inlined | ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => {
|
||||
false
|
||||
}
|
||||
ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external"
|
||||
ExpnKind::Macro(MacroKind::Bang, _) => {
|
||||
// Dummy span for the `def_site` means it's an external macro.
|
||||
|
|
|
@ -8,6 +8,7 @@ use rustc_middle::mir::visit::*;
|
|||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::{self, ConstKind, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
|
||||
use rustc_span::{hygiene::ExpnKind, ExpnData, Span};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use super::simplify::{remove_dead_blocks, CfgSimplifier};
|
||||
|
@ -488,6 +489,8 @@ impl Inliner<'tcx> {
|
|||
cleanup_block: cleanup,
|
||||
in_cleanup_block: false,
|
||||
tcx: self.tcx,
|
||||
callsite_span: callsite.source_info.span,
|
||||
body_span: callee_body.span,
|
||||
};
|
||||
|
||||
// Map all `Local`s, `SourceScope`s and `BasicBlock`s to new ones
|
||||
|
@ -699,6 +702,8 @@ struct Integrator<'a, 'tcx> {
|
|||
cleanup_block: Option<BasicBlock>,
|
||||
in_cleanup_block: bool,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
callsite_span: Span,
|
||||
body_span: Span,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Integrator<'a, 'tcx> {
|
||||
|
@ -743,6 +748,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
|||
*scope = self.map_scope(*scope);
|
||||
}
|
||||
|
||||
fn visit_span(&mut self, span: &mut Span) {
|
||||
// Make sure that all spans track the fact that they were inlined.
|
||||
*span = self.callsite_span.fresh_expansion(ExpnData {
|
||||
def_site: self.body_span,
|
||||
..ExpnData::default(ExpnKind::Inlined, *span, self.tcx.sess.edition(), None)
|
||||
});
|
||||
}
|
||||
|
||||
fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) {
|
||||
// If this is the `RETURN_PLACE`, we need to rebase any projections onto it.
|
||||
let dest_proj_len = self.destination.projection.len();
|
||||
|
|
|
@ -799,7 +799,9 @@ impl<'tcx> SaveContext<'tcx> {
|
|||
|
||||
// These are not macros.
|
||||
// FIXME(eddyb) maybe there is a way to handle them usefully?
|
||||
ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => return None,
|
||||
ExpnKind::Inlined | ExpnKind::Root | ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
let callee_span = self.span_from_span(callee.def_site);
|
||||
|
|
|
@ -766,6 +766,8 @@ pub enum ExpnKind {
|
|||
AstPass(AstPass),
|
||||
/// Desugaring done by the compiler during HIR lowering.
|
||||
Desugaring(DesugaringKind),
|
||||
/// MIR inlining
|
||||
Inlined,
|
||||
}
|
||||
|
||||
impl ExpnKind {
|
||||
|
@ -779,6 +781,7 @@ impl ExpnKind {
|
|||
},
|
||||
ExpnKind::AstPass(kind) => kind.descr().to_string(),
|
||||
ExpnKind::Desugaring(kind) => format!("desugaring of {}", kind.descr()),
|
||||
ExpnKind::Inlined => "inlined source".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue