@@ -14,6 +14,7 @@ use middle::infer;
14
14
use middle:: region;
15
15
use middle:: subst:: { self , Subst } ;
16
16
use middle:: ty:: { self , Ty } ;
17
+ use util:: nodemap:: FnvHashSet ;
17
18
18
19
use syntax:: ast;
19
20
use syntax:: codemap:: { self , Span } ;
@@ -268,7 +269,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>
268
269
rcx : rcx,
269
270
span : span,
270
271
parent_scope : parent_scope,
271
- breadcrumbs : vec ! [ ]
272
+ breadcrumbs : FnvHashSet ( )
272
273
} ,
273
274
TypeContext :: Root ,
274
275
typ,
@@ -331,7 +332,7 @@ enum TypeContext {
331
332
struct DropckContext < ' a , ' b : ' a , ' tcx : ' b > {
332
333
rcx : & ' a mut Rcx < ' b , ' tcx > ,
333
334
/// types that have already been traversed
334
- breadcrumbs : Vec < Ty < ' tcx > > ,
335
+ breadcrumbs : FnvHashSet < Ty < ' tcx > > ,
335
336
/// span for error reporting
336
337
span : Span ,
337
338
/// the scope reachable dtorck types must outlive
@@ -358,15 +359,13 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'tcx>(
358
359
359
360
let opt_phantom_data_def_id = tcx. lang_items . phantom_data ( ) ;
360
361
361
- // FIXME(arielb1): don't be O(n^2)
362
- if cx. breadcrumbs . contains ( & ty) {
362
+ if !cx. breadcrumbs . insert ( ty) {
363
363
debug ! ( "iterate_over_potentially_unsafe_regions_in_type \
364
364
{}ty: {} scope: {:?} - cached",
365
365
( 0 ..depth) . map( |_| ' ' ) . collect:: <String >( ) ,
366
366
ty, cx. parent_scope) ;
367
367
return Ok ( ( ) ) ; // we already visited this type
368
368
}
369
- cx. breadcrumbs . push ( ty) ;
370
369
debug ! ( "iterate_over_potentially_unsafe_regions_in_type \
371
370
{}ty: {} scope: {:?}",
372
371
( 0 ..depth) . map( |_| ' ' ) . collect:: <String >( ) ,
0 commit comments