mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
17a6ae2df3
When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with. Fix #103155.
13 lines
360 B
Rust
13 lines
360 B
Rust
use std::any::Any;
|
|
|
|
fn main()
|
|
{
|
|
fn h(x:i32) -> i32 {3*x}
|
|
let mut vfnfer:Vec<Box<dyn Any>> = vec![];
|
|
vfnfer.push(Box::new(h));
|
|
println!("{:?}",(vfnfer[0] as dyn Fn)(3));
|
|
//~^ ERROR the precise format of `Fn`-family traits'
|
|
//~| ERROR missing generics for trait `Fn`
|
|
//~| ERROR the value of the associated type `Output` in `FnOnce`
|
|
}
|