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

18 lines
438 B
Rust
Raw Normal View History

2023-02-06 09:18:09 -06:00
// run-pass
2023-01-06 02:47:35 -06: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 09:18:09 -06:00
use std::fmt::Debug;
2023-01-06 02:47:35 -06:00
fn main() {
2023-02-06 09:18:09 -06: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 02:47:35 -06:00
}