Use if let
to reduce some excessive indentation.
This commit is contained in:
parent
dcb72e705f
commit
c88954e9c1
1 changed files with 45 additions and 53 deletions
|
@ -1442,15 +1442,14 @@ fn deny_equality_constraints(
|
||||||
let mut err = errors::EqualityInWhere { span: predicate.span, assoc: None, assoc2: None };
|
let mut err = errors::EqualityInWhere { span: predicate.span, assoc: None, assoc2: None };
|
||||||
|
|
||||||
// Given `<A as Foo>::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
|
// Given `<A as Foo>::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
|
||||||
if let TyKind::Path(Some(qself), full_path) = &predicate.lhs_ty.kind {
|
if let TyKind::Path(Some(qself), full_path) = &predicate.lhs_ty.kind
|
||||||
if let TyKind::Path(None, path) = &qself.ty.kind {
|
&& let TyKind::Path(None, path) = &qself.ty.kind
|
||||||
match &path.segments[..] {
|
&& let [PathSegment { ident, args: None, .. }] = &path.segments[..]
|
||||||
[PathSegment { ident, args: None, .. }] => {
|
{
|
||||||
for param in &generics.params {
|
for param in &generics.params {
|
||||||
if param.ident == *ident {
|
if param.ident == *ident
|
||||||
let param = ident;
|
&& let [PathSegment { ident, args, .. }] = &full_path.segments[qself.position..]
|
||||||
match &full_path.segments[qself.position..] {
|
{
|
||||||
[PathSegment { ident, args, .. }] => {
|
|
||||||
// Make a new `Path` from `foo::Bar` to `Foo<Bar = RhsTy>`.
|
// Make a new `Path` from `foo::Bar` to `Foo<Bar = RhsTy>`.
|
||||||
let mut assoc_path = full_path.clone();
|
let mut assoc_path = full_path.clone();
|
||||||
// Remove `Bar` from `Foo::Bar`.
|
// Remove `Bar` from `Foo::Bar`.
|
||||||
|
@ -1488,17 +1487,10 @@ fn deny_equality_constraints(
|
||||||
err.assoc = Some(errors::AssociatedSuggestion {
|
err.assoc = Some(errors::AssociatedSuggestion {
|
||||||
span: predicate.span,
|
span: predicate.span,
|
||||||
ident: *ident,
|
ident: *ident,
|
||||||
param: *param,
|
param: param.ident,
|
||||||
path: pprust::path_to_string(&assoc_path),
|
path: pprust::path_to_string(&assoc_path),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Given `A: Foo, A::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
|
// Given `A: Foo, A::Bar = RhsTy`, suggest `A: Foo<Bar = RhsTy>`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue