diff options
author | Keegan McAllister <mcallister.keegan@gmail.com> | 2014-09-20 15:35:08 -0700 |
---|---|---|
committer | Keegan McAllister <mcallister.keegan@gmail.com> | 2014-09-20 15:35:08 -0700 |
commit | 045328c8e94f5bdfcd67105c5dfa9209f4cd501c (patch) | |
tree | 1d5f8d958e12ae59e0ac720a7873e3c3b08cb1e8 /components/macros/lib.rs | |
parent | d6ba37c68c34a3748a789caeca225083275757e5 (diff) | |
parent | a40b94d7f946d75e1a66af206efda9879b89c707 (diff) | |
download | servo-045328c8e94f5bdfcd67105c5dfa9209f4cd501c.tar.gz servo-045328c8e94f5bdfcd67105c5dfa9209f4cd501c.zip |
Merge pull request #3438 from servo/rustup
Upgrade Rust
Diffstat (limited to 'components/macros/lib.rs')
-rw-r--r-- | components/macros/lib.rs | 67 |
1 files changed, 2 insertions, 65 deletions
diff --git a/components/macros/lib.rs b/components/macros/lib.rs index 1ce4832b19a..b8db24baea1 100644 --- a/components/macros/lib.rs +++ b/components/macros/lib.rs @@ -109,9 +109,9 @@ impl LintPass for UnrootedPass { } } - fn check_fn(&mut self, cx: &Context, kind: &syntax::visit::FnKind, decl: &ast::FnDecl, + fn check_fn(&mut self, cx: &Context, kind: syntax::visit::FnKind, decl: &ast::FnDecl, block: &ast::Block, _span: syntax::codemap::Span, _id: ast::NodeId) { - match *kind { + match kind { syntax::visit::FkItemFn(i, _, _, _) | syntax::visit::FkMethod(i, _, _) if i.as_str() == "new" || i.as_str() == "new_inherited" => { return; @@ -184,66 +184,3 @@ macro_rules! bitfield( } ) ) - - -#[macro_export] -macro_rules! lazy_init( - ($(static ref $N:ident : $T:ty = $e:expr;)*) => ( - $( - #[allow(non_camel_case_types)] - struct $N {__unit__: ()} - static $N: $N = $N {__unit__: ()}; - impl Deref<$T> for $N { - fn deref<'a>(&'a self) -> &'a $T { - unsafe { - static mut s: *const $T = 0 as *const $T; - static mut ONCE: ::sync::one::Once = ::sync::one::ONCE_INIT; - ONCE.doit(|| { - s = ::std::mem::transmute::<Box<$T>, *const $T>(box () ($e)); - }); - &*s - } - } - } - - )* - ) -) - - -#[cfg(test)] -mod tests { - use std::collections::hashmap::HashMap; - lazy_init! { - static ref NUMBER: uint = times_two(3); - static ref VEC: [Box<uint>, ..3] = [box 1, box 2, box 3]; - static ref OWNED_STRING: String = "hello".to_string(); - static ref HASHMAP: HashMap<uint, &'static str> = { - let mut m = HashMap::new(); - m.insert(0u, "abc"); - m.insert(1, "def"); - m.insert(2, "ghi"); - m - }; - } - - fn times_two(n: uint) -> uint { - n * 2 - } - - #[test] - fn test_basic() { - assert_eq!(*OWNED_STRING, "hello".to_string()); - assert_eq!(*NUMBER, 6); - assert!(HASHMAP.find(&1).is_some()); - assert!(HASHMAP.find(&3).is_none()); - assert_eq!(VEC.as_slice(), &[box 1, box 2, box 3]); - } - - #[test] - fn test_repeat() { - assert_eq!(*NUMBER, 6); - assert_eq!(*NUMBER, 6); - assert_eq!(*NUMBER, 6); - } -} |