Skip to content
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

Add a hint that the expressions produce a value #87607

Merged
merged 3 commits into from
Jul 31, 2021

Conversation

JohnTitor
Copy link
Member

Fixes #85913
The second commit is semi-unrelated but it allows us to run the related tests just on src/test/ui/lint.

@JohnTitor JohnTitor closed this Jul 29, 2021
@JohnTitor JohnTitor reopened this Jul 29, 2021
@JohnTitor
Copy link
Member Author

Well, well, well: https://www.githubstatus.com/incidents/8qy34dmg4kdm

@JohnTitor JohnTitor added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2021
Copy link
Contributor

@estebank estebank left a 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

Comment on lines 165 to 174
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()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
);

Copy link
Member Author

@JohnTitor JohnTitor Jul 30, 2021

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.

@JohnTitor
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Jul 30, 2021

📌 Commit 924eddf has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 30, 2021
@bors
Copy link
Contributor

bors commented Jul 31, 2021

⌛ Testing commit 924eddf with merge 337181e...

@bors
Copy link
Contributor

bors commented Jul 31, 2021

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 337181e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 31, 2021
@bors bors merged commit 337181e into rust-lang:master Jul 31, 2021
@rustbot rustbot added this to the 1.56.0 milestone Jul 31, 2021
@JohnTitor JohnTitor deleted the help-to-unused-must-use-op branch July 31, 2021 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unecessary Warning message
4 participants