about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-09-23 07:12:59 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-09-23 07:12:59 +0000
commit90ec6f847fe54e751a045044dabb7e0d252981e3 (patch)
treef3edb4425088b87e91b90967b13f999017f5033d /src/test
parent5ace12c409ef59c654e3f683dd5534a258945a77 (diff)
downloadrust-90ec6f847fe54e751a045044dabb7e0d252981e3.tar.gz
rust-90ec6f847fe54e751a045044dabb7e0d252981e3.zip
Show errors instead of hiding them due to an earlier error
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs17
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr34
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs11
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr14
4 files changed, 61 insertions, 15 deletions
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
index 4cbb6b63670..6e5b8f491ea 100644
--- a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
@@ -6,6 +6,7 @@ mod test_lifetime_param {
     fn assert_static<'a: 'static>() {}
     //~^ WARN: unnecessary lifetime parameter `'a`
     fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
+    //~^ ERROR: lifetime may not live long enough
 }
 
 mod test_higher_kinded_lifetime_param {
@@ -14,14 +15,14 @@ mod test_higher_kinded_lifetime_param {
     fn assert_static<'a: 'static>() {}
     //~^ WARN: unnecessary lifetime parameter `'a`
     fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
+    //~^ ERROR: lifetime may not live long enough
 }
 
 mod test_higher_kinded_lifetime_param2 {
     fn assert_static<'a: 'static>() {}
     //~^ WARN: unnecessary lifetime parameter `'a`
     fn test<'a>() { assert_static::<'a>() }
-    // no error because all the other errors happen first and then we abort before
-    // emitting an error here.
+    //~^ ERROR: lifetime may not live long enough
 }
 
 mod test_type_param {
@@ -29,14 +30,14 @@ mod test_type_param {
     fn defining<A>(s: A) -> Ty<A> { s }
     fn assert_static<A: 'static>() {}
     fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+    //~^ ERROR: parameter type `A` may not live long enough
 }
 
-mod test_type_param_static {
-    type Ty<A> = impl Sized + 'static;
-    //~^ ERROR: the parameter type `A` may not live long enough
-    fn defining<A: 'static>(s: A) -> Ty<A> { s }
-    fn assert_static<A: 'static>() {}
-    fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+mod test_implied_from_fn_sig {
+    type Opaque<T: 'static> = impl Sized;
+    fn defining<T: 'static>() -> Opaque<T> {}
+    fn assert_static<T: 'static>() {}
+    fn test<T>(_: Opaque<T>) { assert_static::<T>(); }
 }
 
 fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
index 16d529698f4..887620a4d50 100644
--- a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
@@ -7,7 +7,7 @@ LL |     fn assert_static<'a: 'static>() {}
    = help: you can use the `'static` lifetime directly, in place of `'a`
 
 warning: unnecessary lifetime parameter `'a`
-  --> $DIR/implied_lifetime_wf_check3.rs:14:22
+  --> $DIR/implied_lifetime_wf_check3.rs:15:22
    |
 LL |     fn assert_static<'a: 'static>() {}
    |                      ^^
@@ -15,24 +15,44 @@ LL |     fn assert_static<'a: 'static>() {}
    = help: you can use the `'static` lifetime directly, in place of `'a`
 
 warning: unnecessary lifetime parameter `'a`
-  --> $DIR/implied_lifetime_wf_check3.rs:20:22
+  --> $DIR/implied_lifetime_wf_check3.rs:22:22
    |
 LL |     fn assert_static<'a: 'static>() {}
    |                      ^^
    |
    = help: you can use the `'static` lifetime directly, in place of `'a`
 
+error: lifetime may not live long enough
+  --> $DIR/implied_lifetime_wf_check3.rs:8:43
+   |
+LL |     fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
+   |             -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/implied_lifetime_wf_check3.rs:17:46
+   |
+LL |     fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
+   |             -- lifetime `'a` defined here    ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+  --> $DIR/implied_lifetime_wf_check3.rs:24:21
+   |
+LL |     fn test<'a>() { assert_static::<'a>() }
+   |             --      ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
+   |             |
+   |             lifetime `'a` defined here
+
 error[E0310]: the parameter type `A` may not live long enough
-  --> $DIR/implied_lifetime_wf_check3.rs:35:18
+  --> $DIR/implied_lifetime_wf_check3.rs:32:41
    |
-LL |     type Ty<A> = impl Sized + 'static;
-   |                  ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+LL |     fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+   |                                         ^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
    |
 help: consider adding an explicit lifetime bound...
    |
-LL |     type Ty<A: 'static> = impl Sized + 'static;
+LL |     fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() }
    |              +++++++++
 
-error: aborting due to previous error; 3 warnings emitted
+error: aborting due to 4 previous errors; 3 warnings emitted
 
 For more information about this error, try `rustc --explain E0310`.
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs
new file mode 100644
index 00000000000..ac32dbde04b
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs
@@ -0,0 +1,11 @@
+#![feature(type_alias_impl_trait)]
+
+mod test_type_param_static {
+    type Ty<A> = impl Sized + 'static;
+    //~^ ERROR: the parameter type `A` may not live long enough
+    fn defining<A: 'static>(s: A) -> Ty<A> { s }
+    fn assert_static<A: 'static>() {}
+    fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
new file mode 100644
index 00000000000..47bc31e78c3
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
@@ -0,0 +1,14 @@
+error[E0310]: the parameter type `A` may not live long enough
+  --> $DIR/implied_lifetime_wf_check4_static.rs:4:18
+   |
+LL |     type Ty<A> = impl Sized + 'static;
+   |                  ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+   |
+help: consider adding an explicit lifetime bound...
+   |
+LL |     type Ty<A: 'static> = impl Sized + 'static;
+   |              +++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0310`.