let obj = box_bar as Box<Foo>; // 此处应该是let obj = box_bar as Box<dyn Foo>;
Rust版本
$ rustc -V
rustc 1.67.0 (fc594f156 2023-01-24)
错误信息
Compiling playground v0.0.1 (/playground)
error[[E0782]](https://doc.rust-lang.org/stable/error-index.html#E0782): trait objects must include the `dyn` keyword
--> src/main.rs:9:30
|
9 | let obj = box_bar as Box<Foo>;
| ^^^
|
help: add `dyn` keyword before this trait
|
9 | let obj = box_bar as Box<dyn Foo>;
| +++
For more information about this error, try `rustc --explain E0782`.
error: could not compile `playground` due to previous error
页码与行数
文本或排版错误
代码错误
Rust版本
错误信息