Turn internal lints into tool lints

This commit is contained in:
flip1995 2019-06-24 10:43:51 +02:00
parent 08b81f2d07
commit 7de6f54728
No known key found for this signature in database
GPG Key ID: 693086869D506637
18 changed files with 47 additions and 37 deletions

View File

@ -306,10 +306,14 @@ fn main() {
}
// This is required for internal lints.
cmd.arg("-Zunstable-options");
if let Some(crate_name) = args.windows(2).find(|a| &*a[0] == "--crate-name") {
let crate_name = crate_name[1].to_string_lossy();
if crate_name.starts_with("rustc") || crate_name.starts_with("syntax") {
cmd.arg("-Zunstable-options");
if crate_name.starts_with("rustc")
|| crate_name.starts_with("syntax")
|| crate_name == "arena"
|| crate_name == "fmt_macros"
{
if stage != "0" {
cmd.arg("-Wrustc::internal");
}

View File

@ -1341,7 +1341,7 @@ struct LateLintPassObjects<'a> {
lints: &'a mut [LateLintPassObject],
}
#[cfg_attr(not(stage0), allow(lint_pass_impl_without_macro))]
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
impl LintPass for LateLintPassObjects<'_> {
fn name(&self) -> &'static str {
panic!()
@ -1511,7 +1511,7 @@ struct EarlyLintPassObjects<'a> {
lints: &'a mut [EarlyLintPassObject],
}
#[cfg_attr(not(stage0), allow(lint_pass_impl_without_macro))]
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
impl LintPass for EarlyLintPassObjects<'_> {
fn name(&self) -> &'static str {
panic!()

View File

@ -11,8 +11,8 @@ use syntax::ast::{Ident, Item, ItemKind};
use syntax::symbol::{sym, Symbol};
use syntax_pos::ExpnInfo;
declare_lint! {
pub DEFAULT_HASH_TYPES,
declare_tool_lint! {
pub rustc::DEFAULT_HASH_TYPES,
Allow,
"forbid HashMap and HashSet and suggest the FxHash* variants"
}
@ -23,7 +23,7 @@ pub struct DefaultHashTypes {
impl DefaultHashTypes {
// we are allowed to use `HashMap` and `HashSet` as identifiers for implementing the lint itself
#[allow(default_hash_types)]
#[cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
pub fn new() -> Self {
let mut map = FxHashMap::default();
map.insert(sym::HashMap, sym::FxHashMap);
@ -51,20 +51,20 @@ impl EarlyLintPass for DefaultHashTypes {
}
}
declare_lint! {
pub USAGE_OF_TY_TYKIND,
declare_tool_lint! {
pub rustc::USAGE_OF_TY_TYKIND,
Allow,
"usage of `ty::TyKind` outside of the `ty::sty` module"
}
declare_lint! {
pub TY_PASS_BY_REFERENCE,
declare_tool_lint! {
pub rustc::TY_PASS_BY_REFERENCE,
Allow,
"passing `Ty` or `TyCtxt` by reference"
}
declare_lint! {
pub USAGE_OF_QUALIFIED_TY,
declare_tool_lint! {
pub rustc::USAGE_OF_QUALIFIED_TY,
Allow,
"using `ty::{Ty,TyCtxt}` instead of importing it"
}
@ -215,8 +215,8 @@ fn gen_args(segment: &PathSegment) -> String {
String::new()
}
declare_lint! {
pub LINT_PASS_IMPL_WITHOUT_MACRO,
declare_tool_lint! {
pub rustc::LINT_PASS_IMPL_WITHOUT_MACRO,
Allow,
"`impl LintPass` without the `declare_lint_pass!` or `impl_lint_pass!` macros"
}

View File

@ -1,6 +1,6 @@
// ignore-tidy-filelength
#![allow(usage_of_ty_tykind)]
#![cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
pub use self::Variance::*;
pub use self::AssocItemContainer::*;

View File

@ -27,7 +27,7 @@
#![cfg_attr(test, feature(test))]
#![deny(rust_2018_idioms)]
#![allow(default_hash_types)]
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
#[macro_use]
extern crate log;

View File

@ -1,6 +1,6 @@
#![feature(proc_macro_hygiene)]
#![deny(rust_2018_idioms)]
#![allow(default_hash_types)]
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
extern crate proc_macro;

View File

@ -60,7 +60,7 @@ pub fn is_known(attr: &Attribute) -> bool {
}
pub fn is_known_lint_tool(m_item: Ident) -> bool {
["clippy"].contains(&m_item.as_str().as_ref())
["clippy", "rustc"].contains(&m_item.as_str().as_ref())
}
impl NestedMetaItem {

View File

@ -8,8 +8,7 @@ extern crate syntax;
extern crate rustc;
extern crate rustc_plugin;
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
LintArray};
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
use rustc_plugin::Registry;
use syntax::ast;
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
@ -19,7 +18,14 @@ declare_tool_lint!(
Warn, "Warn about other stuff"
);
declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP]);
declare_tool_lint!(
/// Some docs
pub rustc::TEST_RUSTC_TOOL_LINT,
Deny,
"Deny internal stuff"
);
declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
impl EarlyLintPass for Pass {
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {

View File

@ -7,7 +7,7 @@ extern crate rustc_data_structures;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use std::collections::{HashMap, HashSet};
#[deny(default_hash_types)]
#[deny(rustc::default_hash_types)]
fn main() {
let _map: HashMap<String, String> = HashMap::default();
//~^ ERROR Prefer FxHashMap over HashMap, it has better performance

View File

@ -7,8 +7,8 @@ LL | let _map: HashMap<String, String> = HashMap::default();
note: lint level defined here
--> $DIR/default_hash_types.rs:10:8
|
LL | #[deny(default_hash_types)]
| ^^^^^^^^^^^^^^^^^^
LL | #[deny(rustc::default_hash_types)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
error: Prefer FxHashMap over HashMap, it has better performance

View File

@ -1,7 +1,7 @@
// compile-flags: -Z unstable-options
#![feature(rustc_private)]
#![deny(lint_pass_impl_without_macro)]
#![deny(rustc::lint_pass_impl_without_macro)]
extern crate rustc;

View File

@ -7,8 +7,8 @@ LL | impl LintPass for Foo {
note: lint level defined here
--> $DIR/lint_pass_impl_without_macro.rs:4:9
|
LL | #![deny(lint_pass_impl_without_macro)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(rustc::lint_pass_impl_without_macro)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
error: implementing `LintPass` by hand

View File

@ -1,7 +1,7 @@
// compile-flags: -Z unstable-options
#![feature(rustc_private)]
#![deny(ty_pass_by_reference)]
#![deny(rustc::ty_pass_by_reference)]
#![allow(unused)]
extern crate rustc;

View File

@ -7,8 +7,8 @@ LL | ty_ref: &Ty<'_>,
note: lint level defined here
--> $DIR/pass_ty_by_ref.rs:4:9
|
LL | #![deny(ty_pass_by_reference)]
| ^^^^^^^^^^^^^^^^^^^^
LL | #![deny(rustc::ty_pass_by_reference)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: passing `TyCtxt<'_>` by reference
--> $DIR/pass_ty_by_ref.rs:15:18

View File

@ -1,7 +1,7 @@
// compile-flags: -Z unstable-options
#![feature(rustc_private)]
#![deny(usage_of_qualified_ty)]
#![deny(rustc::usage_of_qualified_ty)]
#![allow(unused)]
extern crate rustc;

View File

@ -7,8 +7,8 @@ LL | ty_q: ty::Ty<'_>,
note: lint level defined here
--> $DIR/qualified_ty_ty_ctxt.rs:4:9
|
LL | #![deny(usage_of_qualified_ty)]
| ^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(rustc::usage_of_qualified_ty)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: usage of qualified `ty::TyCtxt<'_>`
--> $DIR/qualified_ty_ty_ctxt.rs:27:16

View File

@ -6,7 +6,7 @@ extern crate rustc;
use rustc::ty::{self, Ty, TyKind};
#[deny(usage_of_ty_tykind)]
#[deny(rustc::usage_of_ty_tykind)]
fn main() {
let sty = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>`

View File

@ -7,8 +7,8 @@ LL | let sty = TyKind::Bool;
note: lint level defined here
--> $DIR/ty_tykind_usage.rs:9:8
|
LL | #[deny(usage_of_ty_tykind)]
| ^^^^^^^^^^^^^^^^^^
LL | #[deny(rustc::usage_of_ty_tykind)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: usage of `ty::TyKind::<kind>`
--> $DIR/ty_tykind_usage.rs:14:9