diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 209091683a01..907193fe1d7f 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -464,7 +464,7 @@ impl<'db> SourceAnalyzer<'db> { db, &self.resolver, self.store()?, - generic_def.into(), + self.resolver.expression_store_owner().unwrap_or_else(|| generic_def.into()), generic_def, &generics, // FIXME: Is this correct here? Anyway that should impact mostly diagnostics, which we don't emit here @@ -1890,7 +1890,7 @@ fn resolve_hir_path_<'db>( db, resolver, store?, - def.into(), + resolver.expression_store_owner().unwrap_or_else(|| def.into()), def, &generics, LifetimeElisionKind::Infer, @@ -2094,7 +2094,7 @@ fn resolve_hir_path_qualifier<'db>( db, resolver, store, - def.into(), + resolver.expression_store_owner().unwrap_or_else(|| def.into()), def, &generics, LifetimeElisionKind::Infer, diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 4fea4468c072..fad322aa4f5d 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -11948,3 +11948,25 @@ fn main() {} "#]], ); } + +#[test] +fn resolve_array_type_with_anon_const_panic() { + use syntax::AstNode; + let (analysis, position) = crate::fixture::position( + r#" +fn main() { + let x: [u8; 2 + 2$0] = [0; 4]; +} +"#, + ); + let db = &analysis.db; + hir::attach_db(db, || { + let sema = hir::Semantics::new(db); + let file = sema.parse_guess_edition(position.file_id); + let token = file.syntax().token_at_offset(position.offset).right_biased().unwrap(); + let type_node = token.parent_ancestors().find_map(syntax::ast::Type::cast).unwrap(); + + let resolved = sema.resolve_type(&type_node).unwrap(); + let _ = resolved.as_array(db); + }); +}