@@ -6,8 +6,11 @@ use crate::{
6
6
use hir:: { def_id:: DefId , Body , HirId , HirIdMap } ;
7
7
use rustc_data_structures:: fx:: FxHashSet ;
8
8
use rustc_hir as hir;
9
- use rustc_middle:: hir:: place:: { PlaceBase , Projection , ProjectionKind } ;
10
9
use rustc_middle:: ty:: { ParamEnv , TyCtxt } ;
10
+ use rustc_middle:: {
11
+ hir:: place:: { PlaceBase , Projection , ProjectionKind } ,
12
+ ty:: TypeVisitable ,
13
+ } ;
11
14
12
15
pub ( super ) fn find_consumed_and_borrowed < ' a , ' tcx > (
13
16
fcx : & ' a FnCtxt < ' a , ' tcx > ,
@@ -198,11 +201,13 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
198
201
199
202
// If the type being assigned needs dropped, then the mutation counts as a borrow
200
203
// since it is essentially doing `Drop::drop(&mut x); x = new_value;`.
201
- //
202
- // FIXME(drop-tracking): We need to be more responsible about inference
203
- // variables here, since `needs_drop` is a "raw" type query, i.e. it
204
- // basically requires types to have been fully resolved.
205
- if assignee_place. place . base_ty . needs_drop ( self . tcx , self . param_env ) {
204
+ let ty = self . tcx . erase_regions ( assignee_place. place . base_ty ) ;
205
+ if ty. needs_infer ( ) {
206
+ self . tcx . sess . delay_span_bug (
207
+ self . tcx . hir ( ) . span ( assignee_place. hir_id ) ,
208
+ & format ! ( "inference variables in {ty}" ) ,
209
+ ) ;
210
+ } else if ty. needs_drop ( self . tcx , self . param_env ) {
206
211
self . places
207
212
. borrowed
208
213
. insert ( TrackedValue :: from_place_with_projections_allowed ( assignee_place) ) ;
0 commit comments