Merge from rustc
This commit is contained in:
commit
0e043a86f0
355 changed files with 4274 additions and 2705 deletions
|
|
@ -12,7 +12,6 @@ use std::ffi::OsStr;
|
|||
use std::io::BufReader;
|
||||
use std::io::prelude::*;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Stdio;
|
||||
use std::{env, fs, str};
|
||||
|
||||
use serde_derive::Deserialize;
|
||||
|
|
@ -2507,7 +2506,6 @@ pub fn stream_cargo(
|
|||
#[cfg(feature = "tracing")]
|
||||
let _run_span = crate::trace_cmd!(cmd);
|
||||
|
||||
let cargo = cmd.as_command_mut();
|
||||
// Instruct Cargo to give us json messages on stdout, critically leaving
|
||||
// stderr as piped so we can get those pretty colors.
|
||||
let mut message_format = if builder.config.json_output {
|
||||
|
|
@ -2519,27 +2517,24 @@ pub fn stream_cargo(
|
|||
message_format.push_str(",json-diagnostic-");
|
||||
message_format.push_str(s);
|
||||
}
|
||||
cargo.arg("--message-format").arg(message_format).stdout(Stdio::piped());
|
||||
cmd.arg("--message-format").arg(message_format);
|
||||
|
||||
for arg in tail_args {
|
||||
cargo.arg(arg);
|
||||
cmd.arg(arg);
|
||||
}
|
||||
|
||||
builder.verbose(|| println!("running: {cargo:?}"));
|
||||
builder.verbose(|| println!("running: {cmd:?}"));
|
||||
|
||||
if builder.config.dry_run() {
|
||||
let streaming_command = cmd.stream_capture_stdout(&builder.config.exec_ctx);
|
||||
|
||||
let Some(mut streaming_command) = streaming_command else {
|
||||
return true;
|
||||
}
|
||||
|
||||
let mut child = match cargo.spawn() {
|
||||
Ok(child) => child,
|
||||
Err(e) => panic!("failed to execute command: {cargo:?}\nERROR: {e}"),
|
||||
};
|
||||
|
||||
// Spawn Cargo slurping up its JSON output. We'll start building up the
|
||||
// `deps` array of all files it generated along with a `toplevel` array of
|
||||
// files we need to probe for later.
|
||||
let stdout = BufReader::new(child.stdout.take().unwrap());
|
||||
let stdout = BufReader::new(streaming_command.stdout.take().unwrap());
|
||||
for line in stdout.lines() {
|
||||
let line = t!(line);
|
||||
match serde_json::from_str::<CargoMessage<'_>>(&line) {
|
||||
|
|
@ -2556,13 +2551,14 @@ pub fn stream_cargo(
|
|||
}
|
||||
|
||||
// Make sure Cargo actually succeeded after we read all of its stdout.
|
||||
let status = t!(child.wait());
|
||||
let status = t!(streaming_command.wait());
|
||||
if builder.is_verbose() && !status.success() {
|
||||
eprintln!(
|
||||
"command did not execute successfully: {cargo:?}\n\
|
||||
"command did not execute successfully: {cmd:?}\n\
|
||||
expected success, got: {status}"
|
||||
);
|
||||
}
|
||||
|
||||
status.success()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap_complete::{Generator, shells};
|
||||
|
||||
use crate::core::build_steps::dist::distdir;
|
||||
use crate::core::build_steps::test;
|
||||
use crate::core::build_steps::tool::{self, SourceType, Tool};
|
||||
|
|
@ -285,36 +287,35 @@ impl Step for GenerateWindowsSys {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return tuples of (shell, file containing completions).
|
||||
pub fn get_completion_paths(builder: &Builder<'_>) -> Vec<(&'static dyn Generator, PathBuf)> {
|
||||
vec![
|
||||
(&shells::Bash as &'static dyn Generator, builder.src.join("src/etc/completions/x.py.sh")),
|
||||
(&shells::Zsh, builder.src.join("src/etc/completions/x.py.zsh")),
|
||||
(&shells::Fish, builder.src.join("src/etc/completions/x.py.fish")),
|
||||
(&shells::PowerShell, builder.src.join("src/etc/completions/x.py.ps1")),
|
||||
(&shells::Bash, builder.src.join("src/etc/completions/x.sh")),
|
||||
(&shells::Zsh, builder.src.join("src/etc/completions/x.zsh")),
|
||||
(&shells::Fish, builder.src.join("src/etc/completions/x.fish")),
|
||||
(&shells::PowerShell, builder.src.join("src/etc/completions/x.ps1")),
|
||||
]
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct GenerateCompletions;
|
||||
|
||||
macro_rules! generate_completions {
|
||||
( $( ( $shell:ident, $filename:expr ) ),* ) => {
|
||||
$(
|
||||
if let Some(comp) = get_completion($shell, &$filename) {
|
||||
std::fs::write(&$filename, comp).expect(&format!("writing {} completion", stringify!($shell)));
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
impl Step for GenerateCompletions {
|
||||
type Output = ();
|
||||
|
||||
/// Uses `clap_complete` to generate shell completions.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
use clap_complete::shells::{Bash, Fish, PowerShell, Zsh};
|
||||
|
||||
generate_completions!(
|
||||
(Bash, builder.src.join("src/etc/completions/x.py.sh")),
|
||||
(Zsh, builder.src.join("src/etc/completions/x.py.zsh")),
|
||||
(Fish, builder.src.join("src/etc/completions/x.py.fish")),
|
||||
(PowerShell, builder.src.join("src/etc/completions/x.py.ps1")),
|
||||
(Bash, builder.src.join("src/etc/completions/x.sh")),
|
||||
(Zsh, builder.src.join("src/etc/completions/x.zsh")),
|
||||
(Fish, builder.src.join("src/etc/completions/x.fish")),
|
||||
(PowerShell, builder.src.join("src/etc/completions/x.ps1"))
|
||||
);
|
||||
for (shell, path) in get_completion_paths(builder) {
|
||||
if let Some(comp) = get_completion(shell, &path) {
|
||||
std::fs::write(&path, comp).unwrap_or_else(|e| {
|
||||
panic!("writing completion into {} failed: {e:?}", path.display())
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@ use std::ffi::{OsStr, OsString};
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::{env, fs, iter};
|
||||
|
||||
use clap_complete::shells;
|
||||
|
||||
use crate::core::build_steps::compile::{Std, run_cargo};
|
||||
use crate::core::build_steps::doc::DocumentationFormat;
|
||||
use crate::core::build_steps::gcc::{Gcc, add_cg_gcc_cargo_flags};
|
||||
use crate::core::build_steps::llvm::get_llvm_version;
|
||||
use crate::core::build_steps::run::get_completion_paths;
|
||||
use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget;
|
||||
use crate::core::build_steps::tool::{self, COMPILETEST_ALLOW_FEATURES, SourceType, Tool};
|
||||
use crate::core::build_steps::toolstate::ToolState;
|
||||
|
|
@ -1153,14 +1152,12 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to
|
|||
cmd.delay_failure().run(builder);
|
||||
|
||||
builder.info("x.py completions check");
|
||||
let [bash, zsh, fish, powershell] = ["x.py.sh", "x.py.zsh", "x.py.fish", "x.py.ps1"]
|
||||
.map(|filename| builder.src.join("src/etc/completions").join(filename));
|
||||
let completion_paths = get_completion_paths(builder);
|
||||
if builder.config.cmd.bless() {
|
||||
builder.ensure(crate::core::build_steps::run::GenerateCompletions);
|
||||
} else if get_completion(shells::Bash, &bash).is_some()
|
||||
|| get_completion(shells::Fish, &fish).is_some()
|
||||
|| get_completion(shells::PowerShell, &powershell).is_some()
|
||||
|| crate::flags::get_completion(shells::Zsh, &zsh).is_some()
|
||||
} else if completion_paths
|
||||
.into_iter()
|
||||
.any(|(shell, path)| get_completion(shell, &path).is_some())
|
||||
{
|
||||
eprintln!(
|
||||
"x.py completions were changed; run `x.py run generate-completions` to update them"
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
use clap::{CommandFactory, Parser, ValueEnum};
|
||||
use clap_complete::Generator;
|
||||
#[cfg(feature = "tracing")]
|
||||
use tracing::instrument;
|
||||
|
||||
|
|
@ -644,7 +645,7 @@ impl Subcommand {
|
|||
|
||||
/// Returns the shell completion for a given shell, if the result differs from the current
|
||||
/// content of `path`. If `path` does not exist, always returns `Some`.
|
||||
pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Option<String> {
|
||||
pub fn get_completion(shell: &dyn Generator, path: &Path) -> Option<String> {
|
||||
let mut cmd = Flags::command();
|
||||
let current = if !path.exists() {
|
||||
String::new()
|
||||
|
|
@ -662,7 +663,12 @@ pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Opt
|
|||
.expect("file name should be UTF-8")
|
||||
.rsplit_once('.')
|
||||
.expect("file name should have an extension");
|
||||
clap_complete::generate(shell, &mut cmd, bin_name, &mut buf);
|
||||
|
||||
// We sort of replicate `clap_complete::generate` here, because we want to call it with
|
||||
// `&dyn Generator`, but that function requires `G: Generator` instead.
|
||||
cmd.set_bin_name(bin_name);
|
||||
cmd.build();
|
||||
shell.generate(&cmd, &mut buf);
|
||||
if buf == current.as_bytes() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,4 +446,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
|
|||
severity: ChangeSeverity::Info,
|
||||
summary: "Added new option `build.tidy-extra-checks` to specify a default value for the --extra-checks cli flag.",
|
||||
},
|
||||
ChangeInfo {
|
||||
change_id: 143493,
|
||||
severity: ChangeSeverity::Warning,
|
||||
summary: "The `spellcheck:fix` tidy extra check argument has been removed, use `--bless` instead",
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ use std::fmt::{Debug, Formatter};
|
|||
use std::hash::Hash;
|
||||
use std::panic::Location;
|
||||
use std::path::Path;
|
||||
use std::process::{Child, Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
|
||||
use std::process::{
|
||||
Child, ChildStderr, ChildStdout, Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio,
|
||||
};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use build_helper::ci::CiEnv;
|
||||
|
|
@ -209,15 +211,14 @@ impl<'a> BootstrapCommand {
|
|||
exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Print)
|
||||
}
|
||||
|
||||
/// Provides access to the stdlib Command inside.
|
||||
/// FIXME: This function should be eventually removed from bootstrap.
|
||||
pub fn as_command_mut(&mut self) -> &mut Command {
|
||||
// We proactively mark this command as executed since we can't be certain how the returned
|
||||
// command will be handled. Caching must also be avoided here, as the inner command could be
|
||||
// modified externally without us being aware.
|
||||
self.mark_as_executed();
|
||||
self.do_not_cache();
|
||||
&mut self.command
|
||||
/// Spawn the command in background, while capturing and returning stdout, and printing stderr.
|
||||
/// Returns None in dry-mode
|
||||
#[track_caller]
|
||||
pub fn stream_capture_stdout(
|
||||
&'a mut self,
|
||||
exec_ctx: impl AsRef<ExecutionContext>,
|
||||
) -> Option<StreamingCommand> {
|
||||
exec_ctx.as_ref().stream(self, OutputMode::Capture, OutputMode::Print)
|
||||
}
|
||||
|
||||
/// Mark the command as being executed, disarming the drop bomb.
|
||||
|
|
@ -449,6 +450,12 @@ enum CommandState<'a> {
|
|||
},
|
||||
}
|
||||
|
||||
pub struct StreamingCommand {
|
||||
child: Child,
|
||||
pub stdout: Option<ChildStdout>,
|
||||
pub stderr: Option<ChildStderr>,
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub struct DeferredCommand<'a> {
|
||||
state: CommandState<'a>,
|
||||
|
|
@ -617,6 +624,33 @@ impl ExecutionContext {
|
|||
}
|
||||
exit!(1);
|
||||
}
|
||||
|
||||
/// Spawns the command with configured stdout and stderr handling.
|
||||
///
|
||||
/// Returns None if in dry-run mode or Panics if the command fails to spawn.
|
||||
pub fn stream(
|
||||
&self,
|
||||
command: &mut BootstrapCommand,
|
||||
stdout: OutputMode,
|
||||
stderr: OutputMode,
|
||||
) -> Option<StreamingCommand> {
|
||||
command.mark_as_executed();
|
||||
if !command.run_in_dry_run && self.dry_run() {
|
||||
return None;
|
||||
}
|
||||
let cmd = &mut command.command;
|
||||
cmd.stdout(stdout.stdio());
|
||||
cmd.stderr(stderr.stdio());
|
||||
let child = cmd.spawn();
|
||||
let mut child = match child {
|
||||
Ok(child) => child,
|
||||
Err(e) => panic!("failed to execute command: {cmd:?}\nERROR: {e}"),
|
||||
};
|
||||
|
||||
let stdout = child.stdout.take();
|
||||
let stderr = child.stderr.take();
|
||||
Some(StreamingCommand { child, stdout, stderr })
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<ExecutionContext> for ExecutionContext {
|
||||
|
|
@ -625,6 +659,12 @@ impl AsRef<ExecutionContext> for ExecutionContext {
|
|||
}
|
||||
}
|
||||
|
||||
impl StreamingCommand {
|
||||
pub fn wait(mut self) -> Result<ExitStatus, std::io::Error> {
|
||||
self.child.wait()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DeferredCommand<'a> {
|
||||
pub fn wait_for_output(self, exec_ctx: impl AsRef<ExecutionContext>) -> CommandOutput {
|
||||
match self.state {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
//! to reimplement all the rendering logic in this module because of that.
|
||||
|
||||
use std::io::{BufRead, BufReader, Read, Write};
|
||||
use std::process::{ChildStdout, Stdio};
|
||||
use std::process::ChildStdout;
|
||||
use std::time::Duration;
|
||||
|
||||
use termcolor::{Color, ColorSpec, WriteColor};
|
||||
|
|
@ -34,50 +34,44 @@ pub(crate) fn try_run_tests(
|
|||
cmd: &mut BootstrapCommand,
|
||||
stream: bool,
|
||||
) -> bool {
|
||||
if builder.config.dry_run() {
|
||||
cmd.mark_as_executed();
|
||||
if run_tests(builder, cmd, stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if !run_tests(builder, cmd, stream) {
|
||||
if builder.fail_fast {
|
||||
crate::exit!(1);
|
||||
} else {
|
||||
builder.config.exec_ctx().add_to_delay_failure(format!("{cmd:?}"));
|
||||
false
|
||||
}
|
||||
} else {
|
||||
true
|
||||
if builder.fail_fast {
|
||||
crate::exit!(1);
|
||||
}
|
||||
|
||||
builder.config.exec_ctx().add_to_delay_failure(format!("{cmd:?}"));
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> bool {
|
||||
let cmd = cmd.as_command_mut();
|
||||
cmd.stdout(Stdio::piped());
|
||||
|
||||
builder.verbose(|| println!("running: {cmd:?}"));
|
||||
|
||||
let mut process = cmd.spawn().unwrap();
|
||||
let Some(mut streaming_command) = cmd.stream_capture_stdout(&builder.config.exec_ctx) else {
|
||||
return true;
|
||||
};
|
||||
|
||||
// This runs until the stdout of the child is closed, which means the child exited. We don't
|
||||
// run this on another thread since the builder is not Sync.
|
||||
let renderer = Renderer::new(process.stdout.take().unwrap(), builder);
|
||||
let renderer = Renderer::new(streaming_command.stdout.take().unwrap(), builder);
|
||||
if stream {
|
||||
renderer.stream_all();
|
||||
} else {
|
||||
renderer.render_all();
|
||||
}
|
||||
|
||||
let result = process.wait_with_output().unwrap();
|
||||
if !result.status.success() && builder.is_verbose() {
|
||||
let status = streaming_command.wait().unwrap();
|
||||
if !status.success() && builder.is_verbose() {
|
||||
println!(
|
||||
"\n\ncommand did not execute successfully: {cmd:?}\n\
|
||||
expected success, got: {}",
|
||||
result.status
|
||||
expected success, got: {status}",
|
||||
);
|
||||
}
|
||||
|
||||
result.status.success()
|
||||
status.success()
|
||||
}
|
||||
|
||||
struct Renderer<'a> {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use tempfile::TempDir;
|
|||
|
||||
use crate::core::builder::Builder;
|
||||
use crate::core::config::DryRun;
|
||||
use crate::utils::helpers::get_host_target;
|
||||
use crate::{Build, Config, Flags, t};
|
||||
|
||||
pub mod git;
|
||||
|
|
@ -91,6 +92,13 @@ impl ConfigBuilder {
|
|||
self.args.push("--set".to_string());
|
||||
self.args.push("build.submodules=false".to_string());
|
||||
|
||||
// Override any external LLVM set and inhibit CI LLVM; pretend that we're always building
|
||||
// in-tree LLVM from sources.
|
||||
self.args.push("--set".to_string());
|
||||
self.args.push("llvm.download-ci-llvm=false".to_string());
|
||||
self.args.push("--set".to_string());
|
||||
self.args.push(format!("target.'{}'.llvm-config=false", get_host_target()));
|
||||
|
||||
// Do not mess with the local rustc checkout build directory
|
||||
self.args.push("--build-dir".to_string());
|
||||
self.args.push(self.directory.join("build").display().to_string());
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ floating-point units.
|
|||
|
||||
## Target maintainers
|
||||
|
||||
[@koalatux](https://github.com/koalatux)
|
||||
There are currently no formally documented target maintainers.
|
||||
|
||||
## Requirements
|
||||
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ complete -c x -n "__fish_x_using_subcommand doc" -l skip-std-check-if-no-downloa
|
|||
complete -c x -n "__fish_x_using_subcommand doc" -s h -l help -d 'Print help (see more with \'--help\')'
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l test-args -d 'extra arguments to be passed for the test tool being used (e.g. libtest, compiletest or rustdoc)' -r
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l compiletest-rustc-args -d 'extra options to pass the compiler when running compiletest tests' -r
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l extra-checks -d 'comma-separated list of other files types to check (accepts py, py:lint, py:fmt, shell)' -r
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l extra-checks -d 'comma-separated list of other files types to check (accepts py, py:lint, py:fmt, shell, shell:lint, cpp, cpp:fmt, spellcheck, spellcheck:fix)' -r
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l compare-mode -d 'mode describing what file the actual ui output will be compared to' -r
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l pass -d 'force {check,build,run}-pass tests to this mode' -r
|
||||
complete -c x -n "__fish_x_using_subcommand test" -l run -d 'whether to execute run-* tests' -r
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock {
|
|||
'x;test' {
|
||||
[CompletionResult]::new('--test-args', '--test-args', [CompletionResultType]::ParameterName, 'extra arguments to be passed for the test tool being used (e.g. libtest, compiletest or rustdoc)')
|
||||
[CompletionResult]::new('--compiletest-rustc-args', '--compiletest-rustc-args', [CompletionResultType]::ParameterName, 'extra options to pass the compiler when running compiletest tests')
|
||||
[CompletionResult]::new('--extra-checks', '--extra-checks', [CompletionResultType]::ParameterName, 'comma-separated list of other files types to check (accepts py, py:lint, py:fmt, shell)')
|
||||
[CompletionResult]::new('--extra-checks', '--extra-checks', [CompletionResultType]::ParameterName, 'comma-separated list of other files types to check (accepts py, py:lint, py:fmt, shell, shell:lint, cpp, cpp:fmt, spellcheck, spellcheck:fix)')
|
||||
[CompletionResult]::new('--compare-mode', '--compare-mode', [CompletionResultType]::ParameterName, 'mode describing what file the actual ui output will be compared to')
|
||||
[CompletionResult]::new('--pass', '--pass', [CompletionResultType]::ParameterName, 'force {check,build,run}-pass tests to this mode')
|
||||
[CompletionResult]::new('--run', '--run', [CompletionResultType]::ParameterName, 'whether to execute run-* tests')
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ _arguments "${_arguments_options[@]}" : \
|
|||
_arguments "${_arguments_options[@]}" : \
|
||||
'*--test-args=[extra arguments to be passed for the test tool being used (e.g. libtest, compiletest or rustdoc)]:ARGS:_default' \
|
||||
'*--compiletest-rustc-args=[extra options to pass the compiler when running compiletest tests]:ARGS:_default' \
|
||||
'--extra-checks=[comma-separated list of other files types to check (accepts py, py\:lint, py\:fmt, shell)]:EXTRA_CHECKS:_default' \
|
||||
'--extra-checks=[comma-separated list of other files types to check (accepts py, py\:lint, py\:fmt, shell, shell\:lint, cpp, cpp\:fmt, spellcheck, spellcheck\:fix)]:EXTRA_CHECKS:_default' \
|
||||
'--compare-mode=[mode describing what file the actual ui output will be compared to]:COMPARE MODE:_default' \
|
||||
'--pass=[force {check,build,run}-pass tests to this mode]:check | build | run:_default' \
|
||||
'--run=[whether to execute run-* tests]:auto | always | never:_default' \
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ pub(super) fn build_function(cx: &mut DocContext<'_>, def_id: DefId) -> Box<clea
|
|||
let sig = cx.tcx.fn_sig(def_id).instantiate_identity();
|
||||
// The generics need to be cleaned before the signature.
|
||||
let mut generics = clean_ty_generics(cx, def_id);
|
||||
let bound_vars = clean_bound_vars(sig.bound_vars());
|
||||
let bound_vars = clean_bound_vars(sig.bound_vars(), cx);
|
||||
|
||||
// At the time of writing early & late-bound params are stored separately in rustc,
|
||||
// namely in `generics.params` and `bound_vars` respectively.
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ fn clean_poly_trait_ref_with_constraints<'tcx>(
|
|||
GenericBound::TraitBound(
|
||||
PolyTrait {
|
||||
trait_: clean_trait_ref_with_constraints(cx, poly_trait_ref, constraints),
|
||||
generic_params: clean_bound_vars(poly_trait_ref.bound_vars()),
|
||||
generic_params: clean_bound_vars(poly_trait_ref.bound_vars(), cx),
|
||||
},
|
||||
hir::TraitBoundModifiers::NONE,
|
||||
)
|
||||
|
|
@ -325,24 +325,11 @@ pub(crate) fn clean_middle_const<'tcx>(
|
|||
ConstantKind::TyConst { expr: constant.skip_binder().to_string().into() }
|
||||
}
|
||||
|
||||
pub(crate) fn clean_middle_region(region: ty::Region<'_>) -> Option<Lifetime> {
|
||||
match region.kind() {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
_ if !region.has_name() => None,
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => {
|
||||
Some(Lifetime(name))
|
||||
}
|
||||
ty::ReEarlyParam(ref data) => Some(Lifetime(data.name)),
|
||||
ty::ReBound(..)
|
||||
| ty::ReLateParam(..)
|
||||
| ty::ReVar(..)
|
||||
| ty::ReError(_)
|
||||
| ty::RePlaceholder(..)
|
||||
| ty::ReErased => {
|
||||
debug!("cannot clean region {region:?}");
|
||||
None
|
||||
}
|
||||
}
|
||||
pub(crate) fn clean_middle_region<'tcx>(
|
||||
region: ty::Region<'tcx>,
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> Option<Lifetime> {
|
||||
region.get_name(cx.tcx).map(Lifetime)
|
||||
}
|
||||
|
||||
fn clean_where_predicate<'tcx>(
|
||||
|
|
@ -384,7 +371,7 @@ pub(crate) fn clean_predicate<'tcx>(
|
|||
let bound_predicate = predicate.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::ClauseKind::Trait(pred) => clean_poly_trait_predicate(bound_predicate.rebind(pred), cx),
|
||||
ty::ClauseKind::RegionOutlives(pred) => Some(clean_region_outlives_predicate(pred)),
|
||||
ty::ClauseKind::RegionOutlives(pred) => Some(clean_region_outlives_predicate(pred, cx)),
|
||||
ty::ClauseKind::TypeOutlives(pred) => {
|
||||
Some(clean_type_outlives_predicate(bound_predicate.rebind(pred), cx))
|
||||
}
|
||||
|
|
@ -418,13 +405,16 @@ fn clean_poly_trait_predicate<'tcx>(
|
|||
})
|
||||
}
|
||||
|
||||
fn clean_region_outlives_predicate(pred: ty::RegionOutlivesPredicate<'_>) -> WherePredicate {
|
||||
fn clean_region_outlives_predicate<'tcx>(
|
||||
pred: ty::RegionOutlivesPredicate<'tcx>,
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> WherePredicate {
|
||||
let ty::OutlivesPredicate(a, b) = pred;
|
||||
|
||||
WherePredicate::RegionPredicate {
|
||||
lifetime: clean_middle_region(a).expect("failed to clean lifetime"),
|
||||
lifetime: clean_middle_region(a, cx).expect("failed to clean lifetime"),
|
||||
bounds: vec![GenericBound::Outlives(
|
||||
clean_middle_region(b).expect("failed to clean bounds"),
|
||||
clean_middle_region(b, cx).expect("failed to clean bounds"),
|
||||
)],
|
||||
}
|
||||
}
|
||||
|
|
@ -438,7 +428,7 @@ fn clean_type_outlives_predicate<'tcx>(
|
|||
WherePredicate::BoundPredicate {
|
||||
ty: clean_middle_ty(pred.rebind(ty), cx, None, None),
|
||||
bounds: vec![GenericBound::Outlives(
|
||||
clean_middle_region(lt).expect("failed to clean lifetimes"),
|
||||
clean_middle_region(lt, cx).expect("failed to clean lifetimes"),
|
||||
)],
|
||||
bound_params: Vec::new(),
|
||||
}
|
||||
|
|
@ -1905,8 +1895,8 @@ fn clean_trait_object_lifetime_bound<'tcx>(
|
|||
match region.kind() {
|
||||
ty::ReStatic => Some(Lifetime::statik()),
|
||||
ty::ReEarlyParam(region) => Some(Lifetime(region.name)),
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => {
|
||||
Some(Lifetime(name))
|
||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(def_id), .. }) => {
|
||||
Some(Lifetime(tcx.item_name(def_id)))
|
||||
}
|
||||
ty::ReBound(..)
|
||||
| ty::ReLateParam(_)
|
||||
|
|
@ -1935,7 +1925,9 @@ fn can_elide_trait_object_lifetime_bound<'tcx>(
|
|||
match default {
|
||||
ObjectLifetimeDefault::Static => return region.kind() == ty::ReStatic,
|
||||
// FIXME(fmease): Don't compare lexically but respect de Bruijn indices etc. to handle shadowing correctly.
|
||||
ObjectLifetimeDefault::Arg(default) => return region.get_name() == default.get_name(),
|
||||
ObjectLifetimeDefault::Arg(default) => {
|
||||
return region.get_name(tcx) == default.get_name(tcx);
|
||||
}
|
||||
// > If there is more than one bound from the containing type then an explicit bound must be specified
|
||||
// Due to ambiguity there is no default trait-object lifetime and thus elision is impossible.
|
||||
// Don't elide the lifetime.
|
||||
|
|
@ -1957,7 +1949,7 @@ fn can_elide_trait_object_lifetime_bound<'tcx>(
|
|||
// > If the trait is defined with a single lifetime bound then that bound is used.
|
||||
// > If 'static is used for any lifetime bound then 'static is used.
|
||||
// FIXME(fmease): Don't compare lexically but respect de Bruijn indices etc. to handle shadowing correctly.
|
||||
[object_region] => object_region.get_name() == region.get_name(),
|
||||
[object_region] => object_region.get_name(tcx) == region.get_name(tcx),
|
||||
// There are several distinct trait regions and none are `'static`.
|
||||
// Due to ambiguity there is no default trait-object lifetime and thus elision is impossible.
|
||||
// Don't elide the lifetime.
|
||||
|
|
@ -2051,7 +2043,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||
RawPointer(mutbl, Box::new(clean_middle_ty(bound_ty.rebind(ty), cx, None, None)))
|
||||
}
|
||||
ty::Ref(r, ty, mutbl) => BorrowedRef {
|
||||
lifetime: clean_middle_region(r),
|
||||
lifetime: clean_middle_region(r, cx),
|
||||
mutability: mutbl,
|
||||
type_: Box::new(clean_middle_ty(
|
||||
bound_ty.rebind(ty),
|
||||
|
|
@ -2064,7 +2056,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||
// FIXME: should we merge the outer and inner binders somehow?
|
||||
let sig = bound_ty.skip_binder().fn_sig(cx.tcx);
|
||||
let decl = clean_poly_fn_sig(cx, None, sig);
|
||||
let generic_params = clean_bound_vars(sig.bound_vars());
|
||||
let generic_params = clean_bound_vars(sig.bound_vars(), cx);
|
||||
|
||||
BareFunction(Box::new(BareFunctionDecl {
|
||||
safety: sig.safety(),
|
||||
|
|
@ -2074,7 +2066,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||
}))
|
||||
}
|
||||
ty::UnsafeBinder(inner) => {
|
||||
let generic_params = clean_bound_vars(inner.bound_vars());
|
||||
let generic_params = clean_bound_vars(inner.bound_vars(), cx);
|
||||
let ty = clean_middle_ty(inner.into(), cx, None, None);
|
||||
UnsafeBinder(Box::new(UnsafeBinderTy { generic_params, ty }))
|
||||
}
|
||||
|
|
@ -2148,10 +2140,13 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||
.iter()
|
||||
.flat_map(|pred| pred.bound_vars())
|
||||
.filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
if name != kw::UnderscoreLifetime =>
|
||||
{
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id)) => {
|
||||
let name = cx.tcx.item_name(def_id);
|
||||
if name != kw::UnderscoreLifetime {
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
|
|
@ -2226,7 +2221,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
|
|||
}
|
||||
|
||||
ty::Bound(_, ref ty) => match ty.kind {
|
||||
ty::BoundTyKind::Param(_, name) => Generic(name),
|
||||
ty::BoundTyKind::Param(def_id) => Generic(cx.tcx.item_name(def_id)),
|
||||
ty::BoundTyKind::Anon => panic!("unexpected anonymous bound type variable"),
|
||||
},
|
||||
|
||||
|
|
@ -2282,7 +2277,7 @@ fn clean_middle_opaque_bounds<'tcx>(
|
|||
let trait_ref = match bound_predicate.skip_binder() {
|
||||
ty::ClauseKind::Trait(tr) => bound_predicate.rebind(tr.trait_ref),
|
||||
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
|
||||
return clean_middle_region(reg).map(GenericBound::Outlives);
|
||||
return clean_middle_region(reg, cx).map(GenericBound::Outlives);
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
|
@ -3182,16 +3177,23 @@ fn clean_assoc_item_constraint<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
fn clean_bound_vars(bound_vars: &ty::List<ty::BoundVariableKind>) -> Vec<GenericParamDef> {
|
||||
fn clean_bound_vars<'tcx>(
|
||||
bound_vars: &ty::List<ty::BoundVariableKind>,
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> Vec<GenericParamDef> {
|
||||
bound_vars
|
||||
.into_iter()
|
||||
.filter_map(|var| match var {
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id, name))
|
||||
if name != kw::UnderscoreLifetime =>
|
||||
{
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
ty::BoundVariableKind::Region(ty::BoundRegionKind::Named(def_id)) => {
|
||||
let name = cx.tcx.item_name(def_id);
|
||||
if name != kw::UnderscoreLifetime {
|
||||
Some(GenericParamDef::lifetime(def_id, name))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id, name)) => {
|
||||
ty::BoundVariableKind::Ty(ty::BoundTyKind::Param(def_id)) => {
|
||||
let name = cx.tcx.item_name(def_id);
|
||||
Some(GenericParamDef {
|
||||
name,
|
||||
def_id,
|
||||
|
|
|
|||
|
|
@ -784,7 +784,7 @@ impl Item {
|
|||
// don't want it it `Item::attrs`.
|
||||
hir::Attribute::Parsed(AttributeKind::Deprecation { .. }) => None,
|
||||
// We have separate pretty-printing logic for `#[repr(..)]` attributes.
|
||||
hir::Attribute::Parsed(AttributeKind::Repr(..)) => None,
|
||||
hir::Attribute::Parsed(AttributeKind::Repr { .. }) => None,
|
||||
// target_feature is special-cased because cargo-semver-checks uses it
|
||||
hir::Attribute::Parsed(AttributeKind::TargetFeature(features, _)) => {
|
||||
let mut output = String::new();
|
||||
|
|
|
|||
|
|
@ -125,9 +125,9 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
|
|||
}
|
||||
|
||||
match arg.skip_binder().kind() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided())))
|
||||
}
|
||||
GenericArgKind::Lifetime(lt) => Some(GenericArg::Lifetime(
|
||||
clean_middle_region(lt, cx).unwrap_or(Lifetime::elided()),
|
||||
)),
|
||||
GenericArgKind::Type(ty) => Some(GenericArg::Type(clean_middle_ty(
|
||||
arg.rebind(ty),
|
||||
cx,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit ed6566573eb21b00a3f87815e14ff766fd56ef42
|
||||
Subproject commit 9b1bf4cf041c1c1fe62cf03891ac90431615e780
|
||||
|
|
@ -266,7 +266,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
|
|||
.tcx
|
||||
.hir_attrs(item.hir_id())
|
||||
.iter()
|
||||
.any(|attr| matches!(attr, Attribute::Parsed(AttributeKind::Repr(..))))
|
||||
.any(|attr| matches!(attr, Attribute::Parsed(AttributeKind::Repr{ .. })))
|
||||
{
|
||||
// Do not lint items with a `#[repr]` attribute as their layout may be imposed by an external API.
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use clippy_utils::msrvs::{self, Msrv};
|
|||
use super::REPR_PACKED_WITHOUT_ABI;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, item_span: Span, attrs: &[Attribute], msrv: Msrv) {
|
||||
if let Some(reprs) = find_attr!(attrs, AttributeKind::Repr(r) => r) {
|
||||
if let Some(reprs) = find_attr!(attrs, AttributeKind::Repr { reprs, .. } => reprs) {
|
||||
let packed_span = reprs
|
||||
.iter()
|
||||
.find(|(r, _)| matches!(r, ReprAttr::ReprPacked(..)))
|
||||
|
|
|
|||
|
|
@ -99,5 +99,5 @@ fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: ty::GenericArgsR
|
|||
fn has_c_repr_attr(cx: &LateContext<'_>, hir_id: HirId) -> bool {
|
||||
let attrs = cx.tcx.hir_attrs(hir_id);
|
||||
|
||||
find_attr!(attrs, AttributeKind::Repr(r) if r.iter().any(|(x, _)| *x == ReprAttr::ReprC))
|
||||
find_attr!(attrs, AttributeKind::Repr { reprs, .. } if reprs.iter().any(|(x, _)| *x == ReprAttr::ReprC))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1761,7 +1761,7 @@ pub fn has_attr(attrs: &[hir::Attribute], symbol: Symbol) -> bool {
|
|||
}
|
||||
|
||||
pub fn has_repr_attr(cx: &LateContext<'_>, hir_id: HirId) -> bool {
|
||||
find_attr!(cx.tcx.hir_attrs(hir_id), AttributeKind::Repr(..))
|
||||
find_attr!(cx.tcx.hir_attrs(hir_id), AttributeKind::Repr { .. })
|
||||
}
|
||||
|
||||
pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool {
|
||||
|
|
|
|||
|
|
@ -172,207 +172,422 @@ pub enum Sanitizer {
|
|||
Hwaddress,
|
||||
}
|
||||
|
||||
/// Configuration for compiletest
|
||||
/// Configuration for `compiletest` *per invocation*.
|
||||
///
|
||||
/// In terms of `bootstrap`, this means that `./x test tests/ui tests/run-make` actually correspond
|
||||
/// to *two* separate invocations of `compiletest`.
|
||||
///
|
||||
/// FIXME: this `Config` struct should be broken up into smaller logically contained sub-config
|
||||
/// structs, it's too much of a "soup" of everything at the moment.
|
||||
///
|
||||
/// # Configuration sources
|
||||
///
|
||||
/// Configuration values for `compiletest` comes from several sources:
|
||||
///
|
||||
/// - CLI args passed from `bootstrap` while running the `compiletest` binary.
|
||||
/// - Env vars.
|
||||
/// - Discovery (e.g. trying to identify a suitable debugger based on filesystem discovery).
|
||||
/// - Cached output of running the `rustc` under test (e.g. output of `rustc` print requests).
|
||||
///
|
||||
/// FIXME: make sure we *clearly* account for sources of *all* config options.
|
||||
///
|
||||
/// FIXME: audit these options to make sure we are not hashing less than necessary for build stamp
|
||||
/// (for changed test detection).
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Config {
|
||||
/// `true` to overwrite stderr/stdout files instead of complaining about changes in output.
|
||||
/// Some test [`Mode`]s support [snapshot testing], where a *reference snapshot* of outputs (of
|
||||
/// `stdout`, `stderr`, or other form of artifacts) can be compared to the *actual output*.
|
||||
///
|
||||
/// This option can be set to `true` to update the *reference snapshots* in-place, otherwise
|
||||
/// `compiletest` will only try to compare.
|
||||
///
|
||||
/// [snapshot testing]: https://jestjs.io/docs/snapshot-testing
|
||||
pub bless: bool,
|
||||
|
||||
/// Stop as soon as possible after any test fails.
|
||||
/// May run a few more tests before stopping, due to threading.
|
||||
/// Attempt to stop as soon as possible after any test fails. We may still run a few more tests
|
||||
/// before stopping when multiple test threads are used.
|
||||
pub fail_fast: bool,
|
||||
|
||||
/// The library paths required for running the compiler.
|
||||
/// Path to libraries needed to run the *staged* `rustc`-under-test on the **host** platform.
|
||||
///
|
||||
/// FIXME: maybe rename this to reflect (1) which target platform (host, not target), and (2)
|
||||
/// which `rustc` (the `rustc`-under-test, not the stage 0 `rustc` unless forced).
|
||||
pub compile_lib_path: Utf8PathBuf,
|
||||
|
||||
/// The library paths required for running compiled programs.
|
||||
/// Path to libraries needed to run the compiled executable for the **target** platform. This
|
||||
/// corresponds to the **target** sysroot libraries, including the **target** standard library.
|
||||
///
|
||||
/// FIXME: maybe rename this to reflect (1) which target platform (target, not host), and (2)
|
||||
/// what "run libraries" are against.
|
||||
///
|
||||
/// FIXME: this is very under-documented in conjunction with the `remote-test-client` scheme and
|
||||
/// `RUNNER` scheme to actually run the target executable under the target platform environment,
|
||||
/// cf. [`Self::remote_test_client`] and [`Self::runner`].
|
||||
pub run_lib_path: Utf8PathBuf,
|
||||
|
||||
/// The rustc executable.
|
||||
/// Path to the *staged* `rustc`-under-test. Unless forced, this `rustc` is *staged*, and must
|
||||
/// not be confused with [`Self::stage0_rustc_path`].
|
||||
///
|
||||
/// FIXME: maybe rename this to reflect that this is the `rustc`-under-test.
|
||||
pub rustc_path: Utf8PathBuf,
|
||||
|
||||
/// The cargo executable.
|
||||
/// Path to a *staged* **host** platform cargo executable (unless stage 0 is forced). This
|
||||
/// staged `cargo` is only used within `run-make` test recipes during recipe run time (and is
|
||||
/// *not* used to compile the test recipes), and so must be staged as there may be differences
|
||||
/// between e.g. beta `cargo` vs in-tree `cargo`.
|
||||
///
|
||||
/// FIXME: maybe rename this to reflect that this is a *staged* host cargo.
|
||||
///
|
||||
/// FIXME(#134109): split `run-make` into two test suites, a test suite *with* staged cargo, and
|
||||
/// another test suite *without*.
|
||||
pub cargo_path: Option<Utf8PathBuf>,
|
||||
|
||||
/// Rustc executable used to compile run-make recipes.
|
||||
/// Path to the stage 0 `rustc` used to build `run-make` recipes. This must not be confused with
|
||||
/// [`Self::rustc_path`].
|
||||
pub stage0_rustc_path: Option<Utf8PathBuf>,
|
||||
|
||||
/// The rustdoc executable.
|
||||
/// Path to the `rustdoc`-under-test. Like [`Self::rustc_path`], this `rustdoc` is *staged*.
|
||||
pub rustdoc_path: Option<Utf8PathBuf>,
|
||||
|
||||
/// The coverage-dump executable.
|
||||
/// Path to the `src/tools/coverage-dump/` bootstrap tool executable.
|
||||
pub coverage_dump_path: Option<Utf8PathBuf>,
|
||||
|
||||
/// The Python executable to use for LLDB and htmldocck.
|
||||
/// Path to the Python 3 executable to use for LLDB and htmldocck.
|
||||
///
|
||||
/// FIXME: the `lldb` setup currently requires I believe Python 3.10 **exactly**, it can't even
|
||||
/// be Python 3.11 or 3.9...
|
||||
pub python: String,
|
||||
|
||||
/// The jsondocck executable.
|
||||
/// Path to the `src/tools/jsondocck/` bootstrap tool executable.
|
||||
pub jsondocck_path: Option<String>,
|
||||
|
||||
/// The jsondoclint executable.
|
||||
/// Path to the `src/tools/jsondoclint/` bootstrap tool executable.
|
||||
pub jsondoclint_path: Option<String>,
|
||||
|
||||
/// The LLVM `FileCheck` binary path.
|
||||
/// Path to a host LLVM `FileCheck` executable.
|
||||
pub llvm_filecheck: Option<Utf8PathBuf>,
|
||||
|
||||
/// Path to LLVM's bin directory.
|
||||
/// Path to a host LLVM bintools directory.
|
||||
pub llvm_bin_dir: Option<Utf8PathBuf>,
|
||||
|
||||
/// The path to the Clang executable to run Clang-based tests with. If
|
||||
/// `None` then these tests will be ignored.
|
||||
/// The path to the **target** `clang` executable to run `clang`-based tests with. If `None`,
|
||||
/// then these tests will be ignored.
|
||||
pub run_clang_based_tests_with: Option<String>,
|
||||
|
||||
/// The directory containing the sources.
|
||||
/// Path to the directory containing the sources. This corresponds to the root folder of a
|
||||
/// `rust-lang/rust` checkout.
|
||||
///
|
||||
/// FIXME: this name is confusing, because this is actually `$checkout_root`, **not** the
|
||||
/// `$checkout_root/src/` folder.
|
||||
pub src_root: Utf8PathBuf,
|
||||
/// The directory containing the test suite sources. Must be a subdirectory of `src_root`.
|
||||
|
||||
/// Path to the directory containing the test suites sources. This corresponds to the
|
||||
/// `$src_root/tests/` folder.
|
||||
///
|
||||
/// Must be an immediate subdirectory of [`Self::src_root`].
|
||||
///
|
||||
/// FIXME: this name is also confusing, maybe just call it `tests_root`.
|
||||
pub src_test_suite_root: Utf8PathBuf,
|
||||
|
||||
/// Root build directory (e.g. `build/`).
|
||||
/// Path to the build directory (e.g. `build/`).
|
||||
pub build_root: Utf8PathBuf,
|
||||
/// Test suite specific build directory (e.g. `build/host/test/ui/`).
|
||||
|
||||
/// Path to the test suite specific build directory (e.g. `build/host/test/ui/`).
|
||||
///
|
||||
/// Must be a subdirectory of [`Self::build_root`].
|
||||
pub build_test_suite_root: Utf8PathBuf,
|
||||
|
||||
/// The directory containing the compiler sysroot
|
||||
/// Path to the directory containing the sysroot of the `rustc`-under-test.
|
||||
///
|
||||
/// When stage 0 is forced, this will correspond to the sysroot *of* that specified stage 0
|
||||
/// `rustc`.
|
||||
///
|
||||
/// FIXME: this name is confusing, because it doesn't specify *which* compiler this sysroot
|
||||
/// corresponds to. It's actually the `rustc`-under-test, and not the bootstrap `rustc`, unless
|
||||
/// stage 0 is forced and no custom stage 0 `rustc` was otherwise specified (so that it
|
||||
/// *happens* to run against the bootstrap `rustc`, but this non-custom bootstrap `rustc` case
|
||||
/// is not really supported).
|
||||
pub sysroot_base: Utf8PathBuf,
|
||||
|
||||
/// The number of the stage under test.
|
||||
pub stage: u32,
|
||||
|
||||
/// The id of the stage under test (stage1-xxx, etc).
|
||||
///
|
||||
/// FIXME: reconsider this string; this is hashed for test build stamp.
|
||||
pub stage_id: String,
|
||||
|
||||
/// The test mode, e.g. ui or debuginfo.
|
||||
/// The test [`Mode`]. E.g. [`Mode::Ui`]. Each test mode can correspond to one or more test
|
||||
/// suites.
|
||||
///
|
||||
/// FIXME: stop using stringly-typed test suites!
|
||||
pub mode: Mode,
|
||||
|
||||
/// The test suite (essentially which directory is running, but without the
|
||||
/// directory prefix such as tests)
|
||||
/// The test suite.
|
||||
///
|
||||
/// Example: `tests/ui/` is the "UI" test *suite*, which happens to also be of the [`Mode::Ui`]
|
||||
/// test *mode*.
|
||||
///
|
||||
/// Note that the same test directory (e.g. `tests/coverage/`) may correspond to multiple test
|
||||
/// modes, e.g. `tests/coverage/` can be run under both [`Mode::CoverageRun`] and
|
||||
/// [`Mode::CoverageMap`].
|
||||
///
|
||||
/// FIXME: stop using stringly-typed test suites!
|
||||
pub suite: String,
|
||||
|
||||
/// The debugger to use in debuginfo mode. Unset otherwise.
|
||||
/// When specified, **only** the specified [`Debugger`] will be used to run against the
|
||||
/// `tests/debuginfo` test suite. When unspecified, `compiletest` will attempt to find all three
|
||||
/// of {`lldb`, `cdb`, `gdb`} implicitly, and then try to run the `debuginfo` test suite against
|
||||
/// all three debuggers.
|
||||
///
|
||||
/// FIXME: this implicit behavior is really nasty, in that it makes it hard for the user to
|
||||
/// control *which* debugger(s) are available and used to run the debuginfo test suite. We
|
||||
/// should have `bootstrap` allow the user to *explicitly* configure the debuggers, and *not*
|
||||
/// try to implicitly discover some random debugger from the user environment. This makes the
|
||||
/// debuginfo test suite particularly hard to work with.
|
||||
pub debugger: Option<Debugger>,
|
||||
|
||||
/// Run ignored tests
|
||||
/// Run ignored tests *unconditionally*, overriding their ignore reason.
|
||||
///
|
||||
/// FIXME: this is wired up through the test execution logic, but **not** accessible from
|
||||
/// `bootstrap` directly; `compiletest` exposes this as `--ignored`. I.e. you'd have to use `./x
|
||||
/// test $test_suite -- --ignored=true`.
|
||||
pub run_ignored: bool,
|
||||
|
||||
/// Whether rustc was built with debug assertions.
|
||||
/// Whether *staged* `rustc`-under-test was built with debug assertions.
|
||||
///
|
||||
/// FIXME: make it clearer that this refers to the staged `rustc`-under-test, not stage 0
|
||||
/// `rustc`.
|
||||
pub with_rustc_debug_assertions: bool,
|
||||
|
||||
/// Whether std was built with debug assertions.
|
||||
/// Whether *staged* `std` was built with debug assertions.
|
||||
///
|
||||
/// FIXME: make it clearer that this refers to the staged `std`, not stage 0 `std`.
|
||||
pub with_std_debug_assertions: bool,
|
||||
|
||||
/// Only run tests that match these filters
|
||||
/// Only run tests that match these filters (using `libtest` "test name contains" filter logic).
|
||||
///
|
||||
/// FIXME(#139660): the current hand-rolled test executor intentionally mimics the `libtest`
|
||||
/// "test name contains" filter matching logic to preserve previous `libtest` executor behavior,
|
||||
/// but this is often not intuitive. We should consider changing that behavior with an MCP to do
|
||||
/// test path *prefix* matching which better corresponds to how `compiletest` `tests/` are
|
||||
/// organized, and how users would intuitively expect the filtering logic to work like.
|
||||
pub filters: Vec<String>,
|
||||
|
||||
/// Skip tests matching these substrings. Corresponds to
|
||||
/// `test::TestOpts::skip`. `filter_exact` does not apply to these flags.
|
||||
/// Skip tests matching these substrings. The matching logic exactly corresponds to
|
||||
/// [`Self::filters`] but inverted.
|
||||
///
|
||||
/// FIXME(#139660): ditto on test matching behavior.
|
||||
pub skip: Vec<String>,
|
||||
|
||||
/// Exactly match the filter, rather than a substring
|
||||
/// Exactly match the filter, rather than a substring.
|
||||
///
|
||||
/// FIXME(#139660): ditto on test matching behavior.
|
||||
pub filter_exact: bool,
|
||||
|
||||
/// Force the pass mode of a check/build/run-pass test to this mode.
|
||||
/// Force the pass mode of a check/build/run test to instead use this mode instead.
|
||||
///
|
||||
/// FIXME: make it even more obvious (especially in PR CI where `--pass=check` is used) when a
|
||||
/// pass mode is forced when the test fails, because it can be very non-obvious when e.g. an
|
||||
/// error is emitted only when `//@ build-pass` but not `//@ check-pass`.
|
||||
pub force_pass_mode: Option<PassMode>,
|
||||
|
||||
/// Explicitly enable or disable running.
|
||||
/// Explicitly enable or disable running of the target test binary.
|
||||
///
|
||||
/// FIXME: this scheme is a bit confusing, and at times questionable. Re-evaluate this run
|
||||
/// scheme.
|
||||
///
|
||||
/// FIXME: Currently `--run` is a tri-state, it can be `--run={auto,always,never}`, and when
|
||||
/// `--run=auto` is specified, it's run if the platform doesn't end with `-fuchsia`. See
|
||||
/// [`Config::run_enabled`].
|
||||
pub run: Option<bool>,
|
||||
|
||||
/// A command line to prefix program execution with,
|
||||
/// for running under valgrind for example.
|
||||
/// A command line to prefix target program execution with, for running under valgrind for
|
||||
/// example, i.e. `$runner target.exe [args..]`. Similar to `CARGO_*_RUNNER` configuration.
|
||||
///
|
||||
/// Similar to `CARGO_*_RUNNER` configuration.
|
||||
/// Note: this is not to be confused with [`Self::remote_test_client`], which is a different
|
||||
/// scheme.
|
||||
///
|
||||
/// FIXME: the runner scheme is very under-documented.
|
||||
pub runner: Option<String>,
|
||||
|
||||
/// Flags to pass to the compiler when building for the host
|
||||
/// Compiler flags to pass to the *staged* `rustc`-under-test when building for the **host**
|
||||
/// platform.
|
||||
pub host_rustcflags: Vec<String>,
|
||||
|
||||
/// Flags to pass to the compiler when building for the target
|
||||
/// Compiler flags to pass to the *staged* `rustc`-under-test when building for the **target**
|
||||
/// platform.
|
||||
pub target_rustcflags: Vec<String>,
|
||||
|
||||
/// Whether the compiler and stdlib has been built with randomized struct layouts
|
||||
/// Whether the *staged* `rustc`-under-test and the associated *staged* `std` has been built
|
||||
/// with randomized struct layouts.
|
||||
pub rust_randomized_layout: bool,
|
||||
|
||||
/// Whether tests should be optimized by default. Individual test-suites and test files may
|
||||
/// override this setting.
|
||||
/// Whether tests should be optimized by default (`-O`). Individual test suites and test files
|
||||
/// may override this setting.
|
||||
///
|
||||
/// FIXME: this flag / config option is somewhat misleading. For instance, in ui tests, it's
|
||||
/// *only* applied to the [`PassMode::Run`] test crate and not its auxiliaries.
|
||||
pub optimize_tests: bool,
|
||||
|
||||
/// Target system to be tested
|
||||
/// Target platform tuple.
|
||||
pub target: String,
|
||||
|
||||
/// Host triple for the compiler being invoked
|
||||
/// Host platform tuple.
|
||||
pub host: String,
|
||||
|
||||
/// Path to / name of the Microsoft Console Debugger (CDB) executable
|
||||
/// Path to / name of the Microsoft Console Debugger (CDB) executable.
|
||||
///
|
||||
/// FIXME: this is an *opt-in* "override" option. When this isn't provided, we try to conjure a
|
||||
/// cdb by looking at the user's program files on Windows... See `debuggers::find_cdb`.
|
||||
pub cdb: Option<Utf8PathBuf>,
|
||||
|
||||
/// Version of CDB
|
||||
/// Version of CDB.
|
||||
///
|
||||
/// FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config!
|
||||
///
|
||||
/// FIXME: audit cdb version gating.
|
||||
pub cdb_version: Option<[u16; 4]>,
|
||||
|
||||
/// Path to / name of the GDB executable
|
||||
/// Path to / name of the GDB executable.
|
||||
///
|
||||
/// FIXME: the fallback path when `gdb` isn't provided tries to find *a* `gdb` or `gdb.exe` from
|
||||
/// `PATH`, which is... arguably questionable.
|
||||
///
|
||||
/// FIXME: we are propagating a python from `PYTHONPATH`, not from an explicit config for gdb
|
||||
/// debugger script.
|
||||
pub gdb: Option<String>,
|
||||
|
||||
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
|
||||
///
|
||||
/// FIXME: this gdb version gating scheme is possibly questionable -- gdb does not use semver,
|
||||
/// only its major version is likely materially meaningful, cf.
|
||||
/// <https://sourceware.org/gdb/wiki/Internals%20Versions>. Even the major version I'm not sure
|
||||
/// is super meaningful. Maybe min gdb `major.minor` version gating is sufficient for the
|
||||
/// purposes of debuginfo tests?
|
||||
///
|
||||
/// FIXME: `gdb_version` is *derived* from gdb, but it's *not* technically a config!
|
||||
pub gdb_version: Option<u32>,
|
||||
|
||||
/// Version of LLDB
|
||||
/// Version of LLDB.
|
||||
///
|
||||
/// FIXME: `lldb_version` is *derived* from lldb, but it's *not* technically a config!
|
||||
pub lldb_version: Option<u32>,
|
||||
|
||||
/// Version of LLVM
|
||||
/// Version of LLVM.
|
||||
///
|
||||
/// FIXME: Audit the fallback derivation of
|
||||
/// [`crate::directives::extract_llvm_version_from_binary`], that seems very questionable?
|
||||
pub llvm_version: Option<Version>,
|
||||
|
||||
/// Is LLVM a system LLVM
|
||||
/// Is LLVM a system LLVM.
|
||||
pub system_llvm: bool,
|
||||
|
||||
/// Path to the android tools
|
||||
/// Path to the android tools.
|
||||
///
|
||||
/// Note: this is only used for android gdb debugger script in the debuginfo test suite.
|
||||
///
|
||||
/// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
|
||||
/// `arm-linux-androideabi` target.
|
||||
pub android_cross_path: Utf8PathBuf,
|
||||
|
||||
/// Extra parameter to run adb on arm-linux-androideabi
|
||||
/// Extra parameter to run adb on `arm-linux-androideabi`.
|
||||
///
|
||||
/// FIXME: is this *only* `arm-linux-androideabi`, or is it also for other Tier 2/3 android
|
||||
/// targets?
|
||||
///
|
||||
/// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
|
||||
/// `arm-linux-androideabi` target.
|
||||
pub adb_path: String,
|
||||
|
||||
/// Extra parameter to run test suite on arm-linux-androideabi
|
||||
/// Extra parameter to run test suite on `arm-linux-androideabi`.
|
||||
///
|
||||
/// FIXME: is this *only* `arm-linux-androideabi`, or is it also for other Tier 2/3 android
|
||||
/// targets?
|
||||
///
|
||||
/// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for
|
||||
/// `arm-linux-androideabi` target.
|
||||
pub adb_test_dir: String,
|
||||
|
||||
/// status whether android device available or not
|
||||
/// Status whether android device available or not. When unavailable, this will cause tests to
|
||||
/// panic when the test binary is attempted to be run.
|
||||
///
|
||||
/// FIXME: take a look at this; this also influences adb in gdb code paths in a strange way.
|
||||
pub adb_device_status: bool,
|
||||
|
||||
/// the path containing LLDB's Python module
|
||||
/// Path containing LLDB's Python module.
|
||||
///
|
||||
/// FIXME: `PYTHONPATH` takes precedence over this flag...? See `runtest::run_lldb`.
|
||||
pub lldb_python_dir: Option<String>,
|
||||
|
||||
/// Explain what's going on
|
||||
/// Verbose dump a lot of info.
|
||||
///
|
||||
/// FIXME: this is *way* too coarse; the user can't select *which* info to verbosely dump.
|
||||
pub verbose: bool,
|
||||
|
||||
/// Print one character per test instead of one line
|
||||
/// (Useless) Adjust libtest output format.
|
||||
///
|
||||
/// FIXME: the hand-rolled executor does not support non-JSON output, because `compiletest` need
|
||||
/// to package test outcome as `libtest`-esque JSON that `bootstrap` can intercept *anyway*.
|
||||
/// However, now that we don't use the `libtest` executor, this is useless.
|
||||
pub format: OutputFormat,
|
||||
|
||||
/// Whether to use colors in test.
|
||||
/// Whether to use colors in test output.
|
||||
///
|
||||
/// Note: the exact control mechanism is delegated to [`colored`].
|
||||
pub color: ColorConfig,
|
||||
|
||||
/// where to find the remote test client process, if we're using it
|
||||
/// Where to find the remote test client process, if we're using it.
|
||||
///
|
||||
/// Note: this is *only* used for target platform executables created by `run-make` test
|
||||
/// recipes.
|
||||
///
|
||||
/// Note: this is not to be confused with [`Self::runner`], which is a different scheme.
|
||||
///
|
||||
/// FIXME: the `remote_test_client` scheme is very under-documented.
|
||||
pub remote_test_client: Option<Utf8PathBuf>,
|
||||
|
||||
/// mode describing what file the actual ui output will be compared to
|
||||
/// [`CompareMode`] describing what file the actual ui output will be compared to.
|
||||
///
|
||||
/// FIXME: currently, [`CompareMode`] is a mishmash of lot of things (different borrow-checker
|
||||
/// model, different trait solver, different debugger, etc.).
|
||||
pub compare_mode: Option<CompareMode>,
|
||||
|
||||
/// If true, this will generate a coverage file with UI test files that run `MachineApplicable`
|
||||
/// diagnostics but are missing `run-rustfix` annotations. The generated coverage file is
|
||||
/// created in `<test_suite_build_root>/rustfix_missing_coverage.txt`
|
||||
/// created in `$test_suite_build_root/rustfix_missing_coverage.txt`
|
||||
pub rustfix_coverage: bool,
|
||||
|
||||
/// whether to run `tidy` (html-tidy) when a rustdoc test fails
|
||||
/// Whether to run `tidy` (html-tidy) when a rustdoc test fails.
|
||||
pub has_html_tidy: bool,
|
||||
|
||||
/// whether to run `enzyme` autodiff tests
|
||||
/// Whether to run `enzyme` autodiff tests.
|
||||
pub has_enzyme: bool,
|
||||
|
||||
/// The current Rust channel
|
||||
/// The current Rust channel info.
|
||||
///
|
||||
/// FIXME: treat this more carefully; "stable", "beta" and "nightly" are definitely valid, but
|
||||
/// channel might also be "dev" or such, which should be treated as "nightly".
|
||||
pub channel: String,
|
||||
|
||||
/// Whether adding git commit information such as the commit hash has been enabled for building
|
||||
/// Whether adding git commit information such as the commit hash has been enabled for building.
|
||||
///
|
||||
/// FIXME: `compiletest` cannot trust `bootstrap` for this information, because `bootstrap` can
|
||||
/// have bugs and had bugs on that logic. We need to figure out how to obtain this e.g. directly
|
||||
/// from CI or via git locally.
|
||||
pub git_hash: bool,
|
||||
|
||||
/// The default Rust edition
|
||||
/// The default Rust edition.
|
||||
///
|
||||
/// FIXME: perform stronger validation for this. There are editions that *definitely* exists,
|
||||
/// but there might also be "future" edition.
|
||||
pub edition: Option<String>,
|
||||
|
||||
// Configuration for various run-make tests frobbing things like C compilers
|
||||
// or querying about various LLVM component information.
|
||||
// Configuration for various run-make tests frobbing things like C compilers or querying about
|
||||
// various LLVM component information.
|
||||
//
|
||||
// FIXME: this really should be better packaged together.
|
||||
// FIXME: these need better docs, e.g. for *host*, or for *target*?
|
||||
pub cc: String,
|
||||
pub cxx: String,
|
||||
pub cflags: String,
|
||||
|
|
@ -382,41 +597,63 @@ pub struct Config {
|
|||
pub host_linker: Option<String>,
|
||||
pub llvm_components: String,
|
||||
|
||||
/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests
|
||||
/// Path to a NodeJS executable. Used for JS doctests, emscripten and WASM tests.
|
||||
pub nodejs: Option<String>,
|
||||
/// Path to a npm executable. Used for rustdoc GUI tests
|
||||
/// Path to a npm executable. Used for rustdoc GUI tests.
|
||||
pub npm: Option<String>,
|
||||
|
||||
/// Whether to rerun tests even if the inputs are unchanged.
|
||||
pub force_rerun: bool,
|
||||
|
||||
/// Only rerun the tests that result has been modified according to Git status
|
||||
/// Only rerun the tests that result has been modified according to `git status`.
|
||||
///
|
||||
/// FIXME: this is undocumented.
|
||||
///
|
||||
/// FIXME: how does this interact with [`Self::force_rerun`]?
|
||||
pub only_modified: bool,
|
||||
|
||||
// FIXME: these are really not "config"s, but rather are information derived from
|
||||
// `rustc`-under-test. This poses an interesting conundrum: if we're testing the
|
||||
// `rustc`-under-test, can we trust its print request outputs and target cfgs? In theory, this
|
||||
// itself can break or be unreliable -- ideally, we'd be sharing these kind of information not
|
||||
// through `rustc`-under-test's execution output. In practice, however, print requests are very
|
||||
// unlikely to completely break (we also have snapshot ui tests for them). Furthermore, even if
|
||||
// we share them via some kind of static config, that static config can still be wrong! Who
|
||||
// tests the tester? Therefore, we make a pragmatic compromise here, and use information derived
|
||||
// from print requests produced by the `rustc`-under-test.
|
||||
//
|
||||
// FIXME: move them out from `Config`, because they are *not* configs.
|
||||
pub target_cfgs: OnceLock<TargetCfgs>,
|
||||
pub builtin_cfg_names: OnceLock<HashSet<String>>,
|
||||
pub supported_crate_types: OnceLock<HashSet<String>>,
|
||||
|
||||
/// FIXME: this is why we still need to depend on *staged* `std`, it's because we currently rely
|
||||
/// on `#![feature(internal_output_capture)]` for [`std::io::set_output_capture`] to implement
|
||||
/// `libtest`-esque `--no-capture`.
|
||||
///
|
||||
/// FIXME: rename this to the more canonical `no_capture`, or better, invert this to `capture`
|
||||
/// to avoid `!nocapture` double-negatives.
|
||||
pub nocapture: bool,
|
||||
|
||||
// Needed both to construct build_helper::git::GitConfig
|
||||
/// Needed both to construct [`build_helper::git::GitConfig`].
|
||||
pub nightly_branch: String,
|
||||
pub git_merge_commit_email: String,
|
||||
|
||||
/// True if the profiler runtime is enabled for this target.
|
||||
/// Used by the "needs-profiler-runtime" directive in test files.
|
||||
/// True if the profiler runtime is enabled for this target. Used by the
|
||||
/// `needs-profiler-runtime` directive in test files.
|
||||
pub profiler_runtime: bool,
|
||||
|
||||
/// Command for visual diff display, e.g. `diff-tool --color=always`.
|
||||
pub diff_command: Option<String>,
|
||||
|
||||
/// Path to minicore aux library, used for `no_core` tests that need `core` stubs in
|
||||
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
|
||||
/// ABI tests.
|
||||
/// Path to minicore aux library (`tests/auxiliary/minicore.rs`), used for `no_core` tests that
|
||||
/// need `core` stubs in cross-compilation scenarios that do not otherwise want/need to
|
||||
/// `-Zbuild-std`. Used in e.g. ABI tests.
|
||||
pub minicore_path: Utf8PathBuf,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
/// FIXME: this run scheme is... confusing.
|
||||
pub fn run_enabled(&self) -> bool {
|
||||
self.run.unwrap_or_else(|| {
|
||||
// Auto-detect whether to run based on the platform.
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ pub(crate) fn configure_gdb(config: &Config) -> Option<Arc<Config>> {
|
|||
pub(crate) fn configure_lldb(config: &Config) -> Option<Arc<Config>> {
|
||||
config.lldb_python_dir.as_ref()?;
|
||||
|
||||
// FIXME: this is super old
|
||||
if let Some(350) = config.lldb_version {
|
||||
println!(
|
||||
"WARNING: The used version of LLDB (350) has a \
|
||||
|
|
@ -78,6 +79,7 @@ fn is_pc_windows_msvc_target(target: &str) -> bool {
|
|||
target.ends_with("-pc-windows-msvc")
|
||||
}
|
||||
|
||||
/// FIXME: this is very questionable...
|
||||
fn find_cdb(target: &str) -> Option<Utf8PathBuf> {
|
||||
if !(cfg!(windows) && is_pc_windows_msvc_target(target)) {
|
||||
return None;
|
||||
|
|
|
|||
|
|
@ -207,9 +207,9 @@ impl TestOutcome {
|
|||
///
|
||||
/// Adapted from `filter_tests` in libtest.
|
||||
///
|
||||
/// FIXME(#139660): After the libtest dependency is removed, redesign the whole
|
||||
/// filtering system to do a better job of understanding and filtering _paths_,
|
||||
/// instead of being tied to libtest's substring/exact matching behaviour.
|
||||
/// FIXME(#139660): After the libtest dependency is removed, redesign the whole filtering system to
|
||||
/// do a better job of understanding and filtering _paths_, instead of being tied to libtest's
|
||||
/// substring/exact matching behaviour.
|
||||
fn filter_tests(opts: &Config, tests: Vec<CollectedTest>) -> Vec<CollectedTest> {
|
||||
let mut filtered = tests;
|
||||
|
||||
|
|
@ -235,9 +235,9 @@ fn filter_tests(opts: &Config, tests: Vec<CollectedTest>) -> Vec<CollectedTest>
|
|||
///
|
||||
/// Copied from `get_concurrency` in libtest.
|
||||
///
|
||||
/// FIXME(#139660): After the libtest dependency is removed, consider making
|
||||
/// bootstrap specify the number of threads on the command-line, instead of
|
||||
/// propagating the `RUST_TEST_THREADS` environment variable.
|
||||
/// FIXME(#139660): After the libtest dependency is removed, consider making bootstrap specify the
|
||||
/// number of threads on the command-line, instead of propagating the `RUST_TEST_THREADS`
|
||||
/// environment variable.
|
||||
fn get_concurrency() -> usize {
|
||||
if let Ok(value) = env::var("RUST_TEST_THREADS") {
|
||||
match value.parse::<NonZero<usize>>().ok() {
|
||||
|
|
|
|||
|
|
@ -242,9 +242,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
|
||||
let target = opt_str2(matches.opt_str("target"));
|
||||
let android_cross_path = opt_path(matches, "android-cross-path");
|
||||
// FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config!
|
||||
let (cdb, cdb_version) = debuggers::analyze_cdb(matches.opt_str("cdb"), &target);
|
||||
// FIXME: `gdb_version` is *derived* from gdb, but it's *not* technically a config!
|
||||
let (gdb, gdb_version) =
|
||||
debuggers::analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
|
||||
// FIXME: `lldb_version` is *derived* from lldb, but it's *not* technically a config!
|
||||
let lldb_version =
|
||||
matches.opt_str("lldb-version").as_deref().and_then(debuggers::extract_lldb_version);
|
||||
let color = match matches.opt_str("color").as_deref() {
|
||||
|
|
@ -253,6 +256,9 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
Some("never") => ColorConfig::NeverColor,
|
||||
Some(x) => panic!("argument for --color must be auto, always, or never, but found `{}`", x),
|
||||
};
|
||||
// FIXME: this is very questionable, we really should be obtaining LLVM version info from
|
||||
// `bootstrap`, and not trying to be figuring out that in `compiletest` by running the
|
||||
// `FileCheck` binary.
|
||||
let llvm_version =
|
||||
matches.opt_str("llvm-version").as_deref().map(directives::extract_llvm_version).or_else(
|
||||
|| directives::extract_llvm_version_from_binary(&matches.opt_str("llvm-filecheck")?),
|
||||
|
|
@ -370,6 +376,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
mode.parse::<PassMode>()
|
||||
.unwrap_or_else(|_| panic!("unknown `--pass` option `{}` given", mode))
|
||||
}),
|
||||
// FIXME: this run scheme is... confusing.
|
||||
run: matches.opt_str("run").and_then(|mode| match mode.as_str() {
|
||||
"auto" => None,
|
||||
"always" => Some(true),
|
||||
|
|
@ -545,6 +552,10 @@ pub fn run_tests(config: Arc<Config>) {
|
|||
Some(Debugger::Cdb) => configs.extend(debuggers::configure_cdb(&config)),
|
||||
Some(Debugger::Gdb) => configs.extend(debuggers::configure_gdb(&config)),
|
||||
Some(Debugger::Lldb) => configs.extend(debuggers::configure_lldb(&config)),
|
||||
// FIXME: the *implicit* debugger discovery makes it really difficult to control
|
||||
// which {`cdb`, `gdb`, `lldb`} are used. These should **not** be implicitly
|
||||
// discovered by `compiletest`; these should be explicit `bootstrap` configuration
|
||||
// options that are passed to `compiletest`!
|
||||
None => {
|
||||
configs.extend(debuggers::configure_cdb(&config));
|
||||
configs.extend(debuggers::configure_gdb(&config));
|
||||
|
|
|
|||
|
|
@ -121,6 +121,8 @@ pub fn run(config: Arc<Config>, testpaths: &TestPaths, revision: Option<&str>) {
|
|||
}
|
||||
|
||||
_ => {
|
||||
// FIXME: this logic seems strange as well.
|
||||
|
||||
// android has its own gdb handling
|
||||
if config.debugger == Some(Debugger::Gdb) && config.gdb.is_none() {
|
||||
panic!("gdb not available but debuginfo gdb debuginfo test requested");
|
||||
|
|
@ -1055,18 +1057,20 @@ impl<'test> TestCx<'test> {
|
|||
let proc_res = match &*self.config.target {
|
||||
// This is pretty similar to below, we're transforming:
|
||||
//
|
||||
// program arg1 arg2
|
||||
// ```text
|
||||
// program arg1 arg2
|
||||
// ```
|
||||
//
|
||||
// into
|
||||
//
|
||||
// remote-test-client run program 2 support-lib.so support-lib2.so arg1 arg2
|
||||
// ```text
|
||||
// remote-test-client run program 2 support-lib.so support-lib2.so arg1 arg2
|
||||
// ```
|
||||
//
|
||||
// The test-client program will upload `program` to the emulator
|
||||
// along with all other support libraries listed (in this case
|
||||
// `support-lib.so` and `support-lib2.so`. It will then execute
|
||||
// the program on the emulator with the arguments specified
|
||||
// (in the environment we give the process) and then report back
|
||||
// the same result.
|
||||
// The test-client program will upload `program` to the emulator along with all other
|
||||
// support libraries listed (in this case `support-lib.so` and `support-lib2.so`. It
|
||||
// will then execute the program on the emulator with the arguments specified (in the
|
||||
// environment we give the process) and then report back the same result.
|
||||
_ if self.config.remote_test_client.is_some() => {
|
||||
let aux_dir = self.aux_output_dir_name();
|
||||
let ProcArgs { prog, args } = self.make_run_args();
|
||||
|
|
@ -1532,6 +1536,8 @@ impl<'test> TestCx<'test> {
|
|||
));
|
||||
|
||||
// Optionally prevent default --sysroot if specified in test compile-flags.
|
||||
//
|
||||
// FIXME: I feel like this logic is fairly sus.
|
||||
if !self.props.compile_flags.iter().any(|flag| flag.starts_with("--sysroot"))
|
||||
&& !self.config.host_rustcflags.iter().any(|flag| flag == "--sysroot")
|
||||
{
|
||||
|
|
@ -1918,7 +1924,8 @@ impl<'test> TestCx<'test> {
|
|||
|
||||
fn dump_output_file(&self, out: &str, extension: &str) {
|
||||
let outfile = self.make_out_name(extension);
|
||||
fs::write(outfile.as_std_path(), out).unwrap();
|
||||
fs::write(outfile.as_std_path(), out)
|
||||
.unwrap_or_else(|err| panic!("failed to write {outfile}: {err:?}"));
|
||||
}
|
||||
|
||||
/// Creates a filename for output with the given extension.
|
||||
|
|
|
|||
|
|
@ -322,6 +322,8 @@ impl TestCx<'_> {
|
|||
&["-quiet".as_ref(), "-batch".as_ref(), "-nx".as_ref(), &debugger_script];
|
||||
|
||||
let mut gdb = Command::new(self.config.gdb.as_ref().unwrap());
|
||||
|
||||
// FIXME: we are propagating `PYTHONPATH` from the environment, not a compiletest flag!
|
||||
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
|
||||
format!("{pp}:{rust_pp_module_abs_path}")
|
||||
} else {
|
||||
|
|
@ -443,6 +445,8 @@ impl TestCx<'_> {
|
|||
fn run_lldb(&self, test_executable: &Utf8Path, debugger_script: &Utf8Path) -> ProcRes {
|
||||
// Prepare the lldb_batchmode which executes the debugger script
|
||||
let lldb_script_path = self.config.src_root.join("src/etc/lldb_batchmode.py");
|
||||
|
||||
// FIXME: `PYTHONPATH` takes precedence over the flag...?
|
||||
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
|
||||
format!("{pp}:{}", self.config.lldb_python_dir.as_ref().unwrap())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -359,6 +359,63 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
interp_ok(Scalar::from_i32(0))
|
||||
}
|
||||
|
||||
fn clock_nanosleep(
|
||||
&mut self,
|
||||
clock_id: &OpTy<'tcx>,
|
||||
flags: &OpTy<'tcx>,
|
||||
timespec: &OpTy<'tcx>,
|
||||
rem: &OpTy<'tcx>,
|
||||
) -> InterpResult<'tcx, Scalar> {
|
||||
let this = self.eval_context_mut();
|
||||
let clockid_t_size = this.libc_ty_layout("clockid_t").size;
|
||||
|
||||
let clock_id = this.read_scalar(clock_id)?.to_int(clockid_t_size)?;
|
||||
let timespec = this.deref_pointer_as(timespec, this.libc_ty_layout("timespec"))?;
|
||||
let flags = this.read_scalar(flags)?.to_i32()?;
|
||||
let _rem = this.read_pointer(rem)?; // Signal handlers are not supported, so rem will never be written to.
|
||||
|
||||
// The standard lib through sleep_until only needs CLOCK_MONOTONIC
|
||||
if clock_id != this.eval_libc("CLOCK_MONOTONIC").to_int(clockid_t_size)? {
|
||||
throw_unsup_format!("clock_nanosleep: only CLOCK_MONOTONIC is supported");
|
||||
}
|
||||
|
||||
let duration = match this.read_timespec(×pec)? {
|
||||
Some(duration) => duration,
|
||||
None => {
|
||||
return this.set_last_error_and_return_i32(LibcError("EINVAL"));
|
||||
}
|
||||
};
|
||||
|
||||
let timeout_anchor = if flags == 0 {
|
||||
// No flags set, the timespec should be interperted as a duration
|
||||
// to sleep for
|
||||
TimeoutAnchor::Relative
|
||||
} else if flags == this.eval_libc_i32("TIMER_ABSTIME") {
|
||||
// Only flag TIMER_ABSTIME set, the timespec should be interperted as
|
||||
// an absolute time.
|
||||
TimeoutAnchor::Absolute
|
||||
} else {
|
||||
// The standard lib (through `sleep_until`) only needs TIMER_ABSTIME
|
||||
throw_unsup_format!(
|
||||
"`clock_nanosleep` unsupported flags {flags}, only no flags or \
|
||||
TIMER_ABSTIME is supported"
|
||||
);
|
||||
};
|
||||
|
||||
this.block_thread(
|
||||
BlockReason::Sleep,
|
||||
Some((TimeoutClock::Monotonic, timeout_anchor, duration)),
|
||||
callback!(
|
||||
@capture<'tcx> {}
|
||||
|_this, unblock: UnblockKind| {
|
||||
assert_eq!(unblock, UnblockKind::TimedOut);
|
||||
interp_ok(())
|
||||
}
|
||||
),
|
||||
);
|
||||
interp_ok(Scalar::from_i32(0))
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
fn Sleep(&mut self, timeout: &OpTy<'tcx>) -> InterpResult<'tcx> {
|
||||
let this = self.eval_context_mut();
|
||||
|
|
|
|||
|
|
@ -967,6 +967,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
let result = this.nanosleep(duration, rem)?;
|
||||
this.write_scalar(result, dest)?;
|
||||
}
|
||||
"clock_nanosleep" => {
|
||||
// Currently this function does not exist on all Unixes, e.g. on macOS.
|
||||
this.check_target_os(
|
||||
&["freebsd", "linux", "android", "solaris", "illumos"],
|
||||
link_name,
|
||||
)?;
|
||||
let [clock_id, flags, req, rem] =
|
||||
this.check_shim(abi, CanonAbi::C, link_name, args)?;
|
||||
let result = this.clock_nanosleep(clock_id, flags, req, rem)?;
|
||||
this.write_scalar(result, dest)?;
|
||||
}
|
||||
"sched_getaffinity" => {
|
||||
// Currently this function does not exist on all Unixes, e.g. on macOS.
|
||||
this.check_target_os(&["linux", "freebsd", "android"], link_name)?;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//@ignore-target: windows # no libc time APIs on Windows
|
||||
//@compile-flags: -Zmiri-disable-isolation
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{env, mem, ptr};
|
||||
|
||||
fn main() {
|
||||
|
|
@ -20,6 +21,19 @@ fn main() {
|
|||
test_localtime_r_future_32b();
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
test_localtime_r_future_64b();
|
||||
|
||||
test_nanosleep();
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos"
|
||||
))]
|
||||
{
|
||||
test_clock_nanosleep::absolute();
|
||||
test_clock_nanosleep::relative();
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests whether clock support exists at all
|
||||
|
|
@ -315,3 +329,103 @@ fn test_localtime_r_multiple_calls_deduplication() {
|
|||
NUM_CALLS - 1
|
||||
);
|
||||
}
|
||||
|
||||
fn test_nanosleep() {
|
||||
let start_test_sleep = Instant::now();
|
||||
let duration_zero = libc::timespec { tv_sec: 0, tv_nsec: 0 };
|
||||
let remainder = ptr::null_mut::<libc::timespec>();
|
||||
let is_error = unsafe { libc::nanosleep(&duration_zero, remainder) };
|
||||
assert_eq!(is_error, 0);
|
||||
assert!(start_test_sleep.elapsed() < Duration::from_millis(10));
|
||||
|
||||
let start_test_sleep = Instant::now();
|
||||
let duration_100_millis = libc::timespec { tv_sec: 0, tv_nsec: 1_000_000_000 / 10 };
|
||||
let remainder = ptr::null_mut::<libc::timespec>();
|
||||
let is_error = unsafe { libc::nanosleep(&duration_100_millis, remainder) };
|
||||
assert_eq!(is_error, 0);
|
||||
assert!(start_test_sleep.elapsed() > Duration::from_millis(100));
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos"
|
||||
))]
|
||||
mod test_clock_nanosleep {
|
||||
use super::*;
|
||||
|
||||
/// Helper function used to create an instant in the future
|
||||
fn add_100_millis(mut ts: libc::timespec) -> libc::timespec {
|
||||
// While tv_nsec has type `c_long` tv_sec has type `time_t`. These might
|
||||
// end up as different types (for example: like i32 and i64).
|
||||
const SECOND: libc::c_long = 1_000_000_000;
|
||||
ts.tv_nsec += SECOND / 10;
|
||||
// If this pushes tv_nsec to SECOND or higher, we need to overflow to tv_sec.
|
||||
ts.tv_sec += (ts.tv_nsec / SECOND) as libc::time_t;
|
||||
ts.tv_nsec %= SECOND;
|
||||
ts
|
||||
}
|
||||
|
||||
/// Helper function to get the current time for testing relative sleeps
|
||||
fn timespec_now(clock: libc::clockid_t) -> libc::timespec {
|
||||
let mut timespec = mem::MaybeUninit::<libc::timespec>::uninit();
|
||||
let is_error = unsafe { libc::clock_gettime(clock, timespec.as_mut_ptr()) };
|
||||
assert_eq!(is_error, 0);
|
||||
unsafe { timespec.assume_init() }
|
||||
}
|
||||
|
||||
pub fn absolute() {
|
||||
let start_test_sleep = Instant::now();
|
||||
let before_start = libc::timespec { tv_sec: 0, tv_nsec: 0 };
|
||||
let remainder = ptr::null_mut::<libc::timespec>();
|
||||
let error = unsafe {
|
||||
// this will not sleep since unix time zero is in the past
|
||||
libc::clock_nanosleep(
|
||||
libc::CLOCK_MONOTONIC,
|
||||
libc::TIMER_ABSTIME,
|
||||
&before_start,
|
||||
remainder,
|
||||
)
|
||||
};
|
||||
assert_eq!(error, 0);
|
||||
assert!(start_test_sleep.elapsed() < Duration::from_millis(10));
|
||||
|
||||
let start_test_sleep = Instant::now();
|
||||
let hunderd_millis_after_start = add_100_millis(timespec_now(libc::CLOCK_MONOTONIC));
|
||||
let remainder = ptr::null_mut::<libc::timespec>();
|
||||
let error = unsafe {
|
||||
libc::clock_nanosleep(
|
||||
libc::CLOCK_MONOTONIC,
|
||||
libc::TIMER_ABSTIME,
|
||||
&hunderd_millis_after_start,
|
||||
remainder,
|
||||
)
|
||||
};
|
||||
assert_eq!(error, 0);
|
||||
assert!(start_test_sleep.elapsed() > Duration::from_millis(100));
|
||||
}
|
||||
|
||||
pub fn relative() {
|
||||
const NO_FLAGS: i32 = 0;
|
||||
|
||||
let start_test_sleep = Instant::now();
|
||||
let duration_zero = libc::timespec { tv_sec: 0, tv_nsec: 0 };
|
||||
let remainder = ptr::null_mut::<libc::timespec>();
|
||||
let error = unsafe {
|
||||
libc::clock_nanosleep(libc::CLOCK_MONOTONIC, NO_FLAGS, &duration_zero, remainder)
|
||||
};
|
||||
assert_eq!(error, 0);
|
||||
assert!(start_test_sleep.elapsed() < Duration::from_millis(10));
|
||||
|
||||
let start_test_sleep = Instant::now();
|
||||
let duration_100_millis = libc::timespec { tv_sec: 0, tv_nsec: 1_000_000_000 / 10 };
|
||||
let remainder = ptr::null_mut::<libc::timespec>();
|
||||
let error = unsafe {
|
||||
libc::clock_nanosleep(libc::CLOCK_MONOTONIC, NO_FLAGS, &duration_100_millis, remainder)
|
||||
};
|
||||
assert_eq!(error, 0);
|
||||
assert!(start_test_sleep.elapsed() > Duration::from_millis(100));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//@compile-flags: -Zmiri-disable-isolation
|
||||
#![feature(thread_sleep_until)]
|
||||
|
||||
use std::time::{Duration, Instant, SystemTime};
|
||||
|
||||
|
|
@ -15,6 +16,14 @@ fn test_sleep() {
|
|||
assert!((after - before).as_millis() >= 100);
|
||||
}
|
||||
|
||||
fn test_sleep_until() {
|
||||
let before = Instant::now();
|
||||
let hunderd_millis_after_start = before + Duration::from_millis(100);
|
||||
std::thread::sleep_until(hunderd_millis_after_start);
|
||||
let after = Instant::now();
|
||||
assert!((after - before).as_millis() >= 100);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Check `SystemTime`.
|
||||
let now1 = SystemTime::now();
|
||||
|
|
@ -49,4 +58,5 @@ fn main() {
|
|||
duration_sanity(diff);
|
||||
|
||||
test_sleep();
|
||||
test_sleep_until();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,9 +156,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.27"
|
||||
version = "1.2.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
|
||||
checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -65,6 +65,13 @@ fn check_impl(
|
|||
None => vec![],
|
||||
};
|
||||
|
||||
if lint_args.contains(&"spellcheck:fix") {
|
||||
return Err(Error::Generic(
|
||||
"`spellcheck:fix` is no longer valid, use `--extra=check=spellcheck --bless`"
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
let python_all = lint_args.contains(&"py");
|
||||
let python_lint = lint_args.contains(&"py:lint") || python_all;
|
||||
let python_fmt = lint_args.contains(&"py:fmt") || python_all;
|
||||
|
|
@ -72,8 +79,7 @@ fn check_impl(
|
|||
let shell_lint = lint_args.contains(&"shell:lint") || shell_all;
|
||||
let cpp_all = lint_args.contains(&"cpp");
|
||||
let cpp_fmt = lint_args.contains(&"cpp:fmt") || cpp_all;
|
||||
let spellcheck_all = lint_args.contains(&"spellcheck");
|
||||
let spellcheck_fix = lint_args.contains(&"spellcheck:fix");
|
||||
let spellcheck = lint_args.contains(&"spellcheck");
|
||||
|
||||
let mut py_path = None;
|
||||
|
||||
|
|
@ -226,7 +232,7 @@ fn check_impl(
|
|||
shellcheck_runner(&merge_args(&cfg_args, &file_args_shc))?;
|
||||
}
|
||||
|
||||
if spellcheck_all || spellcheck_fix {
|
||||
if spellcheck {
|
||||
let config_path = root_path.join("typos.toml");
|
||||
// sync target files with .github/workflows/spellcheck.yml
|
||||
let mut args = vec![
|
||||
|
|
@ -238,11 +244,11 @@ fn check_impl(
|
|||
"./src/librustdoc",
|
||||
];
|
||||
|
||||
if spellcheck_all {
|
||||
eprintln!("spellcheck files");
|
||||
} else if spellcheck_fix {
|
||||
if bless {
|
||||
eprintln!("spellcheck files and fix");
|
||||
args.push("--write-changes");
|
||||
} else {
|
||||
eprintln!("spellcheck files");
|
||||
}
|
||||
spellcheck_runner(&args)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -276,7 +276,6 @@ ui/auto-traits/issue-23080-2.rs
|
|||
ui/auto-traits/issue-23080.rs
|
||||
ui/auto-traits/issue-83857-ub.rs
|
||||
ui/auto-traits/issue-84075.rs
|
||||
ui/auxiliary/issue-16822.rs
|
||||
ui/bench/issue-32062.rs
|
||||
ui/binding/issue-40402-1.rs
|
||||
ui/binding/issue-40402-2.rs
|
||||
|
|
@ -1367,9 +1366,6 @@ ui/infinite/issue-41731-infinite-macro-println.rs
|
|||
ui/intrinsics/issue-28575.rs
|
||||
ui/intrinsics/issue-84297-reifying-copy.rs
|
||||
ui/invalid/issue-114435-layout-type-err.rs
|
||||
ui/issue-15924.rs
|
||||
ui/issue-16822.rs
|
||||
ui/issues-71798.rs
|
||||
ui/issues/auxiliary/issue-11224.rs
|
||||
ui/issues/auxiliary/issue-11508.rs
|
||||
ui/issues/auxiliary/issue-11529.rs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue