]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/lazy_static.rs
Rollup merge of #85326 - infinity0:fix-cross-compile-tools, r=Mark-Simulacrum
[rust.git] / src / tools / rustfmt / tests / target / lazy_static.rs
1 // Format `lazy_static!`.
2
3 lazy_static! {
4     static ref CONFIG_NAME_REGEX: regex::Regex =
5         regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern");
6     static ref CONFIG_VALUE_REGEX: regex::Regex = regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#)
7         .expect("Failed creating configuration value pattern");
8 }
9
10 // We need to be able to format `lazy_static!` without known syntax.
11 lazy_static!(xxx, yyyy, zzzzz);
12
13 lazy_static! {}
14
15 // #2354
16 lazy_static! {
17     pub static ref Sbase64_encode_string: ::lisp::LispSubrRef = {
18         let subr = ::remacs_sys::Lisp_Subr {
19             header: ::remacs_sys::Lisp_Vectorlike_Header {
20                 size: ((::remacs_sys::PseudovecType::PVEC_SUBR as ::libc::ptrdiff_t)
21                     << ::remacs_sys::PSEUDOVECTOR_AREA_BITS),
22             },
23             function: self::Fbase64_encode_string as *const ::libc::c_void,
24             min_args: 1i16,
25             max_args: 2i16,
26             symbol_name: (b"base64-encode-string\x00").as_ptr() as *const ::libc::c_char,
27             intspec: ::std::ptr::null(),
28             doc: ::std::ptr::null(),
29             lang: ::remacs_sys::Lisp_Subr_Lang_Rust,
30         };
31         unsafe {
32             let ptr = ::remacs_sys::xmalloc(::std::mem::size_of::<::remacs_sys::Lisp_Subr>())
33                 as *mut ::remacs_sys::Lisp_Subr;
34             ::std::ptr::copy_nonoverlapping(&subr, ptr, 1);
35             ::std::mem::forget(subr);
36             ::lisp::ExternalPtr::new(ptr)
37         }
38     };
39 }
40
41 lazy_static! {
42     static ref FOO: HashMap<
43         String,
44         (
45             &'static str,
46             fn(Foo) -> Result<Box<Bar>, Either<FooError, BarError>>
47         ),
48     > = HashMap::new();
49 }