about summary refs log tree commit diff
path: root/src/test/ui/impl-trait
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/impl-trait')
-rw-r--r--src/test/ui/impl-trait/autoderef.rs19
-rw-r--r--src/test/ui/impl-trait/cross-return-site-inference.rs2
-rw-r--r--src/test/ui/impl-trait/equality2.stderr4
-rw-r--r--src/test/ui/impl-trait/issues/issue-70877.rs2
-rw-r--r--src/test/ui/impl-trait/issues/issue-70877.stderr11
-rw-r--r--src/test/ui/impl-trait/projection.rs2
-rw-r--r--src/test/ui/impl-trait/question_mark.rs2
-rw-r--r--src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs1
-rw-r--r--src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr9
-rw-r--r--src/test/ui/impl-trait/two_tait_defining_each_other2.rs2
-rw-r--r--src/test/ui/impl-trait/two_tait_defining_each_other2.stderr10
11 files changed, 48 insertions, 16 deletions
diff --git a/src/test/ui/impl-trait/autoderef.rs b/src/test/ui/impl-trait/autoderef.rs
new file mode 100644
index 00000000000..5e4f4995447
--- /dev/null
+++ b/src/test/ui/impl-trait/autoderef.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+use std::path::Path;
+use std::ffi::OsStr;
+use std::ops::Deref;
+
+fn frob(path: &str) -> impl Deref<Target = Path> + '_ {
+    OsStr::new(path).as_ref()
+}
+
+fn open_parent<'path>(_path: &'path Path) {
+    todo!()
+}
+
+fn main() {
+    let old_path = frob("hello");
+
+    open_parent(&old_path);
+}
diff --git a/src/test/ui/impl-trait/cross-return-site-inference.rs b/src/test/ui/impl-trait/cross-return-site-inference.rs
index ceb8414650f..c27b5ca9f66 100644
--- a/src/test/ui/impl-trait/cross-return-site-inference.rs
+++ b/src/test/ui/impl-trait/cross-return-site-inference.rs
@@ -42,4 +42,4 @@ fn muh3() -> Result<(), impl std::fmt::Debug> {
     Err(From::from("foo")) //~ ERROR the trait bound `impl Debug: From<&str>` is not satisfied
 }
 
