mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 03:03:21 +00:00
[use_self
] fix FP when trait impl defined in macro
Found when working on `lintcheck --fix`
This commit is contained in:
parent
628a79d6b6
commit
e86e810889
@ -103,6 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||
if parameters.as_ref().map_or(true, |params| {
|
||||
!params.parenthesized && !params.args.iter().any(|arg| matches!(arg, GenericArg::Lifetime(_)))
|
||||
});
|
||||
if !item.span.from_expansion();
|
||||
if !is_from_proc_macro(cx, item); // expensive, should be last check
|
||||
then {
|
||||
StackItem::Check {
|
||||
|
@ -112,4 +112,30 @@ impl NameTrait for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
mod impl_in_macro {
|
||||
macro_rules! parse_ip_impl {
|
||||
// minimized from serde=1.0.118
|
||||
($ty:ty) => {
|
||||
impl FooTrait for $ty {
|
||||
fn new() -> Self {
|
||||
<$ty>::bar()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
trait FooTrait {
|
||||
fn new() -> Self;
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn bar() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
parse_ip_impl!(Foo); // Should not lint
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -112,4 +112,30 @@ impl NameTrait for u8 {
|
||||
}
|
||||
}
|
||||
|
||||
mod impl_in_macro {
|
||||
macro_rules! parse_ip_impl {
|
||||
// minimized from serde=1.0.118
|
||||
($ty:ty) => {
|
||||
impl FooTrait for $ty {
|
||||
fn new() -> Self {
|
||||
<$ty>::bar()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
trait FooTrait {
|
||||
fn new() -> Self;
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
fn bar() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
parse_ip_impl!(Foo); // Should not lint
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user