diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/specialization/specialization-projection.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/specialization/specialization-projection.rs')
-rw-r--r-- | tests/ui/specialization/specialization-projection.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/ui/specialization/specialization-projection.rs b/tests/ui/specialization/specialization-projection.rs new file mode 100644 index 000000000..78afe7a94 --- /dev/null +++ b/tests/ui/specialization/specialization-projection.rs @@ -0,0 +1,42 @@ +// run-pass +#![allow(dead_code)] + +#![feature(specialization)] //~ WARN the feature `specialization` is incomplete + +// Make sure we *can* project non-defaulted associated types +// cf ui/specialization/specialization-default-projection.rs + +// First, do so without any use of specialization + +trait Foo { + type Assoc; +} + +impl<T> Foo for T { + type Assoc = (); +} + +fn generic_foo<T>() -> <T as Foo>::Assoc { + () +} + +// Next, allow for one layer of specialization + +trait Bar { + type Assoc; +} + +impl<T> Bar for T { + default type Assoc = (); +} + +impl<T: Clone> Bar for T { + type Assoc = u8; +} + +fn generic_bar_clone<T: Clone>() -> <T as Bar>::Assoc { + 0u8 +} + +fn main() { +} |