Closed
Description
- Rationale: https://stackoverflow.com/q/47028390
fn main() {
let x = -5;
if x<-1 {
println!("ok");
}
}
The error currently looks like:
error: placement-in expression syntax is experimental and subject to change. (see issue #27779)
--> src/main.rs:3:8
|
3 | if x<-1 {
| ^^^^
|
= help: add #![feature(placement_in_syntax)] to the crate attributes to enable
but the intent was not to use the placement-in, the suggestion is just confusing the user. If we do add #![feature(placement_in_syntax)]
the error message would be even worse:
error[E0277]: the trait bound `{integer}: std::ops::Placer<_>` is not satisfied
--> src/main.rs:5:8
|
5 | if x<-1 {
| ----
| |
| the trait `std::ops::Placer<_>` is not implemented for `{integer}`
| in this macro invocation
|
= help: the following implementations were found:
<std::collections::linked_list::BackPlace<'a, T> as std::ops::Placer<T>>
<std::collections::vec_deque::PlaceBack<'a, T> as std::ops::Placer<T>>
<std::collections::hash_map::Entry<'a, K, V> as std::ops::Placer<V>>
<&'a mut std::collections::BinaryHeap<T> as std::ops::Placer<T>>
and 4 others
= note: required by `std::ops::Placer::make_place`
The suggestion should actually mention inserting a space between <
and -
if a comparison with a negative number is intended, e.g.
error: placement-in expression syntax is experimental and subject to change. (see issue #27779)
--> src/main.rs:3:8
|
3 | if x<-1 {
| ^^^^
| hint: for less-than comparison, try to add some spaces: `x < -1`
|
= help: add #![feature(placement_in_syntax)] to the crate attributes to enable