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;
66use rustc_errors:: Applicability ;
77use rustc_hir:: def:: { DefKind , Res } ;
88use rustc_hir:: { Item , ItemKind , UseKind } ;
9- use rustc_lint:: { LateContext , LateLintPass , LintContext as _ } ;
9+ use rustc_lint:: { LateContext , LateLintPass } ;
1010use rustc_middle:: ty:: Visibility ;
1111use rustc_session:: impl_lint_pass;
1212use rustc_span:: symbol:: kw;
@@ -59,7 +59,7 @@ impl_lint_pass!(UnusedTraitNames => [UNUSED_TRAIT_NAMES]);
5959
6060impl < ' tcx > LateLintPass < ' tcx > for UnusedTraitNames {
6161 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 ( )
6363 && let ItemKind :: Use ( path, UseKind :: Single ( ident) ) = item. kind
6464 // Ignore imports that already use Underscore
6565 && ident. name != kw:: Underscore
Original file line number Diff line number Diff line change @@ -200,11 +200,11 @@ fn msrv_1_33() {
200200 MyStruct.do_things();
201201}
202202
203+ // Linting inside macro expansion is no longer supported
203204mod lint_inside_macro_expansion_bad {
204205 macro_rules! foo {
205206 () => {
206- use std::any::Any as _;
207- //~^ unused_trait_names
207+ use std::any::Any;
208208 fn bar() {
209209 "bar".type_id();
210210 }
@@ -294,22 +294,3 @@ mod allow_lint_import {
294294// "foo".type_id();
295295// }
296296// }
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() {
200200 MyStruct . do_things ( ) ;
201201}
202202
203+ // Linting inside macro expansion is no longer supported
203204mod lint_inside_macro_expansion_bad {
204205 macro_rules! foo {
205206 ( ) => {
206207 use std:: any:: Any ;
207- //~^ unused_trait_names
208208 fn bar( ) {
209209 "bar" . type_id( ) ;
210210 }
@@ -294,22 +294,3 @@ mod allow_lint_import {
294294// "foo".type_id();
295295// }
296296// }
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
5858LL | use simple_trait::{MyStruct, MyTrait};
5959 | ^^^^^^^ help: use: `MyTrait as _`
6060
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
7362
You can’t perform that action at this time.
0 commit comments