Skip to content
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

Merged
merged 1 commit into from
May 31, 2024
Merged

Conversation

GKFX
Copy link
Contributor

@GKFX GKFX commented Apr 28, 2024

Split off from rust-lang/rust#124475. The functionality of the lazy_static crate is now available in the standard library as OnceLock. Rustfmt can now use this directly and drop the dependency.

GKFX added a commit to GKFX/rust that referenced this pull request Apr 28, 2024
Copy link
Contributor

@ytmimi ytmimi left a 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.

src/test/configuration_snippet.rs Show resolved Hide resolved
src/comment.rs Outdated Show resolved Hide resolved
@ytmimi
Copy link
Contributor

ytmimi commented May 2, 2024

Thanks for applying the feedback. Can you squash all of these into a single commit when you get a chance.

@GKFX GKFX force-pushed the prune-dependencies branch 2 times, most recently from 1564457 to 54dfcef Compare May 2, 2024 21:26
ytmimi
ytmimi previously approved these changes May 21, 2024
@ytmimi
Copy link
Contributor

ytmimi commented May 21, 2024

Running our Diff Check Job, and assuming this passes we'll be good to go here

@ytmimi ytmimi dismissed their stale review May 21, 2024 00:48

Diff-Check job failed

@ytmimi
Copy link
Contributor

ytmimi commented May 21, 2024

🤔 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);

@ytmimi
Copy link
Contributor

ytmimi commented May 21, 2024

I think this might just be an issue with the CI job, but I'll need some more time to look into it

@ytmimi
Copy link
Contributor

ytmimi commented May 31, 2024

Seems like it was a temporary CI issue, but now the job is passing. Thanks again for your help on this!

@ytmimi ytmimi merged commit 871113e into rust-lang:master May 31, 2024
27 checks passed
@ytmimi ytmimi added release-notes Needs an associated changelog entry and removed pr-ready-to-merge labels May 31, 2024
github-actions bot pushed a commit to ytmimi/rustfmt that referenced this pull request Jun 7, 2024
@ytmimi ytmimi removed the release-notes Needs an associated changelog entry label Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants