@@ -14,6 +14,7 @@ use middle::infer;
1414use middle:: region;
1515use middle:: subst:: { self , Subst } ;
1616use middle:: ty:: { self , Ty } ;
17+ use util:: nodemap:: FnvHashSet ;
1718
1819use syntax:: ast;
1920use syntax:: codemap:: { self , Span } ;
@@ -268,7 +269,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>
268269 rcx : rcx,
269270 span : span,
270271 parent_scope : parent_scope,
271- breadcrumbs : vec ! [ ]
272+ breadcrumbs : FnvHashSet ( )
272273 } ,
273274 TypeContext :: Root ,
274275 typ,
@@ -331,7 +332,7 @@ enum TypeContext {
331332struct DropckContext < ' a , ' b : ' a , ' tcx : ' b > {
332333 rcx : & ' a mut Rcx < ' b , ' tcx > ,
333334 /// types that have already been traversed
334- breadcrumbs : Vec < Ty < ' tcx > > ,
335+ breadcrumbs : FnvHashSet < Ty < ' tcx > > ,
335336 /// span for error reporting
336337 span : Span ,
337338 /// the scope reachable dtorck types must outlive
@@ -358,15 +359,13 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'tcx>(
358359
359360 let opt_phantom_data_def_id = tcx. lang_items . phantom_data ( ) ;
360361
361- // FIXME(arielb1): don't be O(n^2)
362- if cx. breadcrumbs . contains ( & ty) {
362+ if !cx. breadcrumbs . insert ( ty) {
363363 debug ! ( "iterate_over_potentially_unsafe_regions_in_type \
364364 {}ty: {} scope: {:?} - cached",
365365 ( 0 ..depth) . map( |_| ' ' ) . collect:: <String >( ) ,
366366 ty, cx. parent_scope) ;
367367 return Ok ( ( ) ) ; // we already visited this type
368368 }
369- cx. breadcrumbs . push ( ty) ;
370369 debug ! ( "iterate_over_potentially_unsafe_regions_in_type \
371370 {}ty: {} scope: {:?}",
372371 ( 0 ..depth) . map( |_| ' ' ) . collect:: <String >( ) ,
0 commit comments