about summary refs log tree commit diff
path: root/tests/ui/impl-trait
diff options
context:
space:
mode:
authorAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2024-03-22 08:02:12 +0000
committerAli MJ Al-Nasrawy <alimjalnasrawy@gmail.com>2024-03-28 06:00:26 +0000
commit7c6876f9a9fe400e29430cb47cc11e71c13bb875 (patch)
tree0f5dd58bc769dc525628cbf0c09124efada93217 /tests/ui/impl-trait
parent6b6ed2ea28e591ccae99048f226f98abfcd2e087 (diff)
downloadrust-7c6876f9a9fe400e29430cb47cc11e71c13bb875.tar.gz
rust-7c6876f9a9fe400e29430cb47cc11e71c13bb875.zip
simplify check_unique
Diffstat (limited to 'tests/ui/impl-trait')
-rw-r--r--tests/ui/impl-trait/defining-use-captured-non-universal-region.infer.stderr2
-rw-r--r--tests/ui/impl-trait/defining-use-captured-non-universal-region.rs3
-rw-r--r--tests/ui/impl-trait/defining-use-captured-non-universal-region.statik.stderr33
-rw-r--r--tests/ui/impl-trait/rpit/non-defining-use-lifetimes.rs4
-rw-r--r--tests/ui/impl-trait/rpit/non-defining-use-lifetimes.stderr34
5 files changed, 20 insertions, 56 deletions
diff --git a/tests/ui/impl-trait/defining-use-captured-non-universal-region.infer.stderr b/tests/ui/impl-trait/defining-use-captured-non-universal-region.infer.stderr
index ec062abb2fc..2cb82bf771c 100644
--- a/tests/ui/impl-trait/defining-use-captured-non-universal-region.infer.stderr
+++ b/tests/ui/impl-trait/defining-use-captured-non-universal-region.infer.stderr
@@ -1,5 +1,5 @@
 error[E0792]: expected generic lifetime parameter, found `'_`
