From 0dac05dd627612232403c07ca8bd6d3376eec64a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 8 Dec 2014 13:28:32 -0500 Subject: libsyntax: use unboxed closures --- src/libsyntax/diagnostics/plugin.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/libsyntax/diagnostics') diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 2be11a236d3..cb2a1f8acd8 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -25,14 +25,18 @@ thread_local!(static USED_DIAGNOSTICS: RefCell> = { RefCell::new(HashMap::new()) }) -fn with_registered_diagnostics(f: |&mut HashMap>| -> T) -> T { - REGISTERED_DIAGNOSTICS.with(|slot| { +fn with_registered_diagnostics(f: F) -> T where + F: FnOnce(&mut HashMap>) -> T, +{ + REGISTERED_DIAGNOSTICS.with(move |slot| { f(&mut *slot.borrow_mut()) }) } -fn with_used_diagnostics(f: |&mut HashMap| -> T) -> T { - USED_DIAGNOSTICS.with(|slot| { +fn with_used_diagnostics(f: F) -> T where + F: FnOnce(&mut HashMap) -> T, +{ + USED_DIAGNOSTICS.with(move |slot| { f(&mut *slot.borrow_mut()) }) } -- cgit 1.4.1-3-g733a5