-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Temporarily accept [i|u][32|size] suffixes on a tuple index and warn #60186
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1145,9 +1145,34 @@ impl<'a> Parser<'a> { | |
if text.is_empty() { | ||
self.span_bug(sp, "found empty literal suffix in Some") | ||
} | ||
self.struct_span_err(sp, &format!("suffixes on {} are invalid", kind)) | ||
.span_label(sp, format!("invalid suffix `{}`", text)) | ||
.emit(); | ||
let mut err = if kind == "a tuple index" && | ||
["i32", "u32", "isize", "usize"].contains(&text.to_string().as_str()) | ||
{ | ||
// #59553: warn instead of reject out of hand to allow the fix to percolate | ||
// through the ecosystem when people fix their macros | ||
let mut err = self.struct_span_warn( | ||
sp, | ||
&format!("suffixes on {} are invalid", kind), | ||
); | ||
err.note(&format!( | ||
"`{}` is *temporarily* accepted on tuple index fields as it was \ | ||
incorrectly accepted on stable for a few releases", | ||
text, | ||
)); | ||
err.help( | ||
"on proc macros, you'll want to use `syn::Index::from` or \ | ||
`proc_macro::Literal::*_unsuffixed` for code that will desugar \ | ||
to tuple field access", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 to giving some explicit help here! |
||
); | ||
err.note( | ||
"for more context, see https://github.com/rust-lang/rust/issues/59553", | ||
estebank marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
err | ||
} else { | ||
self.struct_span_err(sp, &format!("suffixes on {} are invalid", kind)) | ||
}; | ||
err.span_label(sp, format!("invalid suffix `{}`", text)); | ||
err.emit(); | ||
} | ||
} | ||
} | ||
|
@@ -1455,6 +1480,9 @@ impl<'a> Parser<'a> { | |
fn struct_span_err<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> { | ||
self.sess.span_diagnostic.struct_span_err(sp, m) | ||
} | ||
fn struct_span_warn<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> { | ||
self.sess.span_diagnostic.struct_span_warn(sp, m) | ||
} | ||
crate fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> ! { | ||
self.sess.span_diagnostic.span_bug(sp, m) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 affects my opinion, by the way -- what is the range of time in which it was accepted? I was assuming it has been accepted forever.
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.
Bisected (using godbolt) to 1.27 being the point at which it was allowed;
Test program: