diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-03-05 14:52:45 +0900 |
|---|---|---|
| committer | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-03-17 07:45:19 +0900 |
| commit | 8240f1a3d3f0ff3e36c19836ea4d783f29752b0b (patch) | |
| tree | b08b0815612310d8db30a3e6cf48fe7a6565e521 /compiler/rustc_parse/src/parser | |
| parent | ea355bc6be34f7c3c1da0342ade39593a7f5e494 (diff) | |
| download | rust-8240f1a3d3f0ff3e36c19836ea4d783f29752b0b.tar.gz rust-8240f1a3d3f0ff3e36c19836ea4d783f29752b0b.zip | |
Fix bad diagnostics for anon params with qualified paths
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index f214b11d5f0..975b9cc15bd 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1627,18 +1627,28 @@ impl<'a> Parser<'a> { ), // Also catches `fn foo(&a)`. PatKind::Ref(ref pat, mutab) => { - if let PatKind::Ident(_, ident, _) = pat.clone().into_inner().kind { - let mutab = mutab.prefix_str(); - ( - ident, - format!("self: &{}{}", mutab, ident), - format!("{}: &{}TypeName", ident, mutab), - format!("_: &{}{}", mutab, ident), - ) - } else { - return None; + match pat.clone().into_inner().kind { + PatKind::Ident(_, ident, _) => { + let mutab = mutab.prefix_str(); + ( + ident, + format!("self: &{}{}", mutab, ident), + format!("{}: &{}TypeName", ident, mutab), + format!("_: &{}{}", mutab, ident), + ) + } + PatKind::Path(..) => { + err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)"); + return None; + } + _ => return None, } } + // Also catches `fn foo(<Bar as T>::Baz)` + PatKind::Path(..) => { + err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)"); + return None; + } // Ignore other `PatKind`. _ => return None, }; |
