1
Fork 0

Fix TyKind lint, make consts no longer fn, etc

This commit is contained in:
Michael Goulet 2022-05-26 20:22:28 -07:00
parent a056a953f0
commit 34e05812e0
17 changed files with 868 additions and 538 deletions

View file

@ -98,8 +98,10 @@ struct Upvar<'tcx> {
by_ref: bool, by_ref: bool,
} }
const fn deref_projection<'tcx>() -> &'tcx [PlaceElem<'tcx>; 1] { /// Associate some local constants with the `'tcx` lifetime
&[ProjectionElem::Deref] struct TyCtxtConsts<'tcx>(TyCtxt<'tcx>);
impl<'tcx> TyCtxtConsts<'tcx> {
const DEREF_PROJECTION: &'tcx [PlaceElem<'tcx>; 1] = &[ProjectionElem::Deref];
} }
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers) {
@ -1445,7 +1447,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// 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 = TyCtxtConsts::DEREF_PROJECTION;
(true, true) (true, true)
} else { } else {
(false, self.locals_are_invalidated_at_exit) (false, self.locals_are_invalidated_at_exit)

View file

@ -33,7 +33,7 @@ use rustc_middle::mir::{self, GeneratorLayout};
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, common_vtable_entries, AdtKind, Instance, ParamEnv, Ty, TyCtxt}; use rustc_middle::ty::{self, 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>(
tcx.vtable_entries(trait_ref) tcx.vtable_entries(trait_ref)
} else { } else {
common_vtable_entries() TyCtxt::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

View file

@ -2,8 +2,8 @@ use std::convert::TryFrom;
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, common_vtable_entries, Ty, COMMON_VTABLE_ENTRIES_ALIGN, self, Ty, TyCtxt, COMMON_VTABLE_ENTRIES_ALIGN, COMMON_VTABLE_ENTRIES_DROPINPLACE,
COMMON_VTABLE_ENTRIES_DROPINPLACE, COMMON_VTABLE_ENTRIES_SIZE, COMMON_VTABLE_ENTRIES_SIZE,
}; };
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
@ -38,7 +38,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
} }
/// 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' (`TyCtxt::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 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
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(TyCtxt::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 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
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(TyCtxt::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");

View file

@ -5,8 +5,8 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}
use rustc_ast as ast; use rustc_ast as ast;
use rustc_errors::Applicability; use rustc_errors::Applicability;
use rustc_hir::def::Res; use rustc_hir::def::Res;
use rustc_hir::{Expr, ExprKind, GenericArg, Path, PathSegment, QPath}; use rustc_hir::{Expr, ExprKind, GenericArg, PatKind, Path, PathSegment, QPath};
use rustc_hir::{HirId, Item, ItemKind, Node, Ty, TyKind}; use rustc_hir::{HirId, Item, ItemKind, Node, Pat, Ty, TyKind};
use rustc_middle::ty; use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::hygiene::{ExpnKind, MacroKind}; use rustc_span::hygiene::{ExpnKind, MacroKind};
@ -123,55 +123,115 @@ declare_lint_pass!(TyTyKind => [
]); ]);
impl<'tcx> LateLintPass<'tcx> for TyTyKind { impl<'tcx> LateLintPass<'tcx> for TyTyKind {
fn check_path(&mut self, cx: &LateContext<'_>, path: &'tcx Path<'tcx>, _: HirId) { fn check_path(
let segments = path.segments.iter().rev().skip(1).rev(); &mut self,
cx: &LateContext<'tcx>,
if let Some(last) = segments.last() { path: &'tcx rustc_hir::Path<'tcx>,
let span = path.span.with_hi(last.ident.span.hi()); _: rustc_hir::HirId,
if lint_ty_kind_usage(cx, last) { ) {
cx.struct_span_lint(USAGE_OF_TY_TYKIND, span, |lint| { if let Some(segment) = path.segments.iter().nth_back(1)
lint.build("usage of `ty::TyKind::<kind>`") && let Some(res) = &segment.res
.span_suggestion( && lint_ty_kind_usage(cx, res)
span, {
"try using ty::<kind> directly", let span = path.span.with_hi(
"ty".to_string(), segment.args.map_or(segment.ident.span, |a| a.span_ext).hi()
Applicability::MaybeIncorrect, // ty maybe needs an import );
) cx.struct_span_lint(USAGE_OF_TY_TYKIND, path.span, |lint| {
.emit(); lint.build("usage of `ty::TyKind::<kind>`")
}) .span_suggestion(
} span,
"try using `ty::<kind>` directly",
"ty".to_string(),
Applicability::MaybeIncorrect, // ty maybe needs an import
)
.emit();
});
} }
} }
fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx Ty<'tcx>) { fn check_ty(&mut self, cx: &LateContext<'_>, ty: &'tcx Ty<'tcx>) {
match &ty.kind { match &ty.kind {
TyKind::Path(QPath::Resolved(_, path)) => { TyKind::Path(QPath::Resolved(_, path)) => {
if let Some(last) = path.segments.iter().last() { if lint_ty_kind_usage(cx, &path.res) {
if lint_ty_kind_usage(cx, last) { cx.struct_span_lint(USAGE_OF_TY_TYKIND, path.span, |lint| {
cx.struct_span_lint(USAGE_OF_TY_TYKIND, path.span, |lint| { let hir = cx.tcx.hir();
lint.build("usage of `ty::TyKind`") match hir.find(hir.get_parent_node(ty.hir_id)) {
.help("try using `Ty` instead") Some(Node::Pat(Pat {
.emit(); kind:
}) PatKind::Path(qpath)
} else { | PatKind::TupleStruct(qpath, ..)
if ty.span.from_expansion() { | PatKind::Struct(qpath, ..),
return; ..
} })) => {
if let Some(t) = is_ty_or_ty_ctxt(cx, ty) { if let QPath::TypeRelative(qpath_ty, ..) = qpath
if path.segments.len() > 1 { && qpath_ty.hir_id == ty.hir_id
cx.struct_span_lint(USAGE_OF_QUALIFIED_TY, path.span, |lint| { {
lint.build(&format!("usage of qualified `ty::{}`", t)) lint.build("usage of `ty::TyKind::<kind>`")
.span_suggestion( .span_suggestion(
path.span, path.span,
"try importing it and using it unqualified", "try using `ty::<kind>` directly",
t, "ty".to_string(),
// The import probably needs to be changed Applicability::MaybeIncorrect, // ty maybe needs an import
Applicability::MaybeIncorrect,
) )
.emit(); .emit();
}) return;
}
} }
Some(Node::Expr(Expr {
kind: ExprKind::Path(qpath),
..
})) => {
if let QPath::TypeRelative(qpath_ty, ..) = qpath
&& qpath_ty.hir_id == ty.hir_id
{
lint.build("usage of `ty::TyKind::<kind>`")
.span_suggestion(
path.span,
"try using `ty::<kind>` directly",
"ty".to_string(),
Applicability::MaybeIncorrect, // ty maybe needs an import
)
.emit();
return;
}
}
// Can't unify these two branches because qpath below is `&&` and above is `&`
// and `A | B` paths don't play well together with adjustments, apparently.
Some(Node::Expr(Expr {
kind: ExprKind::Struct(qpath, ..),
..
})) => {
if let QPath::TypeRelative(qpath_ty, ..) = qpath
&& qpath_ty.hir_id == ty.hir_id
{
lint.build("usage of `ty::TyKind::<kind>`")
.span_suggestion(
path.span,
"try using `ty::<kind>` directly",
"ty".to_string(),
Applicability::MaybeIncorrect, // ty maybe needs an import
)
.emit();
return;
}
}
_ => {}
} }
lint.build("usage of `ty::TyKind`").help("try using `Ty` instead").emit();
})
} else if !ty.span.from_expansion() && let Some(t) = is_ty_or_ty_ctxt(cx, &path) {
if path.segments.len() > 1 {
cx.struct_span_lint(USAGE_OF_QUALIFIED_TY, path.span, |lint| {
lint.build(&format!("usage of qualified `ty::{}`", t))
.span_suggestion(
path.span,
"try importing it and using it unqualified",
t,
// The import probably needs to be changed
Applicability::MaybeIncorrect,
)
.emit();
})
} }
} }
} }
@ -180,42 +240,37 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
} }
} }
fn lint_ty_kind_usage(cx: &LateContext<'_>, segment: &PathSegment<'_>) -> bool { fn lint_ty_kind_usage(cx: &LateContext<'_>, res: &Res) -> bool {
if let Some(res) = segment.res { if let Some(did) = res.opt_def_id() {
if let Some(did) = res.opt_def_id() { cx.tcx.is_diagnostic_item(sym::TyKind, did) || cx.tcx.is_diagnostic_item(sym::IrTyKind, did)
return cx.tcx.is_diagnostic_item(sym::TyKind, did); } else {
} false
} }
false
} }
fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, ty: &Ty<'_>) -> Option<String> { fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, path: &Path<'_>) -> Option<String> {
if let TyKind::Path(QPath::Resolved(_, path)) = &ty.kind { match &path.res {
match path.res { Res::Def(_, def_id) => {
Res::Def(_, def_id) => { if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(*def_id) {
if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(def_id) { return Some(format!("{}{}", name, gen_args(path.segments.last().unwrap())));
return Some(format!("{}{}", name, gen_args(path.segments.last().unwrap())));
}
} }
// Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait.
Res::SelfTy { trait_: None, alias_to: Some((did, _)) } => {
if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() {
if let Some(name @ (sym::Ty | sym::TyCtxt)) =
cx.tcx.get_diagnostic_name(adt.did())
{
// NOTE: This path is currently unreachable as `Ty<'tcx>` is
// defined as a type alias meaning that `impl<'tcx> Ty<'tcx>`
// is not actually allowed.
//
// I(@lcnr) still kept this branch in so we don't miss this
// if we ever change it in the future.
return Some(format!("{}<{}>", name, substs[0]));
}
}
}
_ => (),
} }
// Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait.
Res::SelfTy { trait_: None, alias_to: Some((did, _)) } => {
if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() {
if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(adt.did())
{
// NOTE: This path is currently unreachable as `Ty<'tcx>` is
// defined as a type alias meaning that `impl<'tcx> Ty<'tcx>`
// is not actually allowed.
//
// I(@lcnr) still kept this branch in so we don't miss this
// if we ever change it in the future.
return Some(format!("{}<{}>", name, substs[0]));
}
}
}
_ => (),
} }
None None

View file

@ -94,6 +94,7 @@ pub struct TyInterner<'tcx> {
pub tcx: TyCtxt<'tcx>, pub tcx: TyCtxt<'tcx>,
} }
/*
/// We don't ever actually need this. It's only required for derives. /// We don't ever actually need this. It's only required for derives.
impl<'tcx> Hash for TyInterner<'tcx> { impl<'tcx> Hash for TyInterner<'tcx> {
fn hash<H: Hasher>(&self, _state: &mut H) {} fn hash<H: Hasher>(&self, _state: &mut H) {}
@ -128,6 +129,7 @@ impl fmt::Debug for TyInterner<'_> {
write!(f, "TyInterner") write!(f, "TyInterner")
} }
} }
*/
#[allow(rustc::usage_of_ty_tykind)] #[allow(rustc::usage_of_ty_tykind)]
impl<'tcx> Interner for TyInterner<'tcx> { impl<'tcx> Interner for TyInterner<'tcx> {

View file

@ -207,10 +207,10 @@ pub struct DeepRejectCtxt {
} }
impl DeepRejectCtxt { impl DeepRejectCtxt {
pub fn generic_args_may_unify( pub fn generic_args_may_unify<'tcx>(
self, self,
obligation_arg: ty::GenericArg<'_>, obligation_arg: ty::GenericArg<'tcx>,
impl_arg: ty::GenericArg<'_>, impl_arg: ty::GenericArg<'tcx>,
) -> bool { ) -> bool {
match (obligation_arg.unpack(), impl_arg.unpack()) { match (obligation_arg.unpack(), impl_arg.unpack()) {
// We don't fast reject based on regions for now. // We don't fast reject based on regions for now.
@ -225,7 +225,7 @@ impl DeepRejectCtxt {
} }
} }
pub fn types_may_unify(self, obligation_ty: Ty<'_>, impl_ty: Ty<'_>) -> bool { pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -> bool {
match impl_ty.kind() { match impl_ty.kind() {
// Start by checking whether the type in the impl may unify with // Start by checking whether the type in the impl may unify with
// pretty much everything. Just return `true` in that case. // pretty much everything. Just return `true` in that case.

View file

@ -449,13 +449,13 @@ pub(crate) struct TyS<'tcx> {
} }
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger. // `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
//#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//static_assert_size!(TyS<'_>, 40); static_assert_size!(TyS<'_>, 40);
// We are actually storing a stable hash cache next to the type, so let's // We are actually storing a stable hash cache next to the type, so let's
// also check the full size // also check the full size
//#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
//static_assert_size!(WithStableHash<TyS<'_>>, 56); static_assert_size!(WithStableHash<TyS<'_>>, 56);
/// Use this rather than `TyS`, whenever possible. /// Use this rather than `TyS`, whenever possible.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]

View file

@ -27,9 +27,12 @@ use std::marker::PhantomData;
use std::ops::{ControlFlow, Deref, Range}; use std::ops::{ControlFlow, Deref, Range};
use ty::util::IntTypeExt; use ty::util::IntTypeExt;
use rustc_type_ir::TyKind as IrTyKind;
pub type TyKind<'tcx> = IrTyKind<ty::TyInterner<'tcx>>;
use rustc_type_ir::sty::TyKind::*; use rustc_type_ir::sty::TyKind::*;
use rustc_type_ir::TyKind as IrTyKind;
// Re-export the `TyKind` from `rustc_type_ir` here for convenience
#[rustc_diagnostic_item = "TyKind"]
pub type TyKind<'tcx> = IrTyKind<ty::TyInterner<'tcx>>;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, TyEncodable, TyDecodable)]
#[derive(HashStable, TypeFoldable, Lift)] #[derive(HashStable, TypeFoldable, Lift)]
@ -80,205 +83,6 @@ impl BoundRegionKind {
} }
} }
/*
/// Defines the kinds of types used by the type system.
///
/// 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`.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable, Debug)]
#[derive(HashStable)]
#[rustc_diagnostic_item = "TyKind"]
pub enum TyKind<'tcx> {
/// The primitive boolean type. Written as `bool`.
Bool,
/// The primitive character type; holds a Unicode scalar value
/// (a non-surrogate code point). Written as `char`.
Char,
/// A primitive signed integer type. For example, `i32`.
Int(ty::IntTy),
/// A primitive unsigned integer type. For example, `u32`.
Uint(ty::UintTy),
/// A primitive floating-point type. For example, `f64`.
Float(ty::FloatTy),
/// Algebraic data types (ADT). For example: structures, enumerations and unions.
///
/// For example, the type `List<i32>` would be represented using the `AdtDef`
/// for `struct List<T>` and the substs `[i32]`.
///
/// Note that generic parameters in fields only get lazily substituted
/// by using something like `adt_def.all_fields().map(|field| field.ty(tcx, substs))`.
Adt(AdtDef<'tcx>, SubstsRef<'tcx>),
/// An unsized FFI type that is opaque to Rust. Written as `extern type T`.
Foreign(DefId),
/// The pointee of a string slice. Written as `str`.
Str,
/// An array with the given length. Written as `[T; N]`.
Array(Ty<'tcx>, ty::Const<'tcx>),
/// The pointee of an array slice. Written as `[T]`.
Slice(Ty<'tcx>),
/// A raw pointer. Written as `*mut T` or `*const T`
RawPtr(TypeAndMut<'tcx>),
/// A reference; a pointer with an associated lifetime. Written as
/// `&'a mut T` or `&'a T`.
Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability),
/// The anonymous type of a function declaration/definition. Each
/// function has a unique type.
///
/// For the function `fn foo() -> i32 { 3 }` this type would be
/// shown to the user as `fn() -> i32 {foo}`.
///
/// For example the type of `bar` here:
/// ```rust
/// fn foo() -> i32 { 1 }
/// let bar = foo; // bar: fn() -> i32 {foo}
/// ```
FnDef(DefId, SubstsRef<'tcx>),
/// A pointer to a function. Written as `fn() -> i32`.
///
/// Note that both functions and closures start out as either
/// [FnDef] or [Closure] which can be then be coerced to this variant.
///
/// For example the type of `bar` here:
///
/// ```rust
/// fn foo() -> i32 { 1 }
/// let bar: fn() -> i32 = foo;
/// ```
FnPtr(PolyFnSig<'tcx>),
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
/// The anonymous type of a closure. Used to represent the type of `|a| a`.
///
/// Closure substs contain both the - potentially substituted - generic parameters
/// of its parent and some synthetic parameters. See the documentation for
/// [ClosureSubsts] for more details.
Closure(DefId, SubstsRef<'tcx>),
/// The anonymous type of a generator. Used to represent the type of
/// `|a| yield a`.
///
/// For more info about generator substs, visit the documentation for
/// [GeneratorSubsts].
Generator(DefId, SubstsRef<'tcx>, hir::Movability),
/// A type representing the types stored inside a generator.
/// This should only appear as part of the [GeneratorSubsts].
///
/// Note that the captured variables for generators are stored separately
/// using a tuple in the same way as for closures.
///
/// Unlike upvars, the witness can reference lifetimes from
/// inside of the generator itself. To deal with them in
/// the type of the generator, we convert them to higher ranked
/// lifetimes bound by the witness itself.
///
/// Looking at the following example, the witness for this generator
/// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
///
/// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
/// #![feature(generators)]
/// |a| {
/// let x = &vec![3];
/// yield a;
/// yield x[0];
/// }
/// # ;
/// ```
GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>),
/// The never type `!`.
Never,
/// A tuple type. For example, `(i32, bool)`.
Tuple(&'tcx List<Ty<'tcx>>),
/// The projection of an associated type. For example,
/// `<T as Trait<..>>::N`.
Projection(ProjectionTy<'tcx>),
/// Opaque (`impl Trait`) type found in a return type.
///
/// The `DefId` comes either from
/// * the `impl Trait` ast::Ty node,
/// * or the `type Foo = impl Trait` declaration
///
/// For RPIT the substitutions are for the generics of the function,
/// while for TAIT it is used for the generic parameters of the alias.
///
/// During codegen, `tcx.type_of(def_id)` can be used to get the underlying type.
Opaque(DefId, SubstsRef<'tcx>),
/// A type parameter; for example, `T` in `fn f<T>(x: T) {}`.
Param(ParamTy),
/// Bound type variable, used to represent the `'a` in `for<'a> fn(&'a ())`.
///
/// For canonical queries, we replace inference variables with bound variables,
/// so e.g. when checking whether `&'_ (): Trait<_>` holds, we canonicalize that to
/// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
/// back to inference variables in a new inference context when inside of the query.
///
/// See the `rustc-dev-guide` for more details about
/// [higher-ranked trait bounds][1] and [canonical queries][2].
///
/// [1]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
/// [2]: https://rustc-dev-guide.rust-lang.org/traits/canonical-queries.html
Bound(ty::DebruijnIndex, BoundTy),
/// A placeholder type, used during higher ranked subtyping to instantiate
/// bound variables.
Placeholder(ty::PlaceholderType),
/// A type variable used during type checking.
///
/// Similar to placeholders, inference variables also live in a universe to
/// correctly deal with higher ranked types. Though unlike placeholders,
/// that universe is stored in the `InferCtxt` instead of directly
/// inside of the type.
Infer(InferTy),
/// A placeholder for a type which could not be computed; this is
/// propagated to avoid useless error messages.
Error(DelaySpanBugEmitted),
}
*/
/*
impl<'tcx> TyKind<'tcx> {
#[inline]
pub fn is_primitive(&self) -> bool {
matches!(self, Bool | Char | Int(_) | Uint(_) | Float(_))
}
/// Get the article ("a" or "an") to use with this type.
pub fn article(&self) -> &'static str {
match self {
Int(_) | Float(_) | Array(_, _) => "an",
Adt(def, _) if def.is_enum() => "an",
// This should never happen, but ICEing and causing the user's code
// to not compile felt too harsh.
Error(_) => "a",
_ => "a",
}
}
}
*/
pub trait Article { pub trait Article {
fn article(&self) -> &'static str; fn article(&self) -> &'static str;
} }

