summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/new_ret_no_self.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /src/tools/clippy/tests/ui/new_ret_no_self.rs
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/new_ret_no_self.rs')
-rw-r--r--src/tools/clippy/tests/ui/new_ret_no_self.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/new_ret_no_self.rs b/src/tools/clippy/tests/ui/new_ret_no_self.rs
index 2f315ffe2..beec42f08 100644
--- a/src/tools/clippy/tests/ui/new_ret_no_self.rs
+++ b/src/tools/clippy/tests/ui/new_ret_no_self.rs
@@ -1,3 +1,4 @@
+#![feature(type_alias_impl_trait)]
#![warn(clippy::new_ret_no_self)]
#![allow(dead_code)]
@@ -350,3 +351,75 @@ impl RetOtherSelf<T> {
RetOtherSelf(RetOtherSelfWrapper(t))
}
}
+
+mod issue7344 {
+ struct RetImplTraitSelf<T>(T);
+
+ impl<T> RetImplTraitSelf<T> {
+ // should not trigger lint
+ fn new(t: T) -> impl Into<Self> {
+ Self(t)
+ }
+ }
+
+ struct RetImplTraitNoSelf<T>(T);
+
+ impl<T> RetImplTraitNoSelf<T> {
+ // should trigger lint
+ fn new(t: T) -> impl Into<i32> {
+ 1
+ }
+ }
+
+ trait Trait2<T, U> {}
+ impl<T, U> Trait2<T, U> for () {}
+
+ struct RetImplTraitSelf2<T>(T);
+
+ impl<T> RetImplTraitSelf2<T> {
+ // should not trigger lint
+ fn new(t: T) -> impl Trait2<(), Self> {
+ unimplemented!()
+ }
+ }
+
+ struct RetImplTraitNoSelf2<T>(T);
+
+ impl<T> RetImplTraitNoSelf2<T> {
+ // should trigger lint
+ fn new(t: T) -> impl Trait2<(), i32> {
+ unimplemented!()
+ }
+ }
+
+ struct RetImplTraitSelfAdt<'a>(&'a str);
+
+ impl<'a> RetImplTraitSelfAdt<'a> {
+ // should not trigger lint
+ fn new<'b: 'a>(s: &'b str) -> impl Into<RetImplTraitSelfAdt<'b>> {
+ RetImplTraitSelfAdt(s)
+ }
+ }
+}
+
+mod issue10041 {
+ struct Bomb;
+
+ impl Bomb {
+ // Hidden <Rhs = Self> default generic paramter.
+ pub fn new() -> impl PartialOrd {
+ 0i32
+ }
+ }
+
+ // TAIT with self-referencing bounds
+ type X = impl std::ops::Add<Output = X>;
+
+ struct Bomb2;
+
+ impl Bomb2 {
+ pub fn new() -> X {
+ 0i32
+ }
+ }
+}