diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 7429492f914a3..86ce5fd01a812 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -316,6 +316,11 @@ fn main() { } } + // This is required for internal lints. + if stage != "0" { + cmd.arg("-Zunstable-options"); + } + // Force all crates compiled by this compiler to (a) be unstable and (b) // allow the `rustc_private` feature to link to other unstable crates // also in the sysroot. We also do this for host crates, since those diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 0a5b79c36aad8..6fa15884f5abb 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -12,6 +12,7 @@ test(no_crate_inject, attr(deny(warnings))))] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(alloc)] #![feature(core_intrinsics)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index aacd6cec565a5..2536121c7a324 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -9,6 +9,7 @@ test(attr(deny(warnings))))] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(nll)] #![feature(rustc_private)] diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index 397843fd75afa..abfa96841d9f6 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -1,10 +1,10 @@ -use crate::ty; -use crate::ty::TyCtxt; -use crate::hir::map::definitions::FIRST_FREE_HIGH_DEF_INDEX; +use crate::ty::{self, print::Printer, subst::Kind, Ty, TyCtxt}; +use crate::hir::map::definitions::{DisambiguatedDefPathData, FIRST_FREE_HIGH_DEF_INDEX}; use rustc_data_structures::indexed_vec::Idx; use serialize; use std::fmt; use std::u32; +use syntax::symbol::{LocalInternedString, Symbol}; newtype_index! { pub struct CrateId { @@ -252,6 +252,107 @@ impl DefId { format!("module `{}`", tcx.def_path_str(*self)) } } + + /// Check if a `DefId`'s path matches the given absolute type path usage. + // Uplifted from rust-lang/rust-clippy + pub fn match_path<'a, 'tcx>(self, tcx: TyCtxt<'a, 'tcx, 'tcx>, path: &[&str]) -> bool { + pub struct AbsolutePathPrinter<'a, 'tcx> { + pub tcx: TyCtxt<'a, 'tcx, 'tcx>, + } + + impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> { + type Error = !; + + type Path = Vec; + type Region = (); + type Type = (); + type DynExistential = (); + + fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> { + self.tcx + } + + fn print_region(self, _region: ty::Region<'_>) -> Result { + Ok(()) + } + + fn print_type(self, _ty: Ty<'tcx>) -> Result { + Ok(()) + } + + fn print_dyn_existential( + self, + _predicates: &'tcx ty::List>, + ) -> Result { + Ok(()) + } + + fn path_crate(self, cnum: CrateNum) -> Result { + Ok(vec![self.tcx.original_crate_name(cnum).as_str()]) + } + + fn path_qualified( + self, + self_ty: Ty<'tcx>, + trait_ref: Option>, + ) -> Result { + if trait_ref.is_none() { + if let ty::Adt(def, substs) = self_ty.sty { + return self.print_def_path(def.did, substs); + } + } + + // This shouldn't ever be needed, but just in case: + Ok(vec![match trait_ref { + Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)).as_str(), + None => Symbol::intern(&format!("<{}>", self_ty)).as_str(), + }]) + } + + fn path_append_impl( + self, + print_prefix: impl FnOnce(Self) -> Result, + _disambiguated_data: &DisambiguatedDefPathData, + self_ty: Ty<'tcx>, + trait_ref: Option>, + ) -> Result { + let mut path = print_prefix(self)?; + + // This shouldn't ever be needed, but just in case: + path.push(match trait_ref { + Some(trait_ref) => { + Symbol::intern(&format!("", trait_ref, self_ty)).as_str() + }, + None => Symbol::intern(&format!("", self_ty)).as_str(), + }); + + Ok(path) + } + + fn path_append( + self, + print_prefix: impl FnOnce(Self) -> Result, + disambiguated_data: &DisambiguatedDefPathData, + ) -> Result { + let mut path = print_prefix(self)?; + path.push(disambiguated_data.data.as_interned_str().as_str()); + Ok(path) + } + + fn path_generic_args( + self, + print_prefix: impl FnOnce(Self) -> Result, + _args: &[Kind<'tcx>], + ) -> Result { + print_prefix(self) + } + } + + let names = AbsolutePathPrinter { tcx }.print_def_path(self, &[]).unwrap(); + + names.len() == path.len() + && names.into_iter().zip(path.iter()).all(|(a, &b)| *a == *b) + } } impl serialize::UseSpecializedEncodable for DefId {} diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index e60fdd62debd1..a8e5db26eadc1 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -9,7 +9,6 @@ use crate::session::Session; use std::cmp::Ord; use std::hash as std_hash; -use std::collections::HashMap; use std::cell::RefCell; use syntax::ast; @@ -394,13 +393,12 @@ impl<'a> HashStable> for DelimSpan { } } -pub fn hash_stable_trait_impls<'a, 'gcx, W, R>( +pub fn hash_stable_trait_impls<'a, 'gcx, W>( hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher, blanket_impls: &[DefId], - non_blanket_impls: &HashMap, R>) - where W: StableHasherResult, - R: std_hash::BuildHasher, + non_blanket_impls: &FxHashMap>) + where W: StableHasherResult { { let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 2810b5a8e6ada..19663161fe3fa 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -56,7 +56,7 @@ use crate::hir::Node; use crate::middle::region; use crate::traits::{ObligationCause, ObligationCauseCode}; use crate::ty::error::TypeError; -use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TyKind, TypeFoldable}; +use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TypeFoldable}; use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; use std::{cmp, fmt}; use syntax_pos::{Pos, Span}; @@ -1094,14 +1094,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { (_, false, _) => { if let Some(exp_found) = exp_found { let (def_id, ret_ty) = match exp_found.found.sty { - TyKind::FnDef(def, _) => { + ty::FnDef(def, _) => { (Some(def), Some(self.tcx.fn_sig(def).output())) } _ => (None, None), }; let exp_is_struct = match exp_found.expected.sty { - TyKind::Adt(def, _) => def.is_struct(), + ty::Adt(def, _) => def.is_struct(), _ => false, }; @@ -1140,8 +1140,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { diag: &mut DiagnosticBuilder<'tcx>, ) { match (&exp_found.expected.sty, &exp_found.found.sty) { - (TyKind::Adt(exp_def, exp_substs), TyKind::Ref(_, found_ty, _)) => { - if let TyKind::Adt(found_def, found_substs) = found_ty.sty { + (ty::Adt(exp_def, exp_substs), ty::Ref(_, found_ty, _)) => { + if let ty::Adt(found_def, found_substs) = found_ty.sty { let path_str = format!("{:?}", exp_def); if exp_def == &found_def { let opt_msg = "you can convert from `&Option` to `Option<&T>` using \ @@ -1164,17 +1164,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let mut show_suggestion = true; for (exp_ty, found_ty) in exp_substs.types().zip(found_substs.types()) { match exp_ty.sty { - TyKind::Ref(_, exp_ty, _) => { + ty::Ref(_, exp_ty, _) => { match (&exp_ty.sty, &found_ty.sty) { - (_, TyKind::Param(_)) | - (_, TyKind::Infer(_)) | - (TyKind::Param(_), _) | - (TyKind::Infer(_), _) => {} + (_, ty::Param(_)) | + (_, ty::Infer(_)) | + (ty::Param(_), _) | + (ty::Infer(_), _) => {} _ if ty::TyS::same_type(exp_ty, found_ty) => {} _ => show_suggestion = false, }; } - TyKind::Param(_) | TyKind::Infer(_) => {} + ty::Param(_) | ty::Infer(_) => {} _ => show_suggestion = false, } } diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b87343b43c9f9..0b75cb6c8a3e2 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -29,6 +29,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![allow(explicit_outlives_requirements)] #![feature(arbitrary_self_types)] diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs new file mode 100644 index 0000000000000..d5f8876d1621f --- /dev/null +++ b/src/librustc/lint/internal.rs @@ -0,0 +1,127 @@ +//! Some lints that are only useful in the compiler or crates that use compiler internals, such as +//! Clippy. + +use crate::hir::{HirId, Path, PathSegment, QPath, Ty, TyKind}; +use crate::lint::{ + EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintArray, LintContext, LintPass, +}; +use errors::Applicability; +use rustc_data_structures::fx::FxHashMap; +use syntax::ast::Ident; + +declare_lint! { + pub DEFAULT_HASH_TYPES, + Allow, + "forbid HashMap and HashSet and suggest the FxHash* variants" +} + +pub struct DefaultHashTypes { + map: FxHashMap, +} + +impl DefaultHashTypes { + pub fn new() -> Self { + let mut map = FxHashMap::default(); + map.insert("HashMap".to_string(), "FxHashMap".to_string()); + map.insert("HashSet".to_string(), "FxHashSet".to_string()); + Self { map } + } +} + +impl LintPass for DefaultHashTypes { + fn get_lints(&self) -> LintArray { + lint_array!(DEFAULT_HASH_TYPES) + } + + fn name(&self) -> &'static str { + "DefaultHashTypes" + } +} + +impl EarlyLintPass for DefaultHashTypes { + fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) { + let ident_string = ident.to_string(); + if let Some(replace) = self.map.get(&ident_string) { + let msg = format!( + "Prefer {} over {}, it has better performance", + replace, ident_string + ); + let mut db = cx.struct_span_lint(DEFAULT_HASH_TYPES, ident.span, &msg); + db.span_suggestion( + ident.span, + "use", + replace.to_string(), + Applicability::MaybeIncorrect, // FxHashMap, ... needs another import + ); + db.note(&format!( + "a `use rustc_data_structures::fx::{}` may be necessary", + replace + )) + .emit(); + } + } +} + +declare_lint! { + pub USAGE_OF_TY_TYKIND, + Allow, + "Usage of `ty::TyKind` outside of the `ty::sty` module" +} + +pub struct TyKindUsage; + +impl LintPass for TyKindUsage { + fn get_lints(&self) -> LintArray { + lint_array!(USAGE_OF_TY_TYKIND) + } + + fn name(&self) -> &'static str { + "TyKindUsage" + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TyKindUsage { + fn check_path(&mut self, cx: &LateContext<'_, '_>, path: &'tcx Path, _: HirId) { + let segments = path.segments.iter().rev().skip(1).rev(); + + if let Some(last) = segments.last() { + let span = path.span.with_hi(last.ident.span.hi()); + if lint_ty_kind_usage(cx, last) { + cx.struct_span_lint(USAGE_OF_TY_TYKIND, span, "usage of `ty::TyKind::`") + .span_suggestion( + span, + "try using ty:: directly", + "ty".to_string(), + Applicability::MaybeIncorrect, // ty maybe needs an import + ) + .emit(); + } + } + } + + fn check_ty(&mut self, cx: &LateContext<'_, '_>, ty: &'tcx Ty) { + if let TyKind::Path(qpath) = &ty.node { + if let QPath::Resolved(_, path) = qpath { + if let Some(last) = path.segments.iter().last() { + if lint_ty_kind_usage(cx, last) { + cx.struct_span_lint(USAGE_OF_TY_TYKIND, path.span, "usage of `ty::TyKind`") + .help("try using `ty::Ty` instead") + .emit(); + } + } + } + } + } +} + +fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool { + if segment.ident.as_str() == "TyKind" { + if let Some(def) = segment.def { + if let Some(did) = def.opt_def_id() { + return did.match_path(cx.tcx, &["rustc", "ty", "sty", "TyKind"]); + } + } + } + + false +} diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index a5506bb8f59f4..b54d26054da1c 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -574,6 +574,7 @@ impl_stable_hash_for!(enum self::LintSource { pub type LevelSource = (Level, LintSource); pub mod builtin; +pub mod internal; mod context; mod levels; diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 0eb37f0ac9e96..23be1bbf6c687 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -36,7 +36,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { pub fn field_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, f: &Field) -> Ty<'tcx> { let answer = match self.ty.sty { - ty::TyKind::Adt(adt_def, substs) => { + ty::Adt(adt_def, substs) => { let variant_def = match self.variant_index { None => adt_def.non_enum_variant(), Some(variant_index) => { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 03936a82c7151..aa5610739fd6d 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -219,6 +219,11 @@ pub struct CommonTypes<'tcx> { pub never: Ty<'tcx>, pub err: Ty<'tcx>, + /// Dummy type used for the `Self` of a `TraitRef` created for converting + /// a trait object, and which gets removed in `ExistentialTraitRef`. + /// This type must not appear anywhere in other converted types. + pub trait_object_dummy_self: Ty<'tcx>, + pub re_empty: Region<'tcx>, pub re_static: Region<'tcx>, pub re_erased: Region<'tcx>, @@ -955,6 +960,8 @@ impl<'tcx> CommonTypes<'tcx> { f32: mk(Float(ast::FloatTy::F32)), f64: mk(Float(ast::FloatTy::F64)), + trait_object_dummy_self: mk(Infer(ty::FreshTy(0))), + re_empty: mk_region(RegionKind::ReEmpty), re_static: mk_region(RegionKind::ReStatic), re_erased: mk_region(RegionKind::ReErased), diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 102057c1380ac..7d47867cea125 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(stage0), allow(usage_of_ty_tykind))] + pub use self::Variance::*; pub use self::AssociatedItemContainer::*; pub use self::BorrowKind::*; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 5622fe434363a..26194176350ac 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -1,11 +1,10 @@ #![allow(non_camel_case_types)] -use rustc_data_structures::sync::Lock; +use rustc_data_structures::{fx::FxHashMap, sync::Lock}; use std::cell::{RefCell, Cell}; -use std::collections::HashMap; use std::fmt::Debug; -use std::hash::{Hash, BuildHasher}; +use std::hash::Hash; use std::panic; use std::env; use std::time::{Duration, Instant}; @@ -341,8 +340,8 @@ pub trait MemoizationMap { where OP: FnOnce() -> Self::Value; } -impl MemoizationMap for RefCell> - where K: Hash+Eq+Clone, V: Clone, S: BuildHasher +impl MemoizationMap for RefCell> + where K: Hash+Eq+Clone, V: Clone { type Key = K; type Value = V; diff --git a/src/librustc_allocator/lib.rs b/src/librustc_allocator/lib.rs index 9d6e728e13557..a9e422fb238b8 100644 --- a/src/librustc_allocator/lib.rs +++ b/src/librustc_allocator/lib.rs @@ -2,6 +2,7 @@ #![feature(rustc_private)] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] pub mod expand; diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index cf4669db87e5e..3761a52bcccf2 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -2,6 +2,7 @@ #![allow(non_camel_case_types)] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(nll)] diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index 1e898ced7a600..e2917578c0ece 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -14,6 +14,7 @@ #![allow(unused_attributes)] #![allow(dead_code)] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![allow(explicit_outlives_requirements)] #![recursion_limit="256"] diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 1a3914e6ef44c..330cfe154e302 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -16,6 +16,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #[macro_use] extern crate rustc; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 4b7cffaad5509..2781bfa3ec849 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -17,6 +17,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] pub extern crate getopts; #[cfg(unix)] diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index ebbc5a3d3a340..71bef54cd17a1 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -6,6 +6,7 @@ #![feature(nll)] #![feature(optin_builtin_traits)] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #[allow(unused_extern_crates)] extern crate serialize as rustc_serialize; // used by deriving diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index fe75bbc36c3b1..d7db324f3463e 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -8,6 +8,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #[macro_use] extern crate rustc; #[allow(unused_extern_crates)] diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs index 245a2bf92d530..74085123f89ee 100644 --- a/src/librustc_interface/interface.rs +++ b/src/librustc_interface/interface.rs @@ -12,7 +12,6 @@ use rustc_data_structures::OnDrop; use rustc_data_structures::sync::Lrc; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; use rustc_metadata::cstore::CStore; -use std::collections::HashSet; use std::io::Write; use std::path::PathBuf; use std::result; diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs index 3314681b6981a..353ff6a57a5ef 100644 --- a/src/librustc_interface/lib.rs +++ b/src/librustc_interface/lib.rs @@ -7,6 +7,7 @@ #![cfg_attr(unix, feature(libc))] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![allow(unused_imports)] diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 6e4f2bf24e32f..17523aedffb58 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -21,7 +21,6 @@ use rustc_plugin; use rustc_privacy; use rustc_resolve; use rustc_typeck; -use std::collections::HashSet; use std::env; use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; use std::io::{self, Write}; @@ -109,6 +108,9 @@ pub fn create_session( let codegen_backend = get_codegen_backend(&sess); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); + if sess.unstable_options() { + rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess)); + } let mut cfg = config::build_configuration(&sess, config::to_crate_config(cfg)); add_configuration(&mut cfg, &sess, &*codegen_backend); diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 1fae931e9f1fd..541d779c477fc 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1036,7 +1036,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \ consider instead using an UnsafeCell"; - match get_transmute_from_to(cx, expr) { + match get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (&ty1.sty, &ty2.sty)) { Some((&ty::Ref(_, _, from_mt), &ty::Ref(_, _, to_mt))) => { if to_mt == hir::Mutability::MutMutable && from_mt == hir::Mutability::MutImmutable { @@ -1049,7 +1049,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { fn get_transmute_from_to<'a, 'tcx> (cx: &LateContext<'a, 'tcx>, expr: &hir::Expr) - -> Option<(&'tcx ty::TyKind<'tcx>, &'tcx ty::TyKind<'tcx>)> { + -> Option<(Ty<'tcx>, Ty<'tcx>)> { let def = if let hir::ExprKind::Path(ref qpath) = expr.node { cx.tables.qpath_def(qpath, expr.hir_id) } else { @@ -1062,7 +1062,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes { let sig = cx.tables.node_type(expr.hir_id).fn_sig(cx.tcx); let from = sig.inputs().skip_binder()[0]; let to = *sig.output().skip_binder(); - return Some((&from.sty, &to.sty)); + return Some((from, to)); } None } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index c9301a32d83c4..7e77962a16e0b 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -20,6 +20,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #[macro_use] extern crate rustc; @@ -61,6 +62,7 @@ use nonstandard_style::*; use builtin::*; use types::*; use unused::*; +use rustc::lint::internal::*; /// Useful for other parts of the compiler. pub use builtin::SoftLints; @@ -488,3 +490,18 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { store.register_removed("bad_repr", "replaced with a generic attribute input check"); } + +pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) { + store.register_early_pass(sess, false, false, box DefaultHashTypes::new()); + store.register_late_pass(sess, false, false, false, box TyKindUsage); + store.register_group( + sess, + false, + "internal", + None, + vec![ + LintId::of(DEFAULT_HASH_TYPES), + LintId::of(USAGE_OF_TY_TYKIND), + ], + ); +} diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 494a9bb73ed4b..c82985b549e8e 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -104,7 +104,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { report_bin_hex_error( cx, e, - ty::Int(t), + attr::IntType::SignedInt(t), repr_str, v, negative, @@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { report_bin_hex_error( cx, e, - ty::Uint(t), + attr::IntType::UnsignedInt(t), repr_str, lit_val, false, @@ -321,7 +321,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { // // No suggestion for: `isize`, `usize`. fn get_type_suggestion<'a>( - t: &ty::TyKind<'_>, + t: Ty<'_>, val: u128, negative: bool, ) -> Option { @@ -347,14 +347,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { } } } - match t { - &ty::Int(i) => find_fit!(i, val, negative, + match t.sty { + ty::Int(i) => find_fit!(i, val, negative, I8 => [U8] => [I16, I32, I64, I128], I16 => [U16] => [I32, I64, I128], I32 => [U32] => [I64, I128], I64 => [U64] => [I128], I128 => [U128] => []), - &ty::Uint(u) => find_fit!(u, val, negative, + ty::Uint(u) => find_fit!(u, val, negative, U8 => [U8, U16, U32, U64, U128] => [], U16 => [U16, U32, U64, U128] => [], U32 => [U32, U64, U128] => [], @@ -367,25 +367,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { fn report_bin_hex_error( cx: &LateContext<'_, '_>, expr: &hir::Expr, - ty: ty::TyKind<'_>, + ty: attr::IntType, repr_str: String, val: u128, negative: bool, ) { + let size = layout::Integer::from_attr(&cx.tcx, ty).size(); let (t, actually) = match ty { - ty::Int(t) => { - let ity = attr::IntType::SignedInt(t); - let size = layout::Integer::from_attr(&cx.tcx, ity).size(); + attr::IntType::SignedInt(t) => { let actually = sign_extend(val, size) as i128; (format!("{:?}", t), actually.to_string()) } - ty::Uint(t) => { - let ity = attr::IntType::UnsignedInt(t); - let size = layout::Integer::from_attr(&cx.tcx, ity).size(); + attr::IntType::UnsignedInt(t) => { let actually = truncate(val, size); (format!("{:?}", t), actually.to_string()) } - _ => bug!(), }; let mut err = cx.struct_span_lint( OVERFLOWING_LITERALS, @@ -398,7 +394,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits { repr_str, val, t, actually, t )); if let Some(sugg_ty) = - get_type_suggestion(&cx.tables.node_type(expr.hir_id).sty, val, negative) + get_type_suggestion(&cx.tables.node_type(expr.hir_id), val, negative) { if let Some(pos) = repr_str.chars().position(|c| c == 'i' || c == 'u') { let (sans_suffix, _) = repr_str.split_at(pos); diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 14416b5ce0759..4078171733fc3 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -14,6 +14,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] extern crate libc; #[allow(unused_extern_crates)] diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index c04a36fe9c69c..01c06739e2903 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -223,7 +223,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Some(ref name) => format!("`{}`", name), None => "value".to_owned(), }; - if let ty::TyKind::Param(param_ty) = ty.sty { + if let ty::Param(param_ty) = ty.sty { let tcx = self.infcx.tcx; let generics = tcx.generics_of(self.mir_def_id); let def_id = generics.type_param(¶m_ty, tcx).def_id; @@ -1529,7 +1529,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if let TerminatorKind::Call { func: Operand::Constant(box Constant { literal: ty::Const { - ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, + ty: &ty::TyS { sty: ty::FnDef(id, _), .. }, .. }, .. @@ -1547,7 +1547,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { }; debug!("add_moved_or_invoked_closure_note: closure={:?}", closure); - if let ty::TyKind::Closure(did, _) = self.mir.local_decls[closure].ty.sty { + if let ty::Closure(did, _) = self.mir.local_decls[closure].ty.sty { let hir_id = self.infcx.tcx.hir().as_local_hir_id(did).unwrap(); if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did) @@ -1570,7 +1570,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // Check if we are just moving a closure after it has been invoked. if let Some(target) = target { - if let ty::TyKind::Closure(did, _) = self.mir.local_decls[target].ty.sty { + if let ty::Closure(did, _) = self.mir.local_decls[target].ty.sty { let hir_id = self.infcx.tcx.hir().as_local_hir_id(did).unwrap(); if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did) @@ -1919,7 +1919,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } else { let ty = self.infcx.tcx.type_of(self.mir_def_id); match ty.sty { - ty::TyKind::FnDef(_, _) | ty::TyKind::FnPtr(_) => self.annotate_fn_sig( + ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig( self.mir_def_id, self.infcx.tcx.fn_sig(self.mir_def_id), ), @@ -2164,12 +2164,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // anything. let return_ty = sig.output(); match return_ty.skip_binder().sty { - ty::TyKind::Ref(return_region, _, _) if return_region.has_name() && !is_closure => { + ty::Ref(return_region, _, _) if return_region.has_name() && !is_closure => { // This is case 1 from above, return type is a named reference so we need to // search for relevant arguments. let mut arguments = Vec::new(); for (index, argument) in sig.inputs().skip_binder().iter().enumerate() { - if let ty::TyKind::Ref(argument_region, _, _) = argument.sty { + if let ty::Ref(argument_region, _, _) = argument.sty { if argument_region == return_region { // Need to use the `rustc::ty` types to compare against the // `return_region`. Then use the `rustc::hir` type to get only @@ -2206,7 +2206,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { return_span, }) } - ty::TyKind::Ref(_, _, _) if is_closure => { + ty::Ref(_, _, _) if is_closure => { // This is case 2 from above but only for closures, return type is anonymous // reference so we select // the first argument. @@ -2215,9 +2215,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // Closure arguments are wrapped in a tuple, so we need to get the first // from that. - if let ty::TyKind::Tuple(elems) = argument_ty.sty { + if let ty::Tuple(elems) = argument_ty.sty { let argument_ty = elems.first()?; - if let ty::TyKind::Ref(_, _, _) = argument_ty.sty { + if let ty::Ref(_, _, _) = argument_ty.sty { return Some(AnnotatedBorrowFnSignature::Closure { argument_ty, argument_span, @@ -2227,7 +2227,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { None } - ty::TyKind::Ref(_, _, _) => { + ty::Ref(_, _, _) => { // This is also case 2 from above but for functions, return type is still an // anonymous reference so we select the first argument. let argument_span = fn_decl.inputs.first()?.span; @@ -2238,7 +2238,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // We expect the first argument to be a reference. match argument_ty.sty { - ty::TyKind::Ref(_, _, _) => {} + ty::Ref(_, _, _) => {} _ => return None, } @@ -2366,8 +2366,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // this by hooking into the pretty printer and telling it to label the // lifetimes without names with the value `'0`. match ty.sty { - ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _) - | ty::TyKind::Ref( + ty::Ref(ty::RegionKind::ReLateBound(_, br), _, _) + | ty::Ref( ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }), _, _, @@ -2386,7 +2386,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS); let region = match ty.sty { - ty::TyKind::Ref(region, _, _) => { + ty::Ref(region, _, _) => { match region { ty::RegionKind::ReLateBound(_, br) | ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => { diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index a8c151a22eebc..bf297ae0debf0 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1741,7 +1741,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // no move out from an earlier location) then this is an attempt at initialization // of the union - we should error in that case. let tcx = this.infcx.tcx; - if let ty::TyKind::Adt(def, _) = base.ty(this.mir, tcx).ty.sty { + if let ty::Adt(def, _) = base.ty(this.mir, tcx).ty.sty { if def.is_union() { if this.move_data.path_map[mpi].iter().any(|moi| { this.move_data.moves[*moi].source.is_predecessor_of( diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index b6e7996586e4a..7efe1d83c2e5f 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -532,7 +532,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { if let StatementKind::Assign(_, box Rvalue::Ref(_, _, source)) = &stmt.kind { let ty = source.ty(self.mir, self.infcx.tcx).ty; let ty = match ty.sty { - ty::TyKind::Ref(_, ty, _) => ty, + ty::Ref(_, ty, _) => ty, _ => ty, }; debug!("borrowed_content_source: ty={:?}", ty); @@ -557,7 +557,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { let ty = source.ty(self.mir, self.infcx.tcx).ty; let ty = match ty.sty { - ty::TyKind::Ref(_, ty, _) => ty, + ty::Ref(_, ty, _) => ty, _ => ty, }; debug!("borrowed_content_source: ty={:?}", ty); diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 8a55a59b15b17..b780511315d81 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -5,7 +5,7 @@ use rustc::mir::{ Mutability, Operand, Place, PlaceBase, Projection, ProjectionElem, Static, StaticKind, }; use rustc::mir::{Terminator, TerminatorKind}; -use rustc::ty::{self, Const, DefIdTree, TyS, TyKind, TyCtxt}; +use rustc::ty::{self, Const, DefIdTree, TyS, TyCtxt}; use rustc_data_structures::indexed_vec::Idx; use syntax_pos::Span; use syntax_pos::symbol::keywords; @@ -261,7 +261,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { // Otherwise, check if the name is the self kewyord - in which case // we have an explicit self. Do the same thing in this case and check // for a `self: &mut Self` to suggest removing the `&mut`. - if let ty::TyKind::Ref( + if let ty::Ref( _, _, hir::Mutability::MutMutable ) = local_decl.ty.sty { true @@ -476,7 +476,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { func: Operand::Constant(box Constant { literal: Const { ty: &TyS { - sty: TyKind::FnDef(id, substs), + sty: ty::FnDef(id, substs), .. }, .. @@ -633,8 +633,8 @@ fn annotate_struct_field( field: &mir::Field, ) -> Option<(Span, String)> { // Expect our local to be a reference to a struct of some kind. - if let ty::TyKind::Ref(_, ty, _) = ty.sty { - if let ty::TyKind::Adt(def, _) = ty.sty { + if let ty::Ref(_, ty, _) = ty.sty { + if let ty::Adt(def, _) = ty.sty { let field = def.all_fields().nth(field.index())?; // Use the HIR types to construct the diagnostic message. let hir_id = tcx.hir().as_local_hir_id(field.did)?; diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs index 67b77605f3c92..e30938bc32659 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs @@ -589,7 +589,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // Check the type for a trait object. return match ty.sty { // `&dyn Trait` - ty::TyKind::Ref(_, ty, _) if ty.is_trait() => true, + ty::Ref(_, ty, _) if ty.is_trait() => true, // `Box` _ if ty.is_box() && ty.boxed_ty().is_trait() => true, // `dyn Trait` diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 3773f1a40c792..917e383cae827 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -583,7 +583,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { (self.to_error_region(fr), self.to_error_region(outlived_fr)) { if let Some(ty::TyS { - sty: ty::TyKind::Opaque(did, substs), + sty: ty::Opaque(did, substs), .. }) = infcx .tcx diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index b06ebbdbf34f6..ec5637d17072d 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -39,7 +39,7 @@ use rustc::traits::{ObligationCause, PredicateObligations}; use rustc::ty::fold::TypeFoldable; use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind, UserSubsts}; use rustc::ty::{ - self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind, UserType, + self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, UserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, UserTypeAnnotationIndex, }; @@ -746,7 +746,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { let (variant, substs) = match base_ty { PlaceTy { ty, variant_index: Some(variant_index) } => { match ty.sty { - ty::TyKind::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs), + ty::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs), _ => bug!("can't have downcast of non-adt type"), } } @@ -1136,7 +1136,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { category: ConstraintCategory, ) -> Fallible<()> { if let Err(terr) = self.sub_types(sub, sup, locations, category) { - if let TyKind::Opaque(..) = sup.sty { + if let ty::Opaque(..) = sup.sty { // When you have `let x: impl Foo = ...` in a closure, // the resulting inferend values are stored with the // def-id of the base function. @@ -1389,7 +1389,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } => { let place_type = place.ty(mir, tcx).ty; let adt = match place_type.sty { - TyKind::Adt(adt, _) if adt.is_enum() => adt, + ty::Adt(adt, _) if adt.is_enum() => adt, _ => { span_bug!( stmt.source_info.span, diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 011dc54f3b315..2471c01e3f3d0 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -425,7 +425,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { base, elem: ProjectionElem::Field(_, _), }) if match base.ty(self.builder.mir, self.builder.tcx).ty.sty { - ty::TyKind::Adt(def, _) if def.is_union() => true, + ty::Adt(def, _) if def.is_union() => true, _ => false, } => base, // Otherwise, lookup the place. diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 303ffcb3bfb3a..a9c521f59a96c 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -1754,7 +1754,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( // they should be pointing to memory is when they are subslices of nonzero // slices let (opt_ptr, n, ty) = match value.ty.sty { - ty::TyKind::Array(t, n) => { + ty::Array(t, n) => { match value.val { ConstValue::ByRef(ptr, alloc) => ( Some((ptr, alloc)), @@ -1767,7 +1767,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( ), } }, - ty::TyKind::Slice(t) => { + ty::Slice(t) => { match value.val { ConstValue::Slice(ptr, n) => ( ptr.to_ptr().ok().map(|ptr| ( diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index 50df676aea9fb..7ded973701edc 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -10,7 +10,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization::cmt_; use rustc::middle::region; use rustc::session::Session; -use rustc::ty::{self, Ty, TyCtxt, TyKind}; +use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::subst::{InternalSubsts, SubstsRef}; use rustc::lint; use rustc_errors::{Applicability, DiagnosticBuilder}; @@ -481,7 +481,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>( } let patterns = witnesses.iter().map(|p| (**p).clone()).collect::>>(); if patterns.len() < 4 { - for sp in maybe_point_at_variant(cx, &scrut_ty.sty, patterns.as_slice()) { + for sp in maybe_point_at_variant(cx, scrut_ty, patterns.as_slice()) { err.span_label(sp, "not covered"); } } @@ -498,11 +498,11 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>( fn maybe_point_at_variant( cx: &mut MatchCheckCtxt<'a, 'tcx>, - sty: &TyKind<'tcx>, + ty: Ty<'tcx>, patterns: &[Pattern<'_>], ) -> Vec { let mut covered = vec![]; - if let ty::Adt(def, _) = sty { + if let ty::Adt(def, _) = ty.sty { // Don't point at variants that have already been covered due to other patterns to avoid // visual clutter for pattern in patterns { @@ -518,7 +518,7 @@ fn maybe_point_at_variant( .map(|field_pattern| field_pattern.pattern.clone()) .collect::>(); covered.extend( - maybe_point_at_variant(cx, sty, subpatterns.as_slice()), + maybe_point_at_variant(cx, ty, subpatterns.as_slice()), ); } } @@ -526,7 +526,7 @@ fn maybe_point_at_variant( let subpatterns = subpatterns.iter() .map(|field_pattern| field_pattern.pattern.clone()) .collect::>(); - covered.extend(maybe_point_at_variant(cx, sty, subpatterns.as_slice())); + covered.extend(maybe_point_at_variant(cx, ty, subpatterns.as_slice())); } } } diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index c45e694ebf832..deeed9a0b9846 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -28,6 +28,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![allow(explicit_outlives_requirements)] #[macro_use] extern crate log; diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 6d6a3f9147269..572f7133cad84 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -4,7 +4,7 @@ use rustc::hir::intravisit::FnKind; use rustc::hir::map::blocks::FnLikeNode; use rustc::lint::builtin::UNCONDITIONAL_RECURSION; use rustc::mir::{self, Mir, TerminatorKind}; -use rustc::ty::{AssociatedItem, AssociatedItemContainer, Instance, TyCtxt, TyKind}; +use rustc::ty::{self, AssociatedItem, AssociatedItemContainer, Instance, TyCtxt}; use rustc::ty::subst::InternalSubsts; pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -86,7 +86,7 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, TerminatorKind::Call { ref func, .. } => { let func_ty = func.ty(mir, tcx); - if let TyKind::FnDef(fn_def_id, substs) = func_ty.sty { + if let ty::FnDef(fn_def_id, substs) = func_ty.sty { let (call_fn_id, call_substs) = if let Some(instance) = Instance::resolve(tcx, param_env, diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 7e925f65ee2d7..8187a81f0edab 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -2,7 +2,7 @@ use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, ProjectionElem, Rvalue, Local}; use rustc::mir::visit::{MutVisitor, Visitor}; -use rustc::ty::{TyCtxt, TyKind}; +use rustc::ty::{self, TyCtxt}; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::Idx; use std::mem; @@ -90,7 +90,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for OptimizationFinder<'b, 'a, 'tcx> { if let Rvalue::Len(ref place) = *rvalue { let place_ty = place.ty(&self.mir.local_decls, self.tcx).ty; - if let TyKind::Array(_, len) = place_ty.sty { + if let ty::Array(_, len) = place_ty.sty { let span = self.mir.source_info(location).span; let ty = self.tcx.types.usize; let constant = Constant { span, ty, literal: len, user_ty: None }; diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index dda9457cc8ccf..fd9d6bb5760b1 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -3,7 +3,7 @@ use rustc::hir::def_id::DefId; use rustc::middle::lang_items::LangItem; use rustc::mir::*; -use rustc::ty::{List, Ty, TyCtxt, TyKind}; +use rustc::ty::{self, List, Ty, TyCtxt}; use rustc_data_structures::indexed_vec::{Idx}; use crate::transform::{MirPass, MirSource}; @@ -183,8 +183,8 @@ impl RhsKind { fn sign_of_128bit(ty: Ty<'_>) -> Option { match ty.sty { - TyKind::Int(syntax::ast::IntTy::I128) => Some(true), - TyKind::Uint(syntax::ast::UintTy::U128) => Some(false), + ty::Int(syntax::ast::IntTy::I128) => Some(true), + ty::Uint(syntax::ast::UintTy::U128) => Some(false), _ => None, } } diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index ff2e345d08401..20442a4a566ec 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -12,6 +12,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #[macro_use] extern crate rustc; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 030883c0159fb..9a8970b2935e0 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1,6 +1,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(nll)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 1934f800af757..5216156c0cab8 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -8,6 +8,7 @@ #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] pub use rustc::hir::def::{Namespace, PerNS}; diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 898ea62046d48..a363fe1141891 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -2,6 +2,7 @@ #![feature(custom_attribute)] #![feature(nll)] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![allow(unused_attributes)] #![recursion_limit="256"] diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index efffb1985728d..f1812c20dccde 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -16,6 +16,7 @@ #![feature(step_trait)] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #[macro_use] extern crate log; diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index d52a976981db0..bc034e1fb1627 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -2,6 +2,7 @@ //! the guts are broken up into modules; see the comments in those modules. #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(crate_visibility_modifier)] #![feature(in_band_lifetimes)] diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index fba4414c1275c..8805dade40e4c 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -99,11 +99,6 @@ enum GenericArgPosition { MethodCall, } -/// Dummy type used for the `Self` of a `TraitRef` created for converting -/// a trait object, and which gets removed in `ExistentialTraitRef`. -/// This type must not appear anywhere in other converted types. -const TRAIT_OBJECT_DUMMY_SELF: ty::TyKind<'static> = ty::Infer(ty::FreshTy(0)); - impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { pub fn ast_region_to_region(&self, lifetime: &hir::Lifetime, @@ -595,7 +590,9 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { infer_types, ); - let is_object = self_ty.map_or(false, |ty| ty.sty == TRAIT_OBJECT_DUMMY_SELF); + let is_object = self_ty.map_or(false, |ty| { + ty == self.tcx().types.trait_object_dummy_self + }); let default_needs_object_self = |param: &ty::GenericParamDef| { if let GenericParamDefKind::Type { has_default, .. } = param.kind { if is_object && has_default { @@ -956,10 +953,10 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { } /// Transform a `PolyTraitRef` into a `PolyExistentialTraitRef` by - /// removing the dummy `Self` type (`TRAIT_OBJECT_DUMMY_SELF`). + /// removing the dummy `Self` type (`trait_object_dummy_self`). fn trait_ref_to_existential(&self, trait_ref: ty::TraitRef<'tcx>) -> ty::ExistentialTraitRef<'tcx> { - if trait_ref.self_ty().sty != TRAIT_OBJECT_DUMMY_SELF { + if trait_ref.self_ty() != self.tcx().types.trait_object_dummy_self { bug!("trait_ref_to_existential called on {:?} with non-dummy Self", trait_ref); } ty::ExistentialTraitRef::erase_self_ty(self.tcx(), trait_ref) @@ -980,7 +977,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { } let mut projection_bounds = Vec::new(); - let dummy_self = tcx.mk_ty(TRAIT_OBJECT_DUMMY_SELF); + let dummy_self = self.tcx().types.trait_object_dummy_self; let (principal, potential_assoc_types) = self.instantiate_poly_trait_ref( &trait_bounds[0], dummy_self, @@ -1030,7 +1027,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { } ty::Predicate::Projection(pred) => { // A `Self` within the original bound will be substituted with a - // `TRAIT_OBJECT_DUMMY_SELF`, so check for that. + // `trait_object_dummy_self`, so check for that. let references_self = pred.skip_binder().ty.walk().any(|t| t == dummy_self); @@ -1130,7 +1127,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { err.emit(); } - // Erase the `dummy_self` (`TRAIT_OBJECT_DUMMY_SELF`) used above. + // Erase the `dummy_self` (`trait_object_dummy_self`) used above. let existential_principal = principal.map_bound(|trait_ref| { self.trait_ref_to_existential(trait_ref) }); diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 3579810b8d75f..d108e7c3107af 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -3,7 +3,7 @@ use crate::constrained_generic_params::{identify_constrained_generic_params, Par use crate::hir::def_id::DefId; use rustc::traits::{self, ObligationCauseCode}; -use rustc::ty::{self, Lift, Ty, TyCtxt, TyKind, GenericParamDefKind, TypeFoldable, ToPredicate}; +use rustc::ty::{self, Lift, Ty, TyCtxt, GenericParamDefKind, TypeFoldable, ToPredicate}; use rustc::ty::subst::{Subst, InternalSubsts}; use rustc::util::nodemap::{FxHashSet, FxHashMap}; use rustc::mir::interpret::ConstValue; @@ -354,7 +354,7 @@ fn check_item_type<'a, 'tcx>( let mut forbid_unsized = true; if allow_foreign_ty { - if let TyKind::Foreign(_) = fcx.tcx.struct_tail(item_ty).sty { + if let ty::Foreign(_) = fcx.tcx.struct_tail(item_ty).sty { forbid_unsized = false; } } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 1fa16352b867a..4a7b1e67366e8 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -71,6 +71,7 @@ This API is completely unstable and subject to change. #![recursion_limit="256"] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![allow(explicit_outlives_requirements)] #[macro_use] extern crate log; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 2ebb465d53dbe..6cb937d9216ac 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -1,4 +1,5 @@ #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/")] diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index a6145d5dcb38c..9905b981395c0 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -8,6 +8,7 @@ test(attr(deny(warnings))))] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(crate_visibility_modifier)] #![feature(label_break_value)] diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index aa472eee3cab3..ee0b86963f31d 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -3,6 +3,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(in_band_lifetimes)] #![feature(proc_macro_diagnostic)] diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 48d087ee43cd5..db1543ff13f7e 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -7,6 +7,7 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(rust_2018_idioms)] +#![cfg_attr(not(stage0), deny(internal))] #![feature(const_fn)] #![feature(crate_visibility_modifier)] diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.rs b/src/test/ui-fulldeps/internal-lints/default_hash_types.rs new file mode 100644 index 0000000000000..3264099c876d0 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.rs @@ -0,0 +1,22 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] + +extern crate rustc_data_structures; + +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use std::collections::{HashMap, HashSet}; + +#[deny(default_hash_types)] +fn main() { + let _map: HashMap = HashMap::default(); + //~^ ERROR Prefer FxHashMap over HashMap, it has better performance + //~^^ ERROR Prefer FxHashMap over HashMap, it has better performance + let _set: HashSet = HashSet::default(); + //~^ ERROR Prefer FxHashSet over HashSet, it has better performance + //~^^ ERROR Prefer FxHashSet over HashSet, it has better performance + + // test that the lint doesn't also match the Fx variants themselves + let _fx_map: FxHashMap = FxHashMap::default(); + let _fx_set: FxHashSet = FxHashSet::default(); +} diff --git a/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr new file mode 100644 index 0000000000000..64f322cb0c165 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/default_hash_types.stderr @@ -0,0 +1,39 @@ +error: Prefer FxHashMap over HashMap, it has better performance + --> $DIR/default_hash_types.rs:12:15 + | +LL | let _map: HashMap = HashMap::default(); + | ^^^^^^^ help: use: `FxHashMap` + | +note: lint level defined here + --> $DIR/default_hash_types.rs:10:8 + | +LL | #[deny(default_hash_types)] + | ^^^^^^^^^^^^^^^^^^ + = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary + +error: Prefer FxHashMap over HashMap, it has better performance + --> $DIR/default_hash_types.rs:12:41 + | +LL | let _map: HashMap = HashMap::default(); + | ^^^^^^^ help: use: `FxHashMap` + | + = note: a `use rustc_data_structures::fx::FxHashMap` may be necessary + +error: Prefer FxHashSet over HashSet, it has better performance + --> $DIR/default_hash_types.rs:15:15 + | +LL | let _set: HashSet = HashSet::default(); + | ^^^^^^^ help: use: `FxHashSet` + | + = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary + +error: Prefer FxHashSet over HashSet, it has better performance + --> $DIR/default_hash_types.rs:15:33 + | +LL | let _set: HashSet = HashSet::default(); + | ^^^^^^^ help: use: `FxHashSet` + | + = note: a `use rustc_data_structures::fx::FxHashSet` may be necessary + +error: aborting due to 4 previous errors + diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs new file mode 100644 index 0000000000000..dba0db69b7f39 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -0,0 +1,49 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] + +extern crate rustc; + +use rustc::ty::{self, Ty, TyKind}; + +#[deny(usage_of_ty_tykind)] +fn main() { + let sty = TyKind::Bool; //~ ERROR usage of `ty::TyKind::` + + match sty { + TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Char => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Str => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Never => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::UnnormalizedProjection(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::` + TyKind::Error => (), //~ ERROR usage of `ty::TyKind::` + } + + if let ty::Int(int_ty) = sty {} + + if let TyKind::Int(int_ty) = sty {} //~ ERROR usage of `ty::TyKind::` + + fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind` +} diff --git a/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr new file mode 100644 index 0000000000000..4e94af12453cd --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -0,0 +1,196 @@ +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:11:15 + | +LL | let sty = TyKind::Bool; + | ^^^^^^ help: try using ty:: directly: `ty` + | +note: lint level defined here + --> $DIR/ty_tykind_usage.rs:9:8 + | +LL | #[deny(usage_of_ty_tykind)] + | ^^^^^^^^^^^^^^^^^^ + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:14:9 + | +LL | TyKind::Bool => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:15:9 + | +LL | TyKind::Char => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:16:9 + | +LL | TyKind::Int(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:17:9 + | +LL | TyKind::Uint(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:18:9 + | +LL | TyKind::Float(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:19:9 + | +LL | TyKind::Adt(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:20:9 + | +LL | TyKind::Foreign(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:21:9 + | +LL | TyKind::Str => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:22:9 + | +LL | TyKind::Array(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:23:9 + | +LL | TyKind::Slice(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:24:9 + | +LL | TyKind::RawPtr(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:25:9 + | +LL | TyKind::Ref(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:26:9 + | +LL | TyKind::FnDef(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:27:9 + | +LL | TyKind::FnPtr(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:28:9 + | +LL | TyKind::Dynamic(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:29:9 + | +LL | TyKind::Closure(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:30:9 + | +LL | TyKind::Generator(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:31:9 + | +LL | TyKind::GeneratorWitness(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:32:9 + | +LL | TyKind::Never => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:33:9 + | +LL | TyKind::Tuple(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:34:9 + | +LL | TyKind::Projection(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:35:9 + | +LL | TyKind::UnnormalizedProjection(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:36:9 + | +LL | TyKind::Opaque(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:37:9 + | +LL | TyKind::Param(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:38:9 + | +LL | TyKind::Bound(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:39:9 + | +LL | TyKind::Placeholder(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:40:9 + | +LL | TyKind::Infer(..) => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:41:9 + | +LL | TyKind::Error => (), + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind::` + --> $DIR/ty_tykind_usage.rs:46:12 + | +LL | if let TyKind::Int(int_ty) = sty {} + | ^^^^^^ help: try using ty:: directly: `ty` + +error: usage of `ty::TyKind` + --> $DIR/ty_tykind_usage.rs:48:24 + | +LL | fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} + | ^^^^^^^^^^ + | + = help: try using `ty::Ty` instead + +error: aborting due to 31 previous errors +