From 3bb40f2ea00ceac3e91986a01ef5b2ecc8070f29 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Tue, 19 Oct 2021 20:40:09 -0700 Subject: [PATCH 1/6] Make printed message match the code comment I think this code is getting L0, not L1 cache size, if I'm reading the Intel manual right. (I might not be.) Either way, the code comment and the printed message should match, whichever way is right. :) --- src/doc/unstable-book/src/library-features/asm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/library-features/asm.md b/src/doc/unstable-book/src/library-features/asm.md index 5a2cef24870be..e70933b7bae10 100644 --- a/src/doc/unstable-book/src/library-features/asm.md +++ b/src/doc/unstable-book/src/library-features/asm.md @@ -257,7 +257,7 @@ unsafe { } println!( - "L1 Cache: {}", + "L0 Cache: {}", ((ebx >> 22) + 1) * (((ebx >> 12) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1) ); ``` From 01e441f8e51a8276ccbc3bda6ac616eac13d01b4 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Wed, 27 Oct 2021 22:18:51 +0200 Subject: [PATCH 2/6] Document clippy on nightly-rustc --- src/bootstrap/builder.rs | 1 + src/bootstrap/doc.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index d5656f0f37e03..6ba1b1b6036ea 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -482,6 +482,7 @@ impl<'a> Builder<'a> { doc::RustByExample, doc::RustcBook, doc::CargoBook, + doc::Clippy, doc::EmbeddedBook, doc::EditionGuide, ), diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 6f2470b706a64..2804e7119fbc1 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -755,6 +755,7 @@ tool_doc!( "src/tools/rustfmt", ["rustfmt-nightly", "rustfmt-config_proc_macro"], ); +tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]); #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { From d718b1a79508169f10cd4b691071d4308ac15fc3 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 31 Oct 2021 15:02:38 +0100 Subject: [PATCH 3/6] Add JoinHandle::is_running. --- library/std/src/thread/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 0c1ffeb1a79a4..f8f6411711311 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1402,6 +1402,15 @@ impl JoinHandle { pub fn join(mut self) -> Result { self.0.join() } + + /// Checks if the the associated thread is still running its main function. + /// + /// This might return `false` for a brief moment after the thread's main + /// function has returned, but before the thread itself has stopped running. + #[unstable(feature = "thread_is_running", issue = "none")] + pub fn is_running(&self) -> bool { + Arc::strong_count(&self.0.packet.0) > 1 + } } impl AsInner for JoinHandle { From 67362b301bd00802c10c9fa9bc7396dc7ada83dd Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 31 Oct 2021 15:02:49 +0100 Subject: [PATCH 4/6] Add test for JoinHandle::is_running. --- library/std/src/thread/tests.rs | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 16ad366fc126a..ca0d88135a5d8 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -2,9 +2,13 @@ use super::Builder; use crate::any::Any; use crate::mem; use crate::result; -use crate::sync::mpsc::{channel, Sender}; +use crate::sync::{ + mpsc::{channel, Sender}, + Arc, Barrier, +}; use crate::thread::{self, ThreadId}; use crate::time::Duration; +use crate::time::Instant; // !!! These tests are dangerous. If something is buggy, they will hang, !!! // !!! instead of exiting cleanly. This might wedge the buildbots. !!! @@ -46,6 +50,36 @@ fn test_run_basic() { rx.recv().unwrap(); } +#[test] +fn test_is_running() { + let b = Arc::new(Barrier::new(2)); + let t = thread::spawn({ + let b = b.clone(); + move || { + b.wait(); + 1234 + } + }); + + // Thread is definitely running here, since it's still waiting for the barrier. + assert_eq!(t.is_running(), true); + + // Unblock the barrier. + b.wait(); + + // Now check that t.is_running() becomes false within a reasonable time. + let start = Instant::now(); + while t.is_running() { + assert!(start.elapsed() < Duration::from_secs(2)); + thread::sleep(Duration::from_millis(15)); + } + + // Joining the thread should not block for a significant time now. + let join_time = Instant::now(); + assert_eq!(t.join().unwrap(), 1234); + assert!(join_time.elapsed() < Duration::from_secs(2)); +} + #[test] fn test_join_panic() { match thread::spawn(move || panic!()).join() { From a97bfdc7e78c796d180d40a3c6d2d0a9ce61ebd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 1 Nov 2021 09:01:20 +0200 Subject: [PATCH 5/6] :arrow_up: rust-analyzer --- src/tools/rust-analyzer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index 1f47693e02809..04f03a360ab8f 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit 1f47693e02809c97db61b51247ae4e4d46744c61 +Subproject commit 04f03a360ab8fef3d9c0ff84de2d39b8a196c717 From 978ebd9c8cd91079be62656ca193a9cbc85e157b Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Mon, 1 Nov 2021 15:04:24 +0100 Subject: [PATCH 6/6] Add tracking issue for thread_is_running. --- library/std/src/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index f8f6411711311..12d9f955bb767 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -1407,7 +1407,7 @@ impl JoinHandle { /// /// This might return `false` for a brief moment after the thread's main /// function has returned, but before the thread itself has stopped running. - #[unstable(feature = "thread_is_running", issue = "none")] + #[unstable(feature = "thread_is_running", issue = "90470")] pub fn is_running(&self) -> bool { Arc::strong_count(&self.0.packet.0) > 1 }