Skip to content

Commit 52ca603

Browse files
committed
Auto merge of #95987 - m-ou-se:rollup-sdevd9b, r=m-ou-se
Rollup of 4 pull requests Successful merges: - #95783 (rustdoc doctest: include signal number in exit status) - #95794 (`parse_tt`: a few more tweaks) - #95963 ([bootstrap] Grab the right FileCheck binary for dist when cross-compiling.) - #95975 (Don't test -Cdefault-linker-libraries=yes when cross compiling.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents de56c29 + 550a510 commit 52ca603

9 files changed

+95
-45
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

+11-27
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,12 @@ use rustc_session::parse::ParseSess;
8181
use rustc_span::symbol::MacroRulesNormalizedIdent;
8282
use rustc_span::Span;
8383

84-
use smallvec::{smallvec, SmallVec};
85-
8684
use rustc_data_structures::fx::FxHashMap;
8785
use rustc_data_structures::sync::Lrc;
8886
use rustc_span::symbol::Ident;
8987
use std::borrow::Cow;
9088
use std::collections::hash_map::Entry::{Occupied, Vacant};
9189

92-
// One element is enough to cover 95-99% of vectors for most benchmarks. Also, vectors longer than
93-
// one frequently have many elements, not just two or three.
94-
type NamedMatchVec = SmallVec<[NamedMatch; 1]>;
95-
96-
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
97-
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
98-
rustc_data_structures::static_assert_size!(NamedMatchVec, 48);
99-
10090
/// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from)
10191
/// `mbe::TokenTree`, but designed specifically for fast and easy traversal during matching.
10292
/// Notable differences to `mbe::TokenTree`:
@@ -221,7 +211,11 @@ struct MatcherPos {
221211
/// with one element per metavar decl in the matcher. Each element records token trees matched
222212
/// against the relevant metavar by the black box parser. An element will be a `MatchedSeq` if
223213
/// the corresponding metavar decl is within a sequence.
224-
matches: Lrc<NamedMatchVec>,
214+
///
215+
/// It is critical to performance that this is an `Lrc`, because it gets cloned frequently when
216+
/// processing sequences. Mostly for sequence-ending possibilities that must be tried but end
217+
/// up failing.
218+
matches: Lrc<Vec<NamedMatch>>,
225219
}
226220

