Auto merge of #100171 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum

[beta] Rollup of beta backports

Includes the following PRs:

*  rustc-docs: Be less specific about the representation of +bundle #100074
*  Fix backwards-compatibility check for tests with +whole-archive #100068
*  Revert write! and writeln! to late drop temporaries #99689
*  Upgrade indexmap and thorin-dwp to use hashbrown 0.12 #99251
*  rustdoc: avoid inlining modules with duplicate names #99738

r? `@ghost`
This commit is contained in:
bors 2022-08-05 20:06:44 +00:00
commit 6f955bfdfe
21 changed files with 247 additions and 83 deletions

View file

@ -1700,18 +1700,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.11.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash",
"compiler_builtins",
@ -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",
]
@ -4967,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"
@ -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",
]

View file

@ -163,15 +163,15 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.11.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[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",

View file

@ -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"

View file

@ -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"

View file

@ -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,

View file

@ -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" }

View file

@ -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" }

View file

@ -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.

View file

@ -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

View file

@ -51,19 +51,24 @@ 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<Item> = vec![];
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)));
let mut inserted = FxHashSet::default();
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)
}));
// 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(..)) {

View file

@ -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

View file

@ -0,0 +1,7 @@
use std::io::Write;
#[test]
fn test_thing() {
print!("ran the test");
std::io::stdout().flush().unwrap();
}

View file

@ -0,0 +1,7 @@
use std::io::Write;
#[test]
fn test_thing() {
print!("ran the test");
std::io::stdout().flush().unwrap();
}

View file

@ -0,0 +1,11 @@
pub struct Option;
impl Option {
pub fn unwrap(self) {}
}
/// [`Option::unwrap`]
pub mod task {}
extern "C" {
pub fn main() -> std::os::raw::c_int;
}

View file

@ -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::os::raw::c_int;
}

View file

@ -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 {}

View file

@ -0,0 +1,37 @@
// check-pass
// 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<Self::Output> {
unimplemented!()
}
}
async fn async_main() {
let _write = write!(&mut AsyncStdout, "...").await;
let _writeln = writeln!(&mut AsyncStdout, "...").await;
}
fn main() {
let _ = async_main;
}

View file

@ -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
};
}

View file

@ -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`.

View file

@ -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 */

View file

@ -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"