-  --> $DIR/defining-use-captured-non-universal-region.rs:15:18
+  --> $DIR/defining-use-captured-non-universal-region.rs:14:18
    |
 LL | fn foo<'a>() -> impl Sized + 'a {
    |                              -- this generic parameter must be used with a generic lifetime parameter
diff --git a/tests/ui/impl-trait/defining-use-captured-non-universal-region.rs b/tests/ui/impl-trait/defining-use-captured-non-universal-region.rs
index 4f72333e65e..2d54804f1fa 100644
--- a/tests/ui/impl-trait/defining-use-captured-non-universal-region.rs
+++ b/tests/ui/impl-trait/defining-use-captured-non-universal-region.rs
@@ -8,8 +8,7 @@
 fn foo<'a>() -> impl Sized + 'a {
     #[cfg(statik)]
     let i: i32 = foo::<'static>();
-    //[statik]~^ ERROR opaque type used twice with different lifetimes
-    //[statik]~| ERROR opaque type used twice with different lifetimes
+    //[statik]~^ ERROR expected generic lifetime parameter, found `'static`
 
     #[cfg(infer)]
     let i: i32 = foo::<'_>();
diff --git a/tests/ui/impl-trait/defining-use-captured-non-universal-region.statik.stderr b/tests/ui/impl-trait/defining-use-captured-non-universal-region.statik.stderr
index b44f9ca6944..0d9b7df2257 100644
--- a/tests/ui/impl-trait/defining-use-captured-non-universal-region.statik.stderr
+++ b/tests/ui/impl-trait/defining-use-captured-non-universal-region.statik.stderr
@@ -1,33 +1,12 @@
-error: opaque type used twice with different lifetimes
-  --> $DIR/defining-use-captured-non-universal-region.rs:10:18
-   |
-LL |     let i: i32 = foo::<'static>();
-   |                  ^^^^^^^^^^^^^^^^ lifetime `'static` used here
-...
-LL |     i
-   |     - lifetime `'a` previously used here
-   |
-note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types
-  --> $DIR/defining-use-captured-non-universal-region.rs:10:18
-   |
-LL |     let i: i32 = foo::<'static>();
-   |                  ^^^^^^^^^^^^^^^^
-
-error: opaque type used twice with different lifetimes
-  --> $DIR/defining-use-captured-non-universal-region.rs:10:18
-   |
-LL |     let i: i32 = foo::<'static>();
-   |                  ^^^^^^^^^^^^^^^^ lifetime `'static` used here
-...
-LL |     i
-   |     - lifetime `'a` previously used here
-   |
-note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types
+error[E0792]: expected generic lifetime parameter, found `'static`
   --> $DIR/defining-use-captured-non-universal-region.rs:10:18
    |
+LL | fn foo<'a>() -> impl Sized + 'a {
+   |                              -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
+LL |     #[cfg(statik)]
 LL |     let i: i32 = foo::<'static>();
    |                  ^^^^^^^^^^^^^^^^
-   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
+For more information about this error, try `rustc --explain E0792`.
diff --git a/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.rs b/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.rs
index 923b194d483..cad41d2f2ed 100644
--- a/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.rs
+++ b/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.rs
@@ -12,7 +12,7 @@ mod statik {
     // invalid defining use: Opaque<'static> := ()
     fn foo<'a>(_: Lt<'a>) -> impl Sized + 'a {
         let _: () = foo(Lt::<'static>::None);
-        //~^ ERROR opaque type used twice with different lifetimes
+        //~^ ERROR expected generic lifetime parameter, found `'static`
     }
 }
 
@@ -31,7 +31,7 @@ mod equal {
     // because of the use of equal lifetimes in args
     fn foo<'a, 'b>(_: Lt<'a>, _: Lt<'b>) -> impl Sized + 'a + 'b {
         let _: () = foo(Lt::<'a>::None, Lt::<'a>::None);
-        //~^ ERROR opaque type used twice with different lifetimes
+        //~^ ERROR non-defining opaque type use in defining scope
     }
 }
 
diff --git a/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.stderr b/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.stderr
index e0122d32abe..7ef96a2e595 100644
--- a/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.stderr
+++ b/tests/ui/impl-trait/rpit/non-defining-use-lifetimes.stderr
@@ -1,17 +1,8 @@
-error: opaque type used twice with different lifetimes
-  --> $DIR/non-defining-use-lifetimes.rs:14:16
-   |
-LL |       fn foo<'a>(_: Lt<'a>) -> impl Sized + 'a {
-   |  ______________________________________________-
-LL | |         let _: () = foo(Lt::<'static>::None);
-   | |                ^^ lifetime `'static` used here
-LL | |
-LL | |     }
-   | |_____- lifetime `'a` previously used here
-   |
-note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types
+error[E0792]: expected generic lifetime parameter, found `'static`
   --> $DIR/non-defining-use-lifetimes.rs:14:16
    |
+LL |     fn foo<'a>(_: Lt<'a>) -> impl Sized + 'a {
+   |                                           -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
 LL |         let _: () = foo(Lt::<'static>::None);
    |                ^^
 
@@ -23,22 +14,17 @@ LL |     fn foo<'a>(_: Lt<'a>) -> impl Sized + 'a {
 LL |         let _: () = foo(Lt::<'_>::None);
    |                ^^
 
-error: opaque type used twice with different lifetimes
-  --> $DIR/non-defining-use-lifetimes.rs:33:16
-   |
-LL |       fn foo<'a, 'b>(_: Lt<'a>, _: Lt<'b>) -> impl Sized + 'a + 'b {
-   |  __________________________________________________________________-
-LL | |         let _: () = foo(Lt::<'a>::None, Lt::<'a>::None);
-   | |                ^^ lifetime `'a` used here
-LL | |
-LL | |     }
-   | |_____- lifetime `'b` previously used here
-   |
-note: if all non-lifetime generic parameters are the same, but the lifetime parameters differ, it is not possible to differentiate the opaque types
+error: non-defining opaque type use in defining scope
   --> $DIR/non-defining-use-lifetimes.rs:33:16
    |
 LL |         let _: () = foo(Lt::<'a>::None, Lt::<'a>::None);
    |                ^^
+   |
+note: lifetime used multiple times
+  --> $DIR/non-defining-use-lifetimes.rs:32:58
+   |
+LL |     fn foo<'a, 'b>(_: Lt<'a>, _: Lt<'b>) -> impl Sized + 'a + 'b {
+   |                                                          ^^   ^^
 
 error: aborting due to 3 previous errors