Skip to content

Commit

Permalink
Auto merge of #100171 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
[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`
  • Loading branch information
bors committed Aug 5, 2022
2 parents 7410ebb 8482bac commit 6f955bf
Show file tree
Hide file tree
Showing 21 changed files with 247 additions and 83 deletions.
49 changes: 14 additions & 35 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1700,18 1700,9 @@ dependencies = [

[[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"
version = "0.12.3"
source = "registry https://github.com/rust-lang/crates.io-index"
checksum = "8c21d40587b92fa6a6c6e3c1bdbf87d75511db5672f9c93175574b3a00df1758"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash",
"compiler_builtins",
Expand Down Expand Up @@ -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",
]
Expand Down Expand Up @@ -2559,27 2550,15 @@ 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"
source = "registry https://github.com/rust-lang/crates.io-index"
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
dependencies = [
"crc32fast",
"hashbrown 0.12.0",
"flate2",
"hashbrown",
"indexmap",
"memchr",
]
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -5047,7 5026,7 @@ dependencies = [
"core",
"dlmalloc",
"fortanix-sgx-abi",
"hashbrown 0.12.0",
"hashbrown",
"hermit-abi 0.2.0",
"libc",
"miniz_oxide",
Expand Down Expand Up @@ -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",
]

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_serialize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
14 changes: 6 additions & 8 deletions library/core/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/doc/rustc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..)) {
Expand Down
19 changes: 16 additions & 3 deletions src/test/run-make/native-link-modifier-whole-archive/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,15 10,28 @@

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

# Native lib linked directly into executable
$(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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 1,7 @@
use std::io::Write;

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

#[test]
fn test_thing() {
print!("ran the test");
std::io::stdout().flush().unwrap();
}
11 changes: 11 additions & 0 deletions src/test/rustdoc/auxiliary/issue-99734-aux.rs
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 16 additions & 0 deletions src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 14 additions & 0 deletions src/test/rustdoc/issue-99734-multiple-mods-w-same-name.rs
Original file line number Diff line number Diff line change
@@ -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 {}
37 changes: 37 additions & 0 deletions src/test/ui/macros/format-args-temporaries-async.rs
Original file line number Diff line number Diff line change
@@ -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;
}
Loading

0 comments on commit 6f955bf

Please sign in to comment.