-fn main() {}
\ No newline at end of file
+fn main() {}
diff --git a/src/test/ui/impl-trait/equality2.stderr b/src/test/ui/impl-trait/equality2.stderr
index fd33fa7c674..46053c6e7c1 100644
--- a/src/test/ui/impl-trait/equality2.stderr
+++ b/src/test/ui/impl-trait/equality2.stderr
@@ -15,7 +15,9 @@ LL | fn hide<T: Foo>(x: T) -> impl Foo {
    |                          -------- the found opaque type
 ...
 LL |     let _: u32 = hide(0_u32);
-   |                  ^^^^^^^^^^^ expected `u32`, found opaque type
+   |            ---   ^^^^^^^^^^^ expected `u32`, found opaque type
+   |            |
+   |            expected due to this
    |
    = note:     expected type `u32`
            found opaque type `impl Foo`
diff --git a/src/test/ui/impl-trait/issues/issue-70877.rs b/src/test/ui/impl-trait/issues/issue-70877.rs
index 9cbe33aef5b..1a86fa00ed1 100644
--- a/src/test/ui/impl-trait/issues/issue-70877.rs
+++ b/src/test/ui/impl-trait/issues/issue-70877.rs
@@ -28,7 +28,7 @@ fn ham() -> Foo {
 fn oof() -> impl std::fmt::Debug {
     let mut bar = ham();
     let func = bar.next().unwrap();
-    return func(&"oof"); //~^^^ ERROR opaque type's hidden type cannot be another opaque type
+    return func(&"oof"); //~ ERROR opaque type's hidden type cannot be another opaque type
 }
 
 fn main() {
diff --git a/src/test/ui/impl-trait/issues/issue-70877.stderr b/src/test/ui/impl-trait/issues/issue-70877.stderr
index 2610a198186..7cbd58bdabf 100644
--- a/src/test/ui/impl-trait/issues/issue-70877.stderr
+++ b/src/test/ui/impl-trait/issues/issue-70877.stderr
@@ -13,15 +13,10 @@ LL |         Some(Box::new(quux))
               found enum `Option<Box<for<'r> fn(&'r (dyn ToString + 'r)) -> FooRet {quux}>>`
 
 error: opaque type's hidden type cannot be another opaque type from the same scope
-  --> $DIR/issue-70877.rs:28:34
+  --> $DIR/issue-70877.rs:31:12
    |
-LL |   fn oof() -> impl std::fmt::Debug {
-   |  __________________________________^
-LL | |     let mut bar = ham();
-LL | |     let func = bar.next().unwrap();
-LL | |     return func(&"oof");
-LL | | }
-   | |_^ one of the two opaque types used here has to be outside its defining scope
+LL |     return func(&"oof");
+   |            ^^^^^^^^^^^^ one of the two opaque types used here has to be outside its defining scope
    |
 note: opaque type whose hidden type is being assigned
   --> $DIR/issue-70877.rs:28:13
diff --git a/src/test/ui/impl-trait/projection.rs b/src/test/ui/impl-trait/projection.rs
index 21fc6591e97..b33802e2bc8 100644
--- a/src/test/ui/impl-trait/projection.rs
+++ b/src/test/ui/impl-trait/projection.rs
@@ -26,4 +26,4 @@ fn run<F>(f: F)
 
 fn main() {
     run(|_| {});
-}
\ No newline at end of file
+}
diff --git a/src/test/ui/impl-trait/question_mark.rs b/src/test/ui/impl-trait/question_mark.rs
index 495bf5c1d64..7bd5cff31bb 100644
--- a/src/test/ui/impl-trait/question_mark.rs
+++ b/src/test/ui/impl-trait/question_mark.rs
@@ -27,4 +27,4 @@ pub fn direct() -> Result<(), impl Debug> {
     Err(Target)
 }
 
-fn main() {}
\ No newline at end of file
+fn main() {}
diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs
index a60e34c17b6..6aa832cde71 100644
--- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs
+++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.rs
@@ -21,6 +21,7 @@ mod b {
 
     impl PartialEq<(Foo, i32)> for Bar {
         fn eq(&self, _other: &(Bar, i32)) -> bool {
+            //~^ ERROR impl has stricter requirements than trait
             true
         }
     }
diff --git a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
index eae7d38d116..19d5cdb9d0a 100644
--- a/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
+++ b/src/test/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle.stderr
@@ -14,5 +14,12 @@ LL |     type Foo = impl PartialEq<(Foo, i32)>;
    |
    = note: `Foo` must be used in combination with a concrete type within the same module
 
-error: aborting due to 2 previous errors
+error[E0276]: impl has stricter requirements than trait
+  --> $DIR/recursive-type-alias-impl-trait-declaration-too-subtle.rs:23:9
+   |
+LL |         fn eq(&self, _other: &(Bar, i32)) -> bool {
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `b::Bar: PartialEq<(b::Bar, i32)>`
+
+error: aborting due to 3 previous errors
 
+For more information about this error, try `rustc --explain E0276`.
diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other2.rs b/src/test/ui/impl-trait/two_tait_defining_each_other2.rs
index 3b16d0f5e04..05b09668016 100644
--- a/src/test/ui/impl-trait/two_tait_defining_each_other2.rs
+++ b/src/test/ui/impl-trait/two_tait_defining_each_other2.rs
@@ -1,6 +1,6 @@
 #![feature(type_alias_impl_trait)]
 
-type A = impl Foo;
+type A = impl Foo; //~ ERROR unconstrained opaque type
 type B = impl Foo;
 
 trait Foo {}
diff --git a/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr b/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr
index ef2089a6c5b..4d8f96de162 100644
--- a/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr
+++ b/src/test/ui/impl-trait/two_tait_defining_each_other2.stderr
@@ -1,3 +1,11 @@
+error: unconstrained opaque type
+  --> $DIR/two_tait_defining_each_other2.rs:3:10
+   |
+LL | type A = impl Foo;
+   |          ^^^^^^^^
+   |
+   = note: `A` must be used in combination with a concrete type within the same module
+
 error: opaque type's hidden type cannot be another opaque type from the same scope
   --> $DIR/two_tait_defining_each_other2.rs:9:5
    |
@@ -15,5 +23,5 @@ note: opaque type being used as hidden type
 LL | type A = impl Foo;
    |          ^^^^^^^^
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors