Skip to content

Rollup of 4 pull requests #125838

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

Closed
wants to merge 11 commits into from
7 changes: 5 additions & 2 deletions library/alloc/src/collections/binary_heap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,10 @@ impl<T: Ord> BinaryHeap<T> {
/// heap.push(4);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[rustc_const_stable(
feature = "const_binary_heap_constructor",
since = "CURRENT_RUSTC_VERSION"
)]
#[must_use]
pub const fn new() -> BinaryHeap<T> {
BinaryHeap { data: vec![] }
Expand Down Expand Up @@ -484,7 +487,7 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
/// heap.push(4);
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
#[rustc_const_unstable(feature = "const_binary_heap_new_in", issue = "112353")]
#[must_use]
pub const fn new_in(alloc: A) -> BinaryHeap<T, A> {
BinaryHeap { data: Vec::new_in(alloc) }
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-none",
"ignore-nto",
"ignore-nvptx64",
"ignore-nvptx64-nvidia-cuda",
"ignore-openbsd",
"ignore-pass",
"ignore-remote",
Expand Down
7 changes: 7 additions & 0 deletions src/tools/run-make-support/src/cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ impl Cc {
self
}

/// Specify path of the output binary.
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-o");
self.cmd.arg(path.as_ref());
self
}

/// Get the [`Output`][::std::process::Output] of the finished process.
pub fn command_output(&mut self) -> ::std::process::Output {
self.cmd.output().expect("failed to get output of finished process")
Expand Down
6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ impl Rustc {
self
}

/// Add a suffix in each output filename.
pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {
self.cmd.arg(format!("-Cextra-filename={suffix}"));
self
}

/// Specify type(s) of output files to generate.
pub fn emit(&mut self, kinds: &str) -> &mut Self {
self.cmd.arg(format!("--emit={kinds}"));
Expand Down
4 changes: 0 additions & 4 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/cdylib-dylib-linkage/Makefile
run-make/cdylib-fewer-symbols/Makefile
run-make/cdylib/Makefile
run-make/codegen-options-parsing/Makefile
run-make/comment-section/Makefile
run-make/compiler-lookup-paths-2/Makefile
Expand Down Expand Up @@ -75,7 +74,6 @@ run-make/inaccessible-temp-dir/Makefile
run-make/include_bytes_deps/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/incr-foreign-head-span/Makefile
run-make/incr-prev-body-beyond-eof/Makefile
run-make/incremental-debugger-visualizer/Makefile
run-make/incremental-session-fail/Makefile
run-make/inline-always-many-cgu/Makefile
Expand Down Expand Up @@ -208,7 +206,6 @@ run-make/remap-path-prefix-dwarf/Makefile
run-make/remap-path-prefix/Makefile
run-make/reproducible-build-2/Makefile
run-make/reproducible-build/Makefile
run-make/resolve-rename/Makefile
run-make/return-non-c-like-enum-from-c/Makefile
run-make/return-non-c-like-enum/Makefile
run-make/rlib-chain/Makefile
Expand Down Expand Up @@ -238,7 +235,6 @@ run-make/static-pie/Makefile
run-make/staticlib-blank-lib/Makefile
run-make/staticlib-dylib-linkage/Makefile
run-make/std-core-cycle/Makefile
run-make/suspicious-library/Makefile
run-make/symbol-mangling-hashed/Makefile
run-make/symbol-visibility/Makefile
run-make/symbols-include-type-name/Makefile
Expand Down
23 changes: 0 additions & 23 deletions tests/run-make/cdylib/Makefile

This file was deleted.

39 changes: 39 additions & 0 deletions tests/run-make/cdylib/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This test tries to check that basic cdylib libraries can be compiled and linked successfully
// with C code, that the cdylib itself can depend on another rlib, and that the library can be built
// with LTO.
//
// - `bar.rs` is a rlib
// - `foo.rs` is a cdylib that relies on an extern crate `bar` and defines two `extern "C"`
// functions:
// - `foo()` which calls `bar::bar()`.
// - `bar()` which implements basic addition.

//@ ignore-cross-compile

use std::fs::remove_file;

use run_make_support::{cc, dynamic_lib, is_msvc, run, rustc, tmp_dir};

fn main() {
rustc().input("bar.rs").run();
rustc().input("foo.rs").run();

if is_msvc() {
cc().input("foo.c")
.arg(tmp_dir().join("foo.dll.lib"))
.out_exe("foo")
.run();
} else {
cc().input("foo.c")
.arg("-lfoo")
.output(tmp_dir().join("foo"))
.library_search_path(tmp_dir())
.run();
}

run("foo");
remove_file(dynamic_lib("foo")).unwrap();

rustc().input("foo.rs").arg("-Clto").run();
run("foo");
}
19 changes: 0 additions & 19 deletions tests/run-make/incr-prev-body-beyond-eof/Makefile

This file was deleted.

34 changes: 34 additions & 0 deletions tests/run-make/incr-prev-body-beyond-eof/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// After modifying the span of a function, if the length of
// the span remained the same but the end line number became different,
// this would cause an internal compiler error (ICE), fixed in #76256.

// This test compiles main.rs twice, first with end line 16 and
// then with end line 12. If compilation is successful, the end line
// was hashed by rustc in addition to the span length, and the fix still
// works.

//@ ignore-none
// reason: no-std is not supported

//@ ignore-nvptx64-nvidia-cuda
// FIXME: can't find crate for `std`

use run_make_support::{rustc, target, tmp_dir};
use std::fs;

fn main() {
fs::create_dir(tmp_dir().join("src")).unwrap();
fs::create_dir(tmp_dir().join("incr")).unwrap();
fs::copy("a.rs", tmp_dir().join("src/main.rs")).unwrap();
rustc()
.incremental(tmp_dir().join("incr"))
.input(tmp_dir().join("src/main.rs"))
.target(&target())
.run();
fs::copy("b.rs", tmp_dir().join("src/main.rs")).unwrap();
rustc()
.incremental(tmp_dir().join("incr"))
.input(tmp_dir().join("src/main.rs"))
.target(&target())
.run();
}
150 changes: 86 additions & 64 deletions tests/run-make/print-check-cfg/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,70 @@ use std::ops::Deref;

use run_make_support::rustc;

struct CheckCfg {
args: &'static [&'static str],
contains: Contains,
}

enum Contains {
Some { contains: &'static [&'static str], doesnt_contain: &'static [&'static str] },
Only(&'static str),
}

fn main() {
check(
/*args*/ &[],
/*has_any*/ false,
/*has_any_any*/ true,
/*contains*/ &[],
);
check(
/*args*/ &["--check-cfg=cfg()"],
/*has_any*/ false,
/*has_any_any*/ false,
/*contains*/ &["unix", "miri"],
);
check(
/*args*/ &["--check-cfg=cfg(any())"],
/*has_any*/ true,
/*has_any_any*/ false,
/*contains*/ &["windows", "test"],
);
check(
/*args*/ &["--check-cfg=cfg(feature)"],
/*has_any*/ false,
/*has_any_any*/ false,
/*contains*/ &["unix", "miri", "feature"],
);
check(
/*args*/ &[r#"--check-cfg=cfg(feature, values(none(), "", "test", "lol"))"#],
/*has_any*/ false,
/*has_any_any*/ false,
/*contains*/ &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""],
);
check(
/*args*/
&[
check(CheckCfg { args: &[], contains: Contains::Only("any()=any()") });
check(CheckCfg {
args: &["--check-cfg=cfg()"],
contains: Contains::Some {
contains: &["unix", "miri"],
doesnt_contain: &["any()", "any()=any()"],
},
});
check(CheckCfg {
args: &["--check-cfg=cfg(any())"],
contains: Contains::Some {
contains: &["any()", "unix", r#"target_feature="crt-static""#],
doesnt_contain: &["any()=any()"],
},
});
check(CheckCfg {
args: &["--check-cfg=cfg(feature)"],
contains: Contains::Some {
contains: &["unix", "miri", "feature"],
doesnt_contain: &["any()", "any()=any()", "feature=none()", "feature="],
},
});
check(CheckCfg {
args: &[r#"--check-cfg=cfg(feature, values(none(), "", "test", "lol"))"#],
contains: Contains::Some {
contains: &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""],
doesnt_contain: &["any()", "any()=any()", "feature=none()", "feature="],
},
});
check(CheckCfg {
args: &[
r#"--check-cfg=cfg(feature, values(any()))"#,
r#"--check-cfg=cfg(feature, values("tmp"))"#,
],
/*has_any*/ false,
/*has_any_any*/ false,
/*contains*/ &["unix", "miri", "feature=any()"],
);
check(
/*args*/
&[
contains: Contains::Some {
contains: &["unix", "miri", "feature=any()"],
doesnt_contain: &["any()", "any()=any()", "feature", "feature=", "feature=\"tmp\""],
},
});
check(CheckCfg {
args: &[
r#"--check-cfg=cfg(has_foo, has_bar)"#,
r#"--check-cfg=cfg(feature, values("tmp"))"#,
r#"--check-cfg=cfg(feature, values("tmp"))"#,
],
/*has_any*/ false,
/*has_any_any*/ false,
/*contains*/ &["has_foo", "has_bar", "feature=\"tmp\""],
);
contains: Contains::Some {
contains: &["has_foo", "has_bar", "feature=\"tmp\""],
doesnt_contain: &["any()", "any()=any()", "feature"],
},
});
}

fn check(args: &[&str], has_any: bool, has_any_any: bool, contains: &[&str]) {
fn check(CheckCfg { args, contains }: CheckCfg) {
let output = rustc()
.input("lib.rs")
.arg("-Zunstable-options")
Expand All @@ -72,18 +81,11 @@ fn check(args: &[&str], has_any: bool, has_any_any: bool, contains: &[&str]) {

let stdout = String::from_utf8(output.stdout).unwrap();

let mut found_any = false;
let mut found_any_any = false;
let mut found = HashSet::<String>::new();
let mut recorded = HashSet::<String>::new();

for l in stdout.lines() {
assert!(l == l.trim());
if l == "any()" {
found_any = true;
} else if l == "any()=any()" {
found_any_any = true;
} else if let Some((left, right)) = l.split_once('=') {
if let Some((left, right)) = l.split_once('=') {
if right != "any()" && right != "" {
assert!(right.starts_with("\""));
assert!(right.ends_with("\""));
Expand All @@ -92,17 +94,37 @@ fn check(args: &[&str], has_any: bool, has_any_any: bool, contains: &[&str]) {
} else {
assert!(!l.contains("\""));
}
assert!(recorded.insert(l.to_string()), "{}", &l);
if contains.contains(&l) {
assert!(found.insert(l.to_string()), "{}", &l);
}
assert!(found.insert(l.to_string()), "{}", &l);
}

let should_found = HashSet::<String>::from_iter(contains.iter().map(|s| s.to_string()));
let diff: Vec<_> = should_found.difference(&found).collect();

assert_eq!(found_any, has_any);
assert_eq!(found_any_any, has_any_any);
assert_eq!(found_any_any, recorded.len() == 1);
assert!(diff.is_empty(), "{:?} != {:?} (~ {:?})", &should_found, &found, &diff);
match contains {
Contains::Some { contains, doesnt_contain } => {
{
let should_found =
HashSet::<String>::from_iter(contains.iter().map(|s| s.to_string()));
let diff: Vec<_> = should_found.difference(&found).collect();
assert!(
diff.is_empty(),
"should found: {:?}, didn't found {:?}",
&should_found,
&diff
);
}
{
let should_not_find =
HashSet::<String>::from_iter(doesnt_contain.iter().map(|s| s.to_string()));
let diff: Vec<_> = should_not_find.intersection(&found).collect();
assert!(
diff.is_empty(),
"should not find {:?}, did found {:?}",
&should_not_find,
&diff
);
}
}
Contains::Only(only) => {
assert!(found.contains(&only.to_string()), "{:?} != {:?}", &only, &found);
assert!(found.len() == 1, "len: {}, instead of 1", found.len());
}
}
}
7 changes: 0 additions & 7 deletions tests/run-make/resolve-rename/Makefile

This file was deleted.

Loading
Loading