File tree Expand file tree Collapse file tree 4 files changed +6
-55
lines changed Expand file tree Collapse file tree 4 files changed +6
-55
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use clippy_utils::source::snippet_opt;
6
6
use rustc_errors:: Applicability ;
7
7
use rustc_hir:: def:: { DefKind , Res } ;
8
8
use rustc_hir:: { Item , ItemKind , UseKind } ;
9
- use rustc_lint:: { LateContext , LateLintPass , LintContext as _ } ;
9
+ use rustc_lint:: { LateContext , LateLintPass } ;
10
10
use rustc_middle:: ty:: Visibility ;
11
11
use rustc_session:: impl_lint_pass;
12
12
use rustc_span:: symbol:: kw;
@@ -59,7 +59,7 @@ impl_lint_pass!(UnusedTraitNames => [UNUSED_TRAIT_NAMES]);
59
59
60
60
impl < ' tcx > LateLintPass < ' tcx > for UnusedTraitNames {
61
61
fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx Item < ' tcx > ) {
62
- if !item. span . in_external_macro ( cx . sess ( ) . source_map ( ) )
62
+ if !item. span . from_expansion ( )
63
63
&& let ItemKind :: Use ( path, UseKind :: Single ( ident) ) = item. kind
64
64
// Ignore imports that already use Underscore
65
65
&& ident. name != kw:: Underscore
Original file line number Diff line number Diff line change @@ -200,11 +200,11 @@ fn msrv_1_33() {
200
200
MyStruct.do_things();
201
201
}
202
202
203
+ // Linting inside macro expansion is no longer supported
203
204
mod lint_inside_macro_expansion_bad {
204
205
macro_rules! foo {
205
206
() => {
206
- use std::any::Any as _;
207
- //~^ unused_trait_names
207
+ use std::any::Any;
208
208
fn bar() {
209
209
"bar".type_id();
210
210
}
@@ -294,22 +294,3 @@ mod allow_lint_import {
294
294
// "foo".type_id();
295
295
// }
296
296
// }
297
-
298
- mod issue14924 {
299
- mod m {
300
- pub trait Tr {
301
- fn method(&self) {}
302
- }
303
-
304
- impl Tr for u8 {}
305
- }
306
-
307
- macro gen_import($Br: ident) {
308
- use m::Tr as $Br;
309
- }
310
- gen_import!(Br);
311
-
312
- fn do_something() {
313
- 0u8.method();
314
- }
315
- }
Original file line number Diff line number Diff line change @@ -200,11 +200,11 @@ fn msrv_1_33() {
200
200
MyStruct . do_things ( ) ;
201
201
}
202
202
203
+ // Linting inside macro expansion is no longer supported
203
204
mod lint_inside_macro_expansion_bad {
204
205
macro_rules! foo {
205
206
( ) => {
206
207
use std:: any:: Any ;
207
- //~^ unused_trait_names
208
208
fn bar( ) {
209
209
"bar" . type_id( ) ;
210
210
}
@@ -294,22 +294,3 @@ mod allow_lint_import {
294
294
// "foo".type_id();
295
295
// }
296
296
// }
297
-
298
- mod issue14924 {
299
- mod m {
300
- pub trait Tr {
301
- fn method ( & self ) { }
302
- }
303
-
304
- impl Tr for u8 { }
305
- }
306
-
307
- macro gen_import( $Br: ident) {
308
- use m:: Tr as $Br;
309
- }
310
- gen_import ! ( Br ) ;
311
-
312
- fn do_something ( ) {
313
- 0u8 . method ( ) ;
314
- }
315
- }
Original file line number Diff line number Diff line change @@ -58,16 +58,5 @@ error: importing trait that is only used anonymously
58
58
LL | use simple_trait::{MyStruct, MyTrait};
59
59
| ^^^^^^^ help: use: `MyTrait as _`
60
60
61
- error: importing trait that is only used anonymously
62
- --> tests/ui/unused_trait_names.rs:206:27
63
- |
64
- LL | use std::any::Any;
65
- | ^^^ help: use: `Any as _`
66
- ...
67
- LL | foo!();
68
- | ------ in this macro invocation
69
- |
70
- = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
71
-
72
- error: aborting due to 10 previous errors
61
+ error: aborting due to 9 previous errors
73
62
You can’t perform that action at this time.
0 commit comments