227221
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
@@ -246,18 +240,12 @@ impl MatcherPos {
246240
let mut curr = &mut matches[metavar_idx];
247241
for _ in 0..seq_depth - 1 {
248242
match curr {
249-
MatchedSeq(seq) => {
250-
let seq = Lrc::make_mut(seq);
251-
curr = seq.last_mut().unwrap();
252-
}
243+
MatchedSeq(seq) => curr = seq.last_mut().unwrap(),
253244
_ => unreachable!(),
254245
}
255246
}
256247
match curr {
257-
MatchedSeq(seq) => {
258-
let seq = Lrc::make_mut(seq);
259-
seq.push(m);
260-
}
248+
MatchedSeq(seq) => seq.push(m),
261249
_ => unreachable!(),
262250
}
263251
}
@@ -350,7 +338,7 @@ pub(super) fn count_metavar_decls(matcher: &[TokenTree]) -> usize {
350338
/// ```
351339
#[derive(Debug, Clone)]
352340
crate enum NamedMatch {
353-
MatchedSeq(Lrc<NamedMatchVec>),
341+
MatchedSeq(Vec<NamedMatch>),
354342

355343
// A metavar match of type `tt`.
356344
MatchedTokenTree(rustc_ast::tokenstream::TokenTree),
@@ -388,7 +376,7 @@ pub struct TtParser {
388376

389377
/// Pre-allocate an empty match array, so it can be cloned cheaply for macros with many rules
390378
/// that have no metavars.
391-
empty_matches: Lrc<NamedMatchVec>,
379+
empty_matches: Lrc<Vec<NamedMatch>>,
392380
}
393381

394382
impl TtParser {
@@ -398,7 +386,7 @@ impl TtParser {
398386
cur_mps: vec![],
399387
next_mps: vec![],
400388
bb_mps: vec![],
401-
empty_matches: Lrc::new(smallvec![]),
389+
empty_matches: Lrc::new(vec![]),
402390
}
403391
}
404392

@@ -452,11 +440,7 @@ impl TtParser {
452440
} => {
453441
// Install an empty vec for each metavar within the sequence.
454442
for metavar_idx in next_metavar..next_metavar + num_metavar_decls {
455-
mp.push_match(
456-
metavar_idx,
457-
seq_depth,
458-
MatchedSeq(self.empty_matches.clone()),
459-
);
443+
mp.push_match(metavar_idx, seq_depth, MatchedSeq(vec![]));
460444
}
461445

462446
if op == KleeneOp::ZeroOrMore || op == KleeneOp::ZeroOrOne {

compiler/rustc_expand/src/mbe/macro_rules.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@ pub fn compile_declarative_macro(
439439
let argument_gram = mbe::macro_parser::compute_locs(&sess.parse_sess, &argument_gram);
440440

441441
let parser = Parser::new(&sess.parse_sess, body, true, rustc_parse::MACRO_ARGUMENTS);
442-
let mut tt_parser = TtParser::new(def.ident);
442+
let mut tt_parser =
443+
TtParser::new(Ident::with_dummy_span(if macro_rules { kw::MacroRules } else { kw::Macro }));
443444
let argument_map = match tt_parser.parse_tt(&mut Cow::Borrowed(&parser), &argument_gram) {
444445
Success(m) => m,
445446
Failure(token, msg) => {

src/bootstrap/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,8 @@ impl Build {
865865
}
866866
}
867867
} else {
868-
let base = self.llvm_out(self.config.build).join("build");
869-
let base = if !self.ninja() && self.config.build.contains("msvc") {
868+
let base = self.llvm_out(target).join("build");
869+
let base = if !self.ninja() && target.contains("msvc") {
870870
if self.config.llvm_optimize {
871871
if self.config.llvm_release_debuginfo {
872872
base.join("RelWithDebInfo")

src/librustdoc/doctest.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1069,13 +1069,7 @@ impl Tester for Collector {
10691069
}
10701070
}
10711071
TestFailure::ExecutionFailure(out) => {
1072-
let reason = if let Some(code) = out.status.code() {
1073-
format!("exit code {code}")
1074-
} else {
1075-
String::from("terminated by signal")
1076-
};
1077-
1078-
eprintln!("Test executable failed ({reason}).");
1072+
eprintln!("Test executable failed ({reason}).", reason = out.status);
10791073

10801074
// FIXME(#12309): An unfortunate side-effect of capturing the test
10811075
// executable's output is that the relative ordering between the test's
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// only-windows
2+
// There's a parallel generic version of this test for non-windows platforms.
3+
4+
// Issue #51162: A failed doctest was not printing its stdout/stderr
5+
// FIXME: if/when the output of the test harness can be tested on its own, this test should be
6+
// adapted to use that, and that normalize line can go away
7+
8+
// compile-flags:--test --test-args --test-threads=1
9+
// rustc-env:RUST_BACKTRACE=0
10+
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
11+
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
12+
// failure-status: 101
13+
14+
// doctest fails at runtime
15+
/// ```
16+
/// println!("stdout 1");
17+
/// eprintln!("stderr 1");
18+
/// println!("stdout 2");
19+
/// eprintln!("stderr 2");
20+
/// panic!("oh no");
21+
/// ```
22+
pub struct SomeStruct;
23+
24+
// doctest fails at compile time
25+
/// ```
26+
/// no
27+
/// ```
28+
pub struct OtherStruct;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
running 2 tests
3+
test $DIR/failed-doctest-output-windows.rs - OtherStruct (line 25) ... FAILED
4+
test $DIR/failed-doctest-output-windows.rs - SomeStruct (line 15) ... FAILED
5+
6+
failures:
7+
8+
---- $DIR/failed-doctest-output-windows.rs - OtherStruct (line 25) stdout ----
9+
error[E0425]: cannot find value `no` in this scope
10+
--> $DIR/failed-doctest-output-windows.rs:26:1
11+
|
12+
LL | no
13+
| ^^ not found in this scope
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0425`.
18+
Couldn't compile the test.
19+
---- $DIR/failed-doctest-output-windows.rs - SomeStruct (line 15) stdout ----
20+
Test executable failed (exit code: 101).
21+
22+
stdout:
23+
stdout 1
24+
stdout 2
25+
26+
stderr:
27+
stderr 1
28+
stderr 2
29+
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output-windows.rs:7:1
30+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
31+
32+
33+
34+
failures:
35+
$DIR/failed-doctest-output-windows.rs - OtherStruct (line 25)
36+
$DIR/failed-doctest-output-windows.rs - SomeStruct (line 15)
37+
38+
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
39+

src/test/rustdoc-ui/failed-doctest-output.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// ignore-windows
2+
// There's a parallel version of this test for Windows.
3+
14
// Issue #51162: A failed doctest was not printing its stdout/stderr
25
// FIXME: if/when the output of the test harness can be tested on its own, this test should be
36
// adapted to use that, and that normalize line can go away
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

22
running 2 tests
3-
test $DIR/failed-doctest-output.rs - OtherStruct (line 22) ... FAILED
4-
test $DIR/failed-doctest-output.rs - SomeStruct (line 12) ... FAILED
3+
test $DIR/failed-doctest-output.rs - OtherStruct (line 25) ... FAILED
4+
test $DIR/failed-doctest-output.rs - SomeStruct (line 15) ... FAILED
55

66
failures:
77

8-
---- $DIR/failed-doctest-output.rs - OtherStruct (line 22) stdout ----
8+
---- $DIR/failed-doctest-output.rs - OtherStruct (line 25) stdout ----
99
error[E0425]: cannot find value `no` in this scope
10-
--> $DIR/failed-doctest-output.rs:23:1
10+
--> $DIR/failed-doctest-output.rs:26:1
1111
|
1212
LL | no
1313
| ^^ not found in this scope
@@ -16,8 +16,8 @@ error: aborting due to previous error
1616

1717
For more information about this error, try `rustc --explain E0425`.
1818
Couldn't compile the test.
19-
---- $DIR/failed-doctest-output.rs - SomeStruct (line 12) stdout ----
20-
Test executable failed (exit code 101).
19+
---- $DIR/failed-doctest-output.rs - SomeStruct (line 15) stdout ----
20+
Test executable failed (exit status: 101).
2121

2222
stdout:
2323
stdout 1
@@ -32,8 +32,8 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3232

3333

3434
failures:
35-
$DIR/failed-doctest-output.rs - OtherStruct (line 22)
36-
$DIR/failed-doctest-output.rs - SomeStruct (line 12)
35+
$DIR/failed-doctest-output.rs - OtherStruct (line 25)
36+
$DIR/failed-doctest-output.rs - SomeStruct (line 15)
3737

3838
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
3939

src/test/ui/issues/issue-70093.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// compile-flags: -Zlink-native-libraries=no -Cdefault-linker-libraries=yes
33
// ignore-windows - this will probably only work on unixish systems
44
// ignore-fuchsia - missing __libc_start_main for some reason (#84733)
5+
// ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling
56

67
#[link(name = "some-random-non-existent-library", kind = "static")]
78
extern "C" {}

0 commit comments

Comments
 (0)