File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
103103 if parameters. as_ref( ) . map_or( true , |params| {
104104 !params. parenthesized && !params. args. iter( ) . any( |arg| matches!( arg, GenericArg :: Lifetime ( _) ) )
105105 } ) ;
106+ if !item. span. from_expansion( ) ;
106107 if !is_from_proc_macro( cx, item) ; // expensive, should be last check
107108 then {
108109 StackItem :: Check {
Original file line number Diff line number Diff line change @@ -112,4 +112,30 @@ impl NameTrait for u8 {
112112 }
113113}
114114
115+ mod impl_in_macro {
116+ macro_rules! parse_ip_impl {
117+ // minimized from serde=1.0.118
118+ ($ty:ty) => {
119+ impl FooTrait for $ty {
120+ fn new() -> Self {
121+ <$ty>::bar()
122+ }
123+ }
124+ };
125+ }
126+
127+ struct Foo;
128+
129+ trait FooTrait {
130+ fn new() -> Self;
131+ }
132+
133+ impl Foo {
134+ fn bar() -> Self {
135+ Self
136+ }
137+ }
138+ parse_ip_impl!(Foo); // Should not lint
139+ }
140+
115141fn main() {}
Original file line number Diff line number Diff line change @@ -112,4 +112,30 @@ impl NameTrait for u8 {
112112 }
113113}
114114
115+ mod impl_in_macro {
116+ macro_rules! parse_ip_impl {
117+ // minimized from serde=1.0.118
118+ ( $ty: ty) => {
119+ impl FooTrait for $ty {
120+ fn new( ) -> Self {
121+ <$ty>:: bar( )
122+ }
123+ }
124+ } ;
125+ }
126+
127+ struct Foo ;
128+
129+ trait FooTrait {
130+ fn new ( ) -> Self ;
131+ }
132+
133+ impl Foo {
134+ fn bar ( ) -> Self {
135+ Self
136+ }
137+ }
138+ parse_ip_impl ! ( Foo ) ; // Should not lint
139+ }
140+
115141fn main ( ) { }
You can’t perform that action at this time.
0 commit comments