summaryrefslogtreecommitdiffstats
path: root/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs')
-rw-r--r--tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs
new file mode 100644
index 000000000..ae21a9134
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs
@@ -0,0 +1,38 @@
+#![feature(type_alias_impl_trait)]
+
+trait Callable {
+ type Output;
+ fn call(x: Self) -> Self::Output;
+}
+
+trait PlusOne {
+ fn plus_one(&mut self);
+}
+
+impl<'a> PlusOne for &'a mut i32 {
+ fn plus_one(&mut self) {
+ **self += 1;
+ }
+}
+
+impl<T: PlusOne> Callable for T {
+ type Output = impl PlusOne;
+ fn call(t: T) -> Self::Output { t }
+}
+
+fn test<'a>(y: &'a mut i32) -> impl PlusOne {
+ <&'a mut i32 as Callable>::call(y)
+ //~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds
+}
+
+fn main() {
+ let mut z = 42;
+ let mut thing = test(&mut z);
+ let mut thing2 = test(&mut z);
+ thing.plus_one();
+ assert_eq!(z, 43);
+ thing2.plus_one();
+ assert_eq!(z, 44);
+ thing.plus_one();
+ assert_eq!(z, 45);
+}