Skip to content

Commit 7de6f54

Browse files
committed
Turn internal lints into tool lints
1 parent 08b81f2 commit 7de6f54

18 files changed

+47
-37
lines changed

src/bootstrap/bin/rustc.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,14 @@ fn main() {
306306
}
307307

308308
// This is required for internal lints.
309+
cmd.arg("-Zunstable-options");
309310
if let Some(crate_name) = args.windows(2).find(|a| &*a[0] == "--crate-name") {
310311
let crate_name = crate_name[1].to_string_lossy();
311-
if crate_name.starts_with("rustc") || crate_name.starts_with("syntax") {
312-
cmd.arg("-Zunstable-options");
312+
if crate_name.starts_with("rustc")
313+
|| crate_name.starts_with("syntax")
314+
|| crate_name == "arena"
315+
|| crate_name == "fmt_macros"
316+
{
313317
if stage != "0" {
314318
cmd.arg("-Wrustc::internal");
315319
}

src/librustc/lint/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ struct LateLintPassObjects<'a> {
13411341
lints: &'a mut [LateLintPassObject],
13421342
}
13431343

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

1514-
#[cfg_attr(not(stage0), allow(lint_pass_impl_without_macro))]
1514+
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
15151515
impl LintPass for EarlyLintPassObjects<'_> {
15161516
fn name(&self) -> &'static str {
15171517
panic!()

src/librustc/lint/internal.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use syntax::ast::{Ident, Item, ItemKind};
1111
use syntax::symbol::{sym, Symbol};
1212
use syntax_pos::ExpnInfo;
1313

14-
declare_lint! {
15-
pub DEFAULT_HASH_TYPES,
14+
declare_tool_lint! {
15+
pub rustc::DEFAULT_HASH_TYPES,
1616
Allow,
1717
"forbid HashMap and HashSet and suggest the FxHash* variants"
1818
}
@@ -23,7 +23,7 @@ pub struct DefaultHashTypes {
2323

2424
impl DefaultHashTypes {
2525
// we are allowed to use `HashMap` and `HashSet` as identifiers for implementing the lint itself
26-
#[allow(default_hash_types)]
26+
#[cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
2727
pub fn new() -> Self {
2828
let mut map = FxHashMap::default();
2929
map.insert(sym::HashMap, sym::FxHashMap);
@@ -51,20 +51,20 @@ impl EarlyLintPass for DefaultHashTypes {
5151
}
5252
}
5353

54-
declare_lint! {
55-
pub USAGE_OF_TY_TYKIND,
54+
declare_tool_lint! {
55+
pub rustc::USAGE_OF_TY_TYKIND,
5656
Allow,
5757
"usage of `ty::TyKind` outside of the `ty::sty` module"
5858
}
5959

60-
declare_lint! {
61-
pub TY_PASS_BY_REFERENCE,
60+
declare_tool_lint! {
61+
pub rustc::TY_PASS_BY_REFERENCE,
6262
Allow,
6363
"passing `Ty` or `TyCtxt` by reference"
6464
}
6565

66-
declare_lint! {
67-
pub USAGE_OF_QUALIFIED_TY,
66+
declare_tool_lint! {
67+
pub rustc::USAGE_OF_QUALIFIED_TY,
6868
Allow,
6969
"using `ty::{Ty,TyCtxt}` instead of importing it"
7070
}
@@ -215,8 +215,8 @@ fn gen_args(segment: &PathSegment) -> String {
215215
String::new()
216216
}
217217

218-
declare_lint! {
219-
pub LINT_PASS_IMPL_WITHOUT_MACRO,
218+
declare_tool_lint! {
219+
pub rustc::LINT_PASS_IMPL_WITHOUT_MACRO,
220220
Allow,
221221
"`impl LintPass` without the `declare_lint_pass!` or `impl_lint_pass!` macros"
222222
}

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ignore-tidy-filelength
22

3-
#![allow(usage_of_ty_tykind)]
3+
#![cfg_attr(not(bootstrap), allow(rustc::usage_of_ty_tykind))]
44

55
pub use self::Variance::*;
66
pub use self::AssocItemContainer::*;

src/librustc_data_structures/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![cfg_attr(test, feature(test))]
2828

2929
#![deny(rust_2018_idioms)]
30-
#![allow(default_hash_types)]
30+
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
3131

3232
#[macro_use]
3333
extern crate log;

src/librustc_macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(proc_macro_hygiene)]
22
#![deny(rust_2018_idioms)]
3-
#![allow(default_hash_types)]
3+
#![cfg_attr(not(bootstrap), allow(rustc::default_hash_types))]
44

55
extern crate proc_macro;
66

src/libsyntax/attr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub fn is_known(attr: &Attribute) -> bool {
6060
}
6161

6262
pub fn is_known_lint_tool(m_item: Ident) -> bool {
63-
["clippy"].contains(&m_item.as_str().as_ref())
63+
["clippy", "rustc"].contains(&m_item.as_str().as_ref())
6464
}
6565

6666
impl NestedMetaItem {

src/test/ui-fulldeps/auxiliary/lint-tool-test.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ extern crate syntax;
88
extern crate rustc;
99
extern crate rustc_plugin;
1010

11-
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
12-
LintArray};
11+
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
1312
use rustc_plugin::Registry;
1413
use syntax::ast;
1514
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
@@ -19,7 +18,14 @@ declare_tool_lint!(
1918
Warn, "Warn about other stuff"
2019
);
2120

22-
declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP]);
21+
declare_tool_lint!(
22+
/// Some docs
23+
pub rustc::TEST_RUSTC_TOOL_LINT,
24+
Deny,
25+
"Deny internal stuff"
26+
);
27+
28+
declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]);
2329

2430
impl EarlyLintPass for Pass {
2531
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {

src/test/ui-fulldeps/internal-lints/default_hash_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate rustc_data_structures;
77
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
88
use std::collections::{HashMap, HashSet};
99

10-
#[deny(default_hash_types)]
10+
#[deny(rustc::default_hash_types)]
1111
fn main() {
1212
let _map: HashMap<String, String> = HashMap::default();
1313
//~^ ERROR Prefer FxHashMap over HashMap, it has better performance

src/test/ui-fulldeps/internal-lints/default_hash_types.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | let _map: HashMap<String, String> = HashMap::default();
77
note: lint level defined here
88
--> $DIR/default_hash_types.rs:10:8
99
|
10-
LL | #[deny(default_hash_types)]
11-
| ^^^^^^^^^^^^^^^^^^
10+
LL | #[deny(rustc::default_hash_types)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= note: a `use rustc_data_structures::fx::FxHashMap` may be necessary
1313

1414
error: Prefer FxHashMap over HashMap, it has better performance

src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// compile-flags: -Z unstable-options
22

33
#![feature(rustc_private)]
4-
#![deny(lint_pass_impl_without_macro)]
4+
#![deny(rustc::lint_pass_impl_without_macro)]
55

66
extern crate rustc;
77

src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | impl LintPass for Foo {
77
note: lint level defined here
88
--> $DIR/lint_pass_impl_without_macro.rs:4:9
99
|
10-
LL | #![deny(lint_pass_impl_without_macro)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(rustc::lint_pass_impl_without_macro)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
1313

1414
error: implementing `LintPass` by hand

src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// compile-flags: -Z unstable-options
22

33
#![feature(rustc_private)]
4-
#![deny(ty_pass_by_reference)]
4+
#![deny(rustc::ty_pass_by_reference)]
55
#![allow(unused)]
66

77
extern crate rustc;

src/test/ui-fulldeps/internal-lints/pass_ty_by_ref.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | ty_ref: &Ty<'_>,
77
note: lint level defined here
88
--> $DIR/pass_ty_by_ref.rs:4:9
99
|
10-
LL | #![deny(ty_pass_by_reference)]
11-
| ^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(rustc::ty_pass_by_reference)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: passing `TyCtxt<'_>` by reference
1414
--> $DIR/pass_ty_by_ref.rs:15:18

src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// compile-flags: -Z unstable-options
22

33
#![feature(rustc_private)]
4-
#![deny(usage_of_qualified_ty)]
4+
#![deny(rustc::usage_of_qualified_ty)]
55
#![allow(unused)]
66

77
extern crate rustc;

src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | ty_q: ty::Ty<'_>,
77
note: lint level defined here
88
--> $DIR/qualified_ty_ty_ctxt.rs:4:9
99
|
10-
LL | #![deny(usage_of_qualified_ty)]
11-
| ^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(rustc::usage_of_qualified_ty)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: usage of qualified `ty::TyCtxt<'_>`
1414
--> $DIR/qualified_ty_ty_ctxt.rs:27:16

src/test/ui-fulldeps/internal-lints/ty_tykind_usage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate rustc;
66

77
use rustc::ty::{self, Ty, TyKind};
88

9-
#[deny(usage_of_ty_tykind)]
9+
#[deny(rustc::usage_of_ty_tykind)]
1010
fn main() {
1111
let sty = TyKind::Bool; //~ ERROR usage of `ty::TyKind::<kind>`
1212

src/test/ui-fulldeps/internal-lints/ty_tykind_usage.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | let sty = TyKind::Bool;
77
note: lint level defined here
88
--> $DIR/ty_tykind_usage.rs:9:8
99
|
10-
LL | #[deny(usage_of_ty_tykind)]
11-
| ^^^^^^^^^^^^^^^^^^
10+
LL | #[deny(rustc::usage_of_ty_tykind)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: usage of `ty::TyKind::<kind>`
1414
--> $DIR/ty_tykind_usage.rs:14:9

0 commit comments

Comments
 (0)