Rollup merge of #59316 - flip1995:internal_lints_take_2, r=oli-obk
Internal lints take 2 cc #58701 cc #49509 TODO: Add `#![warn(internal)]` to crates (and fix violations) Crates depending on `rustc_data_structures` - [x] librustc_resolve - [x] librustc_driver - [x] librustc_passes - [x] librustc_metadata - [x] librustc_interface - [x] librustc_save_analysis - [x] librustc_lint - [x] librustc - [x] librustc_incremental - [x] librustc_codegen_utils - [x] libarena - [x] librustc_target - [x] librustc_allocator - [x] librustc_privacy - [x] librustc_traits - [x] librustc_borrowck - [x] libsyntax - [x] librustc_codegen_ssa - [x] libsyntax_ext - [x] librustc_errors - [x] librustc_mir - [x] libsyntax_pos - [x] librustc_typeck Crates with `feature(rustc_private)` Excluding crates, which are already in the list above. Also excluding tools and tests. - [ ] ~~libstd~~ - [x] libfmt_macros - [x] librustdoc r? @oli-obk
This commit is contained in:
commit
dcccab56ba
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -9,6 +9,7 @@
|
||||
test(attr(deny(warnings))))]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
#![feature(nll)]
|
||||
#![feature(rustc_private)]
|
||||
|
@ -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<LocalInternedString>;
|
||||
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<Self::Region, Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_type(self, _ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_dyn_existential(
|
||||
self,
|
||||
_predicates: &'tcx ty::List<ty::ExistentialPredicate<'tcx>>,
|
||||
) -> Result<Self::DynExistential, Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn path_crate(self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
|
||||
Ok(vec![self.tcx.original_crate_name(cnum).as_str()])
|
||||
}
|
||||
|
||||
fn path_qualified(
|
||||
self,
|
||||
self_ty: Ty<'tcx>,
|
||||
trait_ref: Option<ty::TraitRef<'tcx>>,
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
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<Self::Path, Self::Error>,
|
||||
_disambiguated_data: &DisambiguatedDefPathData,
|
||||
self_ty: Ty<'tcx>,
|
||||
trait_ref: Option<ty::TraitRef<'tcx>>,
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
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!("<impl {} for {}>", trait_ref, self_ty)).as_str()
|
||||
},
|
||||
None => Symbol::intern(&format!("<impl {}>", self_ty)).as_str(),
|
||||
});
|
||||
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
fn path_append(
|
||||
self,
|
||||
print_prefix: impl FnOnce(Self) -> Result<Self::Path, Self::Error>,
|
||||
disambiguated_data: &DisambiguatedDefPathData,
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
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<Self::Path, Self::Error>,
|
||||
_args: &[Kind<'tcx>],
|
||||
) -> Result<Self::Path, Self::Error> {
|
||||
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 {}
|
||||
|
@ -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<StableHashingContext<'a>> 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<W>,
|
||||
blanket_impls: &[DefId],
|
||||
non_blanket_impls: &HashMap<fast_reject::SimplifiedType, Vec<DefId>, R>)
|
||||
where W: StableHasherResult,
|
||||
R: std_hash::BuildHasher,
|
||||
non_blanket_impls: &FxHashMap<fast_reject::SimplifiedType, Vec<DefId>>)
|
||||
where W: StableHasherResult
|
||||
{
|
||||
{
|
||||
let mut blanket_impls: SmallVec<[_; 8]> = blanket_impls
|
||||
|
@ -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<T>` 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,
|
||||
}
|
||||
}
|
||||
|
@ -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)]
|
||||
|
127
src/librustc/lint/internal.rs
Normal file
127
src/librustc/lint/internal.rs
Normal file
@ -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<String, String>,
|
||||
}
|
||||
|
||||
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::<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) {
|
||||
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
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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) => {
|
||||
|
@ -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),
|
||||
|
@ -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::*;
|
||||
|
@ -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<K, V, S> MemoizationMap for RefCell<HashMap<K,V,S>>
|
||||
where K: Hash+Eq+Clone, V: Clone, S: BuildHasher
|
||||
impl<K, V> MemoizationMap for RefCell<FxHashMap<K,V>>
|
||||
where K: Hash+Eq+Clone, V: Clone
|
||||
{
|
||||
type Key = K;
|
||||
type Value = V;
|
||||
|
@ -2,6 +2,7 @@
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
pub mod expand;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
#![feature(nll)]
|
||||
|
||||
|
@ -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"]
|
||||
|
@ -16,6 +16,7 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
pub extern crate getopts;
|
||||
#[cfg(unix)]
|
||||
|
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -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;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#![cfg_attr(unix, feature(libc))]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
#![allow(unused_imports)]
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -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<String> {
|
||||
@ -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);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
extern crate libc;
|
||||
#[allow(unused_extern_crates)]
|
||||
|
@ -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, .. }) => {
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
@ -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)?;
|
||||
|
@ -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<dyn Trait>`
|
||||
_ if ty.is_box() && ty.boxed_ty().is_trait() => true,
|
||||
// `dyn Trait`
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
|
@ -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| (
|
||||
|
@ -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::<Vec<Pattern<'_>>>();
|
||||
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<Span> {
|
||||
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::<Vec<_>>();
|
||||
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::<Vec<_>>();
|
||||
covered.extend(maybe_point_at_variant(cx, sty, subpatterns.as_slice()));
|
||||
covered.extend(maybe_point_at_variant(cx, ty, subpatterns.as_slice()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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 };
|
||||
|
@ -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<bool> {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
|
@ -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)]
|
||||
|
@ -8,6 +8,7 @@
|
||||
#![recursion_limit="256"]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
pub use rustc::hir::def::{Namespace, PerNS};
|
||||
|
||||
|
@ -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"]
|
||||
|
@ -16,6 +16,7 @@
|
||||
#![feature(step_trait)]
|
||||
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![cfg_attr(not(stage0), deny(internal))]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
||||
|
@ -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)]
|
||||
|
@ -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)
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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/")]
|
||||
|
@ -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)]
|
||||
|
@ -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)]
|
||||
|
@ -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)]
|
||||
|
22
src/test/ui-fulldeps/internal-lints/default_hash_types.rs
Normal file
22
src/test/ui-fulldeps/internal-lints/default_hash_types.rs
Normal file
@ -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<String, String> = HashMap::default();
|
||||
//~^ ERROR Prefer FxHashMap over HashMap, it has better performance
|
||||
//~^^ ERROR Prefer FxHashMap over HashMap, it has better performance
|
||||
let _set: HashSet<String> = 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<String, String> = FxHashMap::default();
|
||||
let _fx_set: FxHashSet<String> = FxHashSet::default();
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
error: Prefer FxHashMap over HashMap, it has better performance
|
||||
--> $DIR/default_hash_types.rs:12:15
|
||||
|
|
||||
LL | let _map: HashMap<String, String> = 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<String, String> = 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<String> = 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<String> = HashSet::default();
|
||||
| ^^^^^^^ help: use: `FxHashSet`
|
||||
|
|
||||
= note: a `use rustc_data_structures::fx::FxHashSet` may be necessary
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
49
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
Normal file
49
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
Normal file
@ -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::<kind>`
|
||||
|
||||
match sty {
|
||||
TyKind::Bool => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::UnnormalizedProjection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
TyKind::Error => (), //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
}
|
||||
|
||||
if let ty::Int(int_ty) = sty {}
|
||||
|
||||
if let TyKind::Int(int_ty) = sty {} //~ ERROR usage of `ty::TyKind::<kind>`
|
||||
|
||||
fn ty_kind(ty_bad: TyKind<'_>, ty_good: Ty<'_>) {} //~ ERROR usage of `ty::TyKind`
|
||||
}
|
196
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
Normal file
196
src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
Normal file
@ -0,0 +1,196 @@
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:11:15
|
||||
|
|
||||
LL | let sty = TyKind::Bool;
|
||||
| ^^^^^^ help: try using ty::<kind> 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::<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>`
|
||||
--> $DIR/ty_tykind_usage.rs:16:9
|
||||
|
|
||||
LL | TyKind::Int(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:17:9
|
||||
|
|
||||
LL | TyKind::Uint(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:18:9
|
||||
|
|
||||
LL | TyKind::Float(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:19:9
|
||||
|
|
||||
LL | TyKind::Adt(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:20:9
|
||||
|
|
||||
LL | TyKind::Foreign(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:21:9
|
||||
|
|
||||
LL | TyKind::Str => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:22:9
|
||||
|
|
||||
LL | TyKind::Array(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:23:9
|
||||
|
|
||||
LL | TyKind::Slice(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:24:9
|
||||
|
|
||||
LL | TyKind::RawPtr(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:25:9
|
||||
|
|
||||
LL | TyKind::Ref(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:26:9
|
||||
|
|
||||
LL | TyKind::FnDef(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:27:9
|
||||
|
|
||||
LL | TyKind::FnPtr(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:28:9
|
||||
|
|
||||
LL | TyKind::Dynamic(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:29:9
|
||||
|
|
||||
LL | TyKind::Closure(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:30:9
|
||||
|
|
||||
LL | TyKind::Generator(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:31:9
|
||||
|
|
||||
LL | TyKind::GeneratorWitness(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:32:9
|
||||
|
|
||||
LL | TyKind::Never => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:33:9
|
||||
|
|
||||
LL | TyKind::Tuple(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:34:9
|
||||
|
|
||||
LL | TyKind::Projection(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:35:9
|
||||
|
|
||||
LL | TyKind::UnnormalizedProjection(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:36:9
|
||||
|
|
||||
LL | TyKind::Opaque(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:37:9
|
||||
|
|
||||
LL | TyKind::Param(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:38:9
|
||||
|
|
||||
LL | TyKind::Bound(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:39:9
|
||||
|
|
||||
LL | TyKind::Placeholder(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:40:9
|
||||
|
|
||||
LL | TyKind::Infer(..) => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:41:9
|
||||
|
|
||||
LL | TyKind::Error => (),
|
||||
| ^^^^^^ help: try using ty::<kind> directly: `ty`
|
||||
|
||||
error: usage of `ty::TyKind::<kind>`
|
||||
--> $DIR/ty_tykind_usage.rs:46:12
|
||||
|
|
||||
LL | if let TyKind::Int(int_ty) = sty {}
|
||||
| ^^^^^^ help: try using ty::<kind> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user