rust/tests/ui/dyn-star/dyn-star-to-dyn.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
439 B
Rust
Raw Normal View History

2023-02-06 15:18:09 +00:00
//@ run-pass
2023-01-06 08:47:35 +00:00
#![feature(dyn_star)]
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
2023-02-06 15:18:09 +00:00
use std::fmt::Debug;
2023-01-06 08:47:35 +00:00
fn main() {
2023-02-06 15:18:09 +00:00
let x: dyn* Debug = &42;
let x = Box::new(x) as Box<dyn Debug>;
assert_eq!("42", format!("{x:?}"));
// Also test opposite direction.
let x: Box<dyn Debug> = Box::new(42);
let x = &x as dyn* Debug;
assert_eq!("42", format!("{x:?}"));
2023-01-06 08:47:35 +00:00
}