mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 04:18:20 +00:00
Merge pull request #20337 from ChayimFriedman2/double-inlay-hints
Some checks are pending
metrics / generate_final_metrics (push) Blocked by required conditions
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
Some checks are pending
metrics / generate_final_metrics (push) Blocked by required conditions
metrics / build_metrics (push) Waiting to run
metrics / other_metrics (diesel-1.4.8) (push) Blocked by required conditions
metrics / other_metrics (hyper-0.14.18) (push) Blocked by required conditions
metrics / other_metrics (ripgrep-13.0.0) (push) Blocked by required conditions
metrics / other_metrics (self) (push) Blocked by required conditions
metrics / other_metrics (webrender-2022) (push) Blocked by required conditions
rustdoc / rustdoc (push) Waiting to run
fix: When displaying a projection into a type parameter that has bounds as `impl Trait`, collect only the bounds of this projection
This commit is contained in:
commit
e57f18480d
2 changed files with 43 additions and 13 deletions
|
|
@ -620,19 +620,19 @@ impl HirDisplay for ProjectionTy {
|
|||
.generic_predicates(id.parent)
|
||||
.iter()
|
||||
.map(|pred| pred.clone().substitute(Interner, &substs))
|
||||
.filter(|wc| match wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => {
|
||||
matches!(
|
||||
tr.self_type_parameter(Interner).kind(Interner),
|
||||
TyKind::Alias(_)
|
||||
)
|
||||
}
|
||||
WhereClause::TypeOutlives(t) => {
|
||||
matches!(t.ty.kind(Interner), TyKind::Alias(_))
|
||||
}
|
||||
// We shouldn't be here if these exist
|
||||
WhereClause::AliasEq(_) => false,
|
||||
WhereClause::LifetimeOutlives(_) => false,
|
||||
.filter(|wc| {
|
||||
let ty = match wc.skip_binders() {
|
||||
WhereClause::Implemented(tr) => tr.self_type_parameter(Interner),
|
||||
WhereClause::TypeOutlives(t) => t.ty.clone(),
|
||||
// We shouldn't be here if these exist
|
||||
WhereClause::AliasEq(_) | WhereClause::LifetimeOutlives(_) => {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
let TyKind::Alias(AliasTy::Projection(proj)) = ty.kind(Interner) else {
|
||||
return false;
|
||||
};
|
||||
proj == self
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if !bounds.is_empty() {
|
||||
|
|
|
|||
|
|
@ -1065,4 +1065,34 @@ fn bar() {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_20239() {
|
||||
check_with_config(
|
||||
InlayHintsConfig { parameter_hints: true, type_hints: true, ..DISABLED_CONFIG },
|
||||
r#"
|
||||
//- minicore: fn
|
||||
trait Iterator {
|
||||
type Item;
|
||||
fn map<B, F: FnMut(Self::Item) -> B>(self, f: F);
|
||||
}
|
||||
trait ToString {
|
||||
fn to_string(&self);
|
||||
}
|
||||
|
||||
fn check_tostr_eq<L, R>(left: L, right: R)
|
||||
where
|
||||
L: Iterator,
|
||||
L::Item: ToString,
|
||||
R: Iterator,
|
||||
R::Item: ToString,
|
||||
{
|
||||
left.map(|s| s.to_string());
|
||||
// ^ impl ToString
|
||||
right.map(|s| s.to_string());
|
||||
// ^ impl ToString
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue