mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2026-03-21 20:34:07 +00:00
Allow duplicate assoc type shorthand resolution if it points to the same assoc type
And with the same generic args.
This commit is contained in:
@@ -1809,8 +1809,12 @@ fn resolve_type_param_assoc_type_shorthand(
|
||||
return AssocTypeShorthandResolution::Ambiguous {
|
||||
sub_trait_resolution: Some(this_trait_resolution),
|
||||
};
|
||||
} else if supertraits_resolution.is_some() {
|
||||
return AssocTypeShorthandResolution::Ambiguous { sub_trait_resolution: None };
|
||||
} else if let Some(prev_resolution) = &supertraits_resolution {
|
||||
if prev_resolution == lookup_on_bounded_trait {
|
||||
return AssocTypeShorthandResolution::Ambiguous { sub_trait_resolution: None };
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
let (assoc_type, args) = assoc_type_and_args
|
||||
.get_with(|(assoc_type, args)| (*assoc_type, args.as_ref()))
|
||||
|
||||
@@ -2815,3 +2815,28 @@ fn contains_0<S: Collection<Item = i32>>(points: &S) {
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_21773() {
|
||||
check_no_mismatches(
|
||||
r#"
|
||||
trait Neg {
|
||||
type Output;
|
||||
}
|
||||
|
||||
trait Abs: Neg {
|
||||
fn abs(&self) -> Self::Output;
|
||||
}
|
||||
|
||||
trait SelfAbs: Abs + Neg
|
||||
where
|
||||
Self::Output: Neg<Output = Self::Output> + Abs,
|
||||
{
|
||||
}
|
||||
|
||||
fn wrapped_abs<T: SelfAbs<Output = T>>(v: T) -> T {
|
||||
v.abs()
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user