1
Fork 0

Rename some variants

This commit is contained in:
Michael Goulet 2022-08-29 03:53:33 +00:00 committed by Eric Holk
parent 12ec2f0e34
commit b2ed2dcaae
16 changed files with 38 additions and 56 deletions

View file

@ -4,7 +4,6 @@
use crate::ty::{self, Ty};
use rustc_macros::HashStable;
use rustc_type_ir::TraitObjectRepresentation;
/// Types that are represented as ints.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
@ -71,7 +70,7 @@ impl<'tcx> CastTy<'tcx> {
ty::Adt(d, _) if d.is_enum() && d.is_payloadfree() => Some(CastTy::Int(IntTy::CEnum)),
ty::RawPtr(mt) => Some(CastTy::Ptr(mt)),
ty::FnPtr(..) => Some(CastTy::FnPtr),
ty::Dynamic(_, _, TraitObjectRepresentation::Sized) => Some(CastTy::DynStar),
ty::Dynamic(_, _, ty::DynStar) => Some(CastTy::DynStar),
_ => None,
}
}

View file

@ -63,9 +63,7 @@ use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::{Layout, LayoutS, TargetDataLayout, VariantIdx};
use rustc_target::spec::abi;
use rustc_type_ir::sty::TyKind::*;
use rustc_type_ir::{
InternAs, InternIteratorElement, Interner, TraitObjectRepresentation, TypeFlags,
};
use rustc_type_ir::{DynKind, InternAs, InternIteratorElement, Interner, TypeFlags};
use std::any::Any;
use std::borrow::Borrow;
@ -2547,7 +2545,7 @@ impl<'tcx> TyCtxt<'tcx> {
self,
obj: &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>,
reg: ty::Region<'tcx>,
repr: TraitObjectRepresentation,
repr: DynKind,
) -> Ty<'tcx> {
self.mk_ty(Dynamic(obj, reg, repr))
}

View file

@ -21,7 +21,6 @@ use rustc_target::abi::call::{
};
use rustc_target::abi::*;
use rustc_target::spec::{abi::Abi as SpecAbi, HasTargetSpec, PanicStrategy, Target};
use rustc_type_ir::TraitObjectRepresentation;
use std::cmp::{self, Ordering};
use std::fmt;
@ -626,7 +625,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
tcx.intern_layout(self.scalar_pair(data_ptr, metadata))
}
ty::Dynamic(_, _, TraitObjectRepresentation::Sized) => {
ty::Dynamic(_, _, ty::DynStar) => {
let mut pointer = scalar_unit(Pointer);
pointer.valid_range_mut().start = 1;
let mut vtable = scalar_unit(Pointer);
@ -688,7 +687,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Odd unit types.
ty::FnDef(..) => univariant(&[], &ReprOptions::default(), StructKind::AlwaysSized)?,
ty::Dynamic(_, _, TraitObjectRepresentation::Unsized) | ty::Foreign(..) => {
ty::Dynamic(_, _, ty::Dyn) | ty::Foreign(..) => {
let mut unit = self.univariant_uninterned(
ty,
&[],
@ -2444,7 +2443,7 @@ where
| ty::FnDef(..)
| ty::GeneratorWitness(..)
| ty::Foreign(..)
| ty::Dynamic(_, _, TraitObjectRepresentation::Unsized) => {
| ty::Dynamic(_, _, ty::Dyn) => {
bug!("TyAndLayout::field({:?}): not applicable", this)
}
@ -2546,9 +2545,7 @@ where
}
// dyn* (both fields are usize-sized)
ty::Dynamic(_, _, TraitObjectRepresentation::Sized) => {
TyMaybeWithLayout::Ty(tcx.types.usize)
}
ty::Dynamic(_, _, ty::DynStar) => TyMaybeWithLayout::Ty(tcx.types.usize),
ty::Projection(_)
| ty::Bound(..)

View file

@ -58,6 +58,7 @@ use std::ops::ControlFlow;
use std::{fmt, str};
pub use crate::ty::diagnostics::*;
pub use rustc_type_ir::DynKind::*;
pub use rustc_type_ir::InferTy::*;
pub use rustc_type_ir::RegionKind::*;
pub use rustc_type_ir::TyKind::*;

View file

@ -16,7 +16,6 @@ use rustc_session::cstore::{ExternCrate, ExternCrateSource};
use rustc_span::symbol::{kw, Ident, Symbol};
use rustc_target::abi::Size;
use rustc_target::spec::abi::Abi;
use rustc_type_ir::TraitObjectRepresentation;
use std::cell::Cell;
use std::char;
@ -626,8 +625,8 @@ pub trait PrettyPrinter<'tcx>:
p!("(");
}
match repr {
TraitObjectRepresentation::Unsized => p!("dyn "),
TraitObjectRepresentation::Sized => p!("dyn* "),
ty::Dyn => p!("dyn "),
ty::DynStar => p!("dyn* "),
}
p!(print(data));
if print_r {

View file

@ -31,7 +31,7 @@ use ty::util::IntTypeExt;
use rustc_type_ir::sty::TyKind::*;
use rustc_type_ir::RegionKind as IrRegionKind;
use rustc_type_ir::{TraitObjectRepresentation, TyKind as IrTyKind};
use rustc_type_ir::TyKind as IrTyKind;
// Re-export the `TyKind` from `rustc_type_ir` here for convenience
#[rustc_diagnostic_item = "TyKind"]
@ -1852,12 +1852,12 @@ impl<'tcx> Ty<'tcx> {
#[inline]
pub fn is_trait(self) -> bool {
matches!(self.kind(), Dynamic(_, _, TraitObjectRepresentation::Unsized))
matches!(self.kind(), Dynamic(_, _, ty::Dyn))
}
#[inline]
pub fn is_dyn_star(self) -> bool {
matches!(self.kind(), Dynamic(_, _, TraitObjectRepresentation::Sized))
matches!(self.kind(), Dynamic(_, _, ty::DynStar))
}
#[inline]