-
Notifications
You must be signed in to change notification settings - Fork 960
Support formatting for lazy_static::lazy_static!
#6690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Manishearth
merged 4 commits into
rust-lang:master
from
shulaoda:10-10-support-lazy_static!-with-crate-name-format
Oct 13, 2025
+194
−6
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2b0f7b0
Support formatting for lazy_static::lazy_static!
shulaoda e56a61f
u
shulaoda 81da0cd
Add test case for lazy_static::lazy_static! before style edition 2027
shulaoda 7cb4a36
Merge branch 'master' into 10-10-support-lazy_static!-with-crate-name…
Manishearth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
lazy_static::lazy_static! { | ||
static ref CONFIG_NAME_REGEX: regex::Regex = | ||
regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern"); | ||
static ref CONFIG_VALUE_REGEX: regex::Regex = regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#) | ||
.expect("Failed creating configuration value pattern"); | ||
} | ||
|
||
// We need to be able to format `lazy_static::lazy_static!` without known syntax. | ||
lazy_static::lazy_static!( | ||
xxx, | ||
yyyy , | ||
zzzzz | ||
); | ||
|
||
lazy_static::lazy_static!{ | ||
} | ||
|
||
// #2354 | ||
lazy_static::lazy_static ! { | ||
pub static ref Sbase64_encode_string : :: lisp :: LispSubrRef = { | ||
let subr = :: remacs_sys :: Lisp_Subr { | ||
header : :: remacs_sys :: Lisp_Vectorlike_Header { | ||
size : ( | ||
( :: remacs_sys :: PseudovecType :: PVEC_SUBR as :: libc :: ptrdiff_t ) << :: | ||
remacs_sys :: PSEUDOVECTOR_AREA_BITS ) , } , function : self :: | ||
Fbase64_encode_string as * const :: libc :: c_void , min_args : 1i16 , | ||
max_args : 2i16 , symbol_name : ( b"base64-encode-string\x00" ) . as_ptr ( ) | ||
as * const :: libc :: c_char , intspec : :: std :: ptr :: null ( ) , doc : :: | ||
std :: ptr :: null ( ) , lang : :: remacs_sys :: Lisp_Subr_Lang_Rust , } ; | ||
unsafe { | ||
let ptr = :: remacs_sys :: xmalloc ( | ||
:: std :: mem :: size_of :: < :: remacs_sys :: Lisp_Subr > ( ) ) as * mut :: | ||
remacs_sys :: Lisp_Subr ; :: std :: ptr :: copy_nonoverlapping ( | ||
& subr , ptr , 1 ) ; :: std :: mem :: forget ( subr ) ; :: lisp :: ExternalPtr | ||
:: new ( ptr ) } } ; } | ||
|
||
|
||
lazy_static::lazy_static! { | ||
static ref FOO: HashMap<String, | ||
(&'static str, | ||
fn(Foo) -> Result<Box<Bar>, Either<FooError, BarError>> | ||
),> = HashMap::new(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
lazy_static::lazy_static! { | ||
static ref CONFIG_NAME_REGEX: regex::Regex = | ||
regex::Regex::new(r"^## `([^`]+)`").expect("Failed creating configuration pattern"); | ||
static ref CONFIG_VALUE_REGEX: regex::Regex = regex::Regex::new(r#"^#### `"?([^`"]+)"?`"#) | ||
.expect("Failed creating configuration value pattern"); | ||
} | ||
|
||
// We need to be able to format `lazy_static::lazy_static!` without known syntax. | ||
lazy_static::lazy_static!(xxx, yyyy, zzzzz); | ||
|
||
lazy_static::lazy_static! {} | ||
|
||
// #2354 | ||
lazy_static::lazy_static! { | ||
pub static ref Sbase64_encode_string : :: lisp :: LispSubrRef = { | ||
let subr = :: remacs_sys :: Lisp_Subr { | ||
header : :: remacs_sys :: Lisp_Vectorlike_Header { | ||
size : ( | ||
( :: remacs_sys :: PseudovecType :: PVEC_SUBR as :: libc :: ptrdiff_t ) << :: | ||
remacs_sys :: PSEUDOVECTOR_AREA_BITS ) , } , function : self :: | ||
Fbase64_encode_string as * const :: libc :: c_void , min_args : 1i16 , | ||
max_args : 2i16 , symbol_name : ( b"base64-encode-string\x00" ) . as_ptr ( ) | ||
as * const :: libc :: c_char , intspec : :: std :: ptr :: null ( ) , doc : :: | ||
std :: ptr :: null ( ) , lang : :: remacs_sys :: Lisp_Subr_Lang_Rust , } ; | ||
unsafe { | ||
let ptr = :: remacs_sys :: xmalloc ( | ||
:: std :: mem :: size_of :: < :: remacs_sys :: Lisp_Subr > ( ) ) as * mut :: | ||
remacs_sys :: Lisp_Subr ; :: std :: ptr :: copy_nonoverlapping ( | ||
& subr , ptr , 1 ) ; :: std :: mem :: forget ( subr ) ; :: lisp :: ExternalPtr | ||
:: new ( ptr ) } } ; } | ||
|
||
lazy_static::lazy_static! { | ||
static ref FOO: HashMap<String, | ||
(&'static str, | ||
fn(Foo) -> Result<Box<Bar>, Either<FooError, BarError>> | ||
),> = HashMap::new(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.