Rollup merge of #60186 - estebank:accept-suffix, r=nikomatsakis
Temporarily accept [i|u][32|size] suffixes on a tuple index and warn Fix #60138. #59553 will need to be kept open to track the change back to rejecting this code a few versions down thee line.
This commit is contained in:
commit
eb4860c77c
1 changed files with 31 additions and 3 deletions
|
@ -1145,9 +1145,34 @@ impl<'a> Parser<'a> {
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
self.span_bug(sp, "found empty literal suffix in Some")
|
self.span_bug(sp, "found empty literal suffix in Some")
|
||||||
}
|
}
|
||||||
self.struct_span_err(sp, &format!("suffixes on {} are invalid", kind))
|
let mut err = if kind == "a tuple index" &&
|
||||||
.span_label(sp, format!("invalid suffix `{}`", text))
|
["i32", "u32", "isize", "usize"].contains(&text.to_string().as_str())
|
||||||
.emit();
|
{
|
||||||
|
// #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",
|
||||||
|
);
|
||||||
|
err.note(
|
||||||
|
"for more context, see https://github.com/rust-lang/rust/issues/60210",
|
||||||
|
);
|
||||||
|
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> {
|
fn struct_span_err<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> DiagnosticBuilder<'a> {
|
||||||
self.sess.span_diagnostic.struct_span_err(sp, m)
|
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) -> ! {
|
crate fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: &str) -> ! {
|
||||||
self.sess.span_diagnostic.span_bug(sp, m)
|
self.sess.span_diagnostic.span_bug(sp, m)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue