diff options
| author | Michael Goulet <michael@errs.io> | 2022-09-14 23:28:14 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-10-14 04:43:56 +0000 |
| commit | feb4244f54c4ecf828ba8e0ae3d8c23d80b64646 (patch) | |
| tree | 7359d92923722416d1e91cf4984fb9d5ed5bf4c0 /src/test | |
| parent | 76386bd65e650b5289b142daa310a4b98230c3db (diff) | |
| download | rust-feb4244f54c4ecf828ba8e0ae3d8c23d80b64646.tar.gz rust-feb4244f54c4ecf828ba8e0ae3d8c23d80b64646.zip | |
Allow dyn* upcasting
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/dyn-star/upcast.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/dyn-star/upcast.rs b/src/test/ui/dyn-star/upcast.rs new file mode 100644 index 00000000000..cee76ada7df --- /dev/null +++ b/src/test/ui/dyn-star/upcast.rs @@ -0,0 +1,33 @@ +// run-pass + +#![feature(dyn_star, trait_upcasting)] +#![allow(incomplete_features)] + +trait Foo: Bar { + fn hello(&self); +} + +trait Bar { + fn world(&self); +} + +struct W(usize); + +impl Foo for W { + fn hello(&self) { + println!("hello!"); + } +} + +impl Bar for W { + fn world(&self) { + println!("world!"); + } +} + +fn main() { + let w: dyn* Foo = W(0); + w.hello(); + let w: dyn* Bar = w; + w.world(); +} |
