Skip to content

Rollup of 6 pull requests #140444

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 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
false,
None,
*delim,
None,
tokens,
true,
span,
Expand Down Expand Up @@ -679,6 +680,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
false,
None,
*delim,
Some(spacing.open),
tts,
convert_dollar_crate,
dspan.entire(),
Expand Down Expand Up @@ -735,6 +737,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
has_bang: bool,
ident: Option<Ident>,
delim: Delimiter,
open_spacing: Option<Spacing>,
tts: &TokenStream,
convert_dollar_crate: bool,
span: Span,
Expand All @@ -758,16 +761,26 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
self.nbsp();
}
self.word("{");
if !tts.is_empty() {

// Respect `Alone`, if provided, and print a space. Unless the list is empty.
let open_space = (open_spacing == None || open_spacing == Some(Spacing::Alone))
&& !tts.is_empty();
if open_space {
self.space();
}
let ib = self.ibox(0);
self.print_tts(tts, convert_dollar_crate);
self.end(ib);
let empty = tts.is_empty();
self.bclose(span, empty, cb.unwrap());

// Use `open_space` for the spacing *before* the closing delim.
// Because spacing on delimiters is lost when going through
// proc macros, and otherwise we can end up with ugly cases
// like `{ x}`. Symmetry is better.
self.bclose(span, !open_space, cb.unwrap());
}
delim => {
// `open_spacing` is ignored. We never print spaces after
// non-brace opening delims or before non-brace closing delims.
let token_str = self.token_kind_to_string(&delim.as_open_token_kind());
self.word(token_str);
let ib = self.ibox(0);
Expand Down Expand Up @@ -797,6 +810,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
has_bang,
Some(*ident),
macro_def.body.delim,
None,
&macro_def.body.tokens,
true,
sp,
Expand Down Expand Up @@ -844,9 +858,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
self.end(ib);
}

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

fn bclose(&mut self, span: rustc_span::Span, empty: bool, cb: BoxMarker) {
fn bclose(&mut self, span: rustc_span::Span, no_space: bool, cb: BoxMarker) {
let cb = Some(cb);
self.bclose_maybe_open(span, empty, cb)
self.bclose_maybe_open(span, no_space, cb)
}

fn break_offset_if_not_bol(&mut self, n: usize, off: isize) {
Expand Down Expand Up @@ -1423,8 +1437,8 @@ impl<'a> State<'a> {
}
}

let empty = !has_attrs && blk.stmts.is_empty();
self.bclose_maybe_open(blk.span, empty, cb);
let no_space = !has_attrs && blk.stmts.is_empty();
self.bclose_maybe_open(blk.span, no_space, cb);
self.ann.post(self, AnnNode::Block(blk))
}

