diff options
| author | bors <bors@rust-lang.org> | 2019-04-24 03:16:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-04-24 03:16:47 +0000 |
| commit | 8a44125f557706774b6e99912a585fa6a399c183 (patch) | |
| tree | 72ba05ca46788988c1c644515dda05c7d24bab88 /src/libsyntax | |
| parent | 0928511d3a11ecc9703c3c34f0fe36282dd9b171 (diff) | |
| parent | 7304e969df1dddee7ea370df8c91b7dd1ee6d58c (diff) | |
| download | rust-8a44125f557706774b6e99912a585fa6a399c183.tar.gz rust-8a44125f557706774b6e99912a585fa6a399c183.zip | |
Auto merge of #60224 - Centril:rollup-lfuhhsk, r=Centril
Rollup of 5 pull requests Successful merges: - #56278 (Future-proof MIR for dedicated debuginfo.) - #59739 (Stabilize futures_api) - #59822 (Fix dark css rule) - #60186 (Temporarily accept [i|u][32|size] suffixes on a tuple index and warn) - #60190 (Don't generate unnecessary rmeta files.) Failed merges: r? @ghost
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/attr/builtin.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 34 |
2 files changed, 45 insertions, 7 deletions
diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs index 74c952b076c..db821f4e536 100644 --- a/src/libsyntax/attr/builtin.rs +++ b/src/libsyntax/attr/builtin.rs @@ -114,6 +114,8 @@ pub struct Stability { pub const_stability: Option<Symbol>, /// whether the function has a `#[rustc_promotable]` attribute pub promotable: bool, + /// whether the function has a `#[rustc_allow_const_fn_ptr]` attribute + pub allow_const_fn_ptr: bool, } /// The available stability levels. @@ -178,6 +180,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, let mut rustc_depr: Option<RustcDeprecation> = None; let mut rustc_const_unstable: Option<Symbol> = None; let mut promotable = false; + let mut allow_const_fn_ptr = false; let diagnostic = &sess.span_diagnostic; 'outer: for attr in attrs_iter { @@ -187,6 +190,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, "unstable", "stable", "rustc_promotable", + "rustc_allow_const_fn_ptr", ].iter().any(|&s| attr.path == s) { continue // not a stability level } @@ -198,6 +202,9 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, if attr.path == "rustc_promotable" { promotable = true; } + if attr.path == "rustc_allow_const_fn_ptr" { + allow_const_fn_ptr = true; + } // attributes with data else if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta { let meta = meta.as_ref().unwrap(); @@ -354,6 +361,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, rustc_depr: None, const_stability: None, promotable: false, + allow_const_fn_ptr: false, }) } (None, _, _) => { @@ -418,6 +426,7 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, rustc_depr: None, const_stability: None, promotable: false, + allow_const_fn_ptr: false, }) } (None, _) => { @@ -458,13 +467,14 @@ fn find_stability_generic<'a, I>(sess: &ParseSess, } // Merge the const-unstable info into the stability info - if promotable { + if promotable || allow_const_fn_ptr { if let Some(ref mut stab) = stab { - stab.promotable = true; + stab.promotable = promotable; + stab.allow_const_fn_ptr = allow_const_fn_ptr; } else { span_err!(diagnostic, item_sp, E0717, - "rustc_promotable attribute must be paired with \ - either stable or unstable attribute"); + "rustc_promotable and rustc_allow_const_fn_ptr attributes \ + must be paired with either stable or unstable attribute"); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 53dab510ac3..75d687be280 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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", + ); + 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> { 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) } |
