-
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
Suggest && and || instead of 'and' and 'or' #54181
Conversation
cc @estebank I prefer to this PR than mine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! One small piece of feedback left. r=me after dealing with it.
Thank you @csmoe too for your change.
src/libsyntax/parse/parser.rs
Outdated
@@ -732,6 +732,12 @@ impl<'a> Parser<'a> { | |||
format!("expected {} here", expect))) | |||
}; | |||
let mut err = self.fatal(&msg_exp); | |||
if self.token.is_ident_named("and") { | |||
err.help("Use `&&` instead of `and` for the boolean operator"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the following?
err.span_suggestion_with_applicability(
self.span,
"use `&&` instead of `and` for the boolean operator",
"&&".to_string(),
Applicability::MaybeIncorrect,
);
This way the output will be presented inline and third party tools will be able to apply the suggestion in their UIs.
Same change in all four cases.
Appled the recommendation. Also added Is it not a problem that output looks a bit repetitive?:
|
There's a short span suggestion method that hides the actual suggestion and would work well for these, but it doesn't accept |
📌 Commit 79919a7 has been approved by |
As far as I understoon from the description, it is expected to change not directly related code ("modify every caller"), so another review may be needed. Is accepting |
@vi we should always be specifying |
There is already What Applied the |
@bors r+ |
📌 Commit bc63a4a has been approved by |
Also tried replacing all Shall I just push it or submit another pull reqeust? Shall abandoned functions be deprecated? |
@vi that change would be great as a stand alone PR. Remember to fix indentation when needed and changing the stderr files. |
Assuming the change touches tests? |
Suggest && and || instead of 'and' and 'or' Resolves rust-lang#54109. Note: competing pull reqeust: rust-lang#54179 r? @csmoe
Rollup of 5 pull requests Successful merges: - #53941 (rustdoc: Sort implementors) - #54181 (Suggest && and || instead of 'and' and 'or') - #54209 (Partially revert 674a5db "Fix undesirable fallout [from macro modularization]") - #54213 (De-overlap the lifetimes of `flow_inits` and `flow_{un,ever_}inits`.) - #54244 (Add a small search box to seach Rust's standary library) Failed merges: r? @ghost
I believe I was referring to making sure that when a line is above 100 cols, you change it as you did in this PR:
Correct :) |
errrr... why? how is && or || more readable and understandable than |
@berkus I think Rust is just based on C in that aspect. C has If in future some edition of Rust decides to implement both |
I agree that linter is not to blame here, but where and how can I suggest the more readable |
I also like Perl-style |
Resolves #54109.
Note: competing pull reqeust: #54179
r? @csmoe