提交 a056a953 编写于 作者: M Michael Goulet

Initial fixes on top of type interner commit

上级 a7015fe8
...@@ -3676,6 +3676,7 @@ dependencies = [ ...@@ -3676,6 +3676,7 @@ dependencies = [
"rustc_span", "rustc_span",
"rustc_target", "rustc_target",
"rustc_trait_selection", "rustc_trait_selection",
"rustc_type_ir",
"tracing", "tracing",
] ]
...@@ -3969,6 +3970,7 @@ dependencies = [ ...@@ -3969,6 +3970,7 @@ dependencies = [
"rustc_span", "rustc_span",
"rustc_target", "rustc_target",
"rustc_trait_selection", "rustc_trait_selection",
"rustc_type_ir",
"tracing", "tracing",
"unicode-security", "unicode-security",
] ]
...@@ -4041,6 +4043,7 @@ dependencies = [ ...@@ -4041,6 +4043,7 @@ dependencies = [
"rustc_session", "rustc_session",
"rustc_span", "rustc_span",
"rustc_target", "rustc_target",
"rustc_type_ir",
"smallvec", "smallvec",
"snap", "snap",
"tracing", "tracing",
...@@ -4474,6 +4477,7 @@ dependencies = [ ...@@ -4474,6 +4477,7 @@ dependencies = [
"rustc_span", "rustc_span",
"rustc_target", "rustc_target",
"rustc_trait_selection", "rustc_trait_selection",
"rustc_type_ir",
"tracing", "tracing",
] ]
...@@ -4512,6 +4516,7 @@ dependencies = [ ...@@ -4512,6 +4516,7 @@ dependencies = [
"rustc_target", "rustc_target",
"rustc_trait_selection", "rustc_trait_selection",
"rustc_ty_utils", "rustc_ty_utils",
"rustc_type_ir",
"smallvec", "smallvec",
"tracing", "tracing",
] ]
......
...@@ -98,7 +98,9 @@ struct Upvar<'tcx> { ...@@ -98,7 +98,9 @@ struct Upvar<'tcx> {
by_ref: bool, by_ref: bool,
} }
const DEREF_PROJECTION: &[PlaceElem<'_>; 1] = &[ProjectionElem::Deref]; const fn deref_projection<'tcx>() -> &'tcx [PlaceElem<'tcx>; 1] {
&[ProjectionElem::Deref]
}
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers) {
*providers = Providers { *providers = Providers {
...@@ -1443,7 +1445,7 @@ fn check_for_invalidation_at_exit( ...@@ -1443,7 +1445,7 @@ fn check_for_invalidation_at_exit(
// Thread-locals might be dropped after the function exits // Thread-locals might be dropped after the function exits
// We have to dereference the outer reference because // We have to dereference the outer reference because
// borrows don't conflict behind shared references. // borrows don't conflict behind shared references.
root_place.projection = DEREF_PROJECTION; root_place.projection = deref_projection();
(true, true) (true, true)
} else { } else {
(false, self.locals_are_invalidated_at_exit) (false, self.locals_are_invalidated_at_exit)
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::subst::GenericArgKind;
use rustc_middle::ty::{self, AdtKind, Instance, ParamEnv, Ty, TyCtxt, COMMON_VTABLE_ENTRIES}; use rustc_middle::ty::{self, common_vtable_entries, AdtKind, Instance, ParamEnv, Ty, TyCtxt};
use rustc_session::config::{self, DebugInfo}; use rustc_session::config::{self, DebugInfo};
use rustc_span::symbol::Symbol; use rustc_span::symbol::Symbol;
use rustc_span::FileName; use rustc_span::FileName;
...@@ -1392,7 +1392,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>( ...@@ -1392,7 +1392,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
tcx.vtable_entries(trait_ref) tcx.vtable_entries(trait_ref)
} else { } else {
COMMON_VTABLE_ENTRIES common_vtable_entries()
}; };
// All function pointers are described as opaque pointers. This could be improved in the future // All function pointers are described as opaque pointers. This could be improved in the future
......
...@@ -24,3 +24,4 @@ rustc_session = { path = "../rustc_session" } ...@@ -24,3 +24,4 @@ rustc_session = { path = "../rustc_session" }
rustc_target = { path = "../rustc_target" } rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_span = { path = "../rustc_span" } rustc_span = { path = "../rustc_span" }
rustc_type_ir = { path = "../rustc_type_ir" }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use rustc_middle::mir::interpret::{InterpResult, Pointer, PointerArithmetic}; use rustc_middle::mir::interpret::{InterpResult, Pointer, PointerArithmetic};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, Ty, COMMON_VTABLE_ENTRIES, COMMON_VTABLE_ENTRIES_ALIGN, self, common_vtable_entries, Ty, COMMON_VTABLE_ENTRIES_ALIGN,
COMMON_VTABLE_ENTRIES_DROPINPLACE, COMMON_VTABLE_ENTRIES_SIZE, COMMON_VTABLE_ENTRIES_DROPINPLACE, COMMON_VTABLE_ENTRIES_SIZE,
}; };
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
...@@ -38,7 +38,7 @@ pub fn get_vtable( ...@@ -38,7 +38,7 @@ pub fn get_vtable(
} }
/// Resolves the function at the specified slot in the provided /// Resolves the function at the specified slot in the provided
/// vtable. Currently an index of '3' (`COMMON_VTABLE_ENTRIES.len()`) /// vtable. Currently an index of '3' (`common_vtable_entries().len()`)
/// corresponds to the first method declared in the trait of the provided vtable. /// corresponds to the first method declared in the trait of the provided vtable.
pub fn get_vtable_slot( pub fn get_vtable_slot(
&self, &self,
...@@ -64,7 +64,7 @@ pub fn read_drop_type_from_vtable( ...@@ -64,7 +64,7 @@ pub fn read_drop_type_from_vtable(
let vtable = self let vtable = self
.get_ptr_alloc( .get_ptr_alloc(
vtable, vtable,
pointer_size * u64::try_from(COMMON_VTABLE_ENTRIES.len()).unwrap(), pointer_size * u64::try_from(common_vtable_entries().len()).unwrap(),
self.tcx.data_layout.pointer_align.abi, self.tcx.data_layout.pointer_align.abi,
)? )?
.expect("cannot be a ZST"); .expect("cannot be a ZST");
...@@ -99,7 +99,7 @@ pub fn read_size_and_align_from_vtable( ...@@ -99,7 +99,7 @@ pub fn read_size_and_align_from_vtable(
let vtable = self let vtable = self
.get_ptr_alloc( .get_ptr_alloc(
vtable, vtable,
pointer_size * u64::try_from(COMMON_VTABLE_ENTRIES.len()).unwrap(), pointer_size * u64::try_from(common_vtable_entries().len()).unwrap(),
self.tcx.data_layout.pointer_align.abi, self.tcx.data_layout.pointer_align.abi,
)? )?
.expect("cannot be a ZST"); .expect("cannot be a ZST");
......
...@@ -21,3 +21,4 @@ rustc_session = { path = "../rustc_session" } ...@@ -21,3 +21,4 @@ rustc_session = { path = "../rustc_session" }
rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_parse_format = { path = "../rustc_parse_format" } rustc_parse_format = { path = "../rustc_parse_format" }
rustc_infer = { path = "../rustc_infer" } rustc_infer = { path = "../rustc_infer" }
rustc_type_ir = { path = "../rustc_type_ir" }
...@@ -27,3 +27,4 @@ rustc_ast = { path = "../rustc_ast" } ...@@ -27,3 +27,4 @@ rustc_ast = { path = "../rustc_ast" }
rustc_expand = { path = "../rustc_expand" } rustc_expand = { path = "../rustc_expand" }
rustc_span = { path = "../rustc_span" } rustc_span = { path = "../rustc_span" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }
rustc_type_ir = { path = "../rustc_type_ir" }
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
use rustc_middle::thir; use rustc_middle::thir;
use rustc_middle::ty::codec::TyDecoder; use rustc_middle::ty::codec::TyDecoder;
use rustc_middle::ty::fast_reject::SimplifiedType; use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::GeneratorDiagnosticData;
use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility}; use rustc_middle::ty::{self, ParameterizedOverTcx, Ty, TyCtxt, Visibility};
use rustc_middle::ty::{GeneratorDiagnosticData, TyInterner};
use rustc_serialize::{opaque, Decodable, Decoder}; use rustc_serialize::{opaque, Decodable, Decoder};
use rustc_session::cstore::{ use rustc_session::cstore::{
CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib, CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
...@@ -377,12 +377,13 @@ pub fn read_raw_bytes(&mut self, len: usize) -> &[u8] { ...@@ -377,12 +377,13 @@ pub fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
} }
} }
impl<'a, 'tcx> TyDecoder<'tcx> for DecodeContext<'a, 'tcx> { impl<'a, 'tcx> TyDecoder for DecodeContext<'a, 'tcx> {
const CLEAR_CROSS_CRATE: bool = true; const CLEAR_CROSS_CRATE: bool = true;
#[inline] type I = TyInterner<'tcx>;
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx.expect("missing TyCtxt in DecodeContext") fn interner(&self) -> Self::I {
TyInterner { tcx: self.tcx() }
} }
#[inline] #[inline]
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
use rustc_middle::ty::codec::TyEncoder; use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams}; use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams};
use rustc_middle::ty::query::Providers; use rustc_middle::ty::query::Providers;
use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt}; use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt, TyInterner};
use rustc_serialize::{opaque, Encodable, Encoder}; use rustc_serialize::{opaque, Encodable, Encoder};
use rustc_session::config::CrateType; use rustc_session::config::CrateType;
use rustc_session::cstore::{ForeignModule, LinkagePreference, NativeLib}; use rustc_session::cstore::{ForeignModule, LinkagePreference, NativeLib};
...@@ -313,9 +313,11 @@ fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult { ...@@ -313,9 +313,11 @@ fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
} }
} }
impl<'a, 'tcx> TyEncoder<'tcx> for EncodeContext<'a, 'tcx> { impl<'a, 'tcx> TyEncoder for EncodeContext<'a, 'tcx> {
const CLEAR_CROSS_CRATE: bool = true; const CLEAR_CROSS_CRATE: bool = true;
type I = TyInterner<'tcx>;
fn position(&self) -> usize { fn position(&self) -> usize {
self.opaque.position() self.opaque.position()
} }
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
use crate::ty::subst::SubstsRef; use crate::ty::subst::SubstsRef;
use crate::ty::{self, AdtDef, Ty}; use crate::ty::{self, AdtDef, Ty};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_serialize::{Decodable, Encodable};
use rustc_middle::ty::TyInterner; use rustc_middle::ty::TyInterner;
use rustc_serialize::{Decodable, Encodable};
use rustc_span::Span; use rustc_span::Span;
pub use rustc_type_ir::{TyDecoder, TyEncoder}; pub use rustc_type_ir::{TyDecoder, TyEncoder};
use std::hash::Hash; use std::hash::Hash;
...@@ -165,25 +165,6 @@ fn encode(&self, e: &mut E) -> Result<(), E::Error> { ...@@ -165,25 +165,6 @@ fn encode(&self, e: &mut E) -> Result<(), E::Error> {
} }
} }
macro_rules! encodable_via_deref {
($($t:ty),+) => {
$(impl<'tcx, E: TyEncoder<I = TyInterner<'tcx>>> Encodable<E> for $t {
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
(**self).encode(e)
}
})*
}
}
encodable_via_deref! {
&'tcx ty::TypeckResults<'tcx>,
&'tcx traits::ImplSource<'tcx, ()>,
&'tcx mir::Body<'tcx>,
&'tcx mir::UnsafetyCheckResult,
&'tcx mir::BorrowCheckResult<'tcx>,
&'tcx mir::coverage::CodeRegion
}
#[inline] #[inline]
fn decode_arena_allocable< fn decode_arena_allocable<
'tcx, 'tcx,
...@@ -231,7 +212,9 @@ fn decode(decoder: &mut D) -> Ty<'tcx> { ...@@ -231,7 +212,9 @@ fn decode(decoder: &mut D) -> Ty<'tcx> {
} }
} }
impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> Decodable<D> for ty::Binder<'tcx, ty::PredicateKind<'tcx>> { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> Decodable<D>
for ty::Binder<'tcx, ty::PredicateKind<'tcx>>
{
fn decode(decoder: &mut D) -> ty::Binder<'tcx, ty::PredicateKind<'tcx>> { fn decode(decoder: &mut D) -> ty::Binder<'tcx, ty::PredicateKind<'tcx>> {
let bound_vars = Decodable::decode(decoder); let bound_vars = Decodable::decode(decoder);
// Handle shorthands first, if we have a usize > 0x80. // Handle shorthands first, if we have a usize > 0x80.
...@@ -318,7 +301,10 @@ fn decode(decoder: &mut D) -> Self { ...@@ -318,7 +301,10 @@ fn decode(decoder: &mut D) -> Self {
impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize(); let len = decoder.read_usize();
decoder.interner().tcx.mk_type_list((0..len).map::<Ty<'tcx>, _>(|_| Decodable::decode(decoder))) decoder
.interner()
.tcx
.mk_type_list((0..len).map::<Ty<'tcx>, _>(|_| Decodable::decode(decoder)))
} }
} }
...@@ -359,7 +345,9 @@ fn decode(decoder: &mut D) -> Self { ...@@ -359,7 +345,9 @@ fn decode(decoder: &mut D) -> Self {
} }
} }
impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for [(ty::Predicate<'tcx>, Span)] { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D>
for [(ty::Predicate<'tcx>, Span)]
{
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
decoder.interner().tcx.arena.alloc_from_iter( decoder.interner().tcx.arena.alloc_from_iter(
(0..decoder.read_usize()).map(|_| Decodable::decode(decoder)).collect::<Vec<_>>(), (0..decoder.read_usize()).map(|_| Decodable::decode(decoder)).collect::<Vec<_>>(),
...@@ -367,7 +355,9 @@ fn decode(decoder: &mut D) -> &'tcx Self { ...@@ -367,7 +355,9 @@ fn decode(decoder: &mut D) -> &'tcx Self {
} }
} }
impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for [thir::abstract_const::Node<'tcx>] { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D>
for [thir::abstract_const::Node<'tcx>]
{
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
decoder.interner().tcx.arena.alloc_from_iter( decoder.interner().tcx.arena.alloc_from_iter(
(0..decoder.read_usize()).map(|_| Decodable::decode(decoder)).collect::<Vec<_>>(), (0..decoder.read_usize()).map(|_| Decodable::decode(decoder)).collect::<Vec<_>>(),
...@@ -375,7 +365,9 @@ fn decode(decoder: &mut D) -> &'tcx Self { ...@@ -375,7 +365,9 @@ fn decode(decoder: &mut D) -> &'tcx Self {
} }
} }
impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for [thir::abstract_const::NodeId] { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D>
for [thir::abstract_const::NodeId]
{
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
decoder.interner().tcx.arena.alloc_from_iter( decoder.interner().tcx.arena.alloc_from_iter(
(0..decoder.read_usize()).map(|_| Decodable::decode(decoder)).collect::<Vec<_>>(), (0..decoder.read_usize()).map(|_| Decodable::decode(decoder)).collect::<Vec<_>>(),
...@@ -383,7 +375,9 @@ fn decode(decoder: &mut D) -> &'tcx Self { ...@@ -383,7 +375,9 @@ fn decode(decoder: &mut D) -> &'tcx Self {
} }
} }
impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for ty::List<ty::BoundVariableKind> { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D>
for ty::List<ty::BoundVariableKind>
{
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
let len = decoder.read_usize(); let len = decoder.read_usize();
decoder.interner().tcx.mk_bound_variable_kinds( decoder.interner().tcx.mk_bound_variable_kinds(
...@@ -449,17 +443,17 @@ fn decode(decoder: &mut D) -> &'tcx Self { ...@@ -449,17 +443,17 @@ fn decode(decoder: &mut D) -> &'tcx Self {
macro_rules! impl_arena_copy_decoder { macro_rules! impl_arena_copy_decoder {
(<$tcx:tt> $($ty:ty,)*) => { (<$tcx:tt> $($ty:ty,)*) => {
$(impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for $ty { $(impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for $ty {
#[inline] #[inline]
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
decoder.tcx().arena.alloc(Decodable::decode(decoder)) decoder.interner().tcx.arena.alloc(Decodable::decode(decoder))
} }
} }
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [$ty] { impl<'tcx, D: TyDecoder<I = TyInterner<'tcx>>> RefDecodable<'tcx, D> for [$ty] {
#[inline] #[inline]
fn decode(decoder: &mut D) -> &'tcx Self { fn decode(decoder: &mut D) -> &'tcx Self {
decoder.tcx().arena.alloc_from_iter(<Vec<_> as Decodable<D>>::decode(decoder)) decoder.interner().tcx.arena.alloc_from_iter(<Vec<_> as Decodable<D>>::decode(decoder))
} }
})* })*
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
use crate::mir::interpret::{LitToConstInput, Scalar}; use crate::mir::interpret::{LitToConstInput, Scalar};
use crate::ty::{ use crate::ty::{
self, InlineConstSubsts, InlineConstSubstsParts, InternalSubsts, ParamEnv, ParamEnvAnd, Ty, self, InlineConstSubsts, InlineConstSubstsParts, InternalSubsts, ParamEnv, ParamEnvAnd, Ty,
TyCtxt, TyInterner, TypeFoldable, TyCtxt, TypeFoldable,
}; };
use rustc_data_structures::intern::Interned; use rustc_data_structures::intern::Interned;
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
...@@ -40,14 +40,6 @@ pub struct ConstS<'tcx> { ...@@ -40,14 +40,6 @@ pub struct ConstS<'tcx> {
pub val: ConstKind<'tcx>, pub val: ConstKind<'tcx>,
} }
impl<'tcx, S: rustc_type_ir::TyEncoder<I = TyInterner<'tcx>>> rustc_serialize::Encodable<S>
for &'_ Const<'_>
{
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
(*self).encode(s)
}
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(ConstS<'_>, 48); static_assert_size!(ConstS<'_>, 48);
......
...@@ -1744,7 +1744,7 @@ pub trait Lift<'tcx>: fmt::Debug { ...@@ -1744,7 +1744,7 @@ pub trait Lift<'tcx>: fmt::Debug {
impl<'a, 'tcx> Lift<'tcx> for $ty { impl<'a, 'tcx> Lift<'tcx> for $ty {
type Lifted = $lifted; type Lifted = $lifted;
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> { fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
if tcx.interners.$set.contains_pointer_to(&InternedInSet(self.0.0)) { if tcx.interners.$set.contains_pointer_to(&InternedInSet(&*self.0.0)) {
// SAFETY: `self` is interned and therefore valid // SAFETY: `self` is interned and therefore valid
// for the entire lifetime of the `TyCtxt`. // for the entire lifetime of the `TyCtxt`.
Some(unsafe { mem::transmute(self) }) Some(unsafe { mem::transmute(self) })
......
...@@ -68,8 +68,8 @@ ...@@ -68,8 +68,8 @@
pub use self::context::{ pub use self::context::{
tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, tls, CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
CtxtInterners, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData, CtxtInterners, DelaySpanBugEmitted, FreeRegionInfo, GeneratorDiagnosticData,
GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TyInterner, TypeckResults, UserType, GeneratorInteriorTypeCause, GlobalCtxt, Lift, OnDiskCache, TyCtxt, TyInterner, TypeckResults,
UserTypeAnnotationIndex, UserType, UserTypeAnnotationIndex,
}; };
pub use self::instance::{Instance, InstanceDef}; pub use self::instance::{Instance, InstanceDef};
pub use self::list::List; pub use self::list::List;
...@@ -78,13 +78,13 @@ ...@@ -78,13 +78,13 @@
pub use self::sty::BoundRegionKind::*; pub use self::sty::BoundRegionKind::*;
pub use self::sty::RegionKind::*; pub use self::sty::RegionKind::*;
pub use self::sty::{ pub use self::sty::{
Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar, BoundVariableKind, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
CanonicalPolyFnSig, ClosureSubsts, ClosureSubstsParts, ConstVid, EarlyBinder, EarlyBoundRegion, BoundVariableKind, CanonicalPolyFnSig, ClosureSubsts, ClosureSubstsParts, ConstVid,
ExistentialPredicate, ExistentialProjection, ExistentialTraitRef, FnSig, FreeRegion, GenSig, EarlyBinder, EarlyBoundRegion, ExistentialPredicate, ExistentialProjection,
GeneratorSubsts, GeneratorSubstsParts, InlineConstSubsts, InlineConstSubstsParts, ParamConst, ExistentialTraitRef, FnSig, FreeRegion, GenSig, GeneratorSubsts, GeneratorSubstsParts,
ParamTy, PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig, InlineConstSubsts, InlineConstSubstsParts, ParamConst, ParamTy, PolyExistentialProjection,
PolyTraitRef, ProjectionTy, Region, RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut, PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef, ProjectionTy, Region, RegionKind,
UpvarSubsts, VarianceDiagInfo, RegionVid, TraitRef, TyKind, TypeAndMut, UpvarSubsts, VarianceDiagInfo,
}; };
pub use self::trait_def::TraitDef; pub use self::trait_def::TraitDef;
...@@ -463,16 +463,31 @@ pub(crate) struct TyS<'tcx> { ...@@ -463,16 +463,31 @@ pub(crate) struct TyS<'tcx> {
#[rustc_pass_by_value] #[rustc_pass_by_value]
pub struct Ty<'tcx>(Interned<'tcx, WithStableHash<TyS<'tcx>>>); pub struct Ty<'tcx>(Interned<'tcx, WithStableHash<TyS<'tcx>>>);
// Statics only used for internal testing. const LEAKED_BOOL_TY_ALREADY: std::sync::atomic::AtomicBool =
pub static BOOL_TY: Ty<'static> = Ty(Interned::new_unchecked(&WithStableHash { std::sync::atomic::AtomicBool::new(false);
internee: BOOL_TYS,
stable_hash: Fingerprint::ZERO, /// "Static" bool only used for internal testing.
})); ///
const BOOL_TYS: TyS<'static> = TyS { /// FIXME(rustc_type_ir): This really should be replaced with something that doesn't leak.
/// however, since it's used for testing, it's not _that_ bad.
pub fn leak_bool_ty_for_unit_testing<'tcx>() -> Ty<'tcx> {
use std::sync::atomic::*;
if LEAKED_BOOL_TY_ALREADY.load(Ordering::Acquire) {
panic!("Can only leak one bool type, since its equality depends on its address");
} else {
LEAKED_BOOL_TY_ALREADY.store(true, Ordering::Release);
}
Ty(Interned::new_unchecked(Box::leak(Box::new(WithStableHash {
internee: TyS {
kind: ty::Bool, kind: ty::Bool,
flags: TypeFlags::empty(), flags: TypeFlags::empty(),
outer_exclusive_binder: DebruijnIndex::from_usize(0), outer_exclusive_binder: DebruijnIndex::from_usize(0),
}; },
stable_hash: Fingerprint::ZERO,
}))))
}
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> { impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
#[inline] #[inline]
......
...@@ -954,9 +954,7 @@ pub fn projection_bounds<'a>( ...@@ -954,9 +954,7 @@ pub fn projection_bounds<'a>(
} }
#[inline] #[inline]
pub fn auto_traits<'a>( pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item = DefId> + Captures<'tcx> + 'a {
&'a self,
) -> impl Iterator<Item = DefId> + rustc_data_structures::captures::Captures<'tcx> + 'a {
self.iter().filter_map(|predicate| match predicate.skip_binder() { self.iter().filter_map(|predicate| match predicate.skip_binder() {
ExistentialPredicate::AutoTrait(did) => Some(did), ExistentialPredicate::AutoTrait(did) => Some(did),
_ => None, _ => None,
......
...@@ -79,17 +79,17 @@ fn pack(self) -> GenericArg<'tcx> { ...@@ -79,17 +79,17 @@ fn pack(self) -> GenericArg<'tcx> {
let (tag, ptr) = match self { let (tag, ptr) = match self {
GenericArgKind::Lifetime(lt) => { GenericArgKind::Lifetime(lt) => {
// Ensure we can use the tag bits. // Ensure we can use the tag bits.
assert_eq!(mem::align_of_val(lt.0.0) & TAG_MASK, 0); assert_eq!(mem::align_of_val(&*lt.0.0) & TAG_MASK, 0);
(REGION_TAG, lt.0.0 as *const ty::RegionKind as usize) (REGION_TAG, lt.0.0 as *const ty::RegionKind as usize)
} }
GenericArgKind::Type(ty) => { GenericArgKind::Type(ty) => {
// Ensure we can use the tag bits. // Ensure we can use the tag bits.
assert_eq!(mem::align_of_val(ty.0.0) & TAG_MASK, 0); assert_eq!(mem::align_of_val(&*ty.0.0) & TAG_MASK, 0);
(TYPE_TAG, ty.0.0 as *const WithStableHash<ty::TyS<'tcx>> as usize) (TYPE_TAG, ty.0.0 as *const WithStableHash<ty::TyS<'tcx>> as usize)
} }
GenericArgKind::Const(ct) => { GenericArgKind::Const(ct) => {
// Ensure we can use the tag bits. // Ensure we can use the tag bits.
assert_eq!(mem::align_of_val(ct.0.0) & TAG_MASK, 0); assert_eq!(mem::align_of_val(&*ct.0.0) & TAG_MASK, 0);
(CONST_TAG, ct.0.0 as *const ty::ConstS<'tcx> as usize) (CONST_TAG, ct.0.0 as *const ty::ConstS<'tcx> as usize)
} }
}; };
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
use crate::ty::layout::IntegerExt; use crate::ty::layout::IntegerExt;
use crate::ty::query::TyCtxtAt; use crate::ty::query::TyCtxtAt;
use crate::ty::subst::{GenericArgKind, Subst, SubstsRef}; use crate::ty::subst::{GenericArgKind, Subst, SubstsRef};
use crate::ty::{ use crate::ty::{self, DefIdTree, Ty, TyCtxt, TypeFoldable};
self, Const, DebruijnIndex, DefIdTree, List, ReEarlyBound, Ty, TyCtxt, TypeFoldable,
};
use rustc_apfloat::Float as _; use rustc_apfloat::Float as _;
use rustc_ast as ast; use rustc_ast as ast;
use rustc_attr::{self as attr, SignedInt, UnsignedInt}; use rustc_attr::{self as attr, SignedInt, UnsignedInt};
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
use rustc_span::{sym, DUMMY_SP}; use rustc_span::{sym, DUMMY_SP};
use rustc_target::abi::{Integer, Size, TargetDataLayout}; use rustc_target::abi::{Integer, Size, TargetDataLayout};
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use rustc_type_ir::TyKind::*;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::{fmt, iter}; use std::{fmt, iter};
......
...@@ -36,8 +36,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -36,8 +36,9 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
} }
pub const COMMON_VTABLE_ENTRIES: &[VtblEntry<'_>] = pub const fn common_vtable_entries<'tcx>() -> &'tcx [VtblEntry<'tcx>] {
&[VtblEntry::MetadataDropInPlace, VtblEntry::MetadataSize, VtblEntry::MetadataAlign]; &[VtblEntry::MetadataDropInPlace, VtblEntry::MetadataSize, VtblEntry::MetadataAlign]
}
pub const COMMON_VTABLE_ENTRIES_DROPINPLACE: usize = 0; pub const COMMON_VTABLE_ENTRIES_DROPINPLACE: usize = 0;
pub const COMMON_VTABLE_ENTRIES_SIZE: usize = 1; pub const COMMON_VTABLE_ENTRIES_SIZE: usize = 1;
...@@ -57,7 +58,7 @@ pub(super) fn vtable_allocation_provider<'tcx>( ...@@ -57,7 +58,7 @@ pub(super) fn vtable_allocation_provider<'tcx>(
tcx.vtable_entries(trait_ref) tcx.vtable_entries(trait_ref)
} else { } else {
COMMON_VTABLE_ENTRIES common_vtable_entries()
}; };
let layout = tcx let layout = tcx
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
use rustc_index::vec::{Idx, IndexVec}; use rustc_index::vec::{Idx, IndexVec};
use rustc_middle::mir::coverage::CoverageKind; use rustc_middle::mir::coverage::CoverageKind;
use rustc_middle::mir::*; use rustc_middle::mir::*;
use rustc_middle::ty::{self, BOOL_TY}; use rustc_middle::ty::{self, Ty};
use rustc_span::{self, BytePos, Pos, Span, DUMMY_SP}; use rustc_span::{self, BytePos, Pos, Span, DUMMY_SP};
// All `TEMP_BLOCK` targets should be replaced before calling `to_body() -> mir::Body`. // All `TEMP_BLOCK` targets should be replaced before calling `to_body() -> mir::Body`.
...@@ -47,6 +47,7 @@ struct MockBlocks<'tcx> { ...@@ -47,6 +47,7 @@ struct MockBlocks<'tcx> {
blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>, blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
dummy_place: Place<'tcx>, dummy_place: Place<'tcx>,
next_local: usize, next_local: usize,
bool_ty: Ty<'tcx>,
} }
impl<'tcx> MockBlocks<'tcx> { impl<'tcx> MockBlocks<'tcx> {
...@@ -55,6 +56,7 @@ fn new() -> Self { ...@@ -55,6 +56,7 @@ fn new() -> Self {
blocks: IndexVec::new(), blocks: IndexVec::new(),
dummy_place: Place { local: RETURN_PLACE, projection: ty::List::empty() }, dummy_place: Place { local: RETURN_PLACE, projection: ty::List::empty() },
next_local: 0, next_local: 0,
bool_ty: ty::leak_bool_ty_for_unit_testing(),
} }
} }
...@@ -155,7 +157,7 @@ fn goto(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock { ...@@ -155,7 +157,7 @@ fn goto(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock {
fn switchint(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock { fn switchint(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock {
let switchint_kind = TerminatorKind::SwitchInt { let switchint_kind = TerminatorKind::SwitchInt {
discr: Operand::Move(Place::from(self.new_temp())), discr: Operand::Move(Place::from(self.new_temp())),
switch_ty: BOOL_TY, // just a dummy value switch_ty: self.bool_ty, // just a dummy value
targets: SwitchTargets::static_if(0, TEMP_BLOCK, TEMP_BLOCK), targets: SwitchTargets::static_if(0, TEMP_BLOCK, TEMP_BLOCK),
}; };
self.add_block_from(some_from_block, switchint_kind) self.add_block_from(some_from_block, switchint_kind)
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
use rustc_middle::mir::{self, interpret}; use rustc_middle::mir::{self, interpret};
use rustc_middle::thir; use rustc_middle::thir;
use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder}; use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder};
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt, TyInterner};
use rustc_query_system::dep_graph::DepContext; use rustc_query_system::dep_graph::DepContext;
use rustc_query_system::query::{QueryCache, QueryContext, QuerySideEffects}; use rustc_query_system::query::{QueryCache, QueryContext, QuerySideEffects};
use rustc_serialize::{ use rustc_serialize::{
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, VtblEntry, COMMON_VTABLE_ENTRIES, self, common_vtable_entries, GenericParamDefKind, ToPredicate, Ty, TyCtxt, VtblEntry,
}; };
use rustc_span::{sym, Span}; use rustc_span::{sym, Span};
use smallvec::SmallVec; use smallvec::SmallVec;
...@@ -695,7 +695,7 @@ fn vtable_entries<'tcx>( ...@@ -695,7 +695,7 @@ fn vtable_entries<'tcx>(
let vtable_segment_callback = |segment| -> ControlFlow<()> { let vtable_segment_callback = |segment| -> ControlFlow<()> {
match segment { match segment {
VtblSegment::MetadataDSA => { VtblSegment::MetadataDSA => {
entries.extend(COMMON_VTABLE_ENTRIES); entries.extend(common_vtable_entries());
} }
VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => { VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => {
let existential_trait_ref = trait_ref let existential_trait_ref = trait_ref
...@@ -785,7 +785,7 @@ fn vtable_trait_first_method_offset<'tcx>( ...@@ -785,7 +785,7 @@ fn vtable_trait_first_method_offset<'tcx>(
move |segment| { move |segment| {
match segment { match segment {
VtblSegment::MetadataDSA => { VtblSegment::MetadataDSA => {
vtable_base += COMMON_VTABLE_ENTRIES.len(); vtable_base += common_vtable_entries().len();
} }
VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => { VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => {
if tcx.erase_regions(trait_ref) == trait_to_be_found_erased { if tcx.erase_regions(trait_ref) == trait_to_be_found_erased {
......
...@@ -834,7 +834,7 @@ fn confirm_trait_upcasting_unsize_candidate( ...@@ -834,7 +834,7 @@ fn confirm_trait_upcasting_unsize_candidate(
move |segment| { move |segment| {
match segment { match segment {
VtblSegment::MetadataDSA => { VtblSegment::MetadataDSA => {
vptr_offset += ty::COMMON_VTABLE_ENTRIES.len(); vptr_offset += ty::common_vtable_entries().len();
} }
VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => { VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => {
vptr_offset += util::count_own_vtable_entries(tcx, trait_ref); vptr_offset += util::count_own_vtable_entries(tcx, trait_ref);
......
...@@ -14,3 +14,4 @@ rustc_span = { path = "../rustc_span" } ...@@ -14,3 +14,4 @@ rustc_span = { path = "../rustc_span" }
rustc_session = { path = "../rustc_session" } rustc_session = { path = "../rustc_session" }
rustc_target = { path = "../rustc_target" } rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_type_ir = { path = "../rustc_type_ir" }
...@@ -47,7 +47,11 @@ pub trait TyDecoder: Decoder { ...@@ -47,7 +47,11 @@ pub trait TyDecoder: Decoder {
fn position(&self) -> usize; fn position(&self) -> usize;
fn cached_ty_for_shorthand<F>(&mut self, shorthand: usize, or_insert_with: F) -> <Self::I as Interner>::Ty fn cached_ty_for_shorthand<F>(
&mut self,
shorthand: usize,
or_insert_with: F,
) -> <Self::I as Interner>::Ty
where where
F: FnOnce(&mut Self) -> <Self::I as Interner>::Ty; F: FnOnce(&mut Self) -> <Self::I as Interner>::Ty;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/// Types written by the user start out as [hir::TyKind](rustc_hir::TyKind) and get /// Types written by the user start out as [hir::TyKind](rustc_hir::TyKind) and get
/// converted to this representation using `AstConv::ast_ty_to_ty`. /// converted to this representation using `AstConv::ast_ty_to_ty`.
#[allow(rustc::usage_of_ty_tykind)] #[allow(rustc::usage_of_ty_tykind)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
//#[derive(TyEncodable, TyDecodable)] //#[derive(TyEncodable, TyDecodable)]
//#[derive(HashStable)] //#[derive(HashStable)]
#[rustc_diagnostic_item = "TyKind"] #[rustc_diagnostic_item = "TyKind"]
...@@ -186,6 +186,42 @@ pub enum TyKind<I: Interner> { ...@@ -186,6 +186,42 @@ pub enum TyKind<I: Interner> {
Error(I::DelaySpanBugEmitted), Error(I::DelaySpanBugEmitted),
} }
#[allow(rustc::usage_of_ty_tykind)]
impl<I: Interner> Clone for TyKind<I> {
fn clone(&self) -> Self {
use crate::TyKind::*;
match self {
Bool => Bool,
Char => Char,
Int(i) => Int(i.clone()),
Uint(u) => Uint(u.clone()),
Float(f) => Float(f.clone()),
Adt(d, s) => Adt(d.clone(), s.clone()),
Foreign(d) => Foreign(d.clone()),
Str => Str,
Array(t, c) => Array(t.clone(), c.clone()),
Slice(t) => Slice(t.clone()),
RawPtr(t) => RawPtr(t.clone()),
Ref(r, t, m) => Ref(r.clone(), t.clone(), m.clone()),
FnDef(d, s) => FnDef(d.clone(), s.clone()),
FnPtr(s) => FnPtr(s.clone()),
Dynamic(p, r) => Dynamic(p.clone(), r.clone()),
Closure(d, s) => Closure(d.clone(), s.clone()),
Generator(d, s, m) => Generator(d.clone(), s.clone(), m.clone()),
GeneratorWitness(g) => GeneratorWitness(g.clone()),
Never => Never,
Tuple(t) => Tuple(t.clone()),
Projection(p) => Projection(p.clone()),
Opaque(d, s) => Opaque(d.clone(), s.clone()),
Param(p) => Param(p.clone()),
Bound(d, b) => Bound(d.clone(), b.clone()),
Placeholder(p) => Placeholder(p.clone()),
Infer(t) => Infer(t.clone()),
Error(e) => Error(e.clone()),
}
}
}
#[allow(rustc::usage_of_ty_tykind)] #[allow(rustc::usage_of_ty_tykind)]
impl<I: Interner> TyKind<I> { impl<I: Interner> TyKind<I> {
#[inline] #[inline]
...@@ -383,9 +419,7 @@ fn decode(__decoder: &mut __D) -> Self { ...@@ -383,9 +419,7 @@ fn decode(__decoder: &mut __D) -> Self {
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
), ),
9 => Slice(rustc_serialize::Decodable::decode(__decoder)), 9 => Slice(rustc_serialize::Decodable::decode(__decoder)),
10 => RawPtr( 10 => RawPtr(rustc_serialize::Decodable::decode(__decoder)),
rustc_serialize::Decodable::decode(__decoder),
),
11 => Ref( 11 => Ref(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
...@@ -395,9 +429,7 @@ fn decode(__decoder: &mut __D) -> Self { ...@@ -395,9 +429,7 @@ fn decode(__decoder: &mut __D) -> Self {
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
), ),
13 => FnPtr( 13 => FnPtr(rustc_serialize::Decodable::decode(__decoder)),
rustc_serialize::Decodable::decode(__decoder),
),
14 => Dynamic( 14 => Dynamic(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
...@@ -411,38 +443,23 @@ fn decode(__decoder: &mut __D) -> Self { ...@@ -411,38 +443,23 @@ fn decode(__decoder: &mut __D) -> Self {
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
), ),
17 => GeneratorWitness( 17 => GeneratorWitness(rustc_serialize::Decodable::decode(__decoder)),
rustc_serialize::Decodable::decode(__decoder),
),
18 => Never, 18 => Never,
19 => Tuple( 19 => Tuple(rustc_serialize::Decodable::decode(__decoder)),
rustc_serialize::Decodable::decode(__decoder), 20 => Projection(rustc_serialize::Decodable::decode(__decoder)),
),
20 => Projection(
rustc_serialize::Decodable::decode(__decoder),
),
21 => Opaque( 21 => Opaque(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
), ),
22 => Param( 22 => Param(rustc_serialize::Decodable::decode(__decoder)),
rustc_serialize::Decodable::decode(__decoder),
),
23 => Bound( 23 => Bound(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(__decoder),
), ),
24 => Placeholder( 24 => Placeholder(rustc_serialize::Decodable::decode(__decoder)),
rustc_serialize::Decodable::decode(__decoder), 25 => Infer(rustc_serialize::Decodable::decode(__decoder)),
), 26 => Error(rustc_serialize::Decodable::decode(__decoder)),
25 => Infer( _ => panic!(
rustc_serialize::Decodable::decode(__decoder),
),
26 => Error(
rustc_serialize::Decodable::decode(__decoder),
),
_ =>
panic!(
"{}", "{}",
format!( format!(
"invalid enum variant tag while decoding `{}`, expected 0..{}", "invalid enum variant tag while decoding `{}`, expected 0..{}",
......
...@@ -29,3 +29,4 @@ rustc_trait_selection = { path = "../rustc_trait_selection" } ...@@ -29,3 +29,4 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" } rustc_ty_utils = { path = "../rustc_ty_utils" }
rustc_lint = { path = "../rustc_lint" } rustc_lint = { path = "../rustc_lint" }
rustc_serialize = { path = "../rustc_serialize" } rustc_serialize = { path = "../rustc_serialize" }
rustc_type_ir = { path = "../rustc_type_ir" }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::adjustment::AllowTwoPhase;
use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, AssocItem, Ty, TypeAndMut}; use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut};
use rustc_span::symbol::{sym, Symbol}; use rustc_span::symbol::{sym, Symbol};
use rustc_span::{BytePos, Span}; use rustc_span::{BytePos, Span};
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
use rustc_hir as hir; use rustc_hir as hir;
use rustc_index::vec::Idx; use rustc_index::vec::Idx;
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton}; use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
use rustc_middle::ty::{self, FloatTy, InferTy, IntTy, Ty, TyCtxt, TypeFoldable, UintTy}; use rustc_middle::ty::{self, FloatTy, InferTy, IntTy, Ty, TyCtxt, TypeFoldable, UintTy, Article};
use rustc_session::lint; use rustc_session::lint;
use rustc_span::{Span, Symbol, DUMMY_SP}; use rustc_span::{Span, Symbol, DUMMY_SP};
use rustc_target::abi::{Pointer, VariantIdx}; use rustc_target::abi::{Pointer, VariantIdx};
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
}; };
use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::fold::TypeFolder;
use rustc_middle::ty::TyKind::{Adt, Array, Char, FnDef, Never, Ref, Str, Tuple, Uint};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitor}; use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitor};
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_span::symbol::{sym, Ident}; use rustc_span::symbol::{sym, Ident};
...@@ -18,6 +17,7 @@ ...@@ -18,6 +17,7 @@
use rustc_trait_selection::infer::InferCtxtExt; use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt as _; use rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt as _;
use rustc_trait_selection::traits::{FulfillmentError, TraitEngine, TraitEngineExt}; use rustc_trait_selection::traits::{FulfillmentError, TraitEngine, TraitEngineExt};
use rustc_type_ir::sty::TyKind::*;
use std::ops::ControlFlow; use std::ops::ControlFlow;
...@@ -677,6 +677,8 @@ pub fn check_user_unop( ...@@ -677,6 +677,8 @@ pub fn check_user_unop(
operand_ty: Ty<'tcx>, operand_ty: Ty<'tcx>,
op: hir::UnOp, op: hir::UnOp,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
use rustc_type_ir::sty::TyKind::*;
assert!(op.is_by_value()); assert!(op.is_by_value());
match self.lookup_op_method(operand_ty, None, None, Op::Unary(op, ex.span)) { match self.lookup_op_method(operand_ty, None, None, Op::Unary(op, ex.span)) {
Ok(method) => { Ok(method) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册