Expand Down Expand Up @@ -1471,6 +1485,7 @@ impl<'a> State<'a> {
true,
None,
m.args.delim,
None,
&m.args.tokens,
true,
m.span(),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ mod llvm_enzyme {
Spacing::Joint,
)];
let never_arg = ast::DelimArgs {
dspan: ast::tokenstream::DelimSpan::from_single(span),
dspan: DelimSpan::from_single(span),
delim: ast::token::Delimiter::Parenthesis,
tokens: ast::tokenstream::TokenStream::from_iter(ts2),
tokens: TokenStream::from_iter(ts2),
};
let inline_item = ast::AttrItem {
unsafety: ast::Safety::Default,
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ pub trait CodegenBackend {

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

/// Returns two feature sets:
/// - The first has the features that should be set in `cfg(target_features)`.
/// - The second is like the first, but also includes unstable features.
///
/// RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
/// Collect target-specific options that should be set in `cfg(...)`, including
/// `target_feature` and support for unstable float types.
fn target_config(&self, _sess: &Session) -> TargetConfig {
TargetConfig {
target_features: vec![],
unstable_target_features: vec![],
// `true` is used as a default so backends need to acknowledge when they do not
// support the float types, rather than accidentally quietly skipping all tests.
has_reliable_f16: true,
has_reliable_f16_math: true,
has_reliable_f128: true,
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_expand/src/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use rustc_ast::ptr::P;
use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::util::literal;
use rustc_ast::{
self as ast, AnonConst, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp,
attr, token,
attr, token, tokenstream,
};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
Expand Down Expand Up @@ -55,13 +57,13 @@ impl<'a> ExtCtxt<'a> {
&self,
span: Span,
path: ast::Path,
delim: ast::token::Delimiter,
tokens: ast::tokenstream::TokenStream,
delim: Delimiter,
tokens: TokenStream,
) -> P<ast::MacCall> {
P(ast::MacCall {
path,
args: P(ast::DelimArgs {
dspan: ast::tokenstream::DelimSpan { open: span, close: span },
dspan: tokenstream::DelimSpan { open: span, close: span },
delim,
tokens,
}),
Expand Down Expand Up @@ -480,8 +482,8 @@ impl<'a> ExtCtxt<'a> {
span,
[sym::std, sym::unreachable].map(|s| Ident::new(s, span)).to_vec(),
),
ast::token::Delimiter::Parenthesis,
ast::tokenstream::TokenStream::default(),
Delimiter::Parenthesis,
TokenStream::default(),
),
)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ impl<'a> State<'a> {
false,
None,
*delim,
None,
&tokens,
true,
span,
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ dependencies = [

[[package]]
name = "unwinding"
version = "0.2.5"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c"
checksum = "8393f2782b6060a807337ff353780c1ca15206f9ba2424df18cb6e733bd7b345"
dependencies = [
"compiler_builtins",
"gimli",
Expand Down
2 changes: 1 addition & 1 deletion library/unwind/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cfg-if = "1.0"
libc = { version = "0.2.140", features = ['rustc-dep-of-std'], default-features = false }

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

[features]

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ macro_rules! bootstrap_tool {
}
}

pub(crate) const COMPILETEST_ALLOW_FEATURES: &str = "test,internal_output_capture";
pub(crate) const COMPILETEST_ALLOW_FEATURES: &str = "internal_output_capture";

bootstrap_tool!(
// This is marked as an external tool because it includes dependencies
Expand Down
8 changes: 0 additions & 8 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,6 @@ pub struct Config {
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
/// ABI tests.
pub minicore_path: Utf8PathBuf,

/// If true, disable the "new" executor, and use the older libtest-based
/// executor to run tests instead. This is a temporary fallback, to make
/// manual comparative testing easier if bugs are found in the new executor.
///
/// FIXME(Zalathar): Eventually remove this flag and remove the libtest
/// dependency.
pub no_new_executor: bool,
}

impl Config {
Expand Down
1 change: 0 additions & 1 deletion src/tools/compiletest/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::common::{Config, TestPaths};

mod deadline;
mod json;
pub(crate) mod libtest;

pub(crate) fn run_tests(config: &Config, tests: Vec<CollectedTest>) -> bool {
let tests_len = tests.len();
Expand Down
111 changes: 0 additions & 111 deletions src/tools/compiletest/src/executor/libtest.rs

This file was deleted.

19 changes: 7 additions & 12 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![crate_name = "compiletest"]
// Needed by the libtest-based test executor.
#![feature(test)]
// Needed by the "new" test executor that does not depend on libtest.
// FIXME(Zalathar): We should be able to get rid of `internal_output_capture`,
// by having `runtest` manually capture all of its println-like output instead.
// That would result in compiletest being written entirely in stable Rust!
#![feature(internal_output_capture)]

extern crate test;

#[cfg(test)]
mod tests;

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

minicore_path: opt_path(matches, "minicore-path"),

no_new_executor: matches.opt_present("no-new-executor"),
}
}

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

// Check the outcome reported by libtest.
match res {
Expand Down
Loading
Loading