|
| 1 | +error: Rust has no ternary operator |
| 2 | + --> $DIR/ternary_operator.rs:5:19 |
| 3 | + | |
| 4 | +LL | let x = 5 > 2 ? true : false; |
| 5 | + | ^^^^^^^^^^^^^^^ |
| 6 | + | |
| 7 | + = help: use an `if-else` expression instead |
| 8 | + |
| 9 | +error: Rust has no ternary operator |
| 10 | + --> $DIR/ternary_operator.rs:21:19 |
| 11 | + | |
| 12 | +LL | let x = 5 > 2 ? { true } : { false }; |
| 13 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 14 | + | |
| 15 | + = help: use an `if-else` expression instead |
| 16 | + |
| 17 | +error: Rust has no ternary operator |
| 18 | + --> $DIR/ternary_operator.rs:37:19 |
| 19 | + | |
| 20 | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; |
| 21 | + | ^^^^^^^^^^^^^^^^^^^^^^ |
| 22 | + | |
| 23 | + = help: use an `if-else` expression instead |
| 24 | + |
| 25 | +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:` |
| 26 | + --> $DIR/ternary_operator.rs:53:37 |
| 27 | + | |
| 28 | +LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false }; |
| 29 | + | ^ expected one of `.`, `;`, `?`, `else`, or an operator |
| 30 | + | |
| 31 | + = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> |
| 32 | + |
| 33 | +error: Rust has no ternary operator |
| 34 | + --> $DIR/ternary_operator.rs:53:19 |
| 35 | + | |
| 36 | +LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false }; |
| 37 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 38 | + | |
| 39 | + = help: use an `if-else` expression instead |
| 40 | + |
| 41 | +error[E0277]: the `?` operator can only be applied to values that implement `Try` |
| 42 | + --> $DIR/ternary_operator.rs:5:17 |
| 43 | + | |
| 44 | +LL | let x = 5 > 2 ? true : false; |
| 45 | + | ^^^ the `?` operator cannot be applied to type `{integer}` |
| 46 | + | |
| 47 | + = help: the trait `Try` is not implemented for `{integer}` |
| 48 | + |
| 49 | +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) |
| 50 | + --> $DIR/ternary_operator.rs:5:19 |
| 51 | + | |
| 52 | +LL | fn a() { |
| 53 | + | ------ this function should return `Result` or `Option` to accept `?` |
| 54 | +LL | let x = 5 > 2 ? true : false; |
| 55 | + | ^ cannot use the `?` operator in a function that returns `()` |
| 56 | + | |
| 57 | + = help: the trait `FromResidual<_>` is not implemented for `()` |
| 58 | + |
| 59 | +error[E0277]: the `?` operator can only be applied to values that implement `Try` |
| 60 | + --> $DIR/ternary_operator.rs:21:17 |
| 61 | + | |
| 62 | +LL | let x = 5 > 2 ? { true } : { false }; |
| 63 | + | ^^^ the `?` operator cannot be applied to type `{integer}` |
| 64 | + | |
| 65 | + = help: the trait `Try` is not implemented for `{integer}` |
| 66 | + |
| 67 | +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) |
| 68 | + --> $DIR/ternary_operator.rs:21:19 |
| 69 | + | |
| 70 | +LL | fn b() { |
| 71 | + | ------ this function should return `Result` or `Option` to accept `?` |
| 72 | +LL | let x = 5 > 2 ? { true } : { false }; |
| 73 | + | ^ cannot use the `?` operator in a function that returns `()` |
| 74 | + | |
| 75 | + = help: the trait `FromResidual<_>` is not implemented for `()` |
| 76 | + |
| 77 | +error[E0277]: the `?` operator can only be applied to values that implement `Try` |
| 78 | + --> $DIR/ternary_operator.rs:37:17 |
| 79 | + | |
| 80 | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; |
| 81 | + | ^^^ the `?` operator cannot be applied to type `{integer}` |
| 82 | + | |
| 83 | + = help: the trait `Try` is not implemented for `{integer}` |
| 84 | + |
| 85 | +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) |
| 86 | + --> $DIR/ternary_operator.rs:37:19 |
| 87 | + | |
| 88 | +LL | fn c() { |
| 89 | + | ------ this function should return `Result` or `Option` to accept `?` |
| 90 | +LL | let x = 5 > 2 ? f32::MAX : f32::MIN; |
| 91 | + | ^ cannot use the `?` operator in a function that returns `()` |
| 92 | + | |
| 93 | + = help: the trait `FromResidual<_>` is not implemented for `()` |
| 94 | + |
| 95 | +error[E0277]: the `?` operator can only be applied to values that implement `Try` |
| 96 | + --> $DIR/ternary_operator.rs:53:17 |
| 97 | + | |
| 98 | +LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false }; |
| 99 | + | ^^^ the `?` operator cannot be applied to type `{integer}` |
| 100 | + | |
| 101 | + = help: the trait `Try` is not implemented for `{integer}` |
| 102 | + |
| 103 | +error[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 |
| 105 | + | |
| 106 | +LL | fn main() { |
| 107 | + | --------- this function should return `Result` or `Option` to accept `?` |
| 108 | +LL | let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false }; |
| 109 | + | ^ cannot use the `?` operator in a function that returns `()` |
| 110 | + | |
| 111 | + = help: the trait `FromResidual<_>` is not implemented for `()` |
| 112 | + |
| 113 | +error: aborting due to 13 previous errors |
| 114 | + |
| 115 | +For more information about this error, try `rustc --explain E0277`. |
0 commit comments