View file

@ -36,8 +36,10 @@ impl<'tcx> fmt::Debug for VtblEntry<'tcx> {
} }
} }
pub const fn common_vtable_entries<'tcx>() -> &'tcx [VtblEntry<'tcx>] { // Needs to be associated with the `'tcx` lifetime
&[VtblEntry::MetadataDropInPlace, VtblEntry::MetadataSize, VtblEntry::MetadataAlign] impl<'tcx> TyCtxt<'tcx> {
pub const COMMON_VTABLE_ENTRIES: &'tcx [VtblEntry<'tcx>] =
&[VtblEntry::MetadataDropInPlace, VtblEntry::MetadataSize, VtblEntry::MetadataAlign];
} }
pub const COMMON_VTABLE_ENTRIES_DROPINPLACE: usize = 0; pub const COMMON_VTABLE_ENTRIES_DROPINPLACE: usize = 0;
@ -58,7 +60,7 @@ pub(super) fn vtable_allocation_provider<'tcx>(
tcx.vtable_entries(trait_ref) tcx.vtable_entries(trait_ref)
} else { } else {
common_vtable_entries() TyCtxt::COMMON_VTABLE_ENTRIES
}; };
let layout = tcx let layout = tcx

View file

@ -205,6 +205,7 @@ symbols! {
IntoIterator, IntoIterator,
IoRead, IoRead,
IoWrite, IoWrite,
IrTyKind,
Is, Is,
ItemContext, ItemContext,
Iterator, Iterator,

View file

@ -32,9 +32,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem; use rustc_hir::lang_items::LangItem;
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};
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 +693,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(TyCtxt::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 +783,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 += TyCtxt::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 {

View file

@ -12,7 +12,7 @@ use rustc_index::bit_set::GrowableBitSet;
use rustc_infer::infer::InferOk; use rustc_infer::infer::InferOk;
use rustc_infer::infer::LateBoundRegionConversionTime::HigherRankedType; use rustc_infer::infer::LateBoundRegionConversionTime::HigherRankedType;
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef}; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef};
use rustc_middle::ty::{self, EarlyBinder, GenericParamDefKind, Ty}; use rustc_middle::ty::{self, EarlyBinder, GenericParamDefKind, Ty, TyCtxt};
use rustc_middle::ty::{ToPolyTraitRef, ToPredicate}; use rustc_middle::ty::{ToPolyTraitRef, ToPredicate};
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
@ -834,7 +834,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
move |segment| { move |segment| {
match segment { match segment {
VtblSegment::MetadataDSA => { VtblSegment::MetadataDSA => {
vptr_offset += ty::common_vtable_entries().len(); vptr_offset += TyCtxt::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);

View file

@ -21,8 +21,6 @@ pub mod sty;
pub use codec::*; pub use codec::*;
pub use sty::*; pub use sty::*;
extern crate self as rustc_type_ir;
pub trait Interner { pub trait Interner {
type AdtDef: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; type AdtDef: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;
type SubstsRef: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord; type SubstsRef: Clone + Debug + Hash + PartialEq + Eq + PartialOrd + Ord;

View file

@ -1,3 +1,8 @@
#![allow(rustc::usage_of_ty_tykind)]
use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use std::{fmt, hash};
use crate::DebruijnIndex; use crate::DebruijnIndex;
use crate::FloatTy; use crate::FloatTy;
use crate::IntTy; use crate::IntTy;
@ -6,17 +11,17 @@ use crate::TyDecoder;
use crate::TyEncoder; use crate::TyEncoder;
use crate::UintTy; use crate::UintTy;
use self::TyKind::*;
use rustc_serialize::{Decodable, Encodable}; use rustc_serialize::{Decodable, Encodable};
/// Defines the kinds of types used by the type system. /// Defines the kinds of types used by the type system.
/// ///
/// 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` 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)] ///
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] /// The `HashStable` implementation for this type is defined in `rustc_query_system::ich`.
//#[derive(TyEncodable, TyDecodable)] #[rustc_diagnostic_item = "IrTyKind"]
//#[derive(HashStable)]
#[rustc_diagnostic_item = "TyKind"]
pub enum TyKind<I: Interner> { pub enum TyKind<I: Interner> {
/// The primitive boolean type. Written as `bool`. /// The primitive boolean type. Written as `bool`.
Bool, Bool,
@ -95,18 +100,18 @@ pub enum TyKind<I: Interner> {
/// ///
/// Closure substs contain both the - potentially substituted - generic parameters /// Closure substs contain both the - potentially substituted - generic parameters
/// of its parent and some synthetic parameters. See the documentation for /// of its parent and some synthetic parameters. See the documentation for
/// [ClosureSubsts] for more details. /// `ClosureSubsts` for more details.
Closure(I::DefId, I::SubstsRef), Closure(I::DefId, I::SubstsRef),
/// The anonymous type of a generator. Used to represent the type of /// The anonymous type of a generator. Used to represent the type of
/// `|a| yield a`. /// `|a| yield a`.
/// ///
/// For more info about generator substs, visit the documentation for /// For more info about generator substs, visit the documentation for
/// [GeneratorSubsts]. /// `GeneratorSubsts`.
Generator(I::DefId, I::SubstsRef, I::Movability), Generator(I::DefId, I::SubstsRef, I::Movability),
/// A type representing the types stored inside a generator. /// A type representing the types stored inside a generator.
/// This should only appear as part of the [GeneratorSubsts]. /// This should only appear as part of the `GeneratorSubsts`.
/// ///
/// Note that the captured variables for generators are stored separately /// Note that the captured variables for generators are stored separately
/// using a tuple in the same way as for closures. /// using a tuple in the same way as for closures.
@ -186,10 +191,47 @@ pub enum TyKind<I: Interner> {
Error(I::DelaySpanBugEmitted), Error(I::DelaySpanBugEmitted),
} }
#[allow(rustc::usage_of_ty_tykind)] impl<I: Interner> TyKind<I> {
#[inline]
pub fn is_primitive(&self) -> bool {
matches!(self, Bool | Char | Int(_) | Uint(_) | Float(_))
}
}
fn discriminant<I: Interner>(value: &TyKind<I>) -> usize {
match value {
Bool => 0,
Char => 1,
Int(_) => 2,
Uint(_) => 3,
Float(_) => 4,
Adt(_, _) => 5,
Foreign(_) => 6,
Str => 7,
Array(_, _) => 8,
Slice(_) => 9,
RawPtr(_) => 10,
Ref(_, _, _) => 11,
FnDef(_, _) => 12,
FnPtr(_) => 13,
Dynamic(_, _) => 14,
Closure(_, _) => 15,
Generator(_, _, _) => 16,
GeneratorWitness(_) => 17,
Never => 18,
Tuple(_) => 19,
Projection(_) => 20,
Opaque(_, _) => 21,
Param(_) => 22,
Bound(_, _) => 23,
Placeholder(_) => 24,
Infer(_) => 25,
Error(_) => 26,
}
}
impl<I: Interner> Clone for TyKind<I> { impl<I: Interner> Clone for TyKind<I> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
use crate::TyKind::*;
match self { match self {
Bool => Bool, Bool => Bool,
Char => Char, Char => Char,
@ -222,149 +264,553 @@ impl<I: Interner> Clone for TyKind<I> {
} }
} }
#[allow(rustc::usage_of_ty_tykind)] impl<I: Interner> PartialEq for TyKind<I> {
impl<I: Interner> TyKind<I> {
#[inline] #[inline]
pub fn is_primitive(&self) -> bool { fn eq(&self, other: &TyKind<I>) -> bool {
use crate::TyKind::*; let __self_vi = discriminant(self);
matches!(self, Bool | Char | Int(_) | Uint(_) | Float(_)) let __arg_1_vi = discriminant(other);
if __self_vi == __arg_1_vi {
match (&*self, &*other) {
(&Int(ref __self_0), &Int(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Uint(ref __self_0), &Uint(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Float(ref __self_0), &Float(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Adt(ref __self_0, ref __self_1), &Adt(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(&Foreign(ref __self_0), &Foreign(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Array(ref __self_0, ref __self_1), &Array(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(&Slice(ref __self_0), &Slice(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&RawPtr(ref __self_0), &RawPtr(ref __arg_1_0)) => __self_0 == __arg_1_0,
(
&Ref(ref __self_0, ref __self_1, ref __self_2),
&Ref(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
) => __self_0 == __arg_1_0 && __self_1 == __arg_1_1 && __self_2 == __arg_1_2,
(&FnDef(ref __self_0, ref __self_1), &FnDef(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(&FnPtr(ref __self_0), &FnPtr(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Dynamic(ref __self_0, ref __self_1), &Dynamic(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(&Closure(ref __self_0, ref __self_1), &Closure(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(
&Generator(ref __self_0, ref __self_1, ref __self_2),
&Generator(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
) => __self_0 == __arg_1_0 && __self_1 == __arg_1_1 && __self_2 == __arg_1_2,
(&GeneratorWitness(ref __self_0), &GeneratorWitness(ref __arg_1_0)) => {
__self_0 == __arg_1_0
}
(&Tuple(ref __self_0), &Tuple(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Projection(ref __self_0), &Projection(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Opaque(ref __self_0, ref __self_1), &Opaque(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(&Param(ref __self_0), &Param(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Bound(ref __self_0, ref __self_1), &Bound(ref __arg_1_0, ref __arg_1_1)) => {
__self_0 == __arg_1_0 && __self_1 == __arg_1_1
}
(&Placeholder(ref __self_0), &Placeholder(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Infer(ref __self_0), &Infer(ref __arg_1_0)) => __self_0 == __arg_1_0,
(&Error(ref __self_0), &Error(ref __arg_1_0)) => __self_0 == __arg_1_0,
_ => true,
}
} else {
false
}
} }
} }
#[allow(rustc::usage_of_ty_tykind)] impl<I: Interner> Eq for TyKind<I> {}
impl<__I: Interner, __E: TyEncoder> Encodable<__E> for TyKind<__I>
impl<I: Interner> PartialOrd for TyKind<I> {
#[inline]
fn partial_cmp(&self, other: &TyKind<I>) -> Option<Ordering> {
Some(Ord::cmp(self, other))
}
}
impl<I: Interner> Ord for TyKind<I> {
#[inline]
fn cmp(&self, other: &TyKind<I>) -> Ordering {
let __self_vi = discriminant(self);
let __arg_1_vi = discriminant(other);
if __self_vi == __arg_1_vi {
match (&*self, &*other) {
(&Int(ref __self_0), &Int(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Uint(ref __self_0), &Uint(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Float(ref __self_0), &Float(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Adt(ref __self_0, ref __self_1), &Adt(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(&Foreign(ref __self_0), &Foreign(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Array(ref __self_0, ref __self_1), &Array(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(&Slice(ref __self_0), &Slice(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&RawPtr(ref __self_0), &RawPtr(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(
&Ref(ref __self_0, ref __self_1, ref __self_2),
&Ref(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
) => match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => match Ord::cmp(__self_1, __arg_1_1) {
Ordering::Equal => Ord::cmp(__self_2, __arg_1_2),
cmp => cmp,
},
cmp => cmp,
},
(&FnDef(ref __self_0, ref __self_1), &FnDef(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(&FnPtr(ref __self_0), &FnPtr(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Dynamic(ref __self_0, ref __self_1), &Dynamic(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(&Closure(ref __self_0, ref __self_1), &Closure(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(
&Generator(ref __self_0, ref __self_1, ref __self_2),
&Generator(ref __arg_1_0, ref __arg_1_1, ref __arg_1_2),
) => match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => match Ord::cmp(__self_1, __arg_1_1) {
Ordering::Equal => Ord::cmp(__self_2, __arg_1_2),
cmp => cmp,
},
cmp => cmp,
},
(&GeneratorWitness(ref __self_0), &GeneratorWitness(ref __arg_1_0)) => {
Ord::cmp(__self_0, __arg_1_0)
}
(&Tuple(ref __self_0), &Tuple(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Projection(ref __self_0), &Projection(ref __arg_1_0)) => {
Ord::cmp(__self_0, __arg_1_0)
}
(&Opaque(ref __self_0, ref __self_1), &Opaque(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(&Param(ref __self_0), &Param(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Bound(ref __self_0, ref __self_1), &Bound(ref __arg_1_0, ref __arg_1_1)) => {
match Ord::cmp(__self_0, __arg_1_0) {
Ordering::Equal => Ord::cmp(__self_1, __arg_1_1),
cmp => cmp,
}
}
(&Placeholder(ref __self_0), &Placeholder(ref __arg_1_0)) => {
Ord::cmp(__self_0, __arg_1_0)
}
(&Infer(ref __self_0), &Infer(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
(&Error(ref __self_0), &Error(ref __arg_1_0)) => Ord::cmp(__self_0, __arg_1_0),
_ => Ordering::Equal,
}
} else {
Ord::cmp(&__self_vi, &__arg_1_vi)
}
}
}
impl<I: Interner> hash::Hash for TyKind<I> {
fn hash<__H: hash::Hasher>(&self, state: &mut __H) -> () {
match (&*self,) {
(&Int(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Uint(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Float(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Adt(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&Foreign(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Array(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&Slice(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&RawPtr(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Ref(ref __self_0, ref __self_1, ref __self_2),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state);
hash::Hash::hash(__self_2, state)
}
(&FnDef(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&FnPtr(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Dynamic(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&Closure(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&Generator(ref __self_0, ref __self_1, ref __self_2),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state);
hash::Hash::hash(__self_2, state)
}
(&GeneratorWitness(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Tuple(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Projection(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Opaque(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&Param(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Bound(ref __self_0, ref __self_1),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state);
hash::Hash::hash(__self_1, state)
}
(&Placeholder(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Infer(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
(&Error(ref __self_0),) => {
hash::Hash::hash(&discriminant(self), state);
hash::Hash::hash(__self_0, state)
}
_ => hash::Hash::hash(&discriminant(self), state),
}
}
}
impl<I: Interner> fmt::Debug for TyKind<I> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match (&*self,) {
(&Bool,) => fmt::Formatter::write_str(f, "Bool"),
(&Char,) => fmt::Formatter::write_str(f, "Char"),
(&Int(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Int");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Uint(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Uint");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Float(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Float");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Adt(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Adt");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Foreign(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Foreign");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Str,) => fmt::Formatter::write_str(f, "Str"),
(&Array(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Array");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Slice(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Slice");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&RawPtr(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "RawPtr");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Ref(ref __self_0, ref __self_1, ref __self_2),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Ref");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_2);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&FnDef(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "FnDef");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&FnPtr(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "FnPtr");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Dynamic(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Dynamic");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Closure(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Closure");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Generator(ref __self_0, ref __self_1, ref __self_2),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Generator");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_2);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&GeneratorWitness(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "GeneratorWitness");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Never,) => fmt::Formatter::write_str(f, "Never"),
(&Tuple(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Tuple");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Projection(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Projection");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Opaque(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Opaque");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Param(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Param");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Bound(ref __self_0, ref __self_1),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Bound");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_1);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Placeholder(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Placeholder");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Infer(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Infer");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
(&Error(ref __self_0),) => {
let debug_trait_builder = &mut fmt::Formatter::debug_tuple(f, "Error");
let _ = fmt::DebugTuple::field(debug_trait_builder, &__self_0);
fmt::DebugTuple::finish(debug_trait_builder)
}
}
}
}
impl<I: Interner, E: TyEncoder> Encodable<E> for TyKind<I>
where where
__I::DelaySpanBugEmitted: Encodable<__E>, I::DelaySpanBugEmitted: Encodable<E>,
__I::AdtDef: Encodable<__E>, I::AdtDef: Encodable<E>,
__I::SubstsRef: Encodable<__E>, I::SubstsRef: Encodable<E>,
__I::DefId: Encodable<__E>, I::DefId: Encodable<E>,
__I::Ty: Encodable<__E>, I::Ty: Encodable<E>,
__I::Const: Encodable<__E>, I::Const: Encodable<E>,
__I::Region: Encodable<__E>, I::Region: Encodable<E>,
__I::TypeAndMut: Encodable<__E>, I::TypeAndMut: Encodable<E>,
__I::Mutability: Encodable<__E>, I::Mutability: Encodable<E>,
__I::Movability: Encodable<__E>, I::Movability: Encodable<E>,
__I::PolyFnSig: Encodable<__E>, I::PolyFnSig: Encodable<E>,
__I::ListBinderExistentialPredicate: Encodable<__E>, I::ListBinderExistentialPredicate: Encodable<E>,
__I::BinderListTy: Encodable<__E>, I::BinderListTy: Encodable<E>,
__I::ListTy: Encodable<__E>, I::ListTy: Encodable<E>,
__I::ProjectionTy: Encodable<__E>, I::ProjectionTy: Encodable<E>,
__I::ParamTy: Encodable<__E>, I::ParamTy: Encodable<E>,
__I::BoundTy: Encodable<__E>, I::BoundTy: Encodable<E>,
__I::PlaceholderType: Encodable<__E>, I::PlaceholderType: Encodable<E>,
__I::InferTy: Encodable<__E>, I::InferTy: Encodable<E>,
__I::DelaySpanBugEmitted: Encodable<__E>, I::DelaySpanBugEmitted: Encodable<E>,
__I::PredicateKind: Encodable<__E>, I::PredicateKind: Encodable<E>,
__I::AllocId: Encodable<__E>, I::AllocId: Encodable<E>,
{ {
fn encode(&self, e: &mut __E) -> Result<(), <__E as rustc_serialize::Encoder>::Error> { fn encode(&self, e: &mut E) -> Result<(), <E as rustc_serialize::Encoder>::Error> {
rustc_serialize::Encoder::emit_enum(e, |e| { rustc_serialize::Encoder::emit_enum(e, |e| {
use rustc_type_ir::TyKind::*; let disc = discriminant(self);
match self { match self {
Bool => e.emit_enum_variant("Bool", 0, 0, |_| Ok(())), Bool => e.emit_enum_variant("Bool", disc, 0, |_| Ok(())),
Char => e.emit_enum_variant("Char", 1, 0, |_| Ok(())), Char => e.emit_enum_variant("Char", disc, 0, |_| Ok(())),
Int(i) => e.emit_enum_variant("Int", 2, 1, |e| { Int(i) => e.emit_enum_variant("Int", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| i.encode(e))?; e.emit_enum_variant_arg(true, |e| i.encode(e))?;
Ok(()) Ok(())
}), }),
Uint(u) => e.emit_enum_variant("Uint", 3, 1, |e| { Uint(u) => e.emit_enum_variant("Uint", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| u.encode(e))?; e.emit_enum_variant_arg(true, |e| u.encode(e))?;
Ok(()) Ok(())
}), }),
Float(f) => e.emit_enum_variant("Float", 4, 1, |e| { Float(f) => e.emit_enum_variant("Float", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| f.encode(e))?; e.emit_enum_variant_arg(true, |e| f.encode(e))?;
Ok(()) Ok(())
}), }),
Adt(adt, substs) => e.emit_enum_variant("Adt", 5, 2, |e| { Adt(adt, substs) => e.emit_enum_variant("Adt", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| adt.encode(e))?; e.emit_enum_variant_arg(true, |e| adt.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?; e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Ok(()) Ok(())
}), }),
Foreign(def_id) => e.emit_enum_variant("Foreign", 6, 1, |e| { Foreign(def_id) => e.emit_enum_variant("Foreign", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?; e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
Ok(()) Ok(())
}), }),
Str => e.emit_enum_variant("Str", 7, 0, |_| Ok(())), Str => e.emit_enum_variant("Str", disc, 0, |_| Ok(())),
Array(t, c) => e.emit_enum_variant("Array", 8, 2, |e| { Array(t, c) => e.emit_enum_variant("Array", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| t.encode(e))?; e.emit_enum_variant_arg(true, |e| t.encode(e))?;
e.emit_enum_variant_arg(false, |e| c.encode(e))?; e.emit_enum_variant_arg(false, |e| c.encode(e))?;
Ok(()) Ok(())
}), }),
Slice(t) => e.emit_enum_variant("Slice", 9, 1, |e| { Slice(t) => e.emit_enum_variant("Slice", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| t.encode(e))?; e.emit_enum_variant_arg(true, |e| t.encode(e))?;
Ok(()) Ok(())
}), }),
RawPtr(tam) => e.emit_enum_variant("RawPtr", 10, 1, |e| { RawPtr(tam) => e.emit_enum_variant("RawPtr", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| tam.encode(e))?; e.emit_enum_variant_arg(true, |e| tam.encode(e))?;
Ok(()) Ok(())
}), }),
Ref(r, t, m) => e.emit_enum_variant("Ref", 11, 3, |e| { Ref(r, t, m) => e.emit_enum_variant("Ref", disc, 3, |e| {
e.emit_enum_variant_arg(true, |e| r.encode(e))?; e.emit_enum_variant_arg(true, |e| r.encode(e))?;
e.emit_enum_variant_arg(false, |e| t.encode(e))?; e.emit_enum_variant_arg(false, |e| t.encode(e))?;
e.emit_enum_variant_arg(false, |e| m.encode(e))?; e.emit_enum_variant_arg(false, |e| m.encode(e))?;
Ok(()) Ok(())
}), }),
FnDef(def_id, substs) => e.emit_enum_variant("FnDef", 12, 2, |e| { FnDef(def_id, substs) => e.emit_enum_variant("FnDef", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?; e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?; e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Ok(()) Ok(())
}), }),
FnPtr(polyfnsig) => e.emit_enum_variant("FnPtr", 13, 1, |e| { FnPtr(polyfnsig) => e.emit_enum_variant("FnPtr", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| polyfnsig.encode(e))?; e.emit_enum_variant_arg(true, |e| polyfnsig.encode(e))?;
Ok(()) Ok(())
}), }),
Dynamic(l, r) => e.emit_enum_variant("Dynamic", 14, 2, |e| { Dynamic(l, r) => e.emit_enum_variant("Dynamic", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| l.encode(e))?; e.emit_enum_variant_arg(true, |e| l.encode(e))?;
e.emit_enum_variant_arg(false, |e| r.encode(e))?; e.emit_enum_variant_arg(false, |e| r.encode(e))?;
Ok(()) Ok(())
}), }),
Closure(def_id, substs) => e.emit_enum_variant("Closure", 15, 2, |e| { Closure(def_id, substs) => e.emit_enum_variant("Closure", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?; e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?; e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Ok(()) Ok(())
}), }),
Generator(def_id, substs, m) => e.emit_enum_variant("Generator", 16, 3, |e| { Generator(def_id, substs, m) => e.emit_enum_variant("Generator", disc, 3, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?; e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?; e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
e.emit_enum_variant_arg(false, |e| m.encode(e))?; e.emit_enum_variant_arg(false, |e| m.encode(e))?;
Ok(()) Ok(())
}), }),
GeneratorWitness(b) => e.emit_enum_variant("GeneratorWitness", 17, 1, |e| { GeneratorWitness(b) => e.emit_enum_variant("GeneratorWitness", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| b.encode(e))?; e.emit_enum_variant_arg(true, |e| b.encode(e))?;
Ok(()) Ok(())
}), }),
Never => e.emit_enum_variant("Never", 18, 0, |_| Ok(())), Never => e.emit_enum_variant("Never", disc, 0, |_| Ok(())),
Tuple(substs) => e.emit_enum_variant("Tuple", 19, 1, |e| { Tuple(substs) => e.emit_enum_variant("Tuple", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| substs.encode(e))?; e.emit_enum_variant_arg(true, |e| substs.encode(e))?;
Ok(()) Ok(())
}), }),
Projection(p) => e.emit_enum_variant("Projection", 20, 1, |e| { Projection(p) => e.emit_enum_variant("Projection", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| p.encode(e))?; e.emit_enum_variant_arg(true, |e| p.encode(e))?;
Ok(()) Ok(())
}), }),
Opaque(def_id, substs) => e.emit_enum_variant("Opaque", 21, 2, |e| { Opaque(def_id, substs) => e.emit_enum_variant("Opaque", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| def_id.encode(e))?; e.emit_enum_variant_arg(true, |e| def_id.encode(e))?;
e.emit_enum_variant_arg(false, |e| substs.encode(e))?; e.emit_enum_variant_arg(false, |e| substs.encode(e))?;
Ok(()) Ok(())
}), }),
Param(p) => e.emit_enum_variant("Param", 22, 1, |e| { Param(p) => e.emit_enum_variant("Param", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| p.encode(e))?; e.emit_enum_variant_arg(true, |e| p.encode(e))?;
Ok(()) Ok(())
}), }),
Bound(d, b) => e.emit_enum_variant("Bound", 23, 2, |e| { Bound(d, b) => e.emit_enum_variant("Bound", disc, 2, |e| {
e.emit_enum_variant_arg(true, |e| d.encode(e))?; e.emit_enum_variant_arg(true, |e| d.encode(e))?;
e.emit_enum_variant_arg(false, |e| b.encode(e))?; e.emit_enum_variant_arg(false, |e| b.encode(e))?;
Ok(()) Ok(())
}), }),
Placeholder(p) => e.emit_enum_variant("Placeholder", 24, 1, |e| { Placeholder(p) => e.emit_enum_variant("Placeholder", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| p.encode(e))?; e.emit_enum_variant_arg(true, |e| p.encode(e))?;
Ok(()) Ok(())
}), }),
Infer(i) => e.emit_enum_variant("Infer", 25, 1, |e| { Infer(i) => e.emit_enum_variant("Infer", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| i.encode(e))?; e.emit_enum_variant_arg(true, |e| i.encode(e))?;
Ok(()) Ok(())
}), }),
Error(d) => e.emit_enum_variant("Error", 26, 1, |e| { Error(d) => e.emit_enum_variant("Error", disc, 1, |e| {
e.emit_enum_variant_arg(true, |e| d.encode(e))?; e.emit_enum_variant_arg(true, |e| d.encode(e))?;
Ok(()) Ok(())
}), }),
@ -373,92 +819,82 @@ where
} }
} }
#[allow(rustc::usage_of_ty_tykind)] impl<I: Interner, D: TyDecoder<I = I>> Decodable<D> for TyKind<I>
impl<__I: Interner, __D: TyDecoder<I = __I>> Decodable<__D> for TyKind<__I>
where where
__I::DelaySpanBugEmitted: Decodable<__D>, I::DelaySpanBugEmitted: Decodable<D>,
__I::AdtDef: Decodable<__D>, I::AdtDef: Decodable<D>,
__I::SubstsRef: Decodable<__D>, I::SubstsRef: Decodable<D>,
__I::DefId: Decodable<__D>, I::DefId: Decodable<D>,
__I::Ty: Decodable<__D>, I::Ty: Decodable<D>,
__I::Const: Decodable<__D>, I::Const: Decodable<D>,
__I::Region: Decodable<__D>, I::Region: Decodable<D>,
__I::TypeAndMut: Decodable<__D>, I::TypeAndMut: Decodable<D>,
__I::Mutability: Decodable<__D>, I::Mutability: Decodable<D>,
__I::Movability: Decodable<__D>, I::Movability: Decodable<D>,
__I::PolyFnSig: Decodable<__D>, I::PolyFnSig: Decodable<D>,
__I::ListBinderExistentialPredicate: Decodable<__D>, I::ListBinderExistentialPredicate: Decodable<D>,
__I::BinderListTy: Decodable<__D>, I::BinderListTy: Decodable<D>,
__I::ListTy: Decodable<__D>, I::ListTy: Decodable<D>,
__I::ProjectionTy: Decodable<__D>, I::ProjectionTy: Decodable<D>,
__I::ParamTy: Decodable<__D>, I::ParamTy: Decodable<D>,
__I::BoundTy: Decodable<__D>, I::BoundTy: Decodable<D>,
__I::PlaceholderType: Decodable<__D>, I::PlaceholderType: Decodable<D>,
__I::InferTy: Decodable<__D>, I::InferTy: Decodable<D>,
__I::DelaySpanBugEmitted: Decodable<__D>, I::DelaySpanBugEmitted: Decodable<D>,
__I::PredicateKind: Decodable<__D>, I::PredicateKind: Decodable<D>,
__I::AllocId: Decodable<__D>, I::AllocId: Decodable<D>,
{ {
fn decode(__decoder: &mut __D) -> Self { fn decode(d: &mut D) -> Self {
use TyKind::*; match rustc_serialize::Decoder::read_usize(d) {
match rustc_serialize::Decoder::read_usize(__decoder) {
0 => Bool, 0 => Bool,
1 => Char, 1 => Char,
2 => Int(rustc_serialize::Decodable::decode(__decoder)), 2 => Int(rustc_serialize::Decodable::decode(d)),
3 => Uint(rustc_serialize::Decodable::decode(__decoder)), 3 => Uint(rustc_serialize::Decodable::decode(d)),
4 => Float(rustc_serialize::Decodable::decode(__decoder)), 4 => Float(rustc_serialize::Decodable::decode(d)),
5 => Adt( 5 => Adt(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d)),
rustc_serialize::Decodable::decode(__decoder), 6 => Foreign(rustc_serialize::Decodable::decode(d)),
rustc_serialize::Decodable::decode(__decoder),
),
6 => Foreign(rustc_serialize::Decodable::decode(__decoder)),
7 => Str, 7 => Str,
8 => Array( 8 => {
rustc_serialize::Decodable::decode(__decoder), Array(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
rustc_serialize::Decodable::decode(__decoder), }
), 9 => Slice(rustc_serialize::Decodable::decode(d)),
9 => Slice(rustc_serialize::Decodable::decode(__decoder)), 10 => RawPtr(rustc_serialize::Decodable::decode(d)),
10 => RawPtr(rustc_serialize::Decodable::decode(__decoder)),
11 => Ref( 11 => Ref(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
), ),
12 => FnDef( 12 => {
rustc_serialize::Decodable::decode(__decoder), FnDef(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
rustc_serialize::Decodable::decode(__decoder), }
), 13 => FnPtr(rustc_serialize::Decodable::decode(d)),
13 => FnPtr(rustc_serialize::Decodable::decode(__decoder)),
14 => Dynamic( 14 => Dynamic(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
), ),
15 => Closure( 15 => Closure(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
), ),
16 => Generator( 16 => Generator(
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
rustc_serialize::Decodable::decode(__decoder), rustc_serialize::Decodable::decode(d),
), ),
17 => GeneratorWitness(rustc_serialize::Decodable::decode(__decoder)), 17 => GeneratorWitness(rustc_serialize::Decodable::decode(d)),
18 => Never, 18 => Never,
19 => Tuple(rustc_serialize::Decodable::decode(__decoder)), 19 => Tuple(rustc_serialize::Decodable::decode(d)),
20 => Projection(rustc_serialize::Decodable::decode(__decoder)), 20 => Projection(rustc_serialize::Decodable::decode(d)),
21 => Opaque( 21 => {
rustc_serialize::Decodable::decode(__decoder), Opaque(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
rustc_serialize::Decodable::decode(__decoder), }
), 22 => Param(rustc_serialize::Decodable::decode(d)),
22 => Param(rustc_serialize::Decodable::decode(__decoder)), 23 => {
23 => Bound( Bound(rustc_serialize::Decodable::decode(d), rustc_serialize::Decodable::decode(d))
rustc_serialize::Decodable::decode(__decoder), }
rustc_serialize::Decodable::decode(__decoder), 24 => Placeholder(rustc_serialize::Decodable::decode(d)),
), 25 => Infer(rustc_serialize::Decodable::decode(d)),
24 => Placeholder(rustc_serialize::Decodable::decode(__decoder)), 26 => Error(rustc_serialize::Decodable::decode(d)),
25 => Infer(rustc_serialize::Decodable::decode(__decoder)),
26 => Error(rustc_serialize::Decodable::decode(__decoder)),
_ => panic!( _ => panic!(
"{}", "{}",
format!( format!(

View file

@ -154,7 +154,7 @@ fn get_bodies<'tcx>(tcx: TyCtxt<'tcx>) -> Vec<(String, BodyWithBorrowckFacts<'tc
// SAFETY: For soundness we need to ensure that the bodies have // SAFETY: For soundness we need to ensure that the bodies have
// the same lifetime (`'tcx`), which they had before they were // the same lifetime (`'tcx`), which they had before they were
// stored in the thread local. // stored in the thread local.
(def_path.to_string_no_crate_verbose(), body) (def_path.to_string_no_crate_verbose(), unsafe { std::mem::transmute(body) })
}) })
.collect() .collect()
}) })

View file

@ -3,41 +3,43 @@
#![feature(rustc_private)] #![feature(rustc_private)]
extern crate rustc_middle; extern crate rustc_middle;
extern crate rustc_type_ir;
use rustc_middle::ty::{self, Ty, TyKind}; use rustc_middle::ty::{self, Ty, TyKind};
use rustc_type_ir::{Interner, TyKind as IrTyKind};
#[deny(rustc::usage_of_ty_tykind)] #[deny(rustc::usage_of_ty_tykind)]
fn main() { fn main() {
let kind = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>` let kind = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>`
match kind { match kind {
TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
TyKind::Error(_) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Error(_) => (), //~ ERROR usage of `ty::TyKind::<kind>`
} }
if let ty::Int(int_ty) = kind {} if let ty::Int(int_ty) = kind {}
@ -45,4 +47,10 @@ fn main() {
if let TyKind::Int(int_ty) = kind {} //~ ERROR usage of `ty::TyKind::<kind>` if let TyKind::Int(int_ty) = kind {} //~ ERROR usage of `ty::TyKind::<kind>`
fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind` fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind`
fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
//~^ ERROR usage of `ty::TyKind`
//~| ERROR usage of `ty::TyKind`
IrTyKind::Bool //~ ERROR usage of `ty::TyKind::<kind>`
}
} }

View file

@ -1,190 +1,214 @@
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:11:16 --> $DIR/ty_tykind_usage.rs:13:16
| |
LL | let kind = TyKind::Bool; LL | let kind = TyKind::Bool;
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
| |
note: the lint level is defined here note: the lint level is defined here
--> $DIR/ty_tykind_usage.rs:9:8 --> $DIR/ty_tykind_usage.rs:11:8
| |
LL | #[deny(rustc::usage_of_ty_tykind)] LL | #[deny(rustc::usage_of_ty_tykind)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:14:9
|
LL | TyKind::Bool => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:15:9
|
LL | TyKind::Char => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:16:9 --> $DIR/ty_tykind_usage.rs:16:9
| |
LL | TyKind::Int(..) => (), LL | TyKind::Bool => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:17:9 --> $DIR/ty_tykind_usage.rs:17:9
| |
LL | TyKind::Uint(..) => (), LL | TyKind::Char => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:18:9 --> $DIR/ty_tykind_usage.rs:18:9
| |
LL | TyKind::Float(..) => (), LL | TyKind::Int(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:19:9 --> $DIR/ty_tykind_usage.rs:19:9
| |
LL | TyKind::Adt(..) => (), LL | TyKind::Uint(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:20:9 --> $DIR/ty_tykind_usage.rs:20:9
| |
LL | TyKind::Foreign(..) => (), LL | TyKind::Float(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:21:9 --> $DIR/ty_tykind_usage.rs:21:9
| |
LL | TyKind::Str => (), LL | TyKind::Adt(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:22:9 --> $DIR/ty_tykind_usage.rs:22:9
| |
LL | TyKind::Array(..) => (), LL | TyKind::Foreign(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:23:9 --> $DIR/ty_tykind_usage.rs:23:9
| |
LL | TyKind::Slice(..) => (), LL | TyKind::Str => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:24:9 --> $DIR/ty_tykind_usage.rs:24:9
| |
LL | TyKind::RawPtr(..) => (), LL | TyKind::Array(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:25:9 --> $DIR/ty_tykind_usage.rs:25:9
| |
LL | TyKind::Ref(..) => (), LL | TyKind::Slice(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:26:9 --> $DIR/ty_tykind_usage.rs:26:9
| |
LL | TyKind::FnDef(..) => (), LL | TyKind::RawPtr(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:27:9 --> $DIR/ty_tykind_usage.rs:27:9
| |
LL | TyKind::FnPtr(..) => (), LL | TyKind::Ref(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:28:9 --> $DIR/ty_tykind_usage.rs:28:9
| |
LL | TyKind::Dynamic(..) => (), LL | TyKind::FnDef(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:29:9 --> $DIR/ty_tykind_usage.rs:29:9
| |
LL | TyKind::Closure(..) => (), LL | TyKind::FnPtr(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:30:9 --> $DIR/ty_tykind_usage.rs:30:9
| |
LL | TyKind::Generator(..) => (), LL | TyKind::Dynamic(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:31:9 --> $DIR/ty_tykind_usage.rs:31:9
| |
LL | TyKind::GeneratorWitness(..) => (), LL | TyKind::Closure(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:32:9 --> $DIR/ty_tykind_usage.rs:32:9
| |
LL | TyKind::Never => (), LL | TyKind::Generator(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:33:9 --> $DIR/ty_tykind_usage.rs:33:9
| |
LL | TyKind::Tuple(..) => (), LL | TyKind::GeneratorWitness(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:34:9 --> $DIR/ty_tykind_usage.rs:34:9
| |
LL | TyKind::Projection(..) => (), LL | TyKind::Never => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:35:9 --> $DIR/ty_tykind_usage.rs:35:9
| |
LL | TyKind::Opaque(..) => (), LL | TyKind::Tuple(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:36:9 --> $DIR/ty_tykind_usage.rs:36:9
| |
LL | TyKind::Param(..) => (), LL | TyKind::Projection(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:37:9 --> $DIR/ty_tykind_usage.rs:37:9
| |
LL | TyKind::Bound(..) => (), LL | TyKind::Opaque(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:38:9 --> $DIR/ty_tykind_usage.rs:38:9
| |
LL | TyKind::Placeholder(..) => (), LL | TyKind::Param(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:39:9 --> $DIR/ty_tykind_usage.rs:39:9
| |
LL | TyKind::Infer(..) => (), LL | TyKind::Bound(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:40:9 --> $DIR/ty_tykind_usage.rs:40:9
| |
LL | TyKind::Error(_) => (), LL | TyKind::Placeholder(..) => (),
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>` error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:45:12 --> $DIR/ty_tykind_usage.rs:41:9
|
LL | TyKind::Infer(..) => (),
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:42:9
|
LL | TyKind::Error(_) => (),
| ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:47:12
| |
LL | if let TyKind::Int(int_ty) = kind {} LL | if let TyKind::Int(int_ty) = kind {}
| ^^^^^^ help: try using ty::<kind> directly: `ty` | ^^^^^^ help: try using `ty::<kind>` directly: `ty`
error: usage of `ty::TyKind` error: usage of `ty::TyKind`
--> $DIR/ty_tykind_usage.rs:47:24 --> $DIR/ty_tykind_usage.rs:49:24
| |
LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {}
| ^^^^^^^^^^ | ^^^^^^^^^^
| |
= help: try using `Ty` instead = help: try using `Ty` instead
error: aborting due to 30 previous errors error: usage of `ty::TyKind`
--> $DIR/ty_tykind_usage.rs:51:37
|
LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
| ^^^^^^^^^^^
|
= help: try using `Ty` instead
error: usage of `ty::TyKind`
--> $DIR/ty_tykind_usage.rs:51:53
|
LL | fn ir_ty_kind<I: Interner>(bad: IrTyKind<I>) -> IrTyKind<I> {
| ^^^^^^^^^^^
|
= help: try using `Ty` instead
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:54:9
|
LL | IrTyKind::Bool
| --------^^^^^^
| |
| help: try using `ty::<kind>` directly: `ty`
error: aborting due to 33 previous errors