Fix bad diagnostics for anon params with qualified paths
This commit is contained in:
parent
ea355bc6be
commit
8240f1a3d3
3 changed files with 46 additions and 14 deletions
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue