Skip to content

Commit 3480ac2

Browse files
committed
Auto merge of #53887 - flip1995:tool_lints, r=Manishearth
Fix of bug introduced by #53762 (tool_lints) Before implementing backwards compat for tool lints, the `Tool` case when parsing cmdline lints was unreachable. This changed with #53762. This fix is needed for rls test-pass. (@nrc) r? @Manishearth
2 parents a1a8c44 + daa4364 commit 3480ac2

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

src/librustc/lint/context.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,15 @@ impl LintStore {
319319
CheckLintNameResult::NoLint => {
320320
Some(struct_err!(sess, E0602, "unknown lint: `{}`", lint_name))
321321
}
322-
CheckLintNameResult::Tool(_) => unreachable!(),
322+
CheckLintNameResult::Tool(result) => match result {
323+
Err((Some(_), new_name)) => Some(sess.struct_warn(&format!(
324+
"lint name `{}` is deprecated \
325+
and does not have an effect anymore. \
326+
Use: {}",
327+
lint_name, new_name
328+
))),
329+
_ => None,
330+
},
323331
};
324332

325333
if let Some(mut db) = db {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-pass
12+
// aux-build:lint_tool_test.rs
13+
// ignore-stage1
14+
// compile-flags: -A test-lint
15+
16+
#![feature(plugin)]
17+
#![warn(unused)]
18+
#![plugin(lint_tool_test)]
19+
20+
fn lintme() { }
21+
22+
pub fn main() {
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
warning: lint name `test_lint` is deprecated and does not have an effect anymore. Use: clippy::test_lint
2+
|
3+
= note: requested on the command line with `-A test_lint`
4+
5+
warning: item is named 'lintme'
6+
--> $DIR/lint_tool_cmdline_allow.rs:20:1
7+
|
8+
LL | fn lintme() { }
9+
| ^^^^^^^^^^^^^^^
10+
|
11+
= note: #[warn(clippy::test_lint)] on by default
12+
13+
warning: function is never used: `lintme`
14+
--> $DIR/lint_tool_cmdline_allow.rs:20:1
15+
|
16+
LL | fn lintme() { }
17+
| ^^^^^^^^^^^
18+
|
19+
note: lint level defined here
20+
--> $DIR/lint_tool_cmdline_allow.rs:17:9
21+
|
22+
LL | #![warn(unused)]
23+
| ^^^^^^
24+
= note: #[warn(dead_code)] implied by #[warn(unused)]
25+

0 commit comments

Comments
 (0)