diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-01-09 11:28:05 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-01-22 14:35:46 +0000 |
| commit | f75361fec7aecfcede9cf6f0b97f2b1e7756e47b (patch) | |
| tree | 812645d3ec14c64906ea38660d7c02ea521f8e8d /tests | |
| parent | ac332bd9163990491d225e2a24ff92af89030dac (diff) | |
| download | rust-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.rs | 8 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/hidden_behind_struct_field2.stderr | 15 |
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 + |
