Simplify change to layout_of

This commit is contained in:
Esteban Küber 2019-08-03 22:04:39 -07:00
parent db099fb491
commit 23400677d7
8 changed files with 5 additions and 27 deletions

View file

@ -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<Span>) -> Self::TyLayout {
self.layout_of(ty)
}
}
impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> {

View file

@ -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<Span>) -> 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<Span>) -> Self::TyLayout {
self.layout_of(ty)
}
}
// Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users.

View file

@ -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<Span>) -> Self::TyLayout {
self.cx.layout_of(ty)
}
}
impl Deref for Builder<'_, 'll, 'tcx> {

View file

@ -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()
}
}

View file

@ -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<Span>) -> 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<PlaceTy<'tcx, M::PointerTag>>,
return_to_block: StackPopCleanup,

View file

@ -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<Span>) -> Self::TyLayout {
self.layout_of(ty)
}
}
impl<'mir, 'tcx> HasDataLayout for ConstPropagator<'mir, 'tcx> {

View file

@ -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<Span>) -> Self::TyLayout {
self.layout_of(ty)
}
}
impl HasTyCtxt<'tcx> for UnwrapLayoutCx<'tcx> {

View file

@ -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<Span>) -> Self::TyLayout;
fn spanned_layout_of(&self, ty: Self::Ty, _span: Option<Span>) -> Self::TyLayout {
self.layout_of(ty)
}
}
#[derive(Copy, Clone, PartialEq, Eq)]