fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #66089 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4560ea788cb

1.39.0
1.4 KiB29 linesraw
1error[E0423]: expected value, found trait `SomeTrait`
2  --> $DIR/E0033-teach.rs:8:37
3   |
4LL |     let trait_obj: &dyn SomeTrait = SomeTrait;
5   |                                     ^^^^^^^^^ not a value
6
7error[E0038]: the trait `SomeTrait` cannot be made into an object
8  --> $DIR/E0033-teach.rs:8:20
9   |
10LL |     fn foo();
11   |        --- associated function `foo` has no `self` parameter
12...
13LL |     let trait_obj: &dyn SomeTrait = SomeTrait;
14   |                    ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
15
16error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
17  --> $DIR/E0033-teach.rs:12:9
18   |
19LL |     let &invalid = trait_obj;
20   |         ^^^^^^^^ type `&dyn SomeTrait` cannot be dereferenced
21   |
22   = note: This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, this type has no compile-time size. Therefore, all accesses to trait types must be through pointers. If you encounter this error you should try to avoid dereferencing the pointer.
23           
24           You can read more about trait objects in the Trait Objects section of the Reference: https://doc.rust-lang.org/reference/types.html#trait-objects
25
26error: aborting due to 3 previous errors
27
28Some errors have detailed explanations: E0033, E0038, E0423.
29For more information about an error, try `rustc --explain E0033`.