Skip to content

Commit ba2fca8

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 222206 b: refs/heads/master c: e99b53e h: refs/heads/master v: v3
1 parent 04e7f9a commit ba2fca8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 7f9953b9745dec2d67ed735dff461795bd48863a
2+
refs/heads/master: e99b53e1c16b6ab7dcac7ccc841fb9cb9fc75381
33
refs/heads/snap-stage3: a5c12f4e39d32af3c951b66bd2839bc0b5a1125b
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc_typeck/check/dropck.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use middle::infer;
1414
use middle::region;
1515
use middle::subst::{self, Subst};
1616
use middle::ty::{self, Ty};
17+
use util::nodemap::FnvHashSet;
1718

1819
use syntax::ast;
1920
use 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 {
331332
struct 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

Comments
 (0)