diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs')
-rw-r--r-- | src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs new file mode 100644 index 000000000..4c36289f4 --- /dev/null +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs @@ -0,0 +1,36 @@ +// This test documents that `type Out = Box<dyn Bar<Assoc: Copy>>;` +// is allowed and will correctly reject an opaque `type Out` which +// does not satisfy the bound `<TheType as Bar>::Assoc: Copy`. +// +// FIXME(rust-lang/lang): I think this behavior is logical if we want to allow +// `dyn Trait<Assoc: Bound>` but we should decide if we want that. // Centril +// +// Additionally, as reported in https://github.com/rust-lang/rust/issues/63594, +// we check that the spans for the error message are sane here. + +#![feature(associated_type_bounds)] + +fn main() {} + +trait Bar { + type Assoc; +} + +trait Thing { + type Out; + fn func() -> Self::Out; +} + +struct AssocNoCopy; +impl Bar for AssocNoCopy { + type Assoc = String; +} + +impl Thing for AssocNoCopy { + type Out = Box<dyn Bar<Assoc: Copy>>; + + fn func() -> Self::Out { + //~^ ERROR the trait bound `String: Copy` is not satisfied + Box::new(AssocNoCopy) + } +} |