-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #52467 - alexcrichton:lints-and-macros, r=Manishearth
Squash all lints tied to foreign macros by default This PR is a continuation of #49755 (thanks for the initial jump-start @Dylan-DPC!) and is targeted at solving #48855. This change updates the lint infrastructure to, by default, ignore all lints emitted for code that originates in a foreign macro. For example if `println!("...")` injects some idiomatic warnings these are all ignored by default. The rationale here is that for almost all lints there's no action that can be taken if the code originates from a foreign lint. Closes #48855 Closes #52483 Closes #52479
- Loading branch information
Showing
4 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[macro_export] | ||
macro_rules! bar { | ||
() => {use std::string::ToString;} | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! baz { | ||
($i:item) => ($i) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! baz2 { | ||
($($i:tt)*) => ($($i)*) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// aux-build:lints-in-foreign-macros.rs | ||
// compile-pass | ||
|
||
#![warn(unused_imports)] | ||
|
||
#[macro_use] | ||
extern crate lints_in_foreign_macros; | ||
|
||
macro_rules! foo { | ||
() => {use std::string::ToString;} //~ WARN: unused import | ||
} | ||
|
||
mod a { foo!(); } | ||
mod b { bar!(); } | ||
mod c { baz!(use std::string::ToString;); } //~ WARN: unused import | ||
mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
warning: unused import: `std::string::ToString` | ||
--> $DIR/lints-in-foreign-macros.rs:20:16 | ||
| | ||
LL | () => {use std::string::ToString;} //~ WARN: unused import | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | mod a { foo!(); } | ||
| ------- in this macro invocation | ||
| | ||
note: lint level defined here | ||
--> $DIR/lints-in-foreign-macros.rs:14:9 | ||
| | ||
LL | #![warn(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
warning: unused import: `std::string::ToString` | ||
--> $DIR/lints-in-foreign-macros.rs:25:18 | ||
| | ||
LL | mod c { baz!(use std::string::ToString;); } //~ WARN: unused import | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: unused import: `std::string::ToString` | ||
--> $DIR/lints-in-foreign-macros.rs:26:19 | ||
| | ||
LL | mod d { baz2!(use std::string::ToString;); } //~ WARN: unused import | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|