Skip to content

Commit 176626a

Browse files
committed
Auto merge of rust-lang#125840 - jhpratt:rollup-mcsuwkj, r=jhpratt
Rollup of 3 pull requests Successful merges: - rust-lang#125211 (Stablize `const_binary_heap_constructor`) - rust-lang#125683 (Rewrite `suspicious-library`, `resolve-rename` and `incr-prev-body-beyond-eof` `run-make` tests in `rmake.rs` format) - rust-lang#125822 (Refactor `--print=check-cfg` test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dcc9a8f + d400cec commit 176626a

File tree

11 files changed

+162
-103
lines changed

11 files changed

+162
-103
lines changed

library/alloc/src/collections/binary_heap/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,10 @@ impl<T: Ord> BinaryHeap<T> {
440440
/// heap.push(4);
441441
/// ```
442442
#[stable(feature = "rust1", since = "1.0.0")]
443-
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
443+
#[rustc_const_stable(
444+
feature = "const_binary_heap_constructor",
445+
since = "CURRENT_RUSTC_VERSION"
446+
)]
444447
#[must_use]
445448
pub const fn new() -> BinaryHeap<T> {
446449
BinaryHeap { data: vec![] }
@@ -484,7 +487,7 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
484487
/// heap.push(4);
485488
/// ```
486489
#[unstable(feature = "allocator_api", issue = "32838")]
487-
#[rustc_const_unstable(feature = "const_binary_heap_constructor", issue = "112353")]
490+
#[rustc_const_unstable(feature = "const_binary_heap_new_in", issue = "112353")]
488491
#[must_use]
489492
pub const fn new_in(alloc: A) -> BinaryHeap<T, A> {
490493
BinaryHeap { data: Vec::new_in(alloc) }

src/tools/compiletest/src/header.rs

+1
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
799799
"ignore-none",
800800
"ignore-nto",
801801
"ignore-nvptx64",
802+
"ignore-nvptx64-nvidia-cuda",
802803
"ignore-openbsd",
803804
"ignore-pass",
804805
"ignore-remote",

src/tools/run-make-support/src/rustc.rs

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ impl Rustc {
7070
self
7171
}
7272

73+
/// Add a suffix in each output filename.
74+
pub fn extra_filename(&mut self, suffix: &str) -> &mut Self {
75+
self.cmd.arg(format!("-Cextra-filename={suffix}"));
76+
self
77+
}
78+
7379
/// Specify type(s) of output files to generate.
7480
pub fn emit(&mut self, kinds: &str) -> &mut Self {
7581
self.cmd.arg(format!("--emit={kinds}"));

src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ run-make/inaccessible-temp-dir/Makefile
7575
run-make/include_bytes_deps/Makefile
7676
run-make/incr-add-rust-src-component/Makefile
7777
run-make/incr-foreign-head-span/Makefile
78-
run-make/incr-prev-body-beyond-eof/Makefile
7978
run-make/incremental-debugger-visualizer/Makefile
8079
run-make/incremental-session-fail/Makefile
8180
run-make/inline-always-many-cgu/Makefile
@@ -208,7 +207,6 @@ run-make/remap-path-prefix-dwarf/Makefile
208207
run-make/remap-path-prefix/Makefile
209208
run-make/reproducible-build-2/Makefile
210209
run-make/reproducible-build/Makefile
211-
run-make/resolve-rename/Makefile
212210
run-make/return-non-c-like-enum-from-c/Makefile
213211
run-make/return-non-c-like-enum/Makefile
214212
run-make/rlib-chain/Makefile
@@ -238,7 +236,6 @@ run-make/static-pie/Makefile
238236
run-make/staticlib-blank-lib/Makefile
239237
run-make/staticlib-dylib-linkage/Makefile
240238
run-make/std-core-cycle/Makefile
241-
run-make/suspicious-library/Makefile
242239
run-make/symbol-mangling-hashed/Makefile
243240
run-make/symbol-visibility/Makefile
244241
run-make/symbols-include-type-name/Makefile

tests/run-make/incr-prev-body-beyond-eof/Makefile

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// After modifying the span of a function, if the length of
2+
// the span remained the same but the end line number became different,
3+
// this would cause an internal compiler error (ICE), fixed in #76256.
4+
5+
// This test compiles main.rs twice, first with end line 16 and
6+
// then with end line 12. If compilation is successful, the end line
7+
// was hashed by rustc in addition to the span length, and the fix still
8+
// works.
9+
10+
//@ ignore-none
11+
// reason: no-std is not supported
12+
13+
//@ ignore-nvptx64-nvidia-cuda
14+
// FIXME: can't find crate for `std`
15+
16+
use run_make_support::{rustc, target, tmp_dir};
17+
use std::fs;
18+
19+
fn main() {
20+
fs::create_dir(tmp_dir().join("src")).unwrap();
21+
fs::create_dir(tmp_dir().join("incr")).unwrap();
22+
fs::copy("a.rs", tmp_dir().join("src/main.rs")).unwrap();
23+
rustc()
24+
.incremental(tmp_dir().join("incr"))
25+
.input(tmp_dir().join("src/main.rs"))
26+
.target(&target())
27+
.run();
28+
fs::copy("b.rs", tmp_dir().join("src/main.rs")).unwrap();
29+
rustc()
30+
.incremental(tmp_dir().join("incr"))
31+
.input(tmp_dir().join("src/main.rs"))
32+
.target(&target())
33+
.run();
34+
}

tests/run-make/print-check-cfg/rmake.rs

+86-64
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,70 @@ use std::ops::Deref;
88

99
use run_make_support::rustc;
1010

11+
struct CheckCfg {
12+
args: &'static [&'static str],
13+
contains: Contains,
14+
}
15+
16+
enum Contains {
17+
Some { contains: &'static [&'static str], doesnt_contain: &'static [&'static str] },
18+
Only(&'static str),
19+
}
20+
1121
fn main() {
12-
check(
13-
/*args*/ &[],
14-
/*has_any*/ false,
15-
/*has_any_any*/ true,
16-
/*contains*/ &[],
17-
);
18-
check(
19-
/*args*/ &["--check-cfg=cfg()"],
20-
/*has_any*/ false,
21-
/*has_any_any*/ false,
22-
/*contains*/ &["unix", "miri"],
23-
);
24-
check(
25-
/*args*/ &["--check-cfg=cfg(any())"],
26-
/*has_any*/ true,
27-
/*has_any_any*/ false,
28-
/*contains*/ &["windows", "test"],
29-
);
30-
check(
31-
/*args*/ &["--check-cfg=cfg(feature)"],
32-
/*has_any*/ false,
33-
/*has_any_any*/ false,
34-
/*contains*/ &["unix", "miri", "feature"],
35-
);
36-
check(
37-
/*args*/ &[r#"--check-cfg=cfg(feature, values(none(), "", "test", "lol"))"#],
38-
/*has_any*/ false,
39-
/*has_any_any*/ false,
40-
/*contains*/ &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""],
41-
);
42-
check(
43-
/*args*/
44-
&[
22+
check(CheckCfg { args: &[], contains: Contains::Only("any()=any()") });
23+
check(CheckCfg {
24+
args: &["--check-cfg=cfg()"],
25+
contains: Contains::Some {
26+
contains: &["unix", "miri"],
27+
doesnt_contain: &["any()", "any()=any()"],
28+
},
29+
});
30+
check(CheckCfg {
31+
args: &["--check-cfg=cfg(any())"],
32+
contains: Contains::Some {
33+
contains: &["any()", "unix", r#"target_feature="crt-static""#],
34+
doesnt_contain: &["any()=any()"],
35+
},
36+
});
37+
check(CheckCfg {
38+
args: &["--check-cfg=cfg(feature)"],
39+
contains: Contains::Some {
40+
contains: &["unix", "miri", "feature"],
41+
doesnt_contain: &["any()", "any()=any()", "feature=none()", "feature="],
42+
},
43+
});
44+
check(CheckCfg {
45+
args: &[r#"--check-cfg=cfg(feature, values(none(), "", "test", "lol"))"#],
46+
contains: Contains::Some {
47+
contains: &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""],
48+
doesnt_contain: &["any()", "any()=any()", "feature=none()", "feature="],
49+
},
50+
});
51+
check(CheckCfg {
52+
args: &[
4553
r#"--check-cfg=cfg(feature, values(any()))"#,
4654
r#"--check-cfg=cfg(feature, values("tmp"))"#,
4755
],
48-
/*has_any*/ false,
49-
/*has_any_any*/ false,
50-
/*contains*/ &["unix", "miri", "feature=any()"],
51-
);
52-
check(
53-
/*args*/
54-
&[
56+
contains: Contains::Some {
57+
contains: &["unix", "miri", "feature=any()"],
58+
doesnt_contain: &["any()", "any()=any()", "feature", "feature=", "feature=\"tmp\""],
59+
},
60+
});
61+
check(CheckCfg {
62+
args: &[
5563
r#"--check-cfg=cfg(has_foo, has_bar)"#,
5664
r#"--check-cfg=cfg(feature, values("tmp"))"#,
5765
r#"--check-cfg=cfg(feature, values("tmp"))"#,
5866
],
59-
/*has_any*/ false,
60-
/*has_any_any*/ false,
61-
/*contains*/ &["has_foo", "has_bar", "feature=\"tmp\""],
62-
);
67+
contains: Contains::Some {
68+
contains: &["has_foo", "has_bar", "feature=\"tmp\""],
69+
doesnt_contain: &["any()", "any()=any()", "feature"],
70+
},
71+
});
6372
}
6473

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

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

75-
let mut found_any = false;
76-
let mut found_any_any = false;
7784
let mut found = HashSet::<String>::new();
78-
let mut recorded = HashSet::<String>::new();
7985

8086
for l in stdout.lines() {
8187
assert!(l == l.trim());
82-
if l == "any()" {
83-
found_any = true;
84-
} else if l == "any()=any()" {
85-
found_any_any = true;
86-
} else if let Some((left, right)) = l.split_once('=') {
88+
if let Some((left, right)) = l.split_once('=') {
8789
if right != "any()" && right != "" {
8890
assert!(right.starts_with("\""));
8991
assert!(right.ends_with("\""));
@@ -92,17 +94,37 @@ fn check(args: &[&str], has_any: bool, has_any_any: bool, contains: &[&str]) {
9294
} else {
9395
assert!(!l.contains("\""));
9496
}
95-
assert!(recorded.insert(l.to_string()), "{}", &l);
96-
if contains.contains(&l) {
97-
assert!(found.insert(l.to_string()), "{}", &l);
98-
}
97+
assert!(found.insert(l.to_string()), "{}", &l);
9998
}
10099

101-
let should_found = HashSet::<String>::from_iter(contains.iter().map(|s| s.to_string()));
102-
let diff: Vec<_> = should_found.difference(&found).collect();
103-
104-
assert_eq!(found_any, has_any);
105-
assert_eq!(found_any_any, has_any_any);
106-
assert_eq!(found_any_any, recorded.len() == 1);
107-
assert!(diff.is_empty(), "{:?} != {:?} (~ {:?})", &should_found, &found, &diff);
100+
match contains {
101+
Contains::Some { contains, doesnt_contain } => {
102+
{
103+
let should_found =
104+
HashSet::<String>::from_iter(contains.iter().map(|s| s.to_string()));
105+
let diff: Vec<_> = should_found.difference(&found).collect();
106+
assert!(
107+
diff.is_empty(),
108+
"should found: {:?}, didn't found {:?}",
109+
&should_found,
110+
&diff
111+
);
112+
}
113+
{
114+
let should_not_find =
115+
HashSet::<String>::from_iter(doesnt_contain.iter().map(|s| s.to_string()));
116+
let diff: Vec<_> = should_not_find.intersection(&found).collect();
117+
assert!(
118+
diff.is_empty(),
119+
"should not find {:?}, did found {:?}",
120+
&should_not_find,
121+
&diff
122+
);
123+
}
124+
}
125+
Contains::Only(only) => {
126+
assert!(found.contains(&only.to_string()), "{:?} != {:?}", &only, &found);
127+
assert!(found.len() == 1, "len: {}, instead of 1", found.len());
128+
}
129+
}
108130
}

tests/run-make/resolve-rename/Makefile

-7
This file was deleted.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// If a library is compiled with -C extra-filename, the rust compiler
2+
// will take this into account when searching for libraries. However,
3+
// if that library is then renamed, the rust compiler should fall back
4+
// to its regular library location logic and not immediately fail to find
5+
// the renamed library.
6+
// See https://github.com/rust-lang/rust/pull/49253
7+
8+
use run_make_support::{rustc, tmp_dir};
9+
use std::fs;
10+
fn main() {
11+
rustc().extra_filename("-hash").input("foo.rs").run();
12+
rustc().input("bar.rs").run();
13+
fs::rename(tmp_dir().join("libfoo-hash.rlib"), tmp_dir().join("libfoo-another-hash.rlib"))
14+
.unwrap();
15+
rustc().input("baz.rs").run();
16+
}

tests/run-make/suspicious-library/Makefile

-8
This file was deleted.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This test creates some fake dynamic libraries with nothing inside,
2+
// and checks if rustc avoids them and successfully compiles as a result.
3+
4+
//@ ignore-cross-compile
5+
6+
use run_make_support::{dynamic_lib, rustc};
7+
use std::fs::File;
8+
9+
fn main() {
10+
rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
11+
File::create(dynamic_lib("foo-something-special")).unwrap();
12+
File::create(dynamic_lib("foo-something-special2")).unwrap();
13+
rustc().input("bar.rs").run();
14+
}

0 commit comments

Comments
 (0)