Skip to content

Commit d635125

Browse files
committed
Auto merge of rust-lang#140444 - Zalathar:rollup-pbefd89, r=Zalathar
Rollup of 6 pull requests Successful merges: - rust-lang#139883 (crashes: more tests) - rust-lang#140312 (Improve pretty-printing of braces) - rust-lang#140392 (compiletest: Remove the libtest-based executor and its dependency) - rust-lang#140395 (organize and extend forbidden target feature tests) - rust-lang#140422 (unwind: bump `unwinding` dependency to 0.2.6) - rust-lang#140432 (Update documentation for `fn target_config`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents efcbb94 + 762545a commit d635125

File tree

64 files changed

+553
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+553
-249
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

+24-9
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
634634
false,
635635
None,
636636
*delim,
637+
None,
637638
tokens,
638639
true,
639640
span,
@@ -679,6 +680,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
679680
false,
680681
None,
681682
*delim,
683+
Some(spacing.open),
682684
tts,
683685
convert_dollar_crate,
684686
dspan.entire(),
@@ -735,6 +737,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
735737
has_bang: bool,
736738
ident: Option<Ident>,
737739
delim: Delimiter,
740+
open_spacing: Option<Spacing>,
738741
tts: &TokenStream,
739742
convert_dollar_crate: bool,
740743
span: Span,
@@ -758,16 +761,26 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
758761
self.nbsp();
759762
}
760763
self.word("{");
761-
if !tts.is_empty() {
764+
765+
// Respect `Alone`, if provided, and print a space. Unless the list is empty.
766+
let open_space = (open_spacing == None || open_spacing == Some(Spacing::Alone))
767+
&& !tts.is_empty();
768+
if open_space {
762769
self.space();
763770
}
764771
let ib = self.ibox(0);
765772
self.print_tts(tts, convert_dollar_crate);
766773
self.end(ib);
767-
let empty = tts.is_empty();
768-
self.bclose(span, empty, cb.unwrap());
774+
775+
// Use `open_space` for the spacing *before* the closing delim.
776+
// Because spacing on delimiters is lost when going through
777+
// proc macros, and otherwise we can end up with ugly cases
778+
// like `{ x}`. Symmetry is better.
779+
self.bclose(span, !open_space, cb.unwrap());
769780
}
770781
delim => {
782+
// `open_spacing` is ignored. We never print spaces after
783+
// non-brace opening delims or before non-brace closing delims.
771784
let token_str = self.token_kind_to_string(&delim.as_open_token_kind());
772785
self.word(token_str);
773786
let ib = self.ibox(0);
@@ -797,6 +810,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
797810
has_bang,
798811
Some(*ident),
799812
macro_def.body.delim,
813+
None,
800814
&macro_def.body.tokens,
801815
true,
802816
sp,
@@ -844,9 +858,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
844858
self.end(ib);
845859
}
846860

847-
fn bclose_maybe_open(&mut self, span: rustc_span::Span, empty: bool, cb: Option<BoxMarker>) {
861+
fn bclose_maybe_open(&mut self, span: rustc_span::Span, no_space: bool, cb: Option<BoxMarker>) {
848862
let has_comment = self.maybe_print_comment(span.hi());
849-
if !empty || has_comment {
863+
if !no_space || has_comment {
850864
self.break_offset_if_not_bol(1, -INDENT_UNIT);
851865
}
852866
self.word("}");
@@ -855,9 +869,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
855869
}
856870
}
857871

858-
fn bclose(&mut self, span: rustc_span::Span, empty: bool, cb: BoxMarker) {
872+
fn bclose(&mut self, span: rustc_span::Span, no_space: bool, cb: BoxMarker) {
859873
let cb = Some(cb);
860-
self.bclose_maybe_open(span, empty, cb)
874+
self.bclose_maybe_open(span, no_space, cb)
861875
}
862876

863877
fn break_offset_if_not_bol(&mut self, n: usize, off: isize) {
@@ -1423,8 +1437,8 @@ impl<'a> State<'a> {
14231437
}
14241438
}
14251439

1426-
let empty = !has_attrs && blk.stmts.is_empty();
1427-
self.bclose_maybe_open(blk.span, empty, cb);
1440+
let no_space = !has_attrs && blk.stmts.is_empty();
1441+
self.bclose_maybe_open(blk.span, no_space, cb);
14281442
self.ann.post(self, AnnNode::Block(blk))
14291443
}
14301444

@@ -1471,6 +1485,7 @@ impl<'a> State<'a> {
14711485
true,
14721486
None,
14731487
m.args.delim,
1488+
None,
14741489
&m.args.tokens,
14751490
true,
14761491
m.span(),

compiler/rustc_builtin_macros/src/autodiff.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ mod llvm_enzyme {
323323
Spacing::Joint,
324324
)];
325325
let never_arg = ast::DelimArgs {
326-
dspan: ast::tokenstream::DelimSpan::from_single(span),
326+
dspan: DelimSpan::from_single(span),
327327
delim: ast::token::Delimiter::Parenthesis,
328-
tokens: ast::tokenstream::TokenStream::from_iter(ts2),
328+
tokens: TokenStream::from_iter(ts2),
329329
};
330330
let inline_item = ast::AttrItem {
331331
unsafety: ast::Safety::Default,

compiler/rustc_codegen_ssa/src/traits/backend.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@ pub trait CodegenBackend {
4545

4646
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) {}
4747

48-
/// Returns two feature sets:
49-
/// - The first has the features that should be set in `cfg(target_features)`.
50-
/// - The second is like the first, but also includes unstable features.
51-
///
52-
/// RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
48+
/// Collect target-specific options that should be set in `cfg(...)`, including
49+
/// `target_feature` and support for unstable float types.
5350
fn target_config(&self, _sess: &Session) -> TargetConfig {
5451
TargetConfig {
5552
target_features: vec![],
5653
unstable_target_features: vec![],
54+
// `true` is used as a default so backends need to acknowledge when they do not
55+
// support the float types, rather than accidentally quietly skipping all tests.
5756
has_reliable_f16: true,
5857
has_reliable_f16_math: true,
5958
has_reliable_f128: true,

compiler/rustc_expand/src/build.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use rustc_ast::ptr::P;
2+
use rustc_ast::token::Delimiter;
3+
use rustc_ast::tokenstream::TokenStream;
24
use rustc_ast::util::literal;
35
use rustc_ast::{
46
self as ast, AnonConst, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp,
5-
attr, token,
7+
attr, token, tokenstream,
68
};
79
use rustc_span::source_map::Spanned;
810
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
@@ -55,13 +57,13 @@ impl<'a> ExtCtxt<'a> {
5557
&self,
5658
span: Span,
5759
path: ast::Path,
58-
delim: ast::token::Delimiter,
59-
tokens: ast::tokenstream::TokenStream,
60+
delim: Delimiter,
61+
tokens: TokenStream,
6062
) -> P<ast::MacCall> {
6163
P(ast::MacCall {
6264
path,
6365
args: P(ast::DelimArgs {
64-
dspan: ast::tokenstream::DelimSpan { open: span, close: span },
66+
dspan: tokenstream::DelimSpan { open: span, close: span },
6567
delim,
6668
tokens,
6769
}),
@@ -480,8 +482,8 @@ impl<'a> ExtCtxt<'a> {
480482
span,
481483
[sym::std, sym::unreachable].map(|s| Ident::new(s, span)).to_vec(),
482484
),
483-
ast::token::Delimiter::Parenthesis,
484-
ast::tokenstream::TokenStream::default(),
485+
Delimiter::Parenthesis,
486+
TokenStream::default(),
485487
),
486488
)
487489
}

compiler/rustc_hir_pretty/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ impl<'a> State<'a> {
146146
false,
147147
None,
148148
*delim,
149+
None,
149150
&tokens,
150151
true,
151152
span,

library/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ dependencies = [
448448

449449
[[package]]
450450
name = "unwinding"
451-
version = "0.2.5"
451+
version = "0.2.6"
452452
source = "registry+https://github.com/rust-lang/crates.io-index"
453-
checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c"
453+
checksum = "8393f2782b6060a807337ff353780c1ca15206f9ba2424df18cb6e733bd7b345"
454454
dependencies = [
455455
"compiler_builtins",
456456
"gimli",

library/unwind/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cfg-if = "1.0"
2222
libc = { version = "0.2.140", features = ['rustc-dep-of-std'], default-features = false }
2323

2424
[target.'cfg(target_os = "xous")'.dependencies]
25-
unwinding = { version = "0.2.5", features = ['rustc-dep-of-std', 'unwinder', 'fde-custom'], default-features = false }
25+
unwinding = { version = "0.2.6", features = ['rustc-dep-of-std', 'unwinder', 'fde-custom'], default-features = false }
2626

2727
[features]
2828

src/bootstrap/src/core/build_steps/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ macro_rules! bootstrap_tool {
462462
}
463463
}
464464

465-
pub(crate) const COMPILETEST_ALLOW_FEATURES: &str = "test,internal_output_capture";
465+
pub(crate) const COMPILETEST_ALLOW_FEATURES: &str = "internal_output_capture";
466466

467467
bootstrap_tool!(
468468
// This is marked as an external tool because it includes dependencies

src/tools/compiletest/src/common.rs

-8
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,6 @@ pub struct Config {
413413
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
414414
/// ABI tests.
415415
pub minicore_path: Utf8PathBuf,
416-
417-
/// If true, disable the "new" executor, and use the older libtest-based
418-
/// executor to run tests instead. This is a temporary fallback, to make
419-
/// manual comparative testing easier if bugs are found in the new executor.
420-
///
421-
/// FIXME(Zalathar): Eventually remove this flag and remove the libtest
422-
/// dependency.
423-
pub no_new_executor: bool,
424416
}
425417

426418
impl Config {

src/tools/compiletest/src/executor.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use crate::common::{Config, TestPaths};
1212

1313
mod deadline;
1414
mod json;
15-
pub(crate) mod libtest;
1615

1716
pub(crate) fn run_tests(config: &Config, tests: Vec<CollectedTest>) -> bool {
1817
let tests_len = tests.len();

src/tools/compiletest/src/executor/libtest.rs

-111
This file was deleted.

src/tools/compiletest/src/lib.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#![crate_name = "compiletest"]
2-
// Needed by the libtest-based test executor.
3-
#![feature(test)]
42
// Needed by the "new" test executor that does not depend on libtest.
3+
// FIXME(Zalathar): We should be able to get rid of `internal_output_capture`,
4+
// by having `runtest` manually capture all of its println-like output instead.
5+
// That would result in compiletest being written entirely in stable Rust!
56
#![feature(internal_output_capture)]
67

7-
extern crate test;
8-
98
#[cfg(test)]
109
mod tests;
1110

@@ -448,8 +447,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
448447
diff_command: matches.opt_str("compiletest-diff-tool"),
449448

450449
minicore_path: opt_path(matches, "minicore-path"),
451-
452-
no_new_executor: matches.opt_present("no-new-executor"),
453450
}
454451
}
455452

@@ -576,12 +573,10 @@ pub fn run_tests(config: Arc<Config>) {
576573
// Delegate to the executor to filter and run the big list of test structures
577574
// created during test discovery. When the executor decides to run a test,
578575
// it will return control to the rest of compiletest by calling `runtest::run`.
579-
let res = if !config.no_new_executor {
580-
Ok(executor::run_tests(&config, tests))
581-
} else {
582-
// FIXME(Zalathar): Eventually remove the libtest executor entirely.
583-
crate::executor::libtest::execute_tests(&config, tests)
584-
};
576+
// FIXME(Zalathar): Once we're confident that we won't need to revert the
577+
// removal of the libtest-based executor, remove this Result and other
578+
// remnants of the old executor.
579+
let res: io::Result<bool> = Ok(executor::run_tests(&config, tests));
585580

586581
// Check the outcome reported by libtest.
587582
match res {

0 commit comments

Comments
 (0)