fork/rust

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

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

master
4.6 KiB115 linesraw
1error: Rust has no ternary operator
2  --> $DIR/ternary_operator.rs:5:19
3   |
4LL |     let x = 5 > 2 ? true : false;
5   |                   ^^^^^^^^^^^^^^^
6   |
7   = help: use an `if-else` expression instead
8
9error: Rust has no ternary operator
10  --> $DIR/ternary_operator.rs:21:19
11   |
12LL |     let x = 5 > 2 ? { true } : { false };
13   |                   ^^^^^^^^^^^^^^^^^^^^^^^
14   |
15   = help: use an `if-else` expression instead
16
17error: Rust has no ternary operator
18  --> $DIR/ternary_operator.rs:37:19
19   |
20LL |     let x = 5 > 2 ? f32::MAX : f32::MIN;
21   |                   ^^^^^^^^^^^^^^^^^^^^^^
22   |
23   = help: use an `if-else` expression instead
24
25error: expected one of `.`, `;`, `?`, `else`, or an operator, found `:`
26  --> $DIR/ternary_operator.rs:53:37
27   |
28LL |     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
33error: Rust has no ternary operator
34  --> $DIR/ternary_operator.rs:53:19
35   |
36LL |     let x = 5 > 2 ? { let x = vec![]: Vec<u16>; x } : { false };
37   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38   |
39   = help: use an `if-else` expression instead
40
41error[E0277]: the `?` operator can only be applied to values that implement `Try`
42  --> $DIR/ternary_operator.rs:5:17
43   |
44LL |     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
49error[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   |
52LL | fn a() {
53   | ------ this function should return `Result` or `Option` to accept `?`
54LL |     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
59error[E0277]: the `?` operator can only be applied to values that implement `Try`
60  --> $DIR/ternary_operator.rs:21:17
61   |
62LL |     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
67error[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   |
70LL | fn b() {
71   | ------ this function should return `Result` or `Option` to accept `?`
72LL |     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
77error[E0277]: the `?` operator can only be applied to values that implement `Try`
78  --> $DIR/ternary_operator.rs:37:17
79   |
80LL |     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
85error[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   |
88LL | fn c() {
89   | ------ this function should return `Result` or `Option` to accept `?`
90LL |     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
95error[E0277]: the `?` operator can only be applied to values that implement `Try`
96  --> $DIR/ternary_operator.rs:53:17
97   |
98LL |     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
103error[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   |
106LL | fn main() {
107   | --------- this function should return `Result` or `Option` to accept `?`
108LL |     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
113error: aborting due to 13 previous errors
114
115For more information about this error, try `rustc --explain E0277`.