@@ -5,7 +5,6 @@ use hir_def::AdtId;
5
5
use hir_def:: data:: adt:: StructFlags ;
6
6
use hir_def:: lang_item:: LangItem ;
7
7
use stdx:: never;
8
- use triomphe:: Arc ;
9
8
10
9
use crate :: db:: HirDatabaseData ;
11
10
use crate :: {
@@ -47,7 +46,7 @@ pub enum DropGlue {
47
46
HasDropGlue ,
48
47
}
49
48
50
- pub ( crate ) fn has_drop_glue ( db : & dyn HirDatabase , ty : Ty , env : Arc < TraitEnvironment > ) -> DropGlue {
49
+ pub ( crate ) fn has_drop_glue ( db : & dyn HirDatabase , ty : Ty , env : TraitEnvironment < ' _ > ) -> DropGlue {
51
50
match ty. kind ( Interner ) {
52
51
TyKind :: Adt ( adt, subst) => {
53
52
if has_destructor ( db, adt. 0 ) {
@@ -61,10 +60,7 @@ pub(crate) fn has_drop_glue(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironm
61
60
db. field_types ( id. into ( ) )
62
61
. iter ( )
63
62
. map ( |( _, field_ty) | {
64
- db. has_drop_glue (
65
- field_ty. clone ( ) . substitute ( Interner , subst) ,
66
- env. clone ( ) ,
67
- )
63
+ db. has_drop_glue ( field_ty. clone ( ) . substitute ( Interner , subst) , env)
68
64
} )
69
65
. max ( )
70
66
. unwrap_or ( DropGlue :: None )
@@ -79,10 +75,7 @@ pub(crate) fn has_drop_glue(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironm
79
75
db. field_types ( variant. into ( ) )
80
76
. iter ( )
81
77
. map ( |( _, field_ty) | {
82
- db. has_drop_glue (
83
- field_ty. clone ( ) . substitute ( Interner , subst) ,
84
- env. clone ( ) ,
85
- )
78
+ db. has_drop_glue ( field_ty. clone ( ) . substitute ( Interner , subst) , env)
86
79
} )
87
80
. max ( )
88
81
. unwrap_or ( DropGlue :: None )
@@ -94,7 +87,7 @@ pub(crate) fn has_drop_glue(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironm
94
87
TyKind :: Tuple ( _, subst) => subst
95
88
. iter ( Interner )
96
89
. map ( |ty| ty. assert_ty_ref ( Interner ) )
97
- . map ( |ty| db. has_drop_glue ( ty. clone ( ) , env. clone ( ) ) )
90
+ . map ( |ty| db. has_drop_glue ( ty. clone ( ) , env) )
98
91
. max ( )
99
92
. unwrap_or ( DropGlue :: None ) ,
100
93
TyKind :: Array ( ty, len) => {
@@ -124,7 +117,7 @@ pub(crate) fn has_drop_glue(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironm
124
117
let env = db. trait_environment_for_body ( owner) ;
125
118
captures
126
119
. iter ( )
127
- . map ( |capture| db. has_drop_glue ( capture. ty ( subst) , env. clone ( ) ) )
120
+ . map ( |capture| db. has_drop_glue ( capture. ty ( subst) , env) )
128
121
. max ( )
129
122
. unwrap_or ( DropGlue :: None )
130
123
}
@@ -169,11 +162,11 @@ pub(crate) fn has_drop_glue(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironm
169
162
170
163
fn projection_has_drop_glue (
171
164
db : & dyn HirDatabase ,
172
- env : Arc < TraitEnvironment > ,
165
+ env : TraitEnvironment < ' _ > ,
173
166
projection : ProjectionTy ,
174
167
ty : Ty ,
175
168
) -> DropGlue {
176
- let normalized = db. normalize_projection ( projection, env. clone ( ) ) ;
169
+ let normalized = db. normalize_projection ( projection, env) ;
177
170
match normalized. kind ( Interner ) {
178
171
TyKind :: Alias ( AliasTy :: Projection ( _) ) | TyKind :: AssociatedType ( ..) => {
179
172
if is_copy ( db, ty, env) { DropGlue :: None } else { DropGlue :: DependOnParams }
@@ -182,25 +175,25 @@ fn projection_has_drop_glue(
182
175
}
183
176
}
184
177
185
- fn is_copy ( db : & dyn HirDatabase , ty : Ty , env : Arc < TraitEnvironment > ) -> bool {
186
- let Some ( copy_trait) = db. lang_item ( env. krate , LangItem :: Copy ) . and_then ( |it| it. as_trait ( ) )
178
+ fn is_copy ( db : & dyn HirDatabase , ty : Ty , env : TraitEnvironment < ' _ > ) -> bool {
179
+ let Some ( copy_trait) = db. lang_item ( env. krate ( db ) , LangItem :: Copy ) . and_then ( |it| it. as_trait ( ) )
187
180
else {
188
181
return false ;
189
182
} ;
190
183
let trait_ref = TyBuilder :: trait_ref ( db, copy_trait) . push ( ty) . build ( ) ;
191
184
let goal = Canonical {
192
- value : InEnvironment :: new ( & env. env , trait_ref. cast ( Interner ) ) ,
185
+ value : InEnvironment :: new ( env. env ( db ) , trait_ref. cast ( Interner ) ) ,
193
186
binders : CanonicalVarKinds :: empty ( Interner ) ,
194
187
} ;
195
- db. trait_solve ( env. krate , env. block , goal) . is_some ( )
188
+ db. trait_solve ( env. krate ( db ) , env. block ( db ) , goal) . is_some ( )
196
189
}
197
190
198
191
pub ( crate ) fn has_drop_glue_recover (
199
192
_db : & dyn HirDatabase ,
200
193
_cycle : & salsa:: Cycle ,
201
194
_: HirDatabaseData ,
202
195
_ty : Ty ,
203
- _env : Arc < TraitEnvironment > ,
196
+ _env : TraitEnvironment < ' _ > ,
204
197
) -> DropGlue {
205
198
DropGlue :: None
206
199
}
0 commit comments