From 741486885334f603f0ae4050bebdeb347c6720ff Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Mon, 17 Jul 2017 18:01:48 -0600 Subject: [PATCH] Remove TypeId from stack in Builder --- src/bootstrap/builder.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 2338ac1a692..50ecdeb988a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -15,7 +15,7 @@ use std::process::Command; use std::fs; use std::ops::Deref; -use std::any::{TypeId, Any}; +use std::any::Any; use compile; use install; @@ -35,7 +35,7 @@ pub struct Builder<'a> { pub top_stage: u32, pub kind: Kind, cache: Cache, - stack: RefCell)>>, + stack: RefCell>>, } impl<'a> Deref for Builder<'a> { @@ -477,12 +477,12 @@ fn maybe_run(&self, path: Option<&Path>) { /// cache the step, so it is safe (and good!) to call this as often as /// needed to ensure that all dependencies are built. pub fn ensure(&'a self, step: S) -> S::Output { - let type_id = TypeId::of::(); { let mut stack = self.stack.borrow_mut(); - for &(stack_type_id, ref stack_step) in stack.iter() { - if !(type_id == stack_type_id && step == *stack_step.downcast_ref().unwrap()) { - continue + for stack_step in stack.iter() { + // should skip + if stack_step.downcast_ref::().map_or(true, |stack_step| *stack_step != step) { + continue; } let mut out = String::new(); out += &format!("\n\nCycle in build detected when adding {:?}\n", step); @@ -497,13 +497,13 @@ pub fn ensure(&'a self, step: S) -> S::Output { return out; } self.build.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step)); - stack.push((type_id, Box::new(step.clone()))); + stack.push(Box::new(step.clone())); } let out = step.clone().run(self); { let mut stack = self.stack.borrow_mut(); - let (cur_type_id, cur_step) = stack.pop().expect("step stack empty"); - assert_eq!((cur_type_id, cur_step.downcast_ref()), (type_id, Some(&step))); + let cur_step = stack.pop().expect("step stack empty"); + assert_eq!(cur_step.downcast_ref(), Some(&step)); } self.build.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step)); self.cache.put(step, out.clone()); -- 2.44.0