-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When seeing x<-y
in a boolean expression, suggest x < -y
.
#45651
Comments
Should expand the following code: rust/src/libsyntax/feature_gate.rs Lines 1518 to 1519 in 442b7bd
to have a version gate_feature_post! that accepts extra notes, and add a note that if you meant to compare x with 1 you should add a space between < and - (you can get the spans from the two fields in InPlace(expr, expr) .
The same should be done for the case where the feature flag has been enabled:
I believe it is somewhere under: rust/src/librustc/hir/lowering.rs Line 2454 in 442b7bd
The second case can also be dealt with by using |
Can I take this on? I have some time in the latter half of this month. |
@arshiamufti feel free to do so and to ask for help! |
@estebank Hi, Can I take this one? if yes, then I will need your guidance. |
hi @PramodBisht -- i'm actually going to work on this sometime in the near future :) |
@arshiamufti sure! |
…rkor Suggest correct comparison against negative literal When parsing as emplacement syntax (`x<-1`), suggest the correct syntax for comparison against a negative value (`x< -1`). Fix rust-lang#45651.
…rkor Suggest correct comparison against negative literal When parsing as emplacement syntax (`x<-1`), suggest the correct syntax for comparison against a negative value (`x< -1`). Fix rust-lang#45651.
Suggest correct comparison against negative literal When parsing as emplacement syntax (`x<-1`), suggest the correct syntax for comparison against a negative value (`x< -1`). Fix #45651.
Test case:
The error currently looks like:
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:The suggestion should actually mention inserting a space between
<
and-
if a comparison with a negative number is intended, e.g.The text was updated successfully, but these errors were encountered: