-
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
Use structured suggestions for nonstandard style lints #57387
Conversation
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
4179fb7
to
81fd363
Compare
let left = snippet.find('"'); | ||
let right = snippet.rfind('"').map(|pos| snippet.len() - pos); | ||
|
||
if let (Some(left), Some(right)) = (left, right) { |
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.
you can just add a ?
to the initializer of left
and right
instead of pattern matching.
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.
Nice, fixed.
src/libsyntax/diagnostics/plugin.rs
Outdated
Vec::new(), | ||
Vec::new() | ||
vec![ | ||
// #[allow(non_snake_case)] |
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.
While I generally have nothing against this, I'm wondering if we should do an in_macro
in the lint instead.
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.
I think the diagnostic is already not reported in macros? Is this just something funky with syntax extensions?
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.
Oh, right. So it's probably https://github.com/rust-lang/rust/blob/81fd3631c499799afb4bae968a21796eaf5d5c4f/src/libsyntax/diagnostics/plugin.rs#L120 using a dummy span instead of the span from https://github.com/rust-lang/rust/blob/81fd3631c499799afb4bae968a21796eaf5d5c4f/src/libsyntax/diagnostics/plugin.rs#L65
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.
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.
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.
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?
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.
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_help
s don't get emitted with a dummy span, but the lint will. This issue had nothing to do with the dummy span check.
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! That also explains why the lint suddenly started getting reported.
81fd363
to
9e436f9
Compare
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.
9e436f9
to
1b28f5a
Compare
@bors r+ |
📌 Commit 1b28f5a has been approved by |
⌛ Testing commit 1b28f5a with merge 59f835d7d79326242a9cfba0fbfd96c0e39f07b5... |
💔 Test failed - status-appveyor |
@bors retry |
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.
☀️ Test successful - checks-travis, status-appveyor |
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.