]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_middle/src/ty/layout.rs
Rollup merge of #101995 - scottmcm:carrying-mul-example, r=Mark-Simulacrum
[rust.git] / compiler / rustc_middle / src / ty / layout.rs
index b8c4534307cc6e866a5b7fd7647ebf32c4c2c607..cc820d9eb2d9e1c366132ddc5689523ee83b2c49 100644 (file)
@@ -1,7 +1,6 @@
 use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use crate::mir::{GeneratorLayout, GeneratorSavedLocal};
 use crate::ty::normalize_erasing_regions::NormalizationError;
-use crate::ty::subst::Subst;
 use crate::ty::{
     self, layout_sanity_check::sanity_check_layout, subst::SubstsRef, EarlyBinder, ReprOptions, Ty,
     TyCtxt, TypeVisitable,
@@ -626,11 +625,11 @@ fn layout_of_uncached(&self, ty: Ty<'tcx>) -> Result<Layout<'tcx>, LayoutError<'
             }
 
             ty::Dynamic(_, _, ty::DynStar) => {
-                let mut pointer = scalar_unit(Int(dl.ptr_sized_integer(), false));
-                pointer.valid_range_mut().start = 1;
+                let mut data = scalar_unit(Int(dl.ptr_sized_integer(), false));
+                data.valid_range_mut().start = 0;
                 let mut vtable = scalar_unit(Pointer);
                 vtable.valid_range_mut().start = 1;
-                tcx.intern_layout(self.scalar_pair(pointer, vtable))
+                tcx.intern_layout(self.scalar_pair(data, vtable))
             }
 
             // Arrays and slices.
@@ -2474,8 +2473,7 @@ fn field_ty_or_layout<'tcx>(
 
                     match tcx.struct_tail_erasing_lifetimes(pointee, cx.param_env()).kind() {
                         ty::Slice(_) | ty::Str => TyMaybeWithLayout::Ty(tcx.types.usize),
-                        // FIXME(eholk): Do the right thing with trait object representation
-                        ty::Dynamic(_, _, _repr) => {
+                        ty::Dynamic(_, _, ty::Dyn) => {
                             TyMaybeWithLayout::Ty(tcx.mk_imm_ref(
                                 tcx.lifetimes.re_static,
                                 tcx.mk_array(tcx.types.usize, 3),
@@ -2769,9 +2767,14 @@ fn fn_sig_for_fn_abi(
                 // (i.e. due to being inside a projection that got normalized, see
                 // `src/test/ui/polymorphization/normalized_sig_types.rs`), and codegen not keeping
                 // track of a polymorphization `ParamEnv` to allow normalizing later.
+                //
+                // We normalize the `fn_sig` again after substituting at a later point.
                 let mut sig = match *ty.kind() {
                     ty::FnDef(def_id, substs) => tcx
-                        .normalize_erasing_regions(tcx.param_env(def_id), tcx.bound_fn_sig(def_id))
+                        .bound_fn_sig(def_id)
+                        .map_bound(|fn_sig| {
+                            tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig)
+                        })
                         .subst(tcx, substs),
                     _ => unreachable!(),
                 };
@@ -3379,7 +3382,7 @@ fn fn_abi_new_uncached(
         Ok(self.tcx.arena.alloc(fn_abi))
     }
 
-    #[tracing::instrument(level = "debug", skip(self))]
+    #[tracing::instrument(level = "trace", skip(self))]
     fn fn_abi_adjust_for_abi(
         &self,
         fn_abi: &mut FnAbi<'tcx, Ty<'tcx>>,