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

Use structured suggestions for nonstandard style lints #57387

Merged
merged 4 commits into from
Jan 14, 2019

Conversation

euclio
Copy link
Contributor

@euclio euclio commented Jan 6, 2019

This PR modifies the lints in the nonstandard_style group to use structured suggestions. Note that there's a bit of tricky span calculation going on for the crate_name attribute. It also simplifies the code a bit: I don't think the "fallback" suggestions for these lints can actually be triggered.

Fixes #48103.
Fixes #52414.

@rust-highfive
Copy link
Collaborator

r? @davidtwco

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2019
@rust-highfive

This comment has been minimized.

@euclio euclio force-pushed the nonstandard-style-suggestions branch from 4179fb7 to 81fd363 Compare January 7, 2019 01:38
let left = snippet.find('"');
let right = snippet.rfind('"').map(|pos| snippet.len() - pos);

if let (Some(left), Some(right)) = (left, right) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just add a ? to the initializer of left and right instead of pattern matching.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, fixed.

Vec::new(),
Vec::new()
vec![
// #[allow(non_snake_case)]
Copy link
Contributor

Choose a reason for hiding this comment

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

While I generally have nothing against this, I'm wondering if we should do an in_macro in the lint instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the diagnostic is already not reported in macros? Is this just something funky with syntax extensions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@euclio euclio Jan 7, 2019

Choose a reason for hiding this comment

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

with_empty_ctxt already creates an identifier with a dummy span, so won't the lint get triggered anyways? Seems eaiser to me to just allow the lint 😅 I think that's what happened with lint failures inside format!: they were just fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

So... if it's a dummy, why is the lint triggered at all? Did you maybe do this change before you added the dummy check and the allow is now not necessary anymore?

Copy link
Contributor Author

@euclio euclio Jan 8, 2019

Choose a reason for hiding this comment

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

Ok, I was able to fix this by ensuring the syntax extensions use the call-site span with a macro expansion mark instead of just call-site span.

To clarify what I said earlier, the dummy check that I added only ensures that the suggestion gets added, not that the lint fires. span_helps don't get emitted with a dummy span, but the lint will. This issue had nothing to do with the dummy span check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! That also explains why the lint suddenly started getting reported.

@euclio euclio force-pushed the nonstandard-style-suggestions branch from 81fd363 to 9e436f9 Compare January 7, 2019 16:30
Use a structured suggestion and tighten the span to just the identifier.
Use a structured suggestion and tighten the span to just the identifier.
Use a structured suggestion and tighten the span to just the identifier.
@euclio euclio force-pushed the nonstandard-style-suggestions branch from 9e436f9 to 1b28f5a Compare January 8, 2019 18:25
@oli-obk
Copy link
Contributor

oli-obk commented Jan 9, 2019

@bors r+

@bors
Copy link
Contributor

bors commented Jan 9, 2019

📌 Commit 1b28f5a has been approved by oli-obk

@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 Jan 9, 2019
@davidtwco davidtwco assigned oli-obk and unassigned davidtwco Jan 9, 2019
@bors
Copy link
Contributor

bors commented Jan 10, 2019

⌛ Testing commit 1b28f5a with merge 59f835d7d79326242a9cfba0fbfd96c0e39f07b5...

@bors
Copy link
Contributor

bors commented Jan 10, 2019

💔 Test failed - status-appveyor

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 10, 2019
@pietroalbini
Copy link
Member

@bors retry
AppVeyor... what's wrong with you today?

@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 Jan 10, 2019
@bors
Copy link
Contributor

bors commented Jan 14, 2019

⌛ Testing commit 1b28f5a with merge 1d029c6...

bors added a commit that referenced this pull request Jan 14, 2019
Use structured suggestions for nonstandard style lints

This PR modifies the lints in the nonstandard_style group to use structured suggestions. Note that there's a bit of tricky span calculation going on for the `crate_name` attribute. It also simplifies the code a bit: I don't think the "fallback" suggestions for these lints can actually be triggered.

Fixes #48103.
Fixes #52414.
@bors
Copy link
Contributor

bors commented Jan 14, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: oli-obk
Pushing 1d029c6 to master...

@bors bors merged commit 1b28f5a into rust-lang:master Jan 14, 2019
@euclio euclio deleted the nonstandard-style-suggestions branch January 14, 2019 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants