about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-09 11:28:05 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-22 14:35:46 +0000
commitf75361fec7aecfcede9cf6f0b97f2b1e7756e47b (patch)
tree812645d3ec14c64906ea38660d7c02ea521f8e8d /tests
parentac332bd9163990491d225e2a24ff92af89030dac (diff)
downloadrust-f75361fec7aecfcede9cf6f0b97f2b1e7756e47b.tar.gz
rust-f75361fec7aecfcede9cf6f0b97f2b1e7756e47b.zip
Limit impl trait in assoc type defining scope
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs8
-rw-r--r--tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.stderr15
2 files changed, 19 insertions, 4 deletions
diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs
index e440dce5e51..4c881dd1330 100644
--- a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs
+++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.rs
@@ -1,9 +1,8 @@
-//! This test shows that we can even follow projections
-//! into associated types of the same impl if they are
-//! indirectly mentioned in a struct field.
+//! This test shows that we do not treat opaque types
+//! as defined by a method if the opaque type is
+//! only indirectly mentioned in a struct field.
 
 #![feature(impl_trait_in_assoc_type)]
-// check-pass
 
 struct Bar;
 
@@ -16,6 +15,7 @@ impl Trait for Bar {
     type Assoc = impl std::fmt::Debug;
     fn foo() -> Foo {
         Foo { field: () }
+        //~^ ERROR: item constrains opaque type that is not in its signature
     }
 }
 
diff --git a/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.stderr b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.stderr
new file mode 100644
index 00000000000..5c53dfa3a75
--- /dev/null
+++ b/tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.stderr
@@ -0,0 +1,15 @@
+error: item constrains opaque type that is not in its signature
+  --> $DIR/hidden_behind_struct_field2.rs:17:22
+   |
+LL |         Foo { field: () }
+   |                      ^^
+   |
+   = note: this item must mention the opaque type in its signature in order to be able to register hidden types
+note: this item must mention the opaque type in its signature in order to be able to register hidden types
+  --> $DIR/hidden_behind_struct_field2.rs:16:8
+   |
+LL |     fn foo() -> Foo {
+   |        ^^^
+
+error: aborting due to 1 previous error
+