diff options
Diffstat (limited to 'src/makefile')
-rw-r--r-- | src/makefile/mod.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/makefile/mod.rs b/src/makefile/mod.rs index 735c8aa..bf4006a 100644 --- a/src/makefile/mod.rs +++ b/src/makefile/mod.rs @@ -617,9 +617,7 @@ impl<'a> Makefile<'a> { if !targets.contains_key(name) && new_target.is_none() { // well, inference didn't work. is there a default? if let Some(default) = targets.get(".DEFAULT") { - let default = default.borrow(); - let commands = default.commands.clone(); - drop(default); + let commands = default.borrow().commands.clone(); new_target = Some(Target { name: name.into(), prerequisites: vec![], @@ -641,8 +639,9 @@ impl<'a> Makefile<'a> { drop(targets); if let Some(new_target) = new_target { - let mut targets = self.targets.borrow_mut(); - targets.insert(new_target.name.clone(), Rc::new(RefCell::new(new_target))); + self.targets + .borrow_mut() + .insert(new_target.name.clone(), Rc::new(RefCell::new(new_target))); } let targets = self.targets.borrow(); @@ -650,9 +649,7 @@ impl<'a> Makefile<'a> { } pub fn update_target(&self, name: &str) { - let target = self.get_target(name); - let target = target.borrow(); - target.update(self); + self.get_target(name).borrow().update(self); } fn expand_macros(&self, text: &TokenString, target: Option<&Target>) -> String { @@ -729,10 +726,10 @@ impl<'a> Makefile<'a> { macro_pieces.join(" ") } else { - match self.macros.get(name) { - Some((_, macro_value)) => self.expand_macros(¯o_value, target), - None => String::new(), - } + self.macros + .get(name) + .map(|(_, macro_value)| self.expand_macros(¯o_value, target)) + .unwrap_or_else(String::new) }; let macro_value = match replacement { Some((subst1, subst2)) => { |