Skip to content

[WIP] Internal lints #58701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions src/librustc/hir/def_id.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::ty;
use crate::ty::TyCtxt;
use crate::ty::{self, TyCtxt};
use crate::hir::map::definitions::FIRST_FREE_HIGH_DEF_INDEX;
use rustc_data_structures::indexed_vec::Idx;
use serialize;
use std::fmt;
use std::u32;
use syntax::symbol;

newtype_index! {
pub struct CrateId {
@@ -252,6 +252,33 @@ impl DefId {
format!("module `{}`", tcx.item_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(self, tcx: TyCtxt<'_, '_, '_>, path: &[&str]) -> bool {
#[derive(Debug)]
struct AbsolutePathBuffer {
names: Vec<symbol::LocalInternedString>,
}

impl ty::item_path::ItemPathBuffer for AbsolutePathBuffer {
fn root_mode(&self) -> &ty::item_path::RootMode {
const ABSOLUTE: &ty::item_path::RootMode = &ty::item_path::RootMode::Absolute;
ABSOLUTE
}

fn push(&mut self, text: &str) {
self.names.push(symbol::Symbol::intern(text).as_str());
}
}

let mut apb = AbsolutePathBuffer { names: vec![] };

tcx.push_item_path(&mut apb, self, false);

apb.names.len() == path.len()
&& apb.names.into_iter().zip(path.iter()).all(|(a, &b)| *a == *b)
}
}

impl serialize::UseSpecializedEncodable for DefId {}
142 changes: 142 additions & 0 deletions src/librustc/lint/internal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//! Some lints that are only useful in the compiler or crates that use compiler internals, such as
//! Clippy.

use crate::hir::{HirId, Path, 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,
Warn,
"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,
Warn,
"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_iter = path.segments.iter().rev().skip(1).rev();

if let Some(last) = segments_iter.clone().last() {
if last.ident.as_str() == "TyKind" {
let path = Path {
span: path.span.with_hi(last.ident.span.hi()),
def: path.def,
segments: segments_iter.cloned().collect(),
};

if let Some(def) = last.def {
if def
.def_id()
.match_path(cx.tcx, &["rustc", "ty", "sty", "TyKind"])
{
cx.struct_span_lint(
USAGE_OF_TY_TYKIND,
path.span,
"usage of `ty::TyKind::<kind>`",
)
.span_suggestion(
path.span,
"try using ty::<kind> directly",
"ty".to_string(),
Applicability::MaybeIncorrect, // ty maybe needs an import
)
.emit();
}
}
}
}
}

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 last.ident.as_str() == "TyKind" {
if let Some(def) = last.def {
if def
.def_id()
.match_path(cx.tcx, &["rustc", "ty", "sty", "TyKind"])
{
cx.struct_span_lint(
USAGE_OF_TY_TYKIND,
path.span,
"usage of `ty::TyKind`",
)
.help("try using `ty::Ty` instead")
.emit();
}
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
@@ -563,6 +563,7 @@ impl_stable_hash_for!(enum self::LintSource {
pub type LevelSource = (Level, LintSource);

pub mod builtin;
pub mod internal;
mod context;
mod levels;

3 changes: 3 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
@@ -1410,6 +1410,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
merge_functions: Option<MergeFunctions> = (None, parse_merge_functions, [TRACKED],
"control the operation of the MergeFunctions LLVM pass, taking
the same values as the target option of the same name"),
internal_lints: bool = (false, parse_bool, [UNTRACKED],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a new flag we could just reuse the -Zunstable-features flag. If the lints are allow by default, we can add deny attributes to crates in steps, and even with cfg_attr to only turn them on after stage0. That will get us around having to touch bootstrap

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that is way easier. I'll try that ASAP.

"allow internal rustc lints. These lints are probably only useful in the
compiler directly or in crates, that use rustc internals, such as Clippy."),
}

pub fn default_lib_output() -> CrateType {
9 changes: 9 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
@@ -498,6 +498,9 @@ fn run_compiler_with_pool<'a>(
let codegen_backend = get_codegen_backend(&sess);

rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess));
}

let mut cfg = config::build_configuration(&sess, cfg);
target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
@@ -815,10 +818,16 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
if sopts.describe_lints {
let mut ls = lint::LintStore::new();
rustc_lint::register_builtins(&mut ls, Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut ls, Some(&sess));
}
describe_lints(&sess, &ls, false);
return None;
}
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess));
}
let mut cfg = config::build_configuration(&sess, cfg.clone());
let codegen_backend = get_codegen_backend(&sess);
target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
3 changes: 3 additions & 0 deletions src/librustc_driver/test.rs
Original file line number Diff line number Diff line change
@@ -114,6 +114,9 @@ fn test_env_with_pool<F>(
);
let cstore = CStore::new(::get_codegen_backend(&sess).metadata_loader());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess));
}
let input = config::Input::Str {
name: FileName::anon_source_code(&source_string),
input: source_string.to_string(),
16 changes: 16 additions & 0 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
@@ -58,6 +58,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;
@@ -405,3 +406,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, box TyKindUsage);
store.register_group(
sess,
false,
"internal",
None,
vec![
LintId::of(DEFAULT_HASH_TYPES),
LintId::of(USAGE_OF_TY_TYKIND),
],
);
}
3 changes: 3 additions & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
@@ -428,6 +428,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
let codegen_backend = rustc_driver::get_codegen_backend(&sess);
let cstore = Rc::new(CStore::new(codegen_backend.metadata_loader()));
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess));
}

let mut cfg = config::build_configuration(&sess, config::parse_cfgspecs(cfgs));
target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
6 changes: 6 additions & 0 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
@@ -75,6 +75,9 @@ pub fn run(mut options: Options) -> isize {
let codegen_backend = rustc_driver::get_codegen_backend(&sess);
let cstore = CStore::new(codegen_backend.metadata_loader());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess));
}

let mut cfg = config::build_configuration(&sess,
config::parse_cfgspecs(options.cfgs.clone()));
@@ -279,6 +282,9 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
let codegen_backend = rustc_driver::get_codegen_backend(&sess);
let cstore = CStore::new(codegen_backend.metadata_loader());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
if sess.opts.debugging_opts.internal_lints {
rustc_lint::register_internals(&mut sess.lint_store.borrow_mut(), Some(&sess));
}

let outdir = Mutex::new(
if let Some(mut path) = persist_doctests {
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/failed-doctest-output.stdout
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope
3 | no
| ^^ not found in this scope

thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:357:13
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ----
@@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

', src/librustdoc/test.rs:372:17
', src/librustdoc/test.rs:378:17


failures:
24 changes: 24 additions & 0 deletions src/test/ui-fulldeps/internal-lints/default_hash_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// compile-flags: -Z internal-lints

#![feature(rustc_private)]

extern crate rustc_data_structures;

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use std::collections::{HashMap, HashSet};
//~^ WARNING Prefer FxHashMap over HashMap, it has better performance
//~^^ WARNING Prefer FxHashSet over HashSet, it has better performance

#[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();
}
56 changes: 56 additions & 0 deletions src/test/ui-fulldeps/internal-lints/default_hash_types.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
warning: Prefer FxHashMap over HashMap, it has better performance
--> $DIR/default_hash_types.rs:8:24
|
LL | use std::collections::{HashMap, HashSet};
| ^^^^^^^ help: use: `FxHashMap`
|
= note: #[warn(default_hash_types)] on by default
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary

warning: Prefer FxHashSet over HashSet, it has better performance
--> $DIR/default_hash_types.rs:8:33
|
LL | use std::collections::{HashMap, HashSet};
| ^^^^^^^ help: use: `FxHashSet`
|
= note: a `use rustc_data_structures::fx::FxHashSet` may be necessary

error: Prefer FxHashMap over HashMap, it has better performance
--> $DIR/default_hash_types.rs:14:15
|
LL | let _map: HashMap<String, String> = HashMap::default();
| ^^^^^^^ help: use: `FxHashMap`
|
note: lint level defined here
--> $DIR/default_hash_types.rs:12: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:14: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:17: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:17: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 changes: 49 additions & 0 deletions src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// compile-flags: -Z internal-lints

#![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 changes: 196 additions & 0 deletions src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:11:15
|
LL | let sty = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ 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 => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:15:9
|
LL | TyKind::Char => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:16:9
|
LL | TyKind::Int(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:17:9
|
LL | TyKind::Uint(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:18:9
|
LL | TyKind::Float(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:19:9
|
LL | TyKind::Adt(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:20:9
|
LL | TyKind::Foreign(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:21:9
|
LL | TyKind::Str => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:22:9
|
LL | TyKind::Array(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:23:9
|
LL | TyKind::Slice(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:24:9
|
LL | TyKind::RawPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:25:9
|
LL | TyKind::Ref(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:26:9
|
LL | TyKind::FnDef(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:27:9
|
LL | TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:28:9
|
LL | TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:29:9
|
LL | TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:30:9
|
LL | TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:31:9
|
LL | TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:32:9
|
LL | TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:33:9
|
LL | TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:34:9
|
LL | TyKind::Projection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:35:9
|
LL | TyKind::UnnormalizedProjection(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:36:9
|
LL | TyKind::Opaque(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:37:9
|
LL | TyKind::Param(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:38:9
|
LL | TyKind::Bound(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:39:9
|
LL | TyKind::Placeholder(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:40:9
|
LL | TyKind::Infer(..) => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ help: try using ty::<kind> directly: `ty`

error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:41:9
|
LL | TyKind::Error => (), //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ 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 {} //~ ERROR usage of `ty::TyKind::<kind>`
| ^^^^^^ 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<'_>) {} //~ ERROR usage of `ty::TyKind`
| ^^^^^^^^^^
|
= help: try using `ty::Ty` instead

error: aborting due to 31 previous errors

8 changes: 8 additions & 0 deletions src/test/ui-fulldeps/internal-lints/without_compile_flag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// compile-pass

#![allow(unused)]

use std::collections::HashMap;

#[deny(default_hash_types)] //~ WARNING unknown lint: `default_hash_types`
fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: unknown lint: `default_hash_types`
--> $DIR/without_compile_flag.rs:7:8
|
LL | #[deny(default_hash_types)] //~ WARNING unknown lint: `default_hash_types`
| ^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unknown_lints)] on by default