fork/rust

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

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.2 KiB37 linesraw
1error[E0746]: return type cannot have an unboxed trait object
2  --> $DIR/E0746.rs:8:13
3   |
4LL | fn foo() -> dyn Trait { Struct }
5   |             ^^^^^^^^^ doesn't have a size known at compile-time
6   |
7help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type
8   |
9LL | fn foo() -> impl Trait { Struct }
10   |             ~~~~
11help: box the return type, and wrap all of the returned values in `Box::new`
12   |
13LL | fn foo() -> Box<dyn Trait> { Box::new(Struct) }
14   |             ++++         +   +++++++++      +
15
16error[E0746]: return type cannot have an unboxed trait object
17  --> $DIR/E0746.rs:11:13
18   |
19LL | fn bar() -> dyn Trait {
20   |             ^^^^^^^^^ doesn't have a size known at compile-time
21   |
22help: return an `impl Trait` instead of a `dyn Trait`, if all returned values are the same type
23   |
24LL | fn bar() -> impl Trait {
25   |             ~~~~
26help: box the return type, and wrap all of the returned values in `Box::new`
27   |
28LL ~ fn bar() -> Box<dyn Trait> {
29LL |     if true {
30LL ~         return Box::new(0);
31LL |     }
32LL ~     Box::new(42)
33   |
34
35error: aborting due to 2 previous errors
36
37For more information about this error, try `rustc --explain E0746`.