You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/test/ui/impl-trait/object-unsafe-trait-in-return-position-impl-trait.stderr
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,12 @@ LL | B
30
30
|
31
31
= note: to return `impl Trait`, all returned values must be of the same type
32
32
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
33
-
= help: you can instead return a boxed trait object using `Box<dyn ObjectSafe>`
34
33
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
35
34
= help: alternatively, create a new `enum` with a variant for each returned type
35
+
help: you could change the return type to be a boxed trait object
Copy file name to clipboardExpand all lines: src/test/ui/point-to-type-err-cause-on-impl-trait-return.stderr
+30-14Lines changed: 30 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,15 @@ LL | 1u32
12
12
|
13
13
= note: to return `impl Trait`, all returned values must be of the same type
14
14
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
15
-
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
16
15
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
17
16
= help: alternatively, create a new `enum` with a variant for each returned type
17
+
help: you could change the return type to be a boxed trait object
| ---------------------- expected because this return type...
@@ -30,12 +33,15 @@ LL | return 1u32;
30
33
|
31
34
= note: to return `impl Trait`, all returned values must be of the same type
32
35
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
33
-
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
34
36
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
35
37
= help: alternatively, create a new `enum` with a variant for each returned type
38
+
help: you could change the return type to be a boxed trait object
| ---------------------- expected because this return type...
@@ -48,25 +54,27 @@ LL | 1u32
48
54
|
49
55
= note: to return `impl Trait`, all returned values must be of the same type
50
56
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
51
-
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
52
57
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
53
58
= help: alternatively, create a new `enum` with a variant for each returned type
59
+
help: you could change the return type to be a boxed trait object
60
+
|
61
+
LL | fn baz() -> Box<dyn std::fmt::Display> {
62
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
54
63
55
64
error[E0308]: `if` and `else` have incompatible types
| ---------------------- expected because this return type...
@@ -78,17 +86,19 @@ LL | _ => 1u32,
78
86
|
79
87
= note: to return `impl Trait`, all returned values must be of the same type
80
88
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
81
-
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
82
89
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
83
90
= help: alternatively, create a new `enum` with a variant for each returned type
91
+
help: you could change the return type to be a boxed trait object
| ---------------------- expected because this return type...
90
101
LL | / match 13 {
91
-
LL | |
92
102
LL | | 0 => return 0i32,
93
103
| | ---- ...is found to be `i32` here
94
104
LL | | 1 => 1u32,
@@ -98,12 +108,15 @@ LL | | }
98
108
|
99
109
= note: to return `impl Trait`, all returned values must be of the same type
100
110
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
101
-
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
102
111
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
103
112
= help: alternatively, create a new `enum` with a variant for each returned type
113
+
help: you could change the return type to be a boxed trait object
| ---------------------- expected because this return type...
@@ -116,9 +129,12 @@ LL | 1u32
116
129
|
117
130
= note: to return `impl Trait`, all returned values must be of the same type
118
131
= note: for information on `impl Trait`, see <https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits>
119
-
= help: you can instead return a boxed trait object using `Box<dyn std::fmt::Display>`
120
132
= note: for information on trait objects, see <https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types>
121
133
= help: alternatively, create a new `enum` with a variant for each returned type
134
+
help: you could change the return type to be a boxed trait object
0 commit comments