Skip to content

Commit

Permalink
tuple indexing macro compat -> error
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Aug 3, 2019
1 parent 13d2d7f commit 32a18ec
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/libsyntax/parse/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,31 +354,19 @@ impl<'a> Parser<'a> {

crate fn expect_no_suffix(diag: &Handler, sp: Span, kind: &str, suffix: Option<Symbol>) {
if let Some(suf) = suffix {
let mut err = if kind == "a tuple index" &&
[sym::i32, sym::u32, sym::isize, sym::usize].contains(&suf) {
// #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 = diag.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",
suf,
));
let mut err = diag.struct_span_err(sp, &format!("suffixes on {} are invalid", kind));

if kind == "a tuple index"
&& [sym::i32, sym::u32, sym::isize, sym::usize].contains(&suf)
{
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",
`proc_macro::Literal::*_unsuffixed` for code that will desugar \
to tuple field access",
);
err
} else {
diag.struct_span_err(sp, &format!("suffixes on {} are invalid", kind))
};
err.note("for more context, see https://github.com/rust-lang/rust/issues/60210");
}

err.span_label(sp, format!("invalid suffix `{}`", suf));
err.emit();
}
Expand Down

0 comments on commit 32a18ec

Please sign in to comment.