From c006b84d878039f35455a79618bac4a768034cca Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 1 May 2015 12:17:14 -0400 Subject: [PATCH] Trust the borrow checker. --- src/main.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8cd95ddf626..e16537198f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -153,7 +153,7 @@ fn fmt_lines(changes: &mut ChangeSet) { if newline_count > 1 { debug!("track truncate: {} {} {}", f, text.len, newline_count); - truncate_todo.push((f, text.len - newline_count + 1)) + truncate_todo.push((f.to_string(), text.len - newline_count + 1)) } for &(l, _, _) in trims.iter() { @@ -163,12 +163,7 @@ fn fmt_lines(changes: &mut ChangeSet) { } for (f, l) in truncate_todo { - // This unsafe block and the ridiculous dance with the cast is because - // the borrow checker thinks the first borrow of changes lasts for the - // whole function. - unsafe { - (*(changes as *const ChangeSet as *mut ChangeSet)).get_mut(f).truncate(l); - } + changes.get_mut(&f).truncate(l); } }