use rustc_middle::mir::AssertKind;
use rustc_middle::mir::{self, SwitchTargets};
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
- use rustc_middle::ty::print::with_no_trimmed_paths;
+ use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
use rustc_span::source_map::Span;
use rustc_span::{sym, Symbol};
UninitValid => !layout.might_permit_raw_init(bx, /*zero:*/ false),
};
if do_panic {
- let msg_str = with_no_trimmed_paths(|| {
- if layout.abi.is_uninhabited() {
- // Use this error even for the other intrinsics as it is more precise.
- format!("attempted to instantiate uninhabited type `{}`", ty)
- } else if intrinsic == ZeroValid {
- format!("attempted to zero-initialize type `{}`, which is invalid", ty)
- } else {
- format!("attempted to leave type `{}` uninitialized, which is invalid", ty)
- }
+ let msg_str = with_no_visible_paths(|| {
+ with_no_trimmed_paths(|| {
+ if layout.abi.is_uninhabited() {
+ // Use this error even for the other intrinsics as it is more precise.
+ format!("attempted to instantiate uninhabited type `{}`", ty)
+ } else if intrinsic == ZeroValid {
+ format!("attempted to zero-initialize type `{}`, which is invalid", ty)
+ } else {
+ format!(
+ "attempted to leave type `{}` uninitialized, which is invalid",
+ ty
+ )
+ }
+ })
});
let msg = bx.const_str(Symbol::intern(&msg_str));
let location = self.get_caller_location(bx, source_info).immediate();
self.codegen_argument(&mut bx, op, &mut llargs, &fn_abi.args[i]);
}
- if let Some(tup) = untuple {
+ let num_untupled = untuple.map(|tup| {
self.codegen_arguments_untupled(
&mut bx,
tup,
&mut llargs,
&fn_abi.args[first_args.len()..],
)
- }
+ });
let needs_location =
instance.map_or(false, |i| i.def.requires_caller_location(self.cx.tcx()));
if needs_location {
+ let mir_args = if let Some(num_untupled) = num_untupled {
+ first_args.len() + num_untupled
+ } else {
+ args.len()
+ };
assert_eq!(
fn_abi.args.len(),
- args.len() + 1,
- "#[track_caller] fn's must have 1 more argument in their ABI than in their MIR",
+ mir_args + 1,
+ "#[track_caller] fn's must have 1 more argument in their ABI than in their MIR: {:?} {:?} {:?}",
+ instance,
+ fn_span,
+ fn_abi,
);
let location =
self.get_caller_location(&mut bx, mir::SourceInfo { span: fn_span, ..source_info });
operand: &mir::Operand<'tcx>,
llargs: &mut Vec<Bx::Value>,
args: &[ArgAbi<'tcx, Ty<'tcx>>],
- ) {
+ ) -> usize {
let tuple = self.codegen_operand(bx, operand);
// Handle both by-ref and immediate tuples.
self.codegen_argument(bx, op, llargs, &args[i]);
}
}
+ tuple.layout.fields.count()
}
fn get_caller_location(