about summary refs log tree commit diff
path: root/src/test/ui/impl-trait/issues
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-02-01 17:28:46 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-02-02 15:40:12 +0000
commit7f608eb9edb38ff271ff5be50dbbbb424cbf348f (patch)
tree012aa765a63266fb522e081eb5c4e62fb7842b2e /src/test/ui/impl-trait/issues
parentbae04fb3ded72c71a660d34749d83d2752580052 (diff)
downloadrust-7f608eb9edb38ff271ff5be50dbbbb424cbf348f.tar.gz
rust-7f608eb9edb38ff271ff5be50dbbbb424cbf348f.zip
Prevent two opaque types in their defining scopes from being defined via the other
Diffstat (limited to 'src/test/ui/impl-trait/issues')
-rw-r--r--src/test/ui/impl-trait/issues/issue-70877.rs4
-rw-r--r--src/test/ui/impl-trait/issues/issue-70877.stderr19
-rw-r--r--src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr39
3 files changed, 59 insertions, 3 deletions
diff --git a/src/test/ui/impl-trait/issues/issue-70877.rs b/src/test/ui/impl-trait/issues/issue-70877.rs
index 42e5436390c..8169cfafac7 100644
--- a/src/test/ui/impl-trait/issues/issue-70877.rs
+++ b/src/test/ui/impl-trait/issues/issue-70877.rs
@@ -1,7 +1,5 @@
 #![feature(type_alias_impl_trait)]
 
-// check-pass
-
 type FooArg<'a> = &'a dyn ToString;
 type FooRet = impl std::fmt::Debug;
 
@@ -30,7 +28,7 @@ fn ham() -> Foo {
 fn oof() -> impl std::fmt::Debug {
     let mut bar = ham();
     let func = bar.next().unwrap();
-    return func(&"oof");
+    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
new file mode 100644
index 00000000000..8813bff3c35
--- /dev/null
+++ b/src/test/ui/impl-trait/issues/issue-70877.stderr
@@ -0,0 +1,19 @@
+error: opaque type's hidden type cannot be another opaque type from the same scope
+  --> $DIR/issue-70877.rs:31:12
+   |
+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
+   |
+LL | fn oof() -> impl std::fmt::Debug {
+   |             ^^^^^^^^^^^^^^^^^^^^
+note: opaque type being used as hidden type
+  --> $DIR/issue-70877.rs:4:15
+   |
+LL | type FooRet = impl std::fmt::Debug;
+   |               ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr b/src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr
new file mode 100644
index 00000000000..86323add779
--- /dev/null
+++ b/src/test/ui/impl-trait/issues/issue-88236-2.nll.stderr
@@ -0,0 +1,39 @@
+error: higher-ranked subtype error
+  --> $DIR/issue-88236-2.rs:17:5
+   |
+LL |     &()
+   |     ^^^
+
+error: higher-ranked subtype error
+  --> $DIR/issue-88236-2.rs:17:5
+   |
+LL |     &()
+   |     ^^^
+
+error: lifetime may not live long enough
+  --> $DIR/issue-88236-2.rs:20:5
+   |
+LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {
+   |                  -- lifetime `'b` defined here
+LL |     x
+   |     ^ returning this value requires that `'b` must outlive `'static`
+   |
+help: to allow this `impl Trait` to capture borrowed data with lifetime `'b`, add `'b` as a bound
+   |
+LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> + 'b {
+   |                                                                                  ++++
+
+error: higher-ranked subtype error
+  --> $DIR/issue-88236-2.rs:20:5
+   |
+LL |     x
+   |     ^
+
+error: higher-ranked subtype error
+  --> $DIR/issue-88236-2.rs:20:5
+   |
+LL |     x
+   |     ^
+
+error: aborting due to 5 previous errors
+