]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #89120 - In-line:remove_unneded_visible_parents_map, r=estebank
authorbors <bors@rust-lang.org>
Fri, 24 Sep 2021 05:29:49 +0000 (05:29 +0000)
committerbors <bors@rust-lang.org>
Fri, 24 Sep 2021 05:29:49 +0000 (05:29 +0000)
Disable visible path calculation for PrettyPrinter in Ok path of compiler

1  2 
compiler/rustc_codegen_ssa/src/mir/block.rs

index 5aa2a4221338ba3a87530edb861e1661246c4cf4,5ecc5917e973352eece3fffdb864cc8936625289..b0a5631549df85af3bd872d04f00fd6bac9a84b7
@@@ -15,7 -15,7 +15,7 @@@ use rustc_index::vec::Idx
  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};
@@@ -476,15 -476,20 +476,20 @@@ impl<'a, 'tcx, Bx: BuilderMethods<'a, '
                  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 });
@@@ -1130,7 -1127,7 +1135,7 @@@ impl<'a, 'tcx, Bx: BuilderMethods<'a, '
          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(