Auto merge of #18371 - Veykril:veykril/push-kwttrusywysp, r=Veykril

fix: Fix incorrect parsing of use bounds

Fixes https://github.com/rust-lang/rust-analyzer/issues/18357
This commit is contained in:
bors 2024-10-22 11:42:11 +00:00
commit c58427ff94
11 changed files with 184 additions and 25 deletions

View file

@ -19,7 +19,7 @@ use hir_def::{
lang_item::{LangItem, LangItemTarget},
nameres::DefMap,
path::{Path, PathKind},
type_ref::{TraitBoundModifier, TypeBound, TypeRef},
type_ref::{TraitBoundModifier, TypeBound, TypeRef, UseArgRef},
visibility::Visibility,
GenericDefId, HasModule, ImportPathConfig, ItemContainerId, LocalFieldId, Lookup, ModuleDefId,
ModuleId, TraitId,
@ -2025,6 +2025,19 @@ impl HirDisplay for TypeBound {
)?;
path.hir_fmt(f)
}
TypeBound::Use(args) => {
let edition = f.edition();
write!(
f,
"use<{}> ",
args.iter()
.map(|it| match it {
UseArgRef::Lifetime(lt) => lt.name.display(f.db.upcast(), edition),
UseArgRef::Name(n) => n.display(f.db.upcast(), edition),
})
.format(", ")
)
}
TypeBound::Error => write!(f, "{{error}}"),
}
}

View file

@ -1067,7 +1067,7 @@ impl<'a> TyLoweringContext<'a> {
lifetime,
})))
}
TypeBound::Error => None,
TypeBound::Use(_) | TypeBound::Error => None,
};
clause.into_iter().chain(
trait_ref
@ -1087,6 +1087,7 @@ impl<'a> TyLoweringContext<'a> {
path.segments().last()
}
TypeBound::Path(_, TraitBoundModifier::Maybe)
| TypeBound::Use(_)
| TypeBound::Error
| TypeBound::Lifetime(_) => None,
};
@ -1571,7 +1572,7 @@ pub(crate) fn generic_predicates_for_param_query(
})
})
}
TypeBound::Lifetime(_) | TypeBound::Error => false,
TypeBound::Use(_) | TypeBound::Lifetime(_) | TypeBound::Error => false,
}
}
WherePredicate::Lifetime { .. } => false,