Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir-ty/src/db.rs | 17 | ||||
| -rw-r--r-- | crates/hir-ty/src/display.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/infer/callee.rs | 4 | ||||
| -rw-r--r-- | crates/hir-ty/src/infer/closure.rs | 14 | ||||
| -rw-r--r-- | crates/hir-ty/src/infer/coerce.rs | 2 | ||||
| -rw-r--r-- | crates/hir-ty/src/mir/lower.rs | 4 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/interner.rs | 18 | ||||
| -rw-r--r-- | crates/hir-ty/src/next_solver/ty.rs | 2 | ||||
| -rw-r--r-- | crates/hir/src/has_source.rs | 2 | ||||
| -rw-r--r-- | crates/hir/src/lib.rs | 8 |
10 files changed, 40 insertions, 33 deletions
diff --git a/crates/hir-ty/src/db.rs b/crates/hir-ty/src/db.rs index 821ab5fc04..65b2d53398 100644 --- a/crates/hir-ty/src/db.rs +++ b/crates/hir-ty/src/db.rs @@ -230,7 +230,10 @@ pub struct InternedOpaqueTyId { } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub struct InternedClosure(pub ExpressionStoreOwnerId, pub ExprId); +pub struct InternedClosure { + pub owner: ExpressionStoreOwnerId, + pub expr: ExprId, +} #[salsa_macros::interned(constructor = new_impl, no_lifetime, debug, revisions = usize::MAX)] #[derive(PartialOrd, Ord)] @@ -242,8 +245,8 @@ impl InternedClosureId { #[inline] pub fn new(db: &dyn HirDatabase, loc: InternedClosure) -> Self { if cfg!(debug_assertions) { - let store = ExpressionStore::of(db, loc.0); - let expr = &store[loc.1]; + let store = ExpressionStore::of(db, loc.owner); + let expr = &store[loc.expr]; assert!( matches!( expr, @@ -270,8 +273,8 @@ impl InternedCoroutineId { #[inline] pub fn new(db: &dyn HirDatabase, loc: InternedClosure) -> Self { if cfg!(debug_assertions) { - let store = ExpressionStore::of(db, loc.0); - let expr = &store[loc.1]; + let store = ExpressionStore::of(db, loc.owner); + let expr = &store[loc.expr]; assert!( matches!( expr, @@ -299,8 +302,8 @@ impl InternedCoroutineClosureId { #[inline] pub fn new(db: &dyn HirDatabase, loc: InternedClosure) -> Self { if cfg!(debug_assertions) { - let store = ExpressionStore::of(db, loc.0); - let expr = &store[loc.1]; + let store = ExpressionStore::of(db, loc.owner); + let expr = &store[loc.expr]; assert!( matches!( expr, diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs index 8b00bdf391..0b06c10e1c 100644 --- a/crates/hir-ty/src/display.rs +++ b/crates/hir-ty/src/display.rs @@ -1726,7 +1726,7 @@ impl<'db> HirDisplay<'db> for Ty<'db> { } TyKind::Infer(..) => write!(f, "_")?, TyKind::Coroutine(coroutine_id, subst) => { - let InternedClosure(owner, expr_id) = coroutine_id.0.loc(db); + let InternedClosure { owner, expr: expr_id } = coroutine_id.0.loc(db); let CoroutineArgsParts { resume_ty, yield_ty, return_ty, .. } = subst.split_coroutine_args(); let body = ExpressionStore::of(db, owner); diff --git a/crates/hir-ty/src/infer/callee.rs b/crates/hir-ty/src/infer/callee.rs index 6c86b6720f..237c9177f8 100644 --- a/crates/hir-ty/src/infer/callee.rs +++ b/crates/hir-ty/src/infer/callee.rs @@ -136,7 +136,7 @@ impl<'db> InferenceContext<'_, 'db> { ); let adjust_steps = autoderef.adjust_steps_as_infer_ok(); let adjustments = autoderef.ctx().table.register_infer_ok(adjust_steps); - let def_id = def_id.0.loc(autoderef.ctx().db).1; + let def_id = def_id.0.loc(autoderef.ctx().db).expr; autoderef.ctx().record_deferred_call_resolution( def_id, DeferredCallResolution { @@ -187,7 +187,7 @@ impl<'db> InferenceContext<'_, 'db> { ); let adjust_steps = autoderef.adjust_steps_as_infer_ok(); let adjustments = autoderef.ctx().table.register_infer_ok(adjust_steps); - let def_id = def_id.0.loc(autoderef.ctx().db).1; + let def_id = def_id.0.loc(autoderef.ctx().db).expr; autoderef.ctx().record_deferred_call_resolution( def_id, DeferredCallResolution { diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs index f5b974b1db..86e82eb222 100644 --- a/crates/hir-ty/src/infer/closure.rs +++ b/crates/hir-ty/src/infer/closure.rs @@ -132,8 +132,10 @@ impl<'db> InferenceContext<'_, 'db> { }, ); - let closure_id = - InternedClosureId::new(self.db, InternedClosure(self.owner, closure_expr)); + let closure_id = InternedClosureId::new( + self.db, + InternedClosure { owner: self.owner, expr: closure_expr }, + ); (Ty::new_closure(interner, closure_id.into(), closure_args.args), None) } @@ -183,8 +185,10 @@ impl<'db> InferenceContext<'_, 'db> { }, ); - let coroutine_id = - InternedCoroutineId::new(self.db, InternedClosure(self.owner, closure_expr)); + let coroutine_id = InternedCoroutineId::new( + self.db, + InternedClosure { owner: self.owner, expr: closure_expr }, + ); ( Ty::new_coroutine(interner, coroutine_id.into(), coroutine_args.args), @@ -258,7 +262,7 @@ impl<'db> InferenceContext<'_, 'db> { let coroutine_closure_id = InternedCoroutineClosureId::new( self.db, - InternedClosure(self.owner, closure_expr), + InternedClosure { owner: self.owner, expr: closure_expr }, ); // We need to turn the liberated signature that we got from HIR, which diff --git a/crates/hir-ty/src/infer/coerce.rs b/crates/hir-ty/src/infer/coerce.rs index 55e02a6933..1c355c2065 100644 --- a/crates/hir-ty/src/infer/coerce.rs +++ b/crates/hir-ty/src/infer/coerce.rs @@ -1601,7 +1601,7 @@ fn coerce<'db>( } fn is_capturing_closure(db: &dyn HirDatabase, closure: InternedClosureId) -> bool { - let InternedClosure(owner, expr) = closure.loc(db); + let InternedClosure { owner, expr } = closure.loc(db); upvars_mentioned(db, owner) .is_some_and(|upvars| upvars.get(&expr).is_some_and(|upvars| !upvars.is_empty())) } diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index 49fb6f5305..11972e64d0 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -1254,7 +1254,7 @@ impl<'a, 'db> MirLowerCtx<'a, 'db> { not_supported!("closure with non closure type"); }; self.result.closures.push(id.0); - let closure_data = &self.infer.closures_data[&id.0.loc(self.db).1]; + let closure_data = &self.infer.closures_data[&id.0.loc(self.db).expr]; let span = |sources: &[CaptureSourceStack]| match sources .first() @@ -2144,7 +2144,7 @@ pub fn mir_body_for_closure_query<'db>( db: &'db dyn HirDatabase, closure: InternedClosureId, ) -> Result<'db, Arc<MirBody>> { - let InternedClosure(owner, expr) = closure.loc(db); + let InternedClosure { owner, expr } = closure.loc(db); let body_owner = owner.as_def_with_body().expect("MIR lowering should only happen for body-owned closures"); let body = Body::of(db, body_owner); diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs index 14e20dfe80..46ad4488a6 100644 --- a/crates/hir-ty/src/next_solver/interner.rs +++ b/crates/hir-ty/src/next_solver/interner.rs @@ -1269,13 +1269,13 @@ impl<'db> Interner for DbInterner<'db> { SolverDefId::TypeAliasId(it) => it.lookup(self.db()).container, SolverDefId::ConstId(it) => it.lookup(self.db()).container, SolverDefId::InternedClosureId(it) => { - return it.loc(self.db).0.generic_def(self.db()).into(); + return it.loc(self.db).owner.generic_def(self.db()).into(); } SolverDefId::InternedCoroutineId(it) => { - return it.loc(self.db).0.generic_def(self.db()).into(); + return it.loc(self.db).owner.generic_def(self.db()).into(); } SolverDefId::InternedCoroutineClosureId(it) => { - return it.loc(self.db).0.generic_def(self.db()).into(); + return it.loc(self.db).owner.generic_def(self.db()).into(); } SolverDefId::StaticId(_) | SolverDefId::AdtId(_) @@ -1313,7 +1313,7 @@ impl<'db> Interner for DbInterner<'db> { fn coroutine_movability(self, def_id: Self::CoroutineId) -> rustc_ast_ir::Movability { // FIXME: Make this a query? I don't believe this can be accessed from bodies other than // the current infer query, except with revealed opaques - is it rare enough to not matter? - let InternedClosure(owner, expr_id) = def_id.0.loc(self.db); + let InternedClosure { owner, expr: expr_id } = def_id.0.loc(self.db); let store = ExpressionStore::of(self.db, owner); let expr = &store[expr_id]; match *expr { @@ -1330,9 +1330,9 @@ impl<'db> Interner for DbInterner<'db> { } fn coroutine_for_closure(self, def_id: Self::CoroutineClosureId) -> Self::CoroutineId { - let InternedClosure(owner, coroutine_closure_expr) = def_id.0.loc(self.db); + let InternedClosure { owner, expr: coroutine_closure_expr } = def_id.0.loc(self.db); let coroutine_expr = ExpressionStore::coroutine_for_closure(coroutine_closure_expr); - InternedCoroutineId::new(self.db, InternedClosure(owner, coroutine_expr)).into() + InternedCoroutineId::new(self.db, InternedClosure { owner, expr: coroutine_expr }).into() } fn generics_require_sized_self(self, def_id: Self::DefId) -> bool { @@ -1938,7 +1938,7 @@ impl<'db> Interner for DbInterner<'db> { fn is_general_coroutine(self, def_id: Self::CoroutineId) -> bool { // FIXME: Make this a query? I don't believe this can be accessed from bodies other than // the current infer query, except with revealed opaques - is it rare enough to not matter? - let InternedClosure(owner, expr_id) = def_id.0.loc(self.db); + let InternedClosure { owner, expr: expr_id } = def_id.0.loc(self.db); let store = ExpressionStore::of(self.db, owner); matches!( store[expr_id], @@ -1952,7 +1952,7 @@ impl<'db> Interner for DbInterner<'db> { fn coroutine_is_async(self, def_id: Self::CoroutineId) -> bool { // FIXME: Make this a query? I don't believe this can be accessed from bodies other than // the current infer query, except with revealed opaques - is it rare enough to not matter? - let InternedClosure(owner, expr_id) = def_id.0.loc(self.db); + let InternedClosure { owner, expr: expr_id } = def_id.0.loc(self.db); let store = ExpressionStore::of(self.db, owner); matches!( store[expr_id], @@ -2114,7 +2114,7 @@ impl<'db> Interner for DbInterner<'db> { ) { let coroutine = InternedCoroutineId::new( self.db, - InternedClosure(ExpressionStoreOwnerId::Body(def_id), expr_id), + InternedClosure { owner: ExpressionStoreOwnerId::Body(def_id), expr: expr_id }, ); result.push(coroutine.into()); } diff --git a/crates/hir-ty/src/next_solver/ty.rs b/crates/hir-ty/src/next_solver/ty.rs index 3bd20e9064..e8945a77c3 100644 --- a/crates/hir-ty/src/next_solver/ty.rs +++ b/crates/hir-ty/src/next_solver/ty.rs @@ -757,7 +757,7 @@ impl<'db> Ty<'db> { } } TyKind::Coroutine(coroutine_id, _args) => { - let InternedClosure(owner, _) = coroutine_id.0.loc(db); + let InternedClosure { owner, expr: _ } = coroutine_id.0.loc(db); let krate = owner.krate(db); if let Some(future_trait) = hir_def::lang_item::lang_items(db, krate).Future { // This is only used by type walking. diff --git a/crates/hir/src/has_source.rs b/crates/hir/src/has_source.rs index 45c9811cc0..36e6bdf3fb 100644 --- a/crates/hir/src/has_source.rs +++ b/crates/hir/src/has_source.rs @@ -293,7 +293,7 @@ impl HasSource for Param<'_> { .map(|value| InFile { file_id, value }) } Callee::Closure(closure, _) => { - let InternedClosure(owner, expr_id) = closure.loc(db); + let InternedClosure { owner, expr: expr_id } = closure.loc(db); let (_, source_map) = ExpressionStore::with_source_map(db, owner); let ast @ InFile { file_id, value } = source_map.expr_syntax(expr_id).ok()?; let root = db.parse_or_expand(file_id); diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 8cc82113b3..150f90fa97 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2975,10 +2975,10 @@ impl<'db> Param<'db> { } Callee::Closure(closure, _) => { let c = closure.loc(db); - let body_owner = c.0; - let store = ExpressionStore::of(db, c.0); + let body_owner = c.owner; + let store = ExpressionStore::of(db, c.owner); - if let Expr::Closure { args, .. } = &store[c.1] + if let Expr::Closure { args, .. } = &store[c.expr] && let Pat::Bind { id, .. } = &store[args[self.idx]] { return Some(Local { parent: body_owner, binding_id: *id }); @@ -5165,7 +5165,7 @@ impl<'db> Closure<'db> { AnyClosureId::ClosureId(it) => it.loc(db), AnyClosureId::CoroutineClosureId(it) => it.loc(db), }; - let InternedClosure(owner, closure) = closure; + let InternedClosure { owner, expr: closure } = closure; let infer = InferenceResult::of(db, owner); let param_env = body_param_env_from_has_crate(db, owner); infer.closures_data[&closure] |