summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/use_self_trait.fixed
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:21 +0000
commit4e8199b572f2035b7749cba276ece3a26630d23e (patch)
treef09feeed6a0fe39d027b1908aa63ea6b35e4b631 /src/tools/clippy/tests/ui/use_self_trait.fixed
parentAdding upstream version 1.66.0+dfsg1. (diff)
downloadrustc-4e8199b572f2035b7749cba276ece3a26630d23e.tar.xz
rustc-4e8199b572f2035b7749cba276ece3a26630d23e.zip
Adding upstream version 1.67.1+dfsg1.upstream/1.67.1+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/use_self_trait.fixed')
-rw-r--r--src/tools/clippy/tests/ui/use_self_trait.fixed41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/tools/clippy/tests/ui/use_self_trait.fixed b/src/tools/clippy/tests/ui/use_self_trait.fixed
index 9bcd692fb..4e779308d 100644
--- a/src/tools/clippy/tests/ui/use_self_trait.fixed
+++ b/src/tools/clippy/tests/ui/use_self_trait.fixed
@@ -47,8 +47,7 @@ impl Mul for Bad {
impl Clone for Bad {
fn clone(&self) -> Self {
- // FIXME: applicable here
- Bad
+ Self
}
}
@@ -112,4 +111,42 @@ 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
+}
+
+mod full_path_replacement {
+ trait Error {
+ fn custom<T: std::fmt::Display>(_msg: T) -> Self;
+ }
+
+ impl Error for std::fmt::Error {
+ fn custom<T: std::fmt::Display>(_msg: T) -> Self {
+ Self // Should lint
+ }
+ }
+}
+
fn main() {}