-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add a hint that the expressions produce a value #87607
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
Conversation
Well, well, well: https://www.githubstatus.com/incidents/8qy34dmg4kdm |
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.
r=me after addressing the nitpick
compiler/rustc_lint/src/unused.rs
Outdated
lint.note(&format!("the {} produces a value", must_use_op)); | ||
if let Ok(snippet) = cx.sess().source_map().span_to_snippet(expr.span) { | ||
lint.span_suggestion( | ||
expr.span, | ||
"use `let _ = ...` to ignore it", | ||
format!("let _ = {}", snippet), | ||
Applicability::MachineApplicable, | ||
) | ||
.emit() | ||
} |
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.
lint.note(&format!("the {} produces a value", must_use_op)); | |
if let Ok(snippet) = cx.sess().source_map().span_to_snippet(expr.span) { | |
lint.span_suggestion( | |
expr.span, | |
"use `let _ = ...` to ignore it", | |
format!("let _ = {}", snippet), | |
Applicability::MachineApplicable, | |
) | |
.emit() | |
} | |
lint.span_label(expr.span, &format!("the {} produces a value", must_use_op)); | |
lint.span_suggestion_verbose( | |
expr.span, | |
"use `let _ = ...` to ignore the resulting value", | |
"let _ = ".to_string(), | |
Applicability::MachineApplicable, | |
); |
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.
Thanks! Applied it with changing expr.span
to expr.span.shrink_to_lo()
via 924eddf.
17b2e9f
to
924eddf
Compare
@bors r=estebank |
📌 Commit 924eddf has been approved by |
☀️ Test successful - checks-actions |
Fixes #85913
The second commit is semi-unrelated but it allows us to run the related tests just on
src/test/ui/lint
.