From 8240f1a3d3f0ff3e36c19836ea4d783f29752b0b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 5 Mar 2021 14:52:45 +0900 Subject: Fix bad diagnostics for anon params with qualified paths --- compiler/rustc_parse/src/parser/diagnostics.rs | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'compiler/rustc_parse') 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(::Baz)` + PatKind::Path(..) => { + err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)"); + return None; + } // Ignore other `PatKind`. _ => return None, }; -- cgit 1.4.1-3-g733a5