-
Notifications
You must be signed in to change notification settings - Fork 888
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
Remove lazy_static dependency #6154
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see some minor changes made.
Thanks for applying the feedback. Can you squash all of these into a single commit when you get a chance. |
1564457
to
54dfcef
Compare
Running our Diff Check Job, and assuming this passes we'll be good to go here |
🤔 hmmm the job failed when comparing the output from current HEAD (rustfmt 1.7.0-nightly (d5f1200 2024-05-01)) and your latest commit (rustfmt 1.7.0-nightly (54dfcef 2024-05-02)). Surprisingly, compiling both versions of rustfmt locally and running them produces the same output when run on these input snippets, so I'm not 100% what's going on. I'm rerunning the job. For reference here's what the diffs looked like: Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macros/src/lib.rs:8:
#[macro_export]
macro_rules! a_rules_macro {
- ($e:expr) => { ($e, foobar::f()); }
+ ($e:expr) => {
+ ($e, foobar::f());
+ };
}
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macros/examples/ex.rs:8:
#[an_attr_macro]
fn a() {
- f(); // no
+ f(); // no
}
#[an_attr_macro(with_span)]
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macros/examples/ex.rs:15:
fn b() {
- f(); // yes
+ f(); // yes
}
fn c() {
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macros/examples/ex.rs:20:
- a_rules_macro!(f()); // yes
+ a_rules_macro!(f()); // yes
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-whitespace/examples/ex.rs:1:
struct Foo;
impl Foo {
- fn bar() { foobar::ok(); }
+ fn bar() {
+ foobar::ok();
+ }
@ -41252,4 +41230,4 @@ Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macr
fn d() {
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macros/examples/ex.rs:24:
- a_rules_macro!(()); // no
+ a_rules_macro!(()); // no
fn main() {
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-whitespace/examples/ex.rs:7:
- Foo::bar();
+ Foo::bar();
@ -41258,4 +41236,12 @@ Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/rustdoc-scrape-examples-macr
-fn main(){}
+fn main() {}
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs:14:
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/lib.rs:1:
#![no_std]
#![crate_type = "cdylib"]
-
// Allow a few unstable features because we create a panic
// runtime for native wasm exceptions from scratch
-
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/lib.rs:39:
let data = 0x1234usize as *mut u8; // Something to recognize
@ -41[26](https://github.com/rust-lang/rustfmt/actions/runs/9166837698/job/25203001180#step:4:27)3,6 +41249,31 @@ Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/ar
impl ArenaAllocator {
pub const fn new() -> Self {
- Self {
- arena: UnsafeCell::new(Arena::new()),
- }
+ Self { arena: UnsafeCell::new(Arena::new()) }
unsafe {
- core::intrinsics::catch_unwind(|data: *mut u8| {
- let _log_on_drop = LogOnDrop;
+ core::intrinsics::catch_unwind(
+ |data: *mut u8| {
+ let _log_on_drop = LogOnDrop;
- logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data));
- let x = [12];
- let _ = x[4]; // should panic
+ logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data));
+ let x = [12];
+ let _ = x[4]; // should panic
- logging::log_str("This line should not be visible! :(");
- }, data, |data, exception| {
- let exception = *Box::from_raw(exception as *mut String);
- logging::log_str("Caught something!");
- logging::log_str(&alloc::format!(" data : {:?}", data));
- logging::log_str(&alloc::format!(" exception: {:?}", exception));
- });
+ logging::log_str("This line should not be visible! :(");
+ },
+ data,
+ |data, exception| {
+ let exception = *Box::from_raw(exception as *mut String);
+ logging::log_str("Caught something!");
+ logging::log_str(&alloc::format!(" data : {:?}", data));
+ logging::log_str(&alloc::format!(" exception: {:?}", exception));
+ },
+ );
@ -41[27](https://github.com/rust-lang/rustfmt/actions/runs/9166837698/job/25203001180#step:4:28)0 +41280,0 @@ Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/ar
}
@ -41272 +41[28](https://github.com/rust-lang/rustfmt/actions/runs/9166837698/job/25203001180#step:4:29)2,4 @@ Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/ar
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs:42:
logging::log_str("This program terminates correctly.");
Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/panicking.rs:17:
use alloc::boxed::Box;
use alloc::string::ToString;
@ -[41](https://github.com/rust-lang/rustfmt/actions/runs/9166837698/job/25203001180#step:4:42)274,10 +41287,8 @@ Diff in /tmp/rust-lang-rust-EDALDBzK/tests/run-make/wasm-exceptions-nostd/src/ar
impl Arena {
pub const fn new() -> Self {
- Self {
- buf: [0x55; ARENA_SIZE],
- allocated: 0,
- }
+ Self { buf: [0x55; ARENA_SIZE], allocated: 0 }
}
pub unsafe fn alloc(&mut self, layout: Layout) -> *mut u8 {
- let msg = info
- .message()
- .map(|msg| msg.to_string())
- .unwrap_or("(no message)".to_string());
+ let msg = info.message().map(|msg| msg.to_string()).unwrap_or("(no message)".to_string());
let exception = Box::new(msg.to_string());
unsafe {
let exception_raw = Box::into_raw(exception); |
I think this might just be an issue with the CI job, but I'll need some more time to look into it |
54dfcef
to
b4fbe66
Compare
Seems like it was a temporary CI issue, but now the job is passing. Thanks again for your help on this! |
Split off from rust-lang/rust#124475. The functionality of the
lazy_static
crate is now available in the standard library asOnceLock
. Rustfmt can now use this directly and drop the dependency.