From 23400677d7efb82c396d37e01afc9d10698b3d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 3 Aug 2019 22:04:39 -0700 Subject: [PATCH] Simplify change to layout_of --- src/librustc/lint/context.rs | 3 --- src/librustc/ty/layout.rs | 8 +------- src/librustc_codegen_llvm/builder.rs | 4 ---- src/librustc_codegen_ssa/mir/rvalue.rs | 1 - src/librustc_mir/interpret/eval_context.rs | 5 +---- src/librustc_mir/transform/const_prop.rs | 3 --- src/librustc_passes/layout_test.rs | 4 ---- src/librustc_target/abi/mod.rs | 4 +++- 8 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 7d9653a9a55b1..de812410e8bd8 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -901,9 +901,6 @@ impl<'a, 'tcx> LayoutOf for LateContext<'a, 'tcx> { fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout { self.tcx.layout_of(self.param_env.and(ty)) } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.layout_of(ty) - } } impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> { diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 14d35fd4ce891..3b4b814c92a90 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -3,7 +3,7 @@ use crate::ty::{self, Ty, TyCtxt, TypeFoldable, ReprOptions}; use syntax::ast::{self, Ident, IntTy, UintTy}; use syntax::attr; -use syntax_pos::{DUMMY_SP, Span}; +use syntax_pos::DUMMY_SP; use std::cmp; use std::fmt; @@ -1943,9 +1943,6 @@ impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> { Ok(layout) } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.layout_of(ty) - } } impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> { @@ -1977,9 +1974,6 @@ impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> { Ok(layout) } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.layout_of(ty) - } } // Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users. diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index c01ba728034ce..894e5c2fd3d93 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -6,7 +6,6 @@ use crate::type_::Type; use crate::type_of::LayoutLlvmExt; use crate::value::Value; use syntax::symbol::LocalInternedString; -use syntax::source_map::Span; use rustc_codegen_ssa::common::{IntPredicate, TypeKind, RealPredicate}; use rustc_codegen_ssa::MemFlags; use libc::{c_uint, c_char}; @@ -91,9 +90,6 @@ impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> { fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout { self.cx.layout_of(ty) } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.cx.layout_of(ty) - } } impl Deref for Builder<'_, 'll, 'tcx> { diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 56c76cdc026f7..4df45d1586086 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -713,7 +713,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let ty = rvalue.ty(self.mir, self.cx.tcx()); let ty = self.monomorphize(&ty); self.cx.spanned_layout_of(ty, span).is_zst() - // self.cx.layout_of(ty).is_zst() } } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 605afa7b36810..1f23d8c017ccd 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -193,9 +193,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> { .layout_of(self.param_env.and(ty)) .map_err(|layout| err_inval!(Layout(layout)).into()) } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.layout_of(ty) - } } impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { @@ -509,7 +506,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { pub fn push_stack_frame( &mut self, instance: ty::Instance<'tcx>, - span: source_map::Span, + span: Span, body: &'mir mir::Body<'tcx>, return_place: Option>, return_to_block: StackPopCleanup, diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 18b6f408fe12c..a450ec32e1a47 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -134,9 +134,6 @@ impl<'mir, 'tcx> LayoutOf for ConstPropagator<'mir, 'tcx> { fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout { self.tcx.layout_of(self.param_env.and(ty)) } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.layout_of(ty) - } } impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> { diff --git a/src/librustc_passes/layout_test.rs b/src/librustc_passes/layout_test.rs index 8c4635f3566ca..95cb8de70675d 100644 --- a/src/librustc_passes/layout_test.rs +++ b/src/librustc_passes/layout_test.rs @@ -13,7 +13,6 @@ use rustc::ty::Ty; use rustc::ty::TyCtxt; use syntax::ast::Attribute; use syntax::symbol::sym; -use syntax::source_map::Span; pub fn test_layout(tcx: TyCtxt<'_>) { if tcx.features().rustc_attrs { @@ -117,9 +116,6 @@ impl LayoutOf for UnwrapLayoutCx<'tcx> { fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout { self.tcx.layout_of(self.param_env.and(ty)).unwrap() } - fn spanned_layout_of(&self, ty: Ty<'tcx>, _: Option) -> Self::TyLayout { - self.layout_of(ty) - } } impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> { diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index c4f38f4a7f4c3..4f53c7795c2be 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -1013,7 +1013,9 @@ pub trait LayoutOf { type TyLayout; fn layout_of(&self, ty: Self::Ty) -> Self::TyLayout; - fn spanned_layout_of(&self, ty: Self::Ty, span: Option) -> Self::TyLayout; + fn spanned_layout_of(&self, ty: Self::Ty, _span: Option) -> Self::TyLayout { + self.layout_of(ty) + } } #[derive(Copy, Clone, PartialEq, Eq)]