From f1174bd9834663852551a9a310e1d339bbff22dd Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 2 Aug 2022 22:29:29 +0300 Subject: [PATCH 01/12] rustc-docs: Be less specific about the representation of `+bundle` --- src/doc/rustc/src/command-line-arguments.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index bc04dfd4433f6..f05ff3f1b6b4e 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -89,9 +89,9 @@ but it is not guaranteed. If you need whole archive semantics use `+whole-archiv This modifier is only compatible with the `static` linking kind. Using any other kind will result in a compiler error. -When building a rlib or staticlib `+bundle` means that all object files from the native static -library will be added to the rlib or staticlib archive, and then used from it during linking of -the final binary. +When building a rlib or staticlib `+bundle` means that the native static library +will be packed into the rlib or staticlib archive, and then retrieved from there +during linking of the final binary. When building a rlib `-bundle` means that the native static library is registered as a dependency of that rlib "by name", and object files from it are included only during linking of the final From c4840cac86d5df058a38e8172074263586a3556c Mon Sep 17 00:00:00 2001 From: Daniel Sommermann Date: Mon, 1 Aug 2022 11:47:32 -0700 Subject: [PATCH 02/12] Fix backwards-compatibility check for tests with `+whole-archive` Fixes #100066 --- compiler/rustc_codegen_ssa/src/back/link.rs | 2 +- .../Makefile | 19 ++++++++++++++++--- ...irectly_linked_test_minus_whole_archive.rs | 7 +++++++ ...directly_linked_test_plus_whole_archive.rs | 7 +++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_minus_whole_archive.rs create mode 100644 src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_plus_whole_archive.rs diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 72aa790c36357..ea83877bdec06 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2222,7 +2222,7 @@ fn add_local_native_libraries( // be added explicitly if necessary, see the error in `fn link_rlib`) compiled // as an executable due to `--test`. Use whole-archive implicitly, like before // the introduction of native lib modifiers. - || (bundle != Some(false) && sess.opts.test) + || (whole_archive == None && bundle != Some(false) && sess.opts.test) { cmd.link_whole_staticlib( name, diff --git a/src/test/run-make/native-link-modifier-whole-archive/Makefile b/src/test/run-make/native-link-modifier-whole-archive/Makefile index 3b49d1188ae6b..967cb065cad1a 100644 --- a/src/test/run-make/native-link-modifier-whole-archive/Makefile +++ b/src/test/run-make/native-link-modifier-whole-archive/Makefile @@ -1,7 +1,7 @@ # ignore-cross-compile -- compiling C++ code does not work well when cross-compiling -# This test case makes sure that native libraries are linked with --whole-archive semantics -# when the `-bundle,+whole-archive` modifiers are applied to them. +# This test case makes sure that native libraries are linked with appropriate semantics +# when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them. # # The test works by checking that the resulting executables produce the expected output, # part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work @@ -10,8 +10,14 @@ -include ../../run-make-fulldeps/tools.mk -all: $(TMPDIR)/$(call BIN,directly_linked) $(TMPDIR)/$(call BIN,indirectly_linked) $(TMPDIR)/$(call BIN,indirectly_linked_via_attr) +all: $(TMPDIR)/$(call BIN,directly_linked) \ + $(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \ + $(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive) \ + $(TMPDIR)/$(call BIN,indirectly_linked) \ + $(TMPDIR)/$(call BIN,indirectly_linked_via_attr) $(call RUN,directly_linked) | $(CGREP) 'static-initializer.directly_linked.' + $(call RUN,directly_linked_test_plus_whole_archive) --nocapture | $(CGREP) 'static-initializer.' + $(call RUN,directly_linked_test_minus_whole_archive) --nocapture | $(CGREP) -v 'static-initializer.' $(call RUN,indirectly_linked) | $(CGREP) 'static-initializer.indirectly_linked.' $(call RUN,indirectly_linked_via_attr) | $(CGREP) 'static-initializer.native_lib_in_src.' @@ -19,6 +25,13 @@ all: $(TMPDIR)/$(call BIN,directly_linked) $(TMPDIR)/$(call BIN,indirectly_linke $(TMPDIR)/$(call BIN,directly_linked): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) $(RUSTC) directly_linked.rs -l static:+whole-archive=c_static_lib_with_constructor +# Native lib linked into test executable, +whole-archive +$(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) + $(RUSTC) directly_linked_test_plus_whole_archive.rs --test -l static:+whole-archive=c_static_lib_with_constructor +# Native lib linked into test executable, -whole-archive +$(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor) + $(RUSTC) directly_linked_test_minus_whole_archive.rs --test -l static:-whole-archive=c_static_lib_with_constructor + # Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable $(TMPDIR)/$(call BIN,indirectly_linked): $(TMPDIR)/librlib_with_cmdline_native_lib.rlib $(RUSTC) indirectly_linked.rs diff --git a/src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_minus_whole_archive.rs b/src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_minus_whole_archive.rs new file mode 100644 index 0000000000000..20ed8d9d4cd10 --- /dev/null +++ b/src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_minus_whole_archive.rs @@ -0,0 +1,7 @@ +use std::io::Write; + +#[test] +fn test_thing() { + print!("ran the test"); + std::io::stdout().flush().unwrap(); +} diff --git a/src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_plus_whole_archive.rs b/src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_plus_whole_archive.rs new file mode 100644 index 0000000000000..20ed8d9d4cd10 --- /dev/null +++ b/src/test/run-make/native-link-modifier-whole-archive/directly_linked_test_plus_whole_archive.rs @@ -0,0 +1,7 @@ +use std::io::Write; + +#[test] +fn test_thing() { + print!("ran the test"); + std::io::stdout().flush().unwrap(); +} From e4d0981365943e7d915658cecb2f950cc66069b6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 24 Jul 2022 11:06:54 -0700 Subject: [PATCH 03/12] Add regression test minimized from async-std write --- .../macros/format-args-temporaries-async.rs | 40 +++++++++++++++++++ .../format-args-temporaries-async.stderr | 27 +++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/test/ui/macros/format-args-temporaries-async.rs create mode 100644 src/test/ui/macros/format-args-temporaries-async.stderr diff --git a/src/test/ui/macros/format-args-temporaries-async.rs b/src/test/ui/macros/format-args-temporaries-async.rs new file mode 100644 index 0000000000000..fc2e5e2190f33 --- /dev/null +++ b/src/test/ui/macros/format-args-temporaries-async.rs @@ -0,0 +1,40 @@ +// FIXME: check-pass +// check-fail +// edition:2021 + +use std::fmt::{self, Display}; +use std::future::Future; +use std::io; +use std::pin::Pin; +use std::task::{Context, Poll}; + +struct AsyncStdout; + +impl AsyncStdout { + fn write_fmt<'a>(&'a mut self, _args: fmt::Arguments) -> WriteFmtFuture<'a, Self> + where + Self: Unpin, + { + WriteFmtFuture(self) + } +} + +struct WriteFmtFuture<'a, T>(&'a mut T); + +impl<'a, T> Future for WriteFmtFuture<'a, T> { + type Output = io::Result<()>; + fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { + unimplemented!() + } +} + +async fn async_main() { + let _write = write!(&mut AsyncStdout, "...").await; + //~^ ERROR temporary value dropped while borrowed + let _writeln = writeln!(&mut AsyncStdout, "...").await; + //~^ ERROR temporary value dropped while borrowed +} + +fn main() { + let _ = async_main; +} diff --git a/src/test/ui/macros/format-args-temporaries-async.stderr b/src/test/ui/macros/format-args-temporaries-async.stderr new file mode 100644 index 0000000000000..73019d7eb6e49 --- /dev/null +++ b/src/test/ui/macros/format-args-temporaries-async.stderr @@ -0,0 +1,27 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/format-args-temporaries-async.rs:32:30 + | +LL | let _write = write!(&mut AsyncStdout, "...").await; + | ------------^^^^^^^^^^^-------- + | | | + | | creates a temporary which is freed while still in use + | temporary value is freed at the end of this statement + | borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error[E0716]: temporary value dropped while borrowed + --> $DIR/format-args-temporaries-async.rs:34:34 + | +LL | let _writeln = writeln!(&mut AsyncStdout, "...").await; + | --------------^^^^^^^^^^^-------- + | | | + | | creates a temporary which is freed while still in use + | temporary value is freed at the end of this statement + | borrow later used here + | + = note: consider using a `let` binding to create a longer lived value + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0716`. From cd1036e4acd1512f3ee5d9c32d3b418c056bb6ae Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 24 Jul 2022 10:44:00 -0700 Subject: [PATCH 04/12] Revert write! and writeln! to late drop temporaries --- library/core/src/macros/mod.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 673a39c298f7d..f2845cc6a29ec 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -496,10 +496,9 @@ macro_rules! r#try { #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")] macro_rules! write { - ($dst:expr, $($arg:tt)*) => {{ - let result = $dst.write_fmt($crate::format_args!($($arg)*)); - result - }}; + ($dst:expr, $($arg:tt)*) => { + $dst.write_fmt($crate::format_args!($($arg)*)) + }; } /// Write formatted data into a buffer, with a newline appended. @@ -554,10 +553,9 @@ macro_rules! writeln { ($dst:expr $(,)?) => { $crate::write!($dst, "\n") }; - ($dst:expr, $($arg:tt)*) => {{ - let result = $dst.write_fmt($crate::format_args_nl!($($arg)*)); - result - }}; + ($dst:expr, $($arg:tt)*) => { + $dst.write_fmt($crate::format_args_nl!($($arg)*)) + }; } /// Indicates unreachable code. From 9a95c055733a1ba1adecbcb5442536168b8f8085 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 24 Jul 2022 11:16:00 -0700 Subject: [PATCH 05/12] Regression in issue 99684 fixed --- .../macros/format-args-temporaries-async.rs | 5 +--- .../format-args-temporaries-async.stderr | 27 ------------------- 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 src/test/ui/macros/format-args-temporaries-async.stderr diff --git a/src/test/ui/macros/format-args-temporaries-async.rs b/src/test/ui/macros/format-args-temporaries-async.rs index fc2e5e2190f33..d959329b9fce2 100644 --- a/src/test/ui/macros/format-args-temporaries-async.rs +++ b/src/test/ui/macros/format-args-temporaries-async.rs @@ -1,5 +1,4 @@ -// FIXME: check-pass -// check-fail +// check-pass // edition:2021 use std::fmt::{self, Display}; @@ -30,9 +29,7 @@ impl<'a, T> Future for WriteFmtFuture<'a, T> { async fn async_main() { let _write = write!(&mut AsyncStdout, "...").await; - //~^ ERROR temporary value dropped while borrowed let _writeln = writeln!(&mut AsyncStdout, "...").await; - //~^ ERROR temporary value dropped while borrowed } fn main() { diff --git a/src/test/ui/macros/format-args-temporaries-async.stderr b/src/test/ui/macros/format-args-temporaries-async.stderr deleted file mode 100644 index 73019d7eb6e49..0000000000000 --- a/src/test/ui/macros/format-args-temporaries-async.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/format-args-temporaries-async.rs:32:30 - | -LL | let _write = write!(&mut AsyncStdout, "...").await; - | ------------^^^^^^^^^^^-------- - | | | - | | creates a temporary which is freed while still in use - | temporary value is freed at the end of this statement - | borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error[E0716]: temporary value dropped while borrowed - --> $DIR/format-args-temporaries-async.rs:34:34 - | -LL | let _writeln = writeln!(&mut AsyncStdout, "...").await; - | --------------^^^^^^^^^^^-------- - | | | - | | creates a temporary which is freed while still in use - | temporary value is freed at the end of this statement - | borrow later used here - | - = note: consider using a `let` binding to create a longer lived value - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0716`. From eb5fb32fe03cf8390bfadc17993b0a1a0adfd259 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 24 Jul 2022 11:01:01 -0700 Subject: [PATCH 06/12] Move write! and writeln! temporaries test to check-fail --- .../format-args-temporaries-in-write.rs | 50 +++++++++++++++++++ .../format-args-temporaries-in-write.stderr | 43 ++++++++++++++++ src/test/ui/macros/format-args-temporaries.rs | 16 ------ 3 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 src/test/ui/macros/format-args-temporaries-in-write.rs create mode 100644 src/test/ui/macros/format-args-temporaries-in-write.stderr diff --git a/src/test/ui/macros/format-args-temporaries-in-write.rs b/src/test/ui/macros/format-args-temporaries-in-write.rs new file mode 100644 index 0000000000000..339ccbc33ac98 --- /dev/null +++ b/src/test/ui/macros/format-args-temporaries-in-write.rs @@ -0,0 +1,50 @@ +// check-fail + +use std::fmt::{self, Display}; + +struct Mutex; + +impl Mutex { + fn lock(&self) -> MutexGuard { + MutexGuard(self) + } +} + +struct MutexGuard<'a>(&'a Mutex); + +impl<'a> Drop for MutexGuard<'a> { + fn drop(&mut self) { + // Empty but this is a necessary part of the repro. Otherwise borrow + // checker is fine with 'a dangling at the time that MutexGuard goes out + // of scope. + } +} + +struct Out; + +impl Out { + fn write_fmt(&self, _args: fmt::Arguments) {} +} + +impl<'a> Display for MutexGuard<'a> { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + Ok(()) + } +} + +fn main() { + // FIXME(dtolnay): We actually want both of these to work. I think it's + // sadly unimplementable today though. + + let _write = { + let mutex = Mutex; + write!(Out, "{}", mutex.lock()) /* no semicolon */ + //~^ ERROR `mutex` does not live long enough + }; + + let _writeln = { + let mutex = Mutex; + writeln!(Out, "{}", mutex.lock()) /* no semicolon */ + //~^ ERROR `mutex` does not live long enough + }; +} diff --git a/src/test/ui/macros/format-args-temporaries-in-write.stderr b/src/test/ui/macros/format-args-temporaries-in-write.stderr new file mode 100644 index 0000000000000..03ecc4b4418c6 --- /dev/null +++ b/src/test/ui/macros/format-args-temporaries-in-write.stderr @@ -0,0 +1,43 @@ +error[E0597]: `mutex` does not live long enough + --> $DIR/format-args-temporaries-in-write.rs:41:27 + | +LL | write!(Out, "{}", mutex.lock()) /* no semicolon */ + | ^^^^^^^^^^^^ + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... +LL | +LL | }; + | -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` + | | + | `mutex` dropped here while still borrowed + | +help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped + --> $SRC_DIR/core/src/macros/mod.rs:LL:COL + | +LL | $dst.write_fmt($crate::format_args!($($arg)*)); + | + + +error[E0597]: `mutex` does not live long enough + --> $DIR/format-args-temporaries-in-write.rs:47:29 + | +LL | writeln!(Out, "{}", mutex.lock()) /* no semicolon */ + | ^^^^^^^^^^^^ + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... +LL | +LL | }; + | -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` + | | + | `mutex` dropped here while still borrowed + | +help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped + --> $SRC_DIR/core/src/macros/mod.rs:LL:COL + | +LL | $dst.write_fmt($crate::format_args_nl!($($arg)*)); + | + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/macros/format-args-temporaries.rs b/src/test/ui/macros/format-args-temporaries.rs index ddd4c9754bfa4..59323828bc37f 100644 --- a/src/test/ui/macros/format-args-temporaries.rs +++ b/src/test/ui/macros/format-args-temporaries.rs @@ -20,10 +20,6 @@ impl<'a> Drop for MutexGuard<'a> { } } -impl<'a> MutexGuard<'a> { - fn write_fmt(&self, _args: fmt::Arguments) {} -} - impl<'a> Display for MutexGuard<'a> { fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { Ok(()) @@ -31,18 +27,6 @@ impl<'a> Display for MutexGuard<'a> { } fn main() { - let _write = { - let out = Mutex; - let mutex = Mutex; - write!(out.lock(), "{}", mutex.lock()) /* no semicolon */ - }; - - let _writeln = { - let out = Mutex; - let mutex = Mutex; - writeln!(out.lock(), "{}", mutex.lock()) /* no semicolon */ - }; - let _print = { let mutex = Mutex; print!("{}", mutex.lock()) /* no semicolon */ From e44ea248409311a5c8e3c701722b7594c63388ae Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 14 Jul 2022 10:13:52 -0700 Subject: [PATCH 07/12] Upgrade indexmap and thorin-dwp to use hashbrown 0.12 This removes the last dependencies on hashbrown 0.11. --- Cargo.lock | 41 +++++---------------- compiler/rustc_codegen_cranelift/Cargo.lock | 8 ++-- compiler/rustc_codegen_cranelift/Cargo.toml | 2 +- compiler/rustc_codegen_ssa/Cargo.toml | 2 +- compiler/rustc_data_structures/Cargo.toml | 2 +- compiler/rustc_serialize/Cargo.toml | 4 +- src/tools/bump-stage0/Cargo.toml | 2 +- 7 files changed, 20 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d95093335180..292ed1c129c1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1698,15 +1698,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.12.0" @@ -1873,12 +1864,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.2" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown", "rustc-rayon", "serde", ] @@ -2559,19 +2550,6 @@ dependencies = [ "rustc-std-workspace-core", ] -[[package]] -name = "object" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" -dependencies = [ - "crc32fast", - "flate2", - "hashbrown 0.11.2", - "indexmap", - "memchr", -] - [[package]] name = "object" version = "0.29.0" @@ -2579,7 +2557,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown 0.12.0", + "flate2", + "hashbrown", "indexmap", "memchr", ] @@ -5047,7 +5026,7 @@ dependencies = [ "core", "dlmalloc", "fortanix-sgx-abi", - "hashbrown 0.12.0", + "hashbrown", "hermit-abi 0.2.0", "libc", "miniz_oxide", @@ -5306,13 +5285,13 @@ dependencies = [ [[package]] name = "thorin-dwp" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd95b4559c196987c8451b4e14d08a4c796c2844f9adf4d2a2dbc9b3142843be" +checksum = "e6cb0c7868d7f90407531108ab03263d9452a8811b7cdd87675343a40d4aa254" dependencies = [ "gimli 0.26.1", - "hashbrown 0.11.2", - "object 0.28.4", + "hashbrown", + "object 0.29.0", "tracing", ] diff --git a/compiler/rustc_codegen_cranelift/Cargo.lock b/compiler/rustc_codegen_cranelift/Cargo.lock index 7b8e43b639f99..939ccb765c99c 100644 --- a/compiler/rustc_codegen_cranelift/Cargo.lock +++ b/compiler/rustc_codegen_cranelift/Cargo.lock @@ -163,15 +163,15 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758" [[package]] name = "indexmap" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", diff --git a/compiler/rustc_codegen_cranelift/Cargo.toml b/compiler/rustc_codegen_cranelift/Cargo.toml index 18d7f41cf408a..781f26b24dd1d 100644 --- a/compiler/rustc_codegen_cranelift/Cargo.toml +++ b/compiler/rustc_codegen_cranelift/Cargo.toml @@ -19,7 +19,7 @@ gimli = { version = "0.26.0", default-features = false, features = ["write"]} object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } -indexmap = "1.8.0" +indexmap = "1.9.1" libloading = { version = "0.6.0", optional = true } once_cell = "1.10.0" smallvec = "1.6.1" diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 1bdc473c29b6e..2fa66b268752f 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -14,7 +14,7 @@ tracing = "0.1" libc = "0.2.50" jobserver = "0.1.22" tempfile = "3.2" -thorin-dwp = "0.2" +thorin-dwp = "0.3" pathdiff = "0.2.0" serde_json = "1.0.59" snap = "1" diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index 33deadb32d447..3192fc4cc5b2b 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -9,7 +9,7 @@ doctest = false [dependencies] arrayvec = { version = "0.7", default-features = false } ena = "0.14" -indexmap = { version = "1.8.2" } +indexmap = { version = "1.9.1" } tracing = "0.1" jobserver_crate = { version = "0.1.13", package = "jobserver" } rustc_serialize = { path = "../rustc_serialize" } diff --git a/compiler/rustc_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index f6b9e17e58ed9..dbc5c15195c86 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml @@ -4,8 +4,8 @@ version = "0.0.0" edition = "2021" [dependencies] -indexmap = "1.8.0" -smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } +indexmap = "1.9.1" +smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } [dev-dependencies] rustc_macros = { path = "../rustc_macros" } diff --git a/src/tools/bump-stage0/Cargo.toml b/src/tools/bump-stage0/Cargo.toml index cf8840ff6ee89..5df36f0f062c3 100644 --- a/src/tools/bump-stage0/Cargo.toml +++ b/src/tools/bump-stage0/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0.34" curl = "0.4.38" -indexmap = { version = "1.7.0", features = ["serde"] } +indexmap = { version = "1.9.1", features = ["serde"] } serde = { version = "1.0.125", features = ["derive"] } serde_json = "1.0.59" toml = "0.5.7" From 68bfd3a7d24348ebc243c70457183a6f99b3dc01 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sun, 17 Jul 2022 13:23:26 +0200 Subject: [PATCH 08/12] Upgrade hashbrown to 0.12.3 This fixes a double-free in the `clone_from` function if dropping an existing element in the table panics. See https://github.com/rust-lang/hashbrown/pull/348 for more details. --- Cargo.lock | 4 ++-- compiler/rustc_codegen_cranelift/Cargo.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 292ed1c129c1e..b53b4e7b2961d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1700,9 +1700,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", "compiler_builtins", diff --git a/compiler/rustc_codegen_cranelift/Cargo.lock b/compiler/rustc_codegen_cranelift/Cargo.lock index 939ccb765c99c..dac1cef3831de 100644 --- a/compiler/rustc_codegen_cranelift/Cargo.lock +++ b/compiler/rustc_codegen_cranelift/Cargo.lock @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.0" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "indexmap" From 39814b150286f2ab38647615ab07874da3e34110 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 25 Jul 2022 16:35:12 -0700 Subject: [PATCH 09/12] rustdoc: avoid inlining modules with duplicate names Fixes rust-lang/rust#99734 --- src/librustdoc/clean/mod.rs | 7 +++++-- src/test/rustdoc/auxiliary/issue-99734-aux.rs | 7 +++++++ .../issue-99734-multiple-mods-w-same-name.rs | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/test/rustdoc/auxiliary/issue-99734-aux.rs create mode 100644 src/test/rustdoc/issue-99734-multiple-mods-w-same-name.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 31c99b3b30260..6e20ba305dce3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -51,19 +51,22 @@ pub(crate) trait Clean<'tcx, T> { impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { let mut items: Vec = vec![]; + let mut inserted = FxHashSet::default(); items.extend( self.foreigns .iter() .map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)), ); - items.extend(self.mods.iter().map(|x| x.clean(cx))); + items.extend(self.mods.iter().map(|x| { + inserted.insert((ItemType::Module, x.name)); + x.clean(cx) + })); // Split up imports from all other items. // // This covers the case where somebody does an import which should pull in an item, // but there's already an item with the same namespace and same name. Rust gives // priority to the not-imported one, so we should, too. - let mut inserted = FxHashSet::default(); items.extend(self.items.iter().flat_map(|(item, renamed)| { // First, lower everything other than imports. if matches!(item.kind, hir::ItemKind::Use(..)) { diff --git a/src/test/rustdoc/auxiliary/issue-99734-aux.rs b/src/test/rustdoc/auxiliary/issue-99734-aux.rs new file mode 100644 index 0000000000000..8f1f1ec89674f --- /dev/null +++ b/src/test/rustdoc/auxiliary/issue-99734-aux.rs @@ -0,0 +1,7 @@ +pub struct Option; +impl Option { + pub fn unwrap(self) {} +} + +/// [`Option::unwrap`] +pub mod task {} diff --git a/src/test/rustdoc/issue-99734-multiple-mods-w-same-name.rs b/src/test/rustdoc/issue-99734-multiple-mods-w-same-name.rs new file mode 100644 index 0000000000000..b2f9b8b46578b --- /dev/null +++ b/src/test/rustdoc/issue-99734-multiple-mods-w-same-name.rs @@ -0,0 +1,14 @@ +// aux-build:issue-99734-aux.rs +// build-aux-docs +// ignore-cross-compile + +#![crate_name = "foo"] + +#[macro_use] +extern crate issue_99734_aux; + +pub use issue_99734_aux::*; + +// @count foo/index.html '//a[@class="mod"][@title="foo::task mod"]' 1 + +pub mod task {} From 94a868d6a1d036a5f293ab092e6310a300cb6585 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 2 Aug 2022 14:48:23 -0700 Subject: [PATCH 10/12] rustdoc: avoid inlining foreigns with duplicate names --- src/librustdoc/clean/mod.rs | 12 +++++++----- src/test/rustdoc/auxiliary/issue-99734-aux.rs | 4 ++++ .../issue-99734-multiple-foreigns-w-same-name.rs | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6e20ba305dce3..af9ea315ac3cd 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -52,11 +52,13 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { let mut items: Vec = vec![]; let mut inserted = FxHashSet::default(); - items.extend( - self.foreigns - .iter() - .map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)), - ); + items.extend(self.foreigns.iter().map(|(item, renamed)| { + let item = clean_maybe_renamed_foreign_item(cx, item, *renamed); + if let Some(name) = item.name { + inserted.insert((item.type_(), name)); + } + item + })); items.extend(self.mods.iter().map(|x| { inserted.insert((ItemType::Module, x.name)); x.clean(cx) diff --git a/src/test/rustdoc/auxiliary/issue-99734-aux.rs b/src/test/rustdoc/auxiliary/issue-99734-aux.rs index 8f1f1ec89674f..234d55efb554d 100644 --- a/src/test/rustdoc/auxiliary/issue-99734-aux.rs +++ b/src/test/rustdoc/auxiliary/issue-99734-aux.rs @@ -5,3 +5,7 @@ impl Option { /// [`Option::unwrap`] pub mod task {} + +extern "C" { + pub fn main() -> std::ffi::c_int; +} diff --git a/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs b/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs new file mode 100644 index 0000000000000..3208fea05b376 --- /dev/null +++ b/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs @@ -0,0 +1,16 @@ +// aux-build:issue-99734-aux.rs +// build-aux-docs +// ignore-cross-compile + +#![crate_name = "foo"] + +#[macro_use] +extern crate issue_99734_aux; + +pub use issue_99734_aux::*; + +// @count foo/index.html '//a[@class="fn"][@title="foo::main fn"]' 1 + +extern "C" { + pub fn main() -> std::ffi::c_int; +} From 1542579ea92970b59517690f064ff947eabd3c37 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 5 Aug 2022 12:51:46 -0400 Subject: [PATCH 11/12] Update Cargo.lock --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b53b4e7b2961d..5db3c6d554143 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4946,9 +4946,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "cc88c725d61fc6c3132893370cac4a0200e3fedf5da8331c570664b1987f5ca2" [[package]] name = "snap" From 8482bac7be42cbb44a48ed85b018c490de3b4493 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Fri, 5 Aug 2022 13:41:39 -0400 Subject: [PATCH 12/12] fixup rustdoc test --- src/test/rustdoc/auxiliary/issue-99734-aux.rs | 2 +- src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/rustdoc/auxiliary/issue-99734-aux.rs b/src/test/rustdoc/auxiliary/issue-99734-aux.rs index 234d55efb554d..c842a46817ed3 100644 --- a/src/test/rustdoc/auxiliary/issue-99734-aux.rs +++ b/src/test/rustdoc/auxiliary/issue-99734-aux.rs @@ -7,5 +7,5 @@ impl Option { pub mod task {} extern "C" { - pub fn main() -> std::ffi::c_int; + pub fn main() -> std::os::raw::c_int; } diff --git a/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs b/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs index 3208fea05b376..cd2b5b2a28873 100644 --- a/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs +++ b/src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs @@ -12,5 +12,5 @@ pub use issue_99734_aux::*; // @count foo/index.html '//a[@class="fn"][@title="foo::main fn"]' 1 extern "C" { - pub fn main() -> std::ffi::c_int; + pub fn main() -> std::os::raw::c_int; }