@@ -22,16 +22,22 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
2222 |
2323 = help: use an `if-else` expression instead
2424
25+ error: expected one of `.`, `;`, `?`, `}`, or an operator, found keyword `return`
26+ --> $DIR/ternary_operator.rs:54:9
27+ |
28+ LL | v ? return;
29+ | ^^^^^^ expected one of `.`, `;`, `?`, `}`, or an operator
30+
2531error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
26- --> $DIR/ternary_operator.rs:53 :37
32+ --> $DIR/ternary_operator.rs:60 :37
2733 |
2834LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
2935 | ^ expected one of `.`, `;`, `?`, `else`, or an operator
3036 |
3137 = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
3238
3339error: Rust has no ternary operator
34- --> $DIR/ternary_operator.rs:53 :19
40+ --> $DIR/ternary_operator.rs:60 :19
3541 |
3642LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
3743 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -93,15 +99,15 @@ LL | let x = 5 > 2 ? f32::MAX : f32::MIN;
9399 = help: the trait `FromResidual<_>` is not implemented for `()`
94100
95101error[E0277]: the `?` operator can only be applied to values that implement `Try`
96- --> $DIR/ternary_operator.rs:53 :17
102+ --> $DIR/ternary_operator.rs:60 :17
97103 |
98104LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
99105 | ^^^ the `?` operator cannot be applied to type `{integer}`
100106 |
101107 = help: the trait `Try` is not implemented for `{integer}`
102108
103109error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
104- --> $DIR/ternary_operator.rs:53 :19
110+ --> $DIR/ternary_operator.rs:60 :19
105111 |
106112LL | fn main() {
107113 | --------- this function should return `Result` or `Option` to accept `?`
@@ -110,6 +116,6 @@ LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
110116 |
111117 = help: the trait `FromResidual<_>` is not implemented for `()`
112118
113- error: aborting due to 13 previous errors
119+ error: aborting due to 14 previous errors
114120
115121For more information about this error, try `rustc --explain E0277`.
0 commit comments