Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/expr_store/lower.rs')
-rw-r--r--crates/hir-def/src/expr_store/lower.rs49
1 files changed, 15 insertions, 34 deletions
diff --git a/crates/hir-def/src/expr_store/lower.rs b/crates/hir-def/src/expr_store/lower.rs
index 4e877748ca..abd1382801 100644
--- a/crates/hir-def/src/expr_store/lower.rs
+++ b/crates/hir-def/src/expr_store/lower.rs
@@ -960,38 +960,29 @@ impl ExprCollector<'_> {
impl_trait_lower_fn: ImplTraitLowerFn<'_>,
) -> TypeBound {
match node.kind() {
- ast::TypeBoundKind::PathType(path_type) => {
+ ast::TypeBoundKind::PathType(binder, path_type) => {
+ let binder = match binder.and_then(|it| it.generic_param_list()) {
+ Some(gpl) => gpl
+ .lifetime_params()
+ .flat_map(|lp| lp.lifetime().map(|lt| Name::new_lifetime(&lt.text())))
+ .collect(),
+ None => ThinVec::default(),
+ };
let m = match node.question_mark_token() {
Some(_) => TraitBoundModifier::Maybe,
None => TraitBoundModifier::None,
};
self.lower_path_type(&path_type, impl_trait_lower_fn)
.map(|p| {
- TypeBound::Path(self.alloc_path(p, AstPtr::new(&path_type).upcast()), m)
+ let path = self.alloc_path(p, AstPtr::new(&path_type).upcast());
+ if binder.is_empty() {
+ TypeBound::Path(path, m)
+ } else {
+ TypeBound::ForLifetime(binder, path)
+ }
})
.unwrap_or(TypeBound::Error)
}
- ast::TypeBoundKind::ForType(for_type) => {
- let lt_refs = match for_type.generic_param_list() {
- Some(gpl) => gpl
- .lifetime_params()
- .flat_map(|lp| lp.lifetime().map(|lt| Name::new_lifetime(&lt.text())))
- .collect(),
- None => ThinVec::default(),
- };
- let path = for_type.ty().and_then(|ty| match &ty {
- ast::Type::PathType(path_type) => {
- self.lower_path_type(path_type, impl_trait_lower_fn).map(|p| (p, ty))
- }
- _ => None,
- });
- match path {
- Some((p, ty)) => {
- TypeBound::ForLifetime(lt_refs, self.alloc_path(p, AstPtr::new(&ty)))
- }
- None => TypeBound::Error,
- }
- }
ast::TypeBoundKind::Use(gal) => TypeBound::Use(
gal.use_bound_generic_args()
.map(|p| match p {
@@ -1981,13 +1972,7 @@ impl ExprCollector<'_> {
return collector(self, None);
}
};
- if record_diagnostics {
- if let Some(err) = res.err {
- self.store
- .diagnostics
- .push(ExpressionStoreDiagnostics::MacroError { node: macro_call_ptr, err });
- }
- }
+ // No need to push macro and parsing errors as they'll be recreated from `macro_calls()`.
match res.value {
Some((mark, expansion)) => {
@@ -1997,10 +1982,6 @@ impl ExprCollector<'_> {
self.store.expansions.insert(macro_call_ptr, macro_file);
}
- if record_diagnostics {
- // FIXME: Report parse errors here
- }
-
let id = collector(self, expansion.map(|it| it.tree()));
self.expander.exit(mark);
id