Skip to content

Commit 9521dee

Browse files
flip1995Manishearth
authored andcommitted
Add tests for backward compat
1 parent 1114ab6 commit 9521dee

File tree

3 files changed

+72
-7
lines changed

3 files changed

+72
-7
lines changed

src/test/ui-fulldeps/auxiliary/lint_tool_test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
2525
use rustc_plugin::Registry;
2626
use syntax::ast;
2727
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
28+
declare_tool_lint!(pub clippy::TEST_GROUP, Warn, "Warn about other stuff");
2829

2930
struct Pass;
3031

3132
impl LintPass for Pass {
3233
fn get_lints(&self) -> LintArray {
33-
lint_array!(TEST_LINT)
34+
lint_array!(TEST_LINT, TEST_GROUP)
3435
}
3536
}
3637

@@ -39,10 +40,14 @@ impl EarlyLintPass for Pass {
3940
if it.ident.name == "lintme" {
4041
cx.span_lint(TEST_LINT, it.span, "item is named 'lintme'");
4142
}
43+
if it.ident.name == "lintmetoo" {
44+
cx.span_lint(TEST_GROUP, it.span, "item is named 'lintmetoo'");
45+
}
4246
}
4347
}
4448

4549
#[plugin_registrar]
4650
pub fn plugin_registrar(reg: &mut Registry) {
4751
reg.register_early_lint_pass(box Pass);
52+
reg.register_lint_group("clippy::group", Some("clippy_group"), vec![TEST_LINT, TEST_GROUP]);
4853
}

src/test/ui-fulldeps/lint_tool_test.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// run-pass
1211
// aux-build:lint_tool_test.rs
1312
// ignore-stage1
1413
#![feature(plugin)]
1514
#![feature(tool_lints)]
1615
#![plugin(lint_tool_test)]
1716
#![allow(dead_code)]
17+
#![deny(clippy_group)]
18+
//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future
1819

19-
fn lintme() { } //~ WARNING item is named 'lintme'
20+
fn lintme() { } //~ ERROR item is named 'lintme'
21+
22+
#[allow(clippy::group)]
23+
fn lintmetoo() {}
2024

2125
#[allow(clippy::test_lint)]
2226
pub fn main() {
2327
fn lintme() { }
28+
fn lintmetoo() { } //~ ERROR item is named 'lintmetoo'
29+
}
30+
31+
#[allow(test_group)]
32+
//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future
33+
#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
34+
fn hello() {
35+
fn lintmetoo() { }
2436
}
Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,56 @@
1-
warning: item is named 'lintme'
2-
--> $DIR/lint_tool_test.rs:19:1
1+
warning: lint name `clippy_group` is deprecated and may not have an effect in the future
2+
--> $DIR/lint_tool_test.rs:17:9
33
|
4-
LL | fn lintme() { } //~ WARNING item is named 'lintme'
4+
LL | #![deny(clippy_group)]
5+
| ^^^^^^^^^^^^ help: change it to: `clippy::group`
6+
|
7+
= note: #[warn(renamed_and_removed_lints)] on by default
8+
9+
warning: lint name `test_group` is deprecated and may not have an effect in the future
10+
--> $DIR/lint_tool_test.rs:31:9
11+
|
12+
LL | #[allow(test_group)]
13+
| ^^^^^^^^^^ help: change it to: `clippy::test_group`
14+
15+
warning: unknown lint: `this_lint_does_not_exist`
16+
--> $DIR/lint_tool_test.rs:33:8
17+
|
18+
LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist`
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^
20+
|
21+
= note: #[warn(unknown_lints)] on by default
22+
23+
warning: lint name `clippy_group` is deprecated and may not have an effect in the future
24+
--> $DIR/lint_tool_test.rs:17:9
25+
|
26+
LL | #![deny(clippy_group)]
27+
| ^^^^^^^^^^^^ help: change it to: `clippy::group`
28+
29+
error: item is named 'lintme'
30+
--> $DIR/lint_tool_test.rs:20:1
31+
|
32+
LL | fn lintme() { } //~ ERROR item is named 'lintme'
533
| ^^^^^^^^^^^^^^^
634
|
7-
= note: #[warn(clippy::test_lint)] on by default
35+
note: lint level defined here
36+
--> $DIR/lint_tool_test.rs:17:9
37+
|
38+
LL | #![deny(clippy_group)]
39+
| ^^^^^^^^^^^^
40+
= note: #[deny(clippy::test_lint)] implied by #[deny(clippy::group)]
41+
42+
error: item is named 'lintmetoo'
43+
--> $DIR/lint_tool_test.rs:28:5
44+
|
45+
LL | fn lintmetoo() { } //~ ERROR item is named 'lintmetoo'
46+
| ^^^^^^^^^^^^^^^^^^
47+
|
48+
note: lint level defined here
49+
--> $DIR/lint_tool_test.rs:17:9
50+
|
51+
LL | #![deny(clippy_group)]
52+
| ^^^^^^^^^^^^
53+
= note: #[deny(clippy::test_group)] implied by #[deny(clippy::group)]
54+
55+
error: aborting due to 2 previous errors
856

0 commit comments

Comments
 (0)