use rustc_middle::traits::ObligationCause;
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_span::{hygiene::ExpnKind, ExpnData, LocalExpnId, Span};
use rustc_target::spec::abi::Abi;
use super::simplify::{remove_dead_blocks, CfgSimplifier};
continue;
}
- let callsite = match self.resolve_callsite(caller_body, bb, bb_data) {
- None => continue,
- Some(it) => it,
+ let Some(callsite) = self.resolve_callsite(caller_body, bb, bb_data) else {
+ continue;
};
let span = trace_span!("process_blocks", %callsite.callee, ?bb);
// Copy the arguments if needed.
let args: Vec<_> = self.make_call_args(args, &callsite, caller_body, &callee_body);
+ let mut expn_data = ExpnData::default(
+ ExpnKind::Inlined,
+ callsite.source_info.span,
+ self.tcx.sess.edition(),
+ None,
+ None,
+ );
+ expn_data.def_site = callee_body.span;
+ let expn_data =
+ LocalExpnId::fresh(expn_data, self.tcx.create_stable_hashing_context());
let mut integrator = Integrator {
args: &args,
new_locals: Local::new(caller_body.local_decls.len())..,
cleanup_block: cleanup,
in_cleanup_block: false,
tcx: self.tcx,
- callsite_span: callsite.source_info.span,
- body_span: callee_body.span,
+ expn_data,
always_live_locals: BitSet::new_filled(callee_body.local_decls.len()),
};
// The `tmp0`, `tmp1`, and `tmp2` in our example abonve.
let tuple_tmp_args = tuple_tys.iter().enumerate().map(|(i, ty)| {
// This is e.g., `tuple_tmp.0` in our example above.
- let tuple_field =
- Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty.expect_ty()));
+ let tuple_field = Operand::Move(tcx.mk_place_field(tuple, Field::new(i), ty));
// Spill to a local to make e.g., `tmp0`.
self.create_temp_if_necessary(tuple_field, callsite, caller_body)
caller_body: &mut Body<'tcx>,
) -> Local {
// Reuse the operand if it is a moved temporary.
- if let Operand::Move(place) = &arg {
- if let Some(local) = place.as_local() {
- if caller_body.local_kind(local) == LocalKind::Temp {
- return local;
- }
- }
+ if let Operand::Move(place) = &arg
+ && let Some(local) = place.as_local()
+ && caller_body.local_kind(local) == LocalKind::Temp
+ {
+ return local;
}
// Otherwise, create a temporary for the argument.
cleanup_block: Option<BasicBlock>,
in_cleanup_block: bool,
tcx: TyCtxt<'tcx>,
- callsite_span: Span,
- body_span: Span,
+ expn_data: LocalExpnId,
always_live_locals: BitSet<Local>,
}
}
fn visit_span(&mut self, span: &mut Span) {
- let mut expn_data =
- ExpnData::default(ExpnKind::Inlined, *span, self.tcx.sess.edition(), None, None);
- expn_data.def_site = self.body_span;
// Make sure that all spans track the fact that they were inlined.
- *span =
- self.callsite_span.fresh_expansion(expn_data, self.tcx.create_stable_hashing_context());
+ *span = span.fresh_expansion(self.expn_data);
}
fn visit_place(&mut self, place: &mut Place<'tcx>, context: PlaceContext, location: Location) {