Merge from rustc

This commit is contained in:
The Miri Cronjob Bot 2025-07-17 05:06:45 +00:00
commit 52db0ce24f
226 changed files with 3053 additions and 3111 deletions

View file

@ -11,7 +11,6 @@ pub(crate) mod llvm;
pub(crate) mod perf;
pub(crate) mod run;
pub(crate) mod setup;
pub(crate) mod suggest;
pub(crate) mod synthetic_targets;
pub(crate) mod test;
pub(crate) mod tool;

View file

@ -1,68 +0,0 @@
//! Attempt to magically identify good tests to run
use std::path::PathBuf;
use std::str::FromStr;
use clap::Parser;
use crate::core::build_steps::tool::Tool;
use crate::core::builder::Builder;
/// Suggests a list of possible `x.py` commands to run based on modified files in branch.
pub fn suggest(builder: &Builder<'_>, run: bool) {
let git_config = builder.config.git_config();
let suggestions = builder
.tool_cmd(Tool::SuggestTests)
.env("SUGGEST_TESTS_NIGHTLY_BRANCH", git_config.nightly_branch)
.env("SUGGEST_TESTS_MERGE_COMMIT_EMAIL", git_config.git_merge_commit_email)
.run_capture_stdout(builder)
.stdout();
let suggestions = suggestions
.lines()
.map(|line| {
let mut sections = line.split_ascii_whitespace();
// this code expects one suggestion per line in the following format:
// <x_subcommand> {some number of flags} [optional stage number]
let cmd = sections.next().unwrap();
let stage = sections.next_back().and_then(|s| str::parse(s).ok());
let paths: Vec<PathBuf> = sections.map(|p| PathBuf::from_str(p).unwrap()).collect();
(cmd, stage, paths)
})
.collect::<Vec<_>>();
if !suggestions.is_empty() {
println!("==== SUGGESTIONS ====");
for sug in &suggestions {
print!("x {} ", sug.0);
if let Some(stage) = sug.1 {
print!("--stage {stage} ");
}
for path in &sug.2 {
print!("{} ", path.display());
}
println!();
}
println!("=====================");
} else {
println!("No suggestions found!");
return;
}
if run {
for sug in suggestions {
let mut build: crate::Build = builder.build.clone();
build.config.paths = sug.2;
build.config.cmd = crate::core::config::flags::Flags::parse_from(["x.py", sug.0]).cmd;
if let Some(stage) = sug.1 {
build.config.stage = stage;
}
build.build();
}
} else {
println!("HELP: consider using the `--run` flag to automatically run suggested tests");
}
}

View file

@ -47,12 +47,11 @@ impl Step for CrateBootstrap {
const DEFAULT: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
// This step is responsible for several different tool paths. By default
// it will test all of them, but requesting specific tools on the
// command-line (e.g. `./x test suggest-tests`) will test only the
// specified tools.
// This step is responsible for several different tool paths.
//
// By default, it will test all of them, but requesting specific tools on the command-line
// (e.g. `./x test src/tools/coverage-dump`) will test only the specified tools.
run.path("src/tools/jsondoclint")
.path("src/tools/suggest-tests")
.path("src/tools/replace-version-placeholder")
.path("src/tools/coverage-dump")
// We want `./x test tidy` to _run_ the tidy tool, not its tests.

View file

@ -517,7 +517,6 @@ bootstrap_tool!(
ReplaceVersionPlaceholder, "src/tools/replace-version-placeholder", "replace-version-placeholder";
CollectLicenseMetadata, "src/tools/collect-license-metadata", "collect-license-metadata";
GenerateCopyright, "src/tools/generate-copyright", "generate-copyright";
SuggestTests, "src/tools/suggest-tests", "suggest-tests";
GenerateWindowsSys, "src/tools/generate-windows-sys", "generate-windows-sys";
// rustdoc-gui-test has a crate dependency on compiletest, so it needs the same unstable features.
RustdocGUITest, "src/tools/rustdoc-gui-test", "rustdoc-gui-test", is_unstable_tool = true, allow_features = COMPILETEST_ALLOW_FEATURES;

View file

@ -113,7 +113,7 @@ impl Cargo {
match cmd_kind {
// No need to configure the target linker for these command types.
Kind::Clean | Kind::Check | Kind::Suggest | Kind::Format | Kind::Setup => {}
Kind::Clean | Kind::Check | Kind::Format | Kind::Setup => {}
_ => {
cargo.configure_linker(builder, mode);
}

View file

@ -845,7 +845,6 @@ pub enum Kind {
#[value(alias = "r")]
Run,
Setup,
Suggest,
Vendor,
Perf,
}
@ -869,7 +868,6 @@ impl Kind {
Kind::Install => "install",
Kind::Run => "run",
Kind::Setup => "setup",
Kind::Suggest => "suggest",
Kind::Vendor => "vendor",
Kind::Perf => "perf",
}
@ -881,7 +879,6 @@ impl Kind {
Kind::Bench => "Benchmarking",
Kind::Doc => "Documenting",
Kind::Run => "Running",
Kind::Suggest => "Suggesting",
Kind::Clippy => "Linting",
Kind::Perf => "Profiling & benchmarking",
_ => {
@ -1201,7 +1198,7 @@ impl<'a> Builder<'a> {
Kind::Clean => describe!(clean::CleanAll, clean::Rustc, clean::Std),
Kind::Vendor => describe!(vendor::Vendor),
// special-cased in Build::build()
Kind::Format | Kind::Suggest | Kind::Perf => vec![],
Kind::Format | Kind::Perf => vec![],
Kind::MiriTest | Kind::MiriSetup => unreachable!(),
}
}
@ -1269,7 +1266,6 @@ impl<'a> Builder<'a> {
Subcommand::Run { .. } => (Kind::Run, &paths[..]),
Subcommand::Clean { .. } => (Kind::Clean, &paths[..]),
Subcommand::Format { .. } => (Kind::Format, &[][..]),
Subcommand::Suggest { .. } => (Kind::Suggest, &[][..]),
Subcommand::Setup { profile: ref path } => (
Kind::Setup,
path.as_ref().map_or([].as_slice(), |path| std::slice::from_ref(path)),

View file

@ -1050,7 +1050,6 @@ impl Config {
| Subcommand::Run { .. }
| Subcommand::Setup { .. }
| Subcommand::Format { .. }
| Subcommand::Suggest { .. }
| Subcommand::Vendor { .. } => flags_stage.unwrap_or(0),
};
@ -1098,7 +1097,6 @@ impl Config {
| Subcommand::Run { .. }
| Subcommand::Setup { .. }
| Subcommand::Format { .. }
| Subcommand::Suggest { .. }
| Subcommand::Vendor { .. }
| Subcommand::Perf { .. } => {}
}

View file

@ -481,13 +481,6 @@ Arguments:
#[arg(value_name = "<PROFILE>|hook|editor|link")]
profile: Option<PathBuf>,
},
/// Suggest a subset of tests to run, based on modified files
#[command(long_about = "\n")]
Suggest {
/// run suggested tests
#[arg(long)]
run: bool,
},
/// Vendor dependencies
Vendor {
/// Additional `Cargo.toml` to sync and vendor
@ -518,7 +511,6 @@ impl Subcommand {
Subcommand::Install => Kind::Install,
Subcommand::Run { .. } => Kind::Run,
Subcommand::Setup { .. } => Kind::Setup,
Subcommand::Suggest { .. } => Kind::Suggest,
Subcommand::Vendor { .. } => Kind::Vendor,
Subcommand::Perf { .. } => Kind::Perf,
}

View file

@ -216,7 +216,6 @@ than building it.
build.config.cmd,
Subcommand::Clean { .. }
| Subcommand::Check { .. }
| Subcommand::Suggest { .. }
| Subcommand::Format { .. }
| Subcommand::Setup { .. }
);

View file

@ -651,11 +651,9 @@ impl Build {
// Handle hard-coded subcommands.
{
#[cfg(feature = "tracing")]
let _hardcoded_span = span!(
tracing::Level::DEBUG,
"handling hardcoded subcommands (Format, Suggest, Perf)"
)
.entered();
let _hardcoded_span =
span!(tracing::Level::DEBUG, "handling hardcoded subcommands (Format, Perf)")
.entered();
match &self.config.cmd {
Subcommand::Format { check, all } => {
@ -666,9 +664,6 @@ impl Build {
&self.config.paths,
);
}
Subcommand::Suggest { run } => {
return core::build_steps::suggest::suggest(&builder::Builder::new(self), *run);
}
Subcommand::Perf(args) => {
return core::build_steps::perf::perf(&builder::Builder::new(self), args);
}

View file

@ -67,7 +67,6 @@ pub fn fill_compilers(build: &mut Build) {
// We don't need to check cross targets for these commands.
crate::Subcommand::Clean { .. }
| crate::Subcommand::Check { .. }
| crate::Subcommand::Suggest { .. }
| crate::Subcommand::Format { .. }
| crate::Subcommand::Setup { .. } => {
build.hosts.iter().cloned().chain(iter::once(build.host_target)).collect()
@ -221,10 +220,15 @@ fn default_compiler(
}
t if t.contains("-wasi") => {
let root = build
.wasi_sdk_path
.as_ref()
.expect("WASI_SDK_PATH mut be configured for a -wasi target");
let root = if let Some(path) = build.wasi_sdk_path.as_ref() {
path
} else {
if build.config.is_running_on_ci {
panic!("ERROR: WASI_SDK_PATH must be configured for a -wasi target on CI");
}
println!("WARNING: WASI_SDK_PATH not set, using default cc/cxx compiler");
return None;
};
let compiler = match compiler {
Language::C => format!("{t}-clang"),
Language::CPlusPlus => format!("{t}-clang++"),

View file

@ -476,4 +476,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "Option `tool.TOOL_NAME.features` now works on any subcommand, not just `build`.",
},
ChangeInfo {
change_id: 143630,
severity: ChangeSeverity::Warning,
summary: "The current `./x suggest` implementation has been removed due to it being quite broken and a lack of maintenance bandwidth, with no prejudice against re-implementing it in a more maintainable form.",
},
];

View file

@ -43,7 +43,7 @@ pub(crate) struct BuildMetrics {
state: RefCell<MetricsState>,
}
/// NOTE: this isn't really cloning anything, but `x suggest` doesn't need metrics so this is probably ok.
// NOTE: this isn't really cloning anything, but necessary for `Build: Clone`.
impl Clone for BuildMetrics {
fn clone(&self) -> Self {
Self::init()

@ -1 +1 @@
Subproject commit ef1ce8f87a8b18feb1b6a9cf9a4939a79bde6795
Subproject commit b2d1a0821e12a676b496d61891b8e3d374a8e832

@ -1 +1 @@
Subproject commit 41f688a598a5022b749e23d37f3c524f6a0b28e1
Subproject commit fe88fbb68391a465680dd91109f0a151a1676f3e

@ -1 +1 @@
Subproject commit 8b61acfaea822e9ac926190bc8f15791c33336e8
Subproject commit 3ff384320598bbe8d8cfe5cb8f18f78a3a3e6b15

@ -1 +1 @@
Subproject commit e9fc99f107840813916f62e16b3f6d9556e1f2d8
Subproject commit 1f45bd41fa6c17b7c048ed6bfe5f168c4311206a

@ -1 +1 @@
Subproject commit 288b4e4948add43f387cad35adc7b1c54ca6fe12
Subproject commit e386be5f44af711854207c11fdd61bb576270b04

View file

@ -35,7 +35,6 @@
- [Cranelift codegen backend](./tests/codegen-backend-tests/cg_clif.md)
- [GCC codegen backend](./tests/codegen-backend-tests/cg_gcc.md)
- [Performance testing](./tests/perf.md)
- [Suggest tests tool](./tests/suggest-tests.md)
- [Misc info](./tests/misc.md)
- [Debugging the compiler](./compiler-debugging.md)
- [Using the tracing/logging instrumentation](./tracing.md)

View file

@ -61,9 +61,6 @@ and check the output.
Use `--bless` if you've made a change and want to update the `.stderr` files
with the new output.
> `./x suggest` can also be helpful for suggesting which tests to run after a
> change.
Congrats, you are now ready to make a change to the compiler! If you have more
questions, [the full chapter](./how-to-build-and-run.md) might contain the
answers, and if it doesn't, feel free to ask for help on

View file

@ -270,23 +270,6 @@ run the tests at some later time. You can then use `git bisect` to track down
is that you are left with a fairly fine-grained set of commits at the end, all
of which build and pass tests. This often helps reviewing.
## `x suggest`
The `x suggest` subcommand suggests (and runs) a subset of the extensive
`rust-lang/rust` tests based on files you have changed. This is especially
useful for new contributors who have not mastered the arcane `x` flags yet and
more experienced contributors as a shorthand for reducing mental effort. In all
cases it is useful not to run the full tests (which can take on the order of
tens of minutes) and just run a subset which are relevant to your changes. For
example, running `tidy` and `linkchecker` is useful when editing Markdown files,
whereas UI tests are much less likely to be helpful. While `x suggest` is a
useful tool, it does not guarantee perfect coverage (just as PR CI isn't a
substitute for bors). See the [dedicated chapter](../tests/suggest-tests.md) for
more information and contribution instructions.
Please note that `x suggest` is in a beta state currently and the tests that it
will suggest are limited.
## Configuring `rustup` to use nightly
Some parts of the bootstrap process uses pinned, nightly versions of tools like

View file

@ -1,59 +0,0 @@
# Suggest tests tool
This chapter is about the internals of and contribution instructions for the
`suggest-tests` tool. For a high-level overview of the tool, see [this
section](../building/suggested.md#x-suggest). This tool is currently in a beta
state and is tracked by [this](https://github.com/rust-lang/rust/issues/109933)
issue on Github. Currently the number of tests it will suggest are very limited
in scope, we are looking to expand this (contributions welcome!).
## Internals
The tool is defined in a separate crate
([`src/tools/suggest-tests`](https://github.com/rust-lang/rust/blob/master/src/tools/suggest-tests))
which outputs suggestions which are parsed by a shim in bootstrap
([`src/bootstrap/src/core/build_steps/suggest.rs`](https://github.com/rust-lang/rust/blob/master/src/bootstrap/src/core/build_steps/suggest.rs)).
The only notable thing the bootstrap shim does is (when invoked with the `--run`
flag) use bootstrap's internal mechanisms to create a new `Builder` and uses it
to invoke the suggested commands. The `suggest-tests` crate is where the fun
happens, two kinds of suggestions are defined: "static" and "dynamic"
suggestions.
### Static suggestions
Defined
[here](https://github.com/rust-lang/rust/blob/master/src/tools/suggest-tests/src/static_suggestions.rs).
Static suggestions are simple: they are just
[globs](https://crates.io/crates/glob) which map to a `x` command. In
`suggest-tests`, this is implemented with a simple `macro_rules` macro.
### Dynamic suggestions
Defined
[here](https://github.com/rust-lang/rust/blob/master/src/tools/suggest-tests/src/dynamic_suggestions.rs).
These are more complicated than static suggestions and are implemented as
functions with the following signature: `fn(&Path) -> Vec<Suggestion>`. In other
words, each suggestion takes a path to a modified file and (after running
arbitrary Rust code) can return any number of suggestions, or none. Dynamic
suggestions are useful for situations where fine-grained control over
suggestions is needed. For example, modifications to the `compiler/xyz/` path
should trigger the `x test compiler/xyz` suggestion. In the future, dynamic
suggestions might even read file contents to determine if (what) tests should
run.
## Adding a suggestion
The following steps should serve as a rough guide to add suggestions to
`suggest-tests` (very welcome!):
1. Determine the rules for your suggestion. Is it simple and operates only on a
single path or does it match globs? Does it need fine-grained control over
the resulting command or does "one size fit all"?
2. Based on the previous step, decide if your suggestion should be implemented
as either static or dynamic.
3. Implement the suggestion. If it is dynamic then a test is highly recommended,
to verify that your logic is correct and to give an example of the
suggestion. See the
[tests.rs](https://github.com/rust-lang/rust/blob/master/src/tools/suggest-tests/src/tests.rs)
file.
4. Open a PR implementing your suggestion. **(TODO: add example PR)**

View file

@ -32,10 +32,11 @@ are built for NetBSD 8.x but also work on newer OS versions).
## Target Maintainers
[@he32](https://github.com/he32)
[@0323pin](https://github.com/0323pin)
Further contacts:
- [NetBSD/pkgsrc-wip's rust](https://github.com/NetBSD/pkgsrc-wip/blob/master/rust185/Makefile) maintainer (see MAINTAINER variable). This package is part of "pkgsrc work-in-progress" and is used for deployment and testing of new versions of rust
- [NetBSD/pkgsrc-wip's rust](https://github.com/NetBSD/pkgsrc-wip/blob/master/rust188/Makefile) maintainer (see MAINTAINER variable). This package is part of "pkgsrc work-in-progress" and is used for deployment and testing of new versions of rust. Note that we have the convention of having multiple rust versions active in pkgsrc-wip at any one time, so the version number is part of the directory name, and from time to time old versions are culled so this is not a fully "stable" link.
- [NetBSD's pkgsrc lang/rust](https://github.com/NetBSD/pkgsrc/tree/trunk/lang/rust) for the "proper" package in pkgsrc.
- [NetBSD's pkgsrc lang/rust-bin](https://github.com/NetBSD/pkgsrc/tree/trunk/lang/rust-bin) which re-uses the bootstrap kit as a binary distribution and therefore avoids the rather protracted native build time of rust itself

View file

@ -73,7 +73,6 @@ complete -c x -n "__fish_x_needs_command" -a "dist" -d 'Build distribution artif
complete -c x -n "__fish_x_needs_command" -a "install" -d 'Install distribution artifacts'
complete -c x -n "__fish_x_needs_command" -a "run" -d 'Run tools contained in this repository'
complete -c x -n "__fish_x_needs_command" -a "setup" -d 'Set up the environment for development'
complete -c x -n "__fish_x_needs_command" -a "suggest" -d 'Suggest a subset of tests to run, based on modified files'
complete -c x -n "__fish_x_needs_command" -a "vendor" -d 'Vendor dependencies'
complete -c x -n "__fish_x_needs_command" -a "perf" -d 'Perform profiling and benchmarking of the compiler using `rustc-perf`'
complete -c x -n "__fish_x_using_subcommand build" -l config -d 'TOML configuration file for build' -r -F
@ -599,42 +598,6 @@ complete -c x -n "__fish_x_using_subcommand setup" -l enable-bolt-settings -d 'E
complete -c x -n "__fish_x_using_subcommand setup" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
complete -c x -n "__fish_x_using_subcommand setup" -l skip-std-check-if-no-download-rustc -d 'Skip checking the standard library if `rust.download-rustc` isn\'t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers'
complete -c x -n "__fish_x_using_subcommand setup" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c x -n "__fish_x_using_subcommand suggest" -l config -d 'TOML configuration file for build' -r -F
complete -c x -n "__fish_x_using_subcommand suggest" -l build-dir -d 'Build directory, overrides `build.build-dir` in `bootstrap.toml`' -r -f -a "(__fish_complete_directories)"
complete -c x -n "__fish_x_using_subcommand suggest" -l build -d 'host target of the stage0 compiler' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l host -d 'host targets to build' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l target -d 'target targets to build' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l exclude -d 'build paths to exclude' -r -F
complete -c x -n "__fish_x_using_subcommand suggest" -l skip -d 'build paths to skip' -r -F
complete -c x -n "__fish_x_using_subcommand suggest" -l rustc-error-format -d 'rustc error format' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l on-fail -d 'command to run on failure' -r -f -a "(__fish_complete_command)"
complete -c x -n "__fish_x_using_subcommand suggest" -l stage -d 'stage to build (indicates compiler to use/test, e.g., stage 0 uses the bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l keep-stage -d 'stage(s) to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l keep-stage-std -d 'stage(s) of the standard library to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l src -d 'path to the root of the rust checkout' -r -f -a "(__fish_complete_directories)"
complete -c x -n "__fish_x_using_subcommand suggest" -s j -l jobs -d 'number of jobs to run in parallel' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l warnings -d 'if value is deny, will deny warnings if value is warn, will emit warnings otherwise, use the default configured behaviour' -r -f -a "{deny\t'',warn\t'',default\t''}"
complete -c x -n "__fish_x_using_subcommand suggest" -l color -d 'whether to use color in cargo and rustc output' -r -f -a "{always\t'',never\t'',auto\t''}"
complete -c x -n "__fish_x_using_subcommand suggest" -l rust-profile-generate -d 'generate PGO profile with rustc build' -r -F
complete -c x -n "__fish_x_using_subcommand suggest" -l rust-profile-use -d 'use PGO profile for rustc build' -r -F
complete -c x -n "__fish_x_using_subcommand suggest" -l llvm-profile-use -d 'use PGO profile for LLVM build' -r -F
complete -c x -n "__fish_x_using_subcommand suggest" -l reproducible-artifact -d 'Additional reproducible artifacts that should be added to the reproducible artifacts archive' -r
complete -c x -n "__fish_x_using_subcommand suggest" -l set -d 'override options in bootstrap.toml' -r -f
complete -c x -n "__fish_x_using_subcommand suggest" -l ci -d 'Make bootstrap to behave as it\'s running on the CI environment or not' -r -f -a "{true\t'',false\t''}"
complete -c x -n "__fish_x_using_subcommand suggest" -l run -d 'run suggested tests'
complete -c x -n "__fish_x_using_subcommand suggest" -s v -l verbose -d 'use verbose output (-vv for very verbose)'
complete -c x -n "__fish_x_using_subcommand suggest" -s i -l incremental -d 'use incremental compilation'
complete -c x -n "__fish_x_using_subcommand suggest" -l include-default-paths -d 'include default paths in addition to the provided ones'
complete -c x -n "__fish_x_using_subcommand suggest" -l dry-run -d 'dry run; don\'t build anything'
complete -c x -n "__fish_x_using_subcommand suggest" -l dump-bootstrap-shims -d 'Indicates whether to dump the work done from bootstrap shims'
complete -c x -n "__fish_x_using_subcommand suggest" -l json-output -d 'use message-format=json'
complete -c x -n "__fish_x_using_subcommand suggest" -l compile-time-deps -d 'only build proc-macros and build scripts (for rust-analyzer)'
complete -c x -n "__fish_x_using_subcommand suggest" -l bypass-bootstrap-lock -d 'Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)'
complete -c x -n "__fish_x_using_subcommand suggest" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
complete -c x -n "__fish_x_using_subcommand suggest" -l enable-bolt-settings -d 'Enable BOLT link flags'
complete -c x -n "__fish_x_using_subcommand suggest" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
complete -c x -n "__fish_x_using_subcommand suggest" -l skip-std-check-if-no-download-rustc -d 'Skip checking the standard library if `rust.download-rustc` isn\'t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers'
complete -c x -n "__fish_x_using_subcommand suggest" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c x -n "__fish_x_using_subcommand vendor" -l sync -d 'Additional `Cargo.toml` to sync and vendor' -r -F
complete -c x -n "__fish_x_using_subcommand vendor" -l config -d 'TOML configuration file for build' -r -F
complete -c x -n "__fish_x_using_subcommand vendor" -l build-dir -d 'Build directory, overrides `build.build-dir` in `bootstrap.toml`' -r -f -a "(__fish_complete_directories)"

View file

@ -74,7 +74,6 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock {
[CompletionResult]::new('install', 'install', [CompletionResultType]::ParameterValue, 'Install distribution artifacts')
[CompletionResult]::new('run', 'run', [CompletionResultType]::ParameterValue, 'Run tools contained in this repository')
[CompletionResult]::new('setup', 'setup', [CompletionResultType]::ParameterValue, 'Set up the environment for development')
[CompletionResult]::new('suggest', 'suggest', [CompletionResultType]::ParameterValue, 'Suggest a subset of tests to run, based on modified files')
[CompletionResult]::new('vendor', 'vendor', [CompletionResultType]::ParameterValue, 'Vendor dependencies')
[CompletionResult]::new('perf', 'perf', [CompletionResultType]::ParameterValue, 'Perform profiling and benchmarking of the compiler using `rustc-perf`')
break
@ -700,49 +699,6 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock {
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'x;suggest' {
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'TOML configuration file for build')
[CompletionResult]::new('--build-dir', '--build-dir', [CompletionResultType]::ParameterName, 'Build directory, overrides `build.build-dir` in `bootstrap.toml`')
[CompletionResult]::new('--build', '--build', [CompletionResultType]::ParameterName, 'host target of the stage0 compiler')
[CompletionResult]::new('--host', '--host', [CompletionResultType]::ParameterName, 'host targets to build')
[CompletionResult]::new('--target', '--target', [CompletionResultType]::ParameterName, 'target targets to build')
[CompletionResult]::new('--exclude', '--exclude', [CompletionResultType]::ParameterName, 'build paths to exclude')
[CompletionResult]::new('--skip', '--skip', [CompletionResultType]::ParameterName, 'build paths to skip')
[CompletionResult]::new('--rustc-error-format', '--rustc-error-format', [CompletionResultType]::ParameterName, 'rustc error format')
[CompletionResult]::new('--on-fail', '--on-fail', [CompletionResultType]::ParameterName, 'command to run on failure')
[CompletionResult]::new('--stage', '--stage', [CompletionResultType]::ParameterName, 'stage to build (indicates compiler to use/test, e.g., stage 0 uses the bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)')
[CompletionResult]::new('--keep-stage', '--keep-stage', [CompletionResultType]::ParameterName, 'stage(s) to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)')
[CompletionResult]::new('--keep-stage-std', '--keep-stage-std', [CompletionResultType]::ParameterName, 'stage(s) of the standard library to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)')
[CompletionResult]::new('--src', '--src', [CompletionResultType]::ParameterName, 'path to the root of the rust checkout')
[CompletionResult]::new('-j', '-j', [CompletionResultType]::ParameterName, 'number of jobs to run in parallel')
[CompletionResult]::new('--jobs', '--jobs', [CompletionResultType]::ParameterName, 'number of jobs to run in parallel')
[CompletionResult]::new('--warnings', '--warnings', [CompletionResultType]::ParameterName, 'if value is deny, will deny warnings if value is warn, will emit warnings otherwise, use the default configured behaviour')
[CompletionResult]::new('--color', '--color', [CompletionResultType]::ParameterName, 'whether to use color in cargo and rustc output')
[CompletionResult]::new('--rust-profile-generate', '--rust-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with rustc build')
[CompletionResult]::new('--rust-profile-use', '--rust-profile-use', [CompletionResultType]::ParameterName, 'use PGO profile for rustc build')
[CompletionResult]::new('--llvm-profile-use', '--llvm-profile-use', [CompletionResultType]::ParameterName, 'use PGO profile for LLVM build')
[CompletionResult]::new('--reproducible-artifact', '--reproducible-artifact', [CompletionResultType]::ParameterName, 'Additional reproducible artifacts that should be added to the reproducible artifacts archive')
[CompletionResult]::new('--set', '--set', [CompletionResultType]::ParameterName, 'override options in bootstrap.toml')
[CompletionResult]::new('--ci', '--ci', [CompletionResultType]::ParameterName, 'Make bootstrap to behave as it''s running on the CI environment or not')
[CompletionResult]::new('--run', '--run', [CompletionResultType]::ParameterName, 'run suggested tests')
[CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
[CompletionResult]::new('--verbose', '--verbose', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
[CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'use incremental compilation')
[CompletionResult]::new('--incremental', '--incremental', [CompletionResultType]::ParameterName, 'use incremental compilation')
[CompletionResult]::new('--include-default-paths', '--include-default-paths', [CompletionResultType]::ParameterName, 'include default paths in addition to the provided ones')
[CompletionResult]::new('--dry-run', '--dry-run', [CompletionResultType]::ParameterName, 'dry run; don''t build anything')
[CompletionResult]::new('--dump-bootstrap-shims', '--dump-bootstrap-shims', [CompletionResultType]::ParameterName, 'Indicates whether to dump the work done from bootstrap shims')
[CompletionResult]::new('--json-output', '--json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
[CompletionResult]::new('--compile-time-deps', '--compile-time-deps', [CompletionResultType]::ParameterName, 'only build proc-macros and build scripts (for rust-analyzer)')
[CompletionResult]::new('--bypass-bootstrap-lock', '--bypass-bootstrap-lock', [CompletionResultType]::ParameterName, 'Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)')
[CompletionResult]::new('--llvm-profile-generate', '--llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
[CompletionResult]::new('--enable-bolt-settings', '--enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
[CompletionResult]::new('--skip-stage0-validation', '--skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
[CompletionResult]::new('--skip-std-check-if-no-download-rustc', '--skip-std-check-if-no-download-rustc', [CompletionResultType]::ParameterName, 'Skip checking the standard library if `rust.download-rustc` isn''t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'x;vendor' {
[CompletionResult]::new('--sync', '--sync', [CompletionResultType]::ParameterName, 'Additional `Cargo.toml` to sync and vendor')
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'TOML configuration file for build')

View file

@ -73,7 +73,6 @@ complete -c x.py -n "__fish_x.py_needs_command" -a "dist" -d 'Build distribution
complete -c x.py -n "__fish_x.py_needs_command" -a "install" -d 'Install distribution artifacts'
complete -c x.py -n "__fish_x.py_needs_command" -a "run" -d 'Run tools contained in this repository'
complete -c x.py -n "__fish_x.py_needs_command" -a "setup" -d 'Set up the environment for development'
complete -c x.py -n "__fish_x.py_needs_command" -a "suggest" -d 'Suggest a subset of tests to run, based on modified files'
complete -c x.py -n "__fish_x.py_needs_command" -a "vendor" -d 'Vendor dependencies'
complete -c x.py -n "__fish_x.py_needs_command" -a "perf" -d 'Perform profiling and benchmarking of the compiler using `rustc-perf`'
complete -c x.py -n "__fish_x.py_using_subcommand build" -l config -d 'TOML configuration file for build' -r -F
@ -599,42 +598,6 @@ complete -c x.py -n "__fish_x.py_using_subcommand setup" -l enable-bolt-settings
complete -c x.py -n "__fish_x.py_using_subcommand setup" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
complete -c x.py -n "__fish_x.py_using_subcommand setup" -l skip-std-check-if-no-download-rustc -d 'Skip checking the standard library if `rust.download-rustc` isn\'t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers'
complete -c x.py -n "__fish_x.py_using_subcommand setup" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l config -d 'TOML configuration file for build' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l build-dir -d 'Build directory, overrides `build.build-dir` in `bootstrap.toml`' -r -f -a "(__fish_complete_directories)"
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l build -d 'host target of the stage0 compiler' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l host -d 'host targets to build' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l target -d 'target targets to build' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l exclude -d 'build paths to exclude' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l skip -d 'build paths to skip' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l rustc-error-format -d 'rustc error format' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l on-fail -d 'command to run on failure' -r -f -a "(__fish_complete_command)"
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l stage -d 'stage to build (indicates compiler to use/test, e.g., stage 0 uses the bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l keep-stage -d 'stage(s) to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l keep-stage-std -d 'stage(s) of the standard library to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l src -d 'path to the root of the rust checkout' -r -f -a "(__fish_complete_directories)"
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -s j -l jobs -d 'number of jobs to run in parallel' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l warnings -d 'if value is deny, will deny warnings if value is warn, will emit warnings otherwise, use the default configured behaviour' -r -f -a "{deny\t'',warn\t'',default\t''}"
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l color -d 'whether to use color in cargo and rustc output' -r -f -a "{always\t'',never\t'',auto\t''}"
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l rust-profile-generate -d 'generate PGO profile with rustc build' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l rust-profile-use -d 'use PGO profile for rustc build' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l llvm-profile-use -d 'use PGO profile for LLVM build' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l reproducible-artifact -d 'Additional reproducible artifacts that should be added to the reproducible artifacts archive' -r
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l set -d 'override options in bootstrap.toml' -r -f
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l ci -d 'Make bootstrap to behave as it\'s running on the CI environment or not' -r -f -a "{true\t'',false\t''}"
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l run -d 'run suggested tests'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -s v -l verbose -d 'use verbose output (-vv for very verbose)'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -s i -l incremental -d 'use incremental compilation'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l include-default-paths -d 'include default paths in addition to the provided ones'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l dry-run -d 'dry run; don\'t build anything'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l dump-bootstrap-shims -d 'Indicates whether to dump the work done from bootstrap shims'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l json-output -d 'use message-format=json'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l compile-time-deps -d 'only build proc-macros and build scripts (for rust-analyzer)'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l bypass-bootstrap-lock -d 'Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l llvm-profile-generate -d 'generate PGO profile with llvm built for rustc'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l enable-bolt-settings -d 'Enable BOLT link flags'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l skip-stage0-validation -d 'Skip stage0 compiler validation'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -l skip-std-check-if-no-download-rustc -d 'Skip checking the standard library if `rust.download-rustc` isn\'t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers'
complete -c x.py -n "__fish_x.py_using_subcommand suggest" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c x.py -n "__fish_x.py_using_subcommand vendor" -l sync -d 'Additional `Cargo.toml` to sync and vendor' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand vendor" -l config -d 'TOML configuration file for build' -r -F
complete -c x.py -n "__fish_x.py_using_subcommand vendor" -l build-dir -d 'Build directory, overrides `build.build-dir` in `bootstrap.toml`' -r -f -a "(__fish_complete_directories)"

View file

@ -74,7 +74,6 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
[CompletionResult]::new('install', 'install', [CompletionResultType]::ParameterValue, 'Install distribution artifacts')
[CompletionResult]::new('run', 'run', [CompletionResultType]::ParameterValue, 'Run tools contained in this repository')
[CompletionResult]::new('setup', 'setup', [CompletionResultType]::ParameterValue, 'Set up the environment for development')
[CompletionResult]::new('suggest', 'suggest', [CompletionResultType]::ParameterValue, 'Suggest a subset of tests to run, based on modified files')
[CompletionResult]::new('vendor', 'vendor', [CompletionResultType]::ParameterValue, 'Vendor dependencies')
[CompletionResult]::new('perf', 'perf', [CompletionResultType]::ParameterValue, 'Perform profiling and benchmarking of the compiler using `rustc-perf`')
break
@ -700,49 +699,6 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock {
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'x.py;suggest' {
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'TOML configuration file for build')
[CompletionResult]::new('--build-dir', '--build-dir', [CompletionResultType]::ParameterName, 'Build directory, overrides `build.build-dir` in `bootstrap.toml`')
[CompletionResult]::new('--build', '--build', [CompletionResultType]::ParameterName, 'host target of the stage0 compiler')
[CompletionResult]::new('--host', '--host', [CompletionResultType]::ParameterName, 'host targets to build')
[CompletionResult]::new('--target', '--target', [CompletionResultType]::ParameterName, 'target targets to build')
[CompletionResult]::new('--exclude', '--exclude', [CompletionResultType]::ParameterName, 'build paths to exclude')
[CompletionResult]::new('--skip', '--skip', [CompletionResultType]::ParameterName, 'build paths to skip')
[CompletionResult]::new('--rustc-error-format', '--rustc-error-format', [CompletionResultType]::ParameterName, 'rustc error format')
[CompletionResult]::new('--on-fail', '--on-fail', [CompletionResultType]::ParameterName, 'command to run on failure')
[CompletionResult]::new('--stage', '--stage', [CompletionResultType]::ParameterName, 'stage to build (indicates compiler to use/test, e.g., stage 0 uses the bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)')
[CompletionResult]::new('--keep-stage', '--keep-stage', [CompletionResultType]::ParameterName, 'stage(s) to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)')
[CompletionResult]::new('--keep-stage-std', '--keep-stage-std', [CompletionResultType]::ParameterName, 'stage(s) of the standard library to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)')
[CompletionResult]::new('--src', '--src', [CompletionResultType]::ParameterName, 'path to the root of the rust checkout')
[CompletionResult]::new('-j', '-j', [CompletionResultType]::ParameterName, 'number of jobs to run in parallel')
[CompletionResult]::new('--jobs', '--jobs', [CompletionResultType]::ParameterName, 'number of jobs to run in parallel')
[CompletionResult]::new('--warnings', '--warnings', [CompletionResultType]::ParameterName, 'if value is deny, will deny warnings if value is warn, will emit warnings otherwise, use the default configured behaviour')
[CompletionResult]::new('--color', '--color', [CompletionResultType]::ParameterName, 'whether to use color in cargo and rustc output')
[CompletionResult]::new('--rust-profile-generate', '--rust-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with rustc build')
[CompletionResult]::new('--rust-profile-use', '--rust-profile-use', [CompletionResultType]::ParameterName, 'use PGO profile for rustc build')
[CompletionResult]::new('--llvm-profile-use', '--llvm-profile-use', [CompletionResultType]::ParameterName, 'use PGO profile for LLVM build')
[CompletionResult]::new('--reproducible-artifact', '--reproducible-artifact', [CompletionResultType]::ParameterName, 'Additional reproducible artifacts that should be added to the reproducible artifacts archive')
[CompletionResult]::new('--set', '--set', [CompletionResultType]::ParameterName, 'override options in bootstrap.toml')
[CompletionResult]::new('--ci', '--ci', [CompletionResultType]::ParameterName, 'Make bootstrap to behave as it''s running on the CI environment or not')
[CompletionResult]::new('--run', '--run', [CompletionResultType]::ParameterName, 'run suggested tests')
[CompletionResult]::new('-v', '-v', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
[CompletionResult]::new('--verbose', '--verbose', [CompletionResultType]::ParameterName, 'use verbose output (-vv for very verbose)')
[CompletionResult]::new('-i', '-i', [CompletionResultType]::ParameterName, 'use incremental compilation')
[CompletionResult]::new('--incremental', '--incremental', [CompletionResultType]::ParameterName, 'use incremental compilation')
[CompletionResult]::new('--include-default-paths', '--include-default-paths', [CompletionResultType]::ParameterName, 'include default paths in addition to the provided ones')
[CompletionResult]::new('--dry-run', '--dry-run', [CompletionResultType]::ParameterName, 'dry run; don''t build anything')
[CompletionResult]::new('--dump-bootstrap-shims', '--dump-bootstrap-shims', [CompletionResultType]::ParameterName, 'Indicates whether to dump the work done from bootstrap shims')
[CompletionResult]::new('--json-output', '--json-output', [CompletionResultType]::ParameterName, 'use message-format=json')
[CompletionResult]::new('--compile-time-deps', '--compile-time-deps', [CompletionResultType]::ParameterName, 'only build proc-macros and build scripts (for rust-analyzer)')
[CompletionResult]::new('--bypass-bootstrap-lock', '--bypass-bootstrap-lock', [CompletionResultType]::ParameterName, 'Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)')
[CompletionResult]::new('--llvm-profile-generate', '--llvm-profile-generate', [CompletionResultType]::ParameterName, 'generate PGO profile with llvm built for rustc')
[CompletionResult]::new('--enable-bolt-settings', '--enable-bolt-settings', [CompletionResultType]::ParameterName, 'Enable BOLT link flags')
[CompletionResult]::new('--skip-stage0-validation', '--skip-stage0-validation', [CompletionResultType]::ParameterName, 'Skip stage0 compiler validation')
[CompletionResult]::new('--skip-std-check-if-no-download-rustc', '--skip-std-check-if-no-download-rustc', [CompletionResultType]::ParameterName, 'Skip checking the standard library if `rust.download-rustc` isn''t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers')
[CompletionResult]::new('-h', '-h', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
[CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, 'Print help (see more with ''--help'')')
break
}
'x.py;vendor' {
[CompletionResult]::new('--sync', '--sync', [CompletionResultType]::ParameterName, 'Additional `Cargo.toml` to sync and vendor')
[CompletionResult]::new('--config', '--config', [CompletionResultType]::ParameterName, 'TOML configuration file for build')

View file

@ -54,9 +54,6 @@ _x.py() {
x.py,setup)
cmd="x.py__setup"
;;
x.py,suggest)
cmd="x.py__suggest"
;;
x.py,test)
cmd="x.py__test"
;;
@ -85,7 +82,7 @@ _x.py() {
case "${cmd}" in
x.py)
opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]... build check clippy fix fmt doc test miri bench clean dist install run setup suggest vendor perf"
opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]... build check clippy fix fmt doc test miri bench clean dist install run setup vendor perf"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@ -3877,192 +3874,6 @@ _x.py() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
x.py__suggest)
opts="-v -i -j -h --run --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--config)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--build-dir)
COMPREPLY=()
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o plusdirs
fi
return 0
;;
--build)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--host)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--target)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--exclude)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--skip)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--rustc-error-format)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--on-fail)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--stage)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--keep-stage)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--keep-stage-std)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--src)
COMPREPLY=()
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o plusdirs
fi
return 0
;;
--jobs)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
-j)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--warnings)
COMPREPLY=($(compgen -W "deny warn default" -- "${cur}"))
return 0
;;
--color)
COMPREPLY=($(compgen -W "always never auto" -- "${cur}"))
return 0
;;
--rust-profile-generate)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--rust-profile-use)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--llvm-profile-use)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--reproducible-artifact)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--set)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--ci)
COMPREPLY=($(compgen -W "true false" -- "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
x.py__test)
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then

View file

@ -715,51 +715,6 @@ _arguments "${_arguments_options[@]}" : \
'*::paths -- paths for the subcommand:_files' \
&& ret=0
;;
(suggest)
_arguments "${_arguments_options[@]}" : \
'--config=[TOML configuration file for build]:FILE:_files' \
'--build-dir=[Build directory, overrides \`build.build-dir\` in \`bootstrap.toml\`]:DIR:_files -/' \
'--build=[host target of the stage0 compiler]:BUILD:' \
'--host=[host targets to build]:HOST:' \
'--target=[target targets to build]:TARGET:' \
'*--exclude=[build paths to exclude]:PATH:_files' \
'*--skip=[build paths to skip]:PATH:_files' \
'--rustc-error-format=[rustc error format]:RUSTC_ERROR_FORMAT:' \
'--on-fail=[command to run on failure]:CMD:_cmdstring' \
'--stage=[stage to build (indicates compiler to use/test, e.g., stage 0 uses the bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)]:N:' \
'*--keep-stage=[stage(s) to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)]:N:' \
'*--keep-stage-std=[stage(s) of the standard library to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)]:N:' \
'--src=[path to the root of the rust checkout]:DIR:_files -/' \
'-j+[number of jobs to run in parallel]:JOBS:' \
'--jobs=[number of jobs to run in parallel]:JOBS:' \
'--warnings=[if value is deny, will deny warnings if value is warn, will emit warnings otherwise, use the default configured behaviour]:deny|warn:(deny warn default)' \
'--color=[whether to use color in cargo and rustc output]:STYLE:(always never auto)' \
'--rust-profile-generate=[generate PGO profile with rustc build]:PROFILE:_files' \
'--rust-profile-use=[use PGO profile for rustc build]:PROFILE:_files' \
'--llvm-profile-use=[use PGO profile for LLVM build]:PROFILE:_files' \
'*--reproducible-artifact=[Additional reproducible artifacts that should be added to the reproducible artifacts archive]:REPRODUCIBLE_ARTIFACT:_default' \
'*--set=[override options in bootstrap.toml]:section.option=value:' \
'--ci=[Make bootstrap to behave as it'\''s running on the CI environment or not]:bool:(true false)' \
'--run[run suggested tests]' \
'*-v[use verbose output (-vv for very verbose)]' \
'*--verbose[use verbose output (-vv for very verbose)]' \
'-i[use incremental compilation]' \
'--incremental[use incremental compilation]' \
'--include-default-paths[include default paths in addition to the provided ones]' \
'--dry-run[dry run; don'\''t build anything]' \
'--dump-bootstrap-shims[Indicates whether to dump the work done from bootstrap shims]' \
'--json-output[use message-format=json]' \
'--compile-time-deps[only build proc-macros and build scripts (for rust-analyzer)]' \
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'--skip-std-check-if-no-download-rustc[Skip checking the standard library if \`rust.download-rustc\` isn'\''t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::paths -- paths for the subcommand:_files' \
&& ret=0
;;
(vendor)
_arguments "${_arguments_options[@]}" : \
'*--sync=[Additional \`Cargo.toml\` to sync and vendor]:SYNC:_files' \
@ -1120,7 +1075,6 @@ _x.py_commands() {
'install:Install distribution artifacts' \
'run:Run tools contained in this repository' \
'setup:Set up the environment for development' \
'suggest:Suggest a subset of tests to run, based on modified files' \
'vendor:Vendor dependencies' \
'perf:Perform profiling and benchmarking of the compiler using \`rustc-perf\`' \
)
@ -1227,11 +1181,6 @@ _x.py__setup_commands() {
local commands; commands=()
_describe -t commands 'x.py setup commands' commands "$@"
}
(( $+functions[_x.py__suggest_commands] )) ||
_x.py__suggest_commands() {
local commands; commands=()
_describe -t commands 'x.py suggest commands' commands "$@"
}
(( $+functions[_x.py__test_commands] )) ||
_x.py__test_commands() {
local commands; commands=()

View file

@ -54,9 +54,6 @@ _x() {
x,setup)
cmd="x__setup"
;;
x,suggest)
cmd="x__suggest"
;;
x,test)
cmd="x__test"
;;
@ -85,7 +82,7 @@ _x() {
case "${cmd}" in
x)
opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]... build check clippy fix fmt doc test miri bench clean dist install run setup suggest vendor perf"
opts="-v -i -j -h --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]... build check clippy fix fmt doc test miri bench clean dist install run setup vendor perf"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@ -3877,192 +3874,6 @@ _x() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
x__suggest)
opts="-v -i -j -h --run --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--config)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--build-dir)
COMPREPLY=()
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o plusdirs
fi
return 0
;;
--build)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--host)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--target)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--exclude)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--skip)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--rustc-error-format)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--on-fail)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--stage)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--keep-stage)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--keep-stage-std)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--src)
COMPREPLY=()
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o plusdirs
fi
return 0
;;
--jobs)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
-j)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--warnings)
COMPREPLY=($(compgen -W "deny warn default" -- "${cur}"))
return 0
;;
--color)
COMPREPLY=($(compgen -W "always never auto" -- "${cur}"))
return 0
;;
--rust-profile-generate)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--rust-profile-use)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--llvm-profile-use)
local oldifs
if [ -n "${IFS+x}" ]; then
oldifs="$IFS"
fi
IFS=$'\n'
COMPREPLY=($(compgen -f "${cur}"))
if [ -n "${oldifs+x}" ]; then
IFS="$oldifs"
fi
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o filenames
fi
return 0
;;
--reproducible-artifact)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--set)
COMPREPLY=("${cur}")
if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
compopt -o nospace
fi
return 0
;;
--ci)
COMPREPLY=($(compgen -W "true false" -- "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
x__test)
opts="-v -i -j -h --no-fail-fast --test-args --compiletest-rustc-args --no-doc --doc --bless --extra-checks --force-rerun --only-modified --compare-mode --pass --run --rustfix-coverage --no-capture --verbose --incremental --config --build-dir --build --host --target --exclude --skip --include-default-paths --rustc-error-format --on-fail --dry-run --dump-bootstrap-shims --stage --keep-stage --keep-stage-std --src --jobs --warnings --json-output --compile-time-deps --color --bypass-bootstrap-lock --rust-profile-generate --rust-profile-use --llvm-profile-use --llvm-profile-generate --enable-bolt-settings --skip-stage0-validation --reproducible-artifact --set --ci --skip-std-check-if-no-download-rustc --help [PATHS]... [ARGS]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then

View file

@ -715,51 +715,6 @@ _arguments "${_arguments_options[@]}" : \
'*::paths -- paths for the subcommand:_files' \
&& ret=0
;;
(suggest)
_arguments "${_arguments_options[@]}" : \
'--config=[TOML configuration file for build]:FILE:_files' \
'--build-dir=[Build directory, overrides \`build.build-dir\` in \`bootstrap.toml\`]:DIR:_files -/' \
'--build=[host target of the stage0 compiler]:BUILD:' \
'--host=[host targets to build]:HOST:' \
'--target=[target targets to build]:TARGET:' \
'*--exclude=[build paths to exclude]:PATH:_files' \
'*--skip=[build paths to skip]:PATH:_files' \
'--rustc-error-format=[rustc error format]:RUSTC_ERROR_FORMAT:' \
'--on-fail=[command to run on failure]:CMD:_cmdstring' \
'--stage=[stage to build (indicates compiler to use/test, e.g., stage 0 uses the bootstrap compiler, stage 1 the stage 0 rustc artifacts, etc.)]:N:' \
'*--keep-stage=[stage(s) to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)]:N:' \
'*--keep-stage-std=[stage(s) of the standard library to keep without recompiling (pass multiple times to keep e.g., both stages 0 and 1)]:N:' \
'--src=[path to the root of the rust checkout]:DIR:_files -/' \
'-j+[number of jobs to run in parallel]:JOBS:' \
'--jobs=[number of jobs to run in parallel]:JOBS:' \
'--warnings=[if value is deny, will deny warnings if value is warn, will emit warnings otherwise, use the default configured behaviour]:deny|warn:(deny warn default)' \
'--color=[whether to use color in cargo and rustc output]:STYLE:(always never auto)' \
'--rust-profile-generate=[generate PGO profile with rustc build]:PROFILE:_files' \
'--rust-profile-use=[use PGO profile for rustc build]:PROFILE:_files' \
'--llvm-profile-use=[use PGO profile for LLVM build]:PROFILE:_files' \
'*--reproducible-artifact=[Additional reproducible artifacts that should be added to the reproducible artifacts archive]:REPRODUCIBLE_ARTIFACT:_default' \
'*--set=[override options in bootstrap.toml]:section.option=value:' \
'--ci=[Make bootstrap to behave as it'\''s running on the CI environment or not]:bool:(true false)' \
'--run[run suggested tests]' \
'*-v[use verbose output (-vv for very verbose)]' \
'*--verbose[use verbose output (-vv for very verbose)]' \
'-i[use incremental compilation]' \
'--incremental[use incremental compilation]' \
'--include-default-paths[include default paths in addition to the provided ones]' \
'--dry-run[dry run; don'\''t build anything]' \
'--dump-bootstrap-shims[Indicates whether to dump the work done from bootstrap shims]' \
'--json-output[use message-format=json]' \
'--compile-time-deps[only build proc-macros and build scripts (for rust-analyzer)]' \
'--bypass-bootstrap-lock[Bootstrap uses this value to decide whether it should bypass locking the build process. This is rarely needed (e.g., compiling the std library for different targets in parallel)]' \
'--llvm-profile-generate[generate PGO profile with llvm built for rustc]' \
'--enable-bolt-settings[Enable BOLT link flags]' \
'--skip-stage0-validation[Skip stage0 compiler validation]' \
'--skip-std-check-if-no-download-rustc[Skip checking the standard library if \`rust.download-rustc\` isn'\''t available. This is mostly for RA as building the stage1 compiler to check the library tree on each code change might be too much for some computers]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::paths -- paths for the subcommand:_files' \
&& ret=0
;;
(vendor)
_arguments "${_arguments_options[@]}" : \
'*--sync=[Additional \`Cargo.toml\` to sync and vendor]:SYNC:_files' \
@ -1120,7 +1075,6 @@ _x_commands() {
'install:Install distribution artifacts' \
'run:Run tools contained in this repository' \
'setup:Set up the environment for development' \
'suggest:Suggest a subset of tests to run, based on modified files' \
'vendor:Vendor dependencies' \
'perf:Perform profiling and benchmarking of the compiler using \`rustc-perf\`' \
)
@ -1227,11 +1181,6 @@ _x__setup_commands() {
local commands; commands=()
_describe -t commands 'x setup commands' commands "$@"
}
(( $+functions[_x__suggest_commands] )) ||
_x__suggest_commands() {
local commands; commands=()
_describe -t commands 'x suggest commands' commands "$@"
}
(( $+functions[_x__test_commands] )) ||
_x__test_commands() {
local commands; commands=()

View file

@ -759,79 +759,48 @@ impl Item {
Some(tcx.visibility(def_id))
}
fn attributes_without_repr(&self, tcx: TyCtxt<'_>, is_json: bool) -> Vec<String> {
const ALLOWED_ATTRIBUTES: &[Symbol] =
&[sym::export_name, sym::link_section, sym::no_mangle, sym::non_exhaustive];
/// Get a list of attributes excluding `#[repr]` to display.
///
/// Only used by the HTML output-format.
fn attributes_without_repr(&self) -> Vec<String> {
self.attrs
.other_attrs
.iter()
.filter_map(|attr| {
if let hir::Attribute::Parsed(AttributeKind::LinkSection { name, .. }) = attr {
.filter_map(|attr| match attr {
hir::Attribute::Parsed(AttributeKind::LinkSection { name, .. }) => {
Some(format!("#[link_section = \"{name}\"]"))
}
// NoMangle is special cased, as it appears in HTML output, and we want to show it in source form, not HIR printing.
// It is also used by cargo-semver-checks.
else if let hir::Attribute::Parsed(AttributeKind::NoMangle(..)) = attr {
hir::Attribute::Parsed(AttributeKind::NoMangle(..)) => {
Some("#[no_mangle]".to_string())
} else if let hir::Attribute::Parsed(AttributeKind::ExportName { name, .. }) = attr
{
Some(format!("#[export_name = \"{name}\"]"))
} else if let hir::Attribute::Parsed(AttributeKind::NonExhaustive(..)) = attr {
Some("#[non_exhaustive]".to_string())
} else if is_json {
match attr {
// rustdoc-json stores this in `Item::deprecation`, so we
// 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,
// target_feature is special-cased because cargo-semver-checks uses it
hir::Attribute::Parsed(AttributeKind::TargetFeature(features, _)) => {
let mut output = String::new();
for (i, (feature, _)) in features.iter().enumerate() {
if i != 0 {
output.push_str(", ");
}
output.push_str(&format!("enable=\"{}\"", feature.as_str()));
}
Some(format!("#[target_feature({output})]"))
}
hir::Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)) => {
Some("#[automatically_derived]".to_string())
}
_ => Some({
let mut s = rustc_hir_pretty::attribute_to_string(&tcx, attr);
assert_eq!(s.pop(), Some('\n'));
s
}),
}
} else {
if !attr.has_any_name(ALLOWED_ATTRIBUTES) {
return None;
}
Some(
rustc_hir_pretty::attribute_to_string(&tcx, attr)
.replace("\\\n", "")
.replace('\n', "")
.replace(" ", " "),
)
}
hir::Attribute::Parsed(AttributeKind::ExportName { name, .. }) => {
Some(format!("#[export_name = \"{name}\"]"))
}
hir::Attribute::Parsed(AttributeKind::NonExhaustive(..)) => {
Some("#[non_exhaustive]".to_string())
}
_ => None,
})
.collect()
}
pub(crate) fn attributes(&self, tcx: TyCtxt<'_>, cache: &Cache, is_json: bool) -> Vec<String> {
let mut attrs = self.attributes_without_repr(tcx, is_json);
/// Get a list of attributes to display on this item.
///
/// Only used by the HTML output-format.
pub(crate) fn attributes(&self, tcx: TyCtxt<'_>, cache: &Cache) -> Vec<String> {
let mut attrs = self.attributes_without_repr();
if let Some(repr_attr) = self.repr(tcx, cache, is_json) {
if let Some(repr_attr) = self.repr(tcx, cache) {
attrs.push(repr_attr);
}
attrs
}
/// Returns a stringified `#[repr(...)]` attribute.
pub(crate) fn repr(&self, tcx: TyCtxt<'_>, cache: &Cache, is_json: bool) -> Option<String> {
repr_attributes(tcx, cache, self.def_id()?, self.type_(), is_json)
///
/// Only used by the HTML output-format.
pub(crate) fn repr(&self, tcx: TyCtxt<'_>, cache: &Cache) -> Option<String> {
repr_attributes(tcx, cache, self.def_id()?, self.type_())
}
pub fn is_doc_hidden(&self) -> bool {
@ -843,12 +812,14 @@ impl Item {
}
}
/// Return a string representing the `#[repr]` attribute if present.
///
/// Only used by the HTML output-format.
pub(crate) fn repr_attributes(
tcx: TyCtxt<'_>,
cache: &Cache,
def_id: DefId,
item_type: ItemType,
is_json: bool,
) -> Option<String> {
use rustc_abi::IntegerType;
@ -865,7 +836,6 @@ pub(crate) fn repr_attributes(
// Render `repr(transparent)` iff the non-1-ZST field is public or at least one
// field is public in case all fields are 1-ZST fields.
let render_transparent = cache.document_private
|| is_json
|| adt
.all_fields()
.find(|field| {

View file

@ -1191,7 +1191,7 @@ fn render_assoc_item(
// a whitespace prefix and newline.
fn render_attributes_in_pre(it: &clean::Item, prefix: &str, cx: &Context<'_>) -> impl fmt::Display {
fmt::from_fn(move |f| {
for a in it.attributes(cx.tcx(), cx.cache(), false) {
for a in it.attributes(cx.tcx(), cx.cache()) {
writeln!(f, "{prefix}{a}")?;
}
Ok(())
@ -1207,7 +1207,7 @@ fn render_code_attribute(code_attr: CodeAttribute, w: &mut impl fmt::Write) {
// When an attribute is rendered inside a <code> tag, it is formatted using
// a div to produce a newline after it.
fn render_attributes_in_code(w: &mut impl fmt::Write, it: &clean::Item, cx: &Context<'_>) {
for attr in it.attributes(cx.tcx(), cx.cache(), false) {
for attr in it.attributes(cx.tcx(), cx.cache()) {
render_code_attribute(CodeAttribute(attr), w);
}
}
@ -1219,7 +1219,7 @@ fn render_repr_attributes_in_code(
def_id: DefId,
item_type: ItemType,
) {
if let Some(repr) = clean::repr_attributes(cx.tcx(), cx.cache(), def_id, item_type, false) {
if let Some(repr) = clean::repr_attributes(cx.tcx(), cx.cache(), def_id, item_type) {
render_code_attribute(CodeAttribute(repr), w);
}
}

View file

@ -1487,12 +1487,11 @@ impl<'a, 'cx: 'a> ItemUnion<'a, 'cx> {
self.cx.cache(),
self.def_id,
ItemType::Union,
false,
) {
writeln!(f, "{repr}")?;
};
} else {
for a in self.it.attributes(self.cx.tcx(), self.cx.cache(), false) {
for a in self.it.attributes(self.cx.tcx(), self.cx.cache()) {
writeln!(f, "{a}")?;
}
}

View file

@ -5,10 +5,12 @@
use rustc_abi::ExternAbi;
use rustc_ast::ast;
use rustc_attr_data_structures::{self as attrs, DeprecatedSince};
use rustc_hir as hir;
use rustc_hir::def::CtorKind;
use rustc_hir::def_id::DefId;
use rustc_hir::{HeaderSafety, Safety};
use rustc_metadata::rendered_const;
use rustc_middle::ty::TyCtxt;
use rustc_middle::{bug, ty};
use rustc_span::{Pos, kw, sym};
use rustdoc_json_types::*;
@ -39,7 +41,12 @@ impl JsonRenderer<'_> {
})
.collect();
let docs = item.opt_doc_value();
let attrs = item.attributes(self.tcx, &self.cache, true);
let attrs = item
.attrs
.other_attrs
.iter()
.filter_map(|a| maybe_from_hir_attr(a, item.item_id, self.tcx))
.collect();
let span = item.span(self.tcx);
let visibility = item.visibility(self.tcx);
let clean::ItemInner { name, item_id, .. } = *item.inner;
@ -886,3 +893,93 @@ impl FromClean<ItemType> for ItemKind {
}
}
}
/// Maybe convert a attribute from hir to json.
///
/// Returns `None` if the attribute shouldn't be in the output.
fn maybe_from_hir_attr(
attr: &hir::Attribute,
item_id: ItemId,
tcx: TyCtxt<'_>,
) -> Option<Attribute> {
use attrs::AttributeKind as AK;
let kind = match attr {
hir::Attribute::Parsed(kind) => kind,
hir::Attribute::Unparsed(_) => {
// FIXME: We should handle `#[doc(hidden)]`.
return Some(other_attr(tcx, attr));
}
};
Some(match kind {
AK::Deprecation { .. } => return None, // Handled separately into Item::deprecation.
AK::DocComment { .. } => unreachable!("doc comments stripped out earlier"),
AK::MustUse { reason, span: _ } => {
Attribute::MustUse { reason: reason.map(|s| s.to_string()) }
}
AK::Repr { .. } => repr_attr(
tcx,
item_id.as_def_id().expect("all items that could have #[repr] have a DefId"),
),
AK::ExportName { name, span: _ } => Attribute::ExportName(name.to_string()),
AK::LinkSection { name, span: _ } => Attribute::LinkSection(name.to_string()),
AK::TargetFeature(features, _span) => Attribute::TargetFeature {
enable: features.iter().map(|(feat, _span)| feat.to_string()).collect(),
},
AK::NoMangle(_) => Attribute::NoMangle,
AK::NonExhaustive(_) => Attribute::NonExhaustive,
AK::AutomaticallyDerived(_) => Attribute::AutomaticallyDerived,
_ => other_attr(tcx, attr),
})
}
fn other_attr(tcx: TyCtxt<'_>, attr: &hir::Attribute) -> Attribute {
let mut s = rustc_hir_pretty::attribute_to_string(&tcx, attr);
assert_eq!(s.pop(), Some('\n'));
Attribute::Other(s)
}
fn repr_attr(tcx: TyCtxt<'_>, def_id: DefId) -> Attribute {
let repr = tcx.adt_def(def_id).repr();
let kind = if repr.c() {
ReprKind::C
} else if repr.transparent() {
ReprKind::Transparent
} else if repr.simd() {
ReprKind::Simd
} else {
ReprKind::Rust
};
let align = repr.align.map(|a| a.bytes());
let packed = repr.pack.map(|p| p.bytes());
let int = repr.int.map(format_integer_type);
Attribute::Repr(AttributeRepr { kind, align, packed, int })
}
fn format_integer_type(it: rustc_abi::IntegerType) -> String {
use rustc_abi::Integer::*;
use rustc_abi::IntegerType::*;
match it {
Pointer(true) => "isize",
Pointer(false) => "usize",
Fixed(I8, true) => "i8",
Fixed(I8, false) => "u8",
Fixed(I16, true) => "i16",
Fixed(I16, false) => "u16",
Fixed(I32, true) => "i32",
Fixed(I32, false) => "u32",
Fixed(I64, true) => "i64",
Fixed(I64, false) => "u64",
Fixed(I128, true) => "i128",
Fixed(I128, false) => "u128",
}
.to_owned()
}

View file

@ -37,8 +37,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line
// are deliberately not in a doc comment, because they need not be in public docs.)
//
// Latest feature: Pretty printing of no_mangle attributes changed
pub const FORMAT_VERSION: u32 = 53;
// Latest feature: Structured Attributes
pub const FORMAT_VERSION: u32 = 54;
/// The root of the emitted JSON blob.
///
@ -195,13 +195,94 @@ pub struct Item {
/// - `#[repr(C)]` and other reprs also appear as themselves,
/// though potentially with a different order: e.g. `repr(i8, C)` may become `repr(C, i8)`.
/// Multiple repr attributes on the same item may be combined into an equivalent single attr.
pub attrs: Vec<String>,
pub attrs: Vec<Attribute>,
/// Information about the items deprecation, if present.
pub deprecation: Option<Deprecation>,
/// The type-specific fields describing this item.
pub inner: ItemEnum,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
/// An attribute, e.g. `#[repr(C)]`
///
/// This doesn't include:
/// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead.
/// - `#[deprecated]`. These are in [`Item::deprecation`] instead.
pub enum Attribute {
/// `#[non_exhaustive]`
NonExhaustive,
/// `#[must_use]`
MustUse { reason: Option<String> },
/// `#[export_name = "name"]`
ExportName(String),
/// `#[link_section = "name"]`
LinkSection(String),
/// `#[automatically_derived]`
AutomaticallyDerived,
/// `#[repr]`
Repr(AttributeRepr),
/// `#[no_mangle]`
NoMangle,
/// #[target_feature(enable = "feature1", enable = "feature2")]
TargetFeature { enable: Vec<String> },
/// Something else.
///
/// Things here are explicitly *not* covered by the [`FORMAT_VERSION`]
/// constant, and may change without bumping the format version.
///
/// As an implementation detail, this is currently either:
/// 1. A HIR debug printing, like `"#[attr = Optimize(Speed)]"`
/// 2. The attribute as it appears in source form, like
/// `"#[optimize(speed)]"`.
Other(String),
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
/// The contents of a `#[repr(...)]` attribute.
///
/// Used in [`Attribute::Repr`].
pub struct AttributeRepr {
/// The representation, e.g. `#[repr(C)]`, `#[repr(transparent)]`
pub kind: ReprKind,
/// Alignment in bytes, if explicitly specified by `#[repr(align(...)]`.
pub align: Option<u64>,
/// Alignment in bytes, if explicitly specified by `#[repr(packed(...)]]`.
pub packed: Option<u64>,
/// The integer type for an enum descriminant, if explicitly specified.
///
/// e.g. `"i32"`, for `#[repr(C, i32)]`
pub int: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
/// The kind of `#[repr]`.
///
/// See [AttributeRepr::kind]`.
pub enum ReprKind {
/// `#[repr(Rust)]`
///
/// Also the default.
Rust,
/// `#[repr(C)]`
C,
/// `#[repr(transparent)]
Transparent,
/// `#[repr(simd)]`
Simd,
}
/// A range of source code.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Span {
@ -1343,7 +1424,7 @@ pub struct Static {
/// Is the static `unsafe`?
///
/// This is only true if it's in an `extern` block, and not explicity marked
/// This is only true if it's in an `extern` block, and not explicitly marked
/// as `safe`.
///
/// ```rust

@ -1 +1 @@
Subproject commit eabb4cd923deb73e714f7ad3f5234d68ca284dbe
Subproject commit 6833aa715d724437dc1247d0166afe314ab6854e

View file

@ -971,6 +971,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-mips64",
"only-msp430",
"only-msvc",
"only-musl",
"only-nightly",
"only-nvptx64",
"only-powerpc",

View file

@ -13,7 +13,7 @@ use rustc_index::IndexVec;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::dependency_format::Linkage;
use rustc_middle::middle::exported_symbols::ExportedSymbol;
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, MaybeResult, TyAndLayout};
use rustc_middle::ty::layout::{LayoutOf, MaybeResult, TyAndLayout};
use rustc_middle::ty::{self, Binder, FloatTy, FnSig, IntTy, Ty, TyCtxt, UintTy};
use rustc_session::config::CrateType;
use rustc_span::{Span, Symbol};

View file

@ -0,0 +1,6 @@
fn main() {
let v: Vec<u16> = vec![1, 2];
// This read is also misaligned. We make sure that the OOB message has priority.
let x = unsafe { *v.as_ptr().wrapping_byte_sub(5) }; //~ ERROR: before the beginning of the allocation
panic!("this should never print: {}", x);
}

View file

@ -0,0 +1,21 @@
error: Undefined Behavior: memory access failed: attempting to access 2 bytes, but got ALLOC-0x5 which points to before the beginning of the allocation
--> tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs:LL:CC
|
LL | let x = unsafe { *v.as_ptr().wrapping_byte_sub(5) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
help: ALLOC was allocated here:
--> tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs:LL:CC
|
LL | let v: Vec<u16> = vec![1, 2];
| ^^^^^^^^^^
= note: BACKTRACE (of the first span):
= note: inside `main` at tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs:LL:CC
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View file

@ -0,0 +1,6 @@
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
let x = unsafe { x.wrapping_offset(-1).offset(-1) }; //~ERROR: before the beginning of the allocation
panic!("this should never print: {:?}", x);
}

View file

@ -0,0 +1,20 @@
error: Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by -1 bytes, but got ALLOC-0x1 which points to before the beginning of the allocation
--> tests/fail/intrinsics/ptr_offset_out_of_bounds_neg2.rs:LL:CC
|
LL | let x = unsafe { x.wrapping_offset(-1).offset(-1) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
help: ALLOC was allocated here:
--> tests/fail/intrinsics/ptr_offset_out_of_bounds_neg2.rs:LL:CC
|
LL | let v = [0i8; 4];
| ^
= note: BACKTRACE (of the first span):
= note: inside `main` at tests/fail/intrinsics/ptr_offset_out_of_bounds_neg2.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View file

@ -335,7 +335,9 @@ fn run(support_lib_count: usize, exe: String, all_args: Vec<String>) {
std::process::exit(code);
} else {
println!("died due to signal {}", code);
std::process::exit(3);
// Behave like bash and other tools and exit with 128 + the signal
// number. That way we can avoid special case code in other places.
std::process::exit(128 + code);
}
}

View file

@ -1,6 +1,7 @@
use std::collections::BTreeSet;
use std::path::Path;
use object::{self, Object, ObjectSymbol, SymbolIterator};
use object::{self, Object, ObjectSymbol};
/// Given an [`object::File`], find the exported dynamic symbol names via
/// [`object::Object::exports`]. This does not distinguish between which section the symbols appear
@ -14,47 +15,180 @@ pub fn exported_dynamic_symbol_names<'file>(file: &'file object::File<'file>) ->
.collect()
}
/// Iterate through the symbols in an object file. See [`object::Object::symbols`].
/// Check an object file's symbols for any matching **substrings**. That is, if an object file
/// contains a symbol named `hello_world`, it will be matched against a provided `substrings` of
/// `["hello", "bar"]`.
///
/// Returns `true` if **any** of the symbols found in the object file at `path` contain a
/// **substring** listed in `substrings`.
///
/// Panics if `path` is not a valid object file readable by the current user or if `path` cannot be
/// parsed as a recognized object file.
///
/// # Platform-specific behavior
///
/// On Windows MSVC, the binary (e.g. `main.exe`) does not contain the symbols, but in the separate
/// PDB file instead. Furthermore, you will need to use [`crate::llvm::llvm_pdbutil`] as `object`
/// crate does not handle PDB files.
#[track_caller]
pub fn with_symbol_iter<P, F, R>(path: P, func: F) -> R
pub fn object_contains_any_symbol_substring<P, S>(path: P, substrings: &[S]) -> bool
where
P: AsRef<Path>,
F: FnOnce(&mut SymbolIterator<'_, '_>) -> R,
S: AsRef<str>,
{
let path = path.as_ref();
let blob = crate::fs::read(path);
let f = object::File::parse(&*blob)
let obj = object::File::parse(&*blob)
.unwrap_or_else(|e| panic!("failed to parse `{}`: {e}", path.display()));
let mut iter = f.symbols();
func(&mut iter)
let substrings = substrings.iter().map(|s| s.as_ref()).collect::<Vec<_>>();
for sym in obj.symbols() {
for substring in &substrings {
if sym.name_bytes().unwrap().windows(substring.len()).any(|x| x == substring.as_bytes())
{
return true;
}
}
}
false
}
/// Check an object file's symbols for substrings.
/// Check an object file's symbols for any exact matches against those provided in
/// `candidate_symbols`.
///
/// Returns `true` if any of the symbols found in the object file at `path` contain a substring
/// listed in `substrings`.
/// Returns `true` if **any** of the symbols found in the object file at `path` contain an **exact
/// match** against those listed in `candidate_symbols`. Take care to account for (1) platform
/// differences and (2) calling convention and symbol decorations differences.
///
/// Panics if `path` is not a valid object file readable by the current user or if `path` cannot be
/// parsed as a recognized object file.
///
/// # Platform-specific behavior
///
/// See [`object_contains_any_symbol_substring`].
#[track_caller]
pub fn any_symbol_contains(path: impl AsRef<Path>, substrings: &[&str]) -> bool {
with_symbol_iter(path, |syms| {
for sym in syms {
for substring in substrings {
if sym
.name_bytes()
.unwrap()
.windows(substring.len())
.any(|x| x == substring.as_bytes())
{
eprintln!("{:?} contains {}", sym, substring);
return true;
}
pub fn object_contains_any_symbol<P, S>(path: P, candidate_symbols: &[S]) -> bool
where
P: AsRef<Path>,
S: AsRef<str>,
{
let path = path.as_ref();
let blob = crate::fs::read(path);
let obj = object::File::parse(&*blob)
.unwrap_or_else(|e| panic!("failed to parse `{}`: {e}", path.display()));
let candidate_symbols = candidate_symbols.iter().map(|s| s.as_ref()).collect::<Vec<_>>();
for sym in obj.symbols() {
for candidate_symbol in &candidate_symbols {
if sym.name_bytes().unwrap() == candidate_symbol.as_bytes() {
return true;
}
}
false
})
}
false
}
#[derive(Debug, PartialEq)]
pub enum ContainsAllSymbolSubstringsOutcome<'a> {
Ok,
MissingSymbolSubstrings(BTreeSet<&'a str>),
}
/// Check an object file's symbols for presence of all of provided **substrings**. That is, if an
/// object file contains symbols `["hello", "goodbye", "world"]`, it will be matched against a list
/// of `substrings` of `["he", "go"]`. In this case, `he` is a substring of `hello`, and `go` is a
/// substring of `goodbye`, so each of `substrings` was found.
///
/// Returns `true` if **all** `substrings` were present in the names of symbols for the given object
/// file (as substrings of symbol names).
///
/// Panics if `path` is not a valid object file readable by the current user or if `path` cannot be
/// parsed as a recognized object file.
///
/// # Platform-specific behavior
///
/// See [`object_contains_any_symbol_substring`].
#[track_caller]
pub fn object_contains_all_symbol_substring<'s, P, S>(
path: P,
substrings: &'s [S],
) -> ContainsAllSymbolSubstringsOutcome<'s>
where
P: AsRef<Path>,
S: AsRef<str>,
{
let path = path.as_ref();
let blob = crate::fs::read(path);
let obj = object::File::parse(&*blob)
.unwrap_or_else(|e| panic!("failed to parse `{}`: {e}", path.display()));
let substrings = substrings.iter().map(|s| s.as_ref());
let mut unmatched_symbol_substrings = BTreeSet::from_iter(substrings);
unmatched_symbol_substrings.retain(|unmatched_symbol_substring| {
for sym in obj.symbols() {
if sym
.name_bytes()
.unwrap()
.windows(unmatched_symbol_substring.len())
.any(|x| x == unmatched_symbol_substring.as_bytes())
{
return false;
}
}
true
});
if unmatched_symbol_substrings.is_empty() {
ContainsAllSymbolSubstringsOutcome::Ok
} else {
ContainsAllSymbolSubstringsOutcome::MissingSymbolSubstrings(unmatched_symbol_substrings)
}
}
#[derive(Debug, PartialEq)]
pub enum ContainsAllSymbolsOutcome<'a> {
Ok,
MissingSymbols(BTreeSet<&'a str>),
}
/// Check an object file contains all symbols provided in `candidate_symbols`.
///
/// Returns `true` if **all** of the symbols in `candidate_symbols` are found within the object file
/// at `path` by **exact match**. Take care to account for (1) platform differences and (2) calling
/// convention and symbol decorations differences.
///
/// Panics if `path` is not a valid object file readable by the current user or if `path` cannot be
/// parsed as a recognized object file.
///
/// # Platform-specific behavior
///
/// See [`object_contains_any_symbol_substring`].
#[track_caller]
pub fn object_contains_all_symbols<P, S>(
path: P,
candidate_symbols: &[S],
) -> ContainsAllSymbolsOutcome<'_>
where
P: AsRef<Path>,
S: AsRef<str>,
{
let path = path.as_ref();
let blob = crate::fs::read(path);
let obj = object::File::parse(&*blob)
.unwrap_or_else(|e| panic!("failed to parse `{}`: {e}", path.display()));
let candidate_symbols = candidate_symbols.iter().map(|s| s.as_ref());
let mut unmatched_symbols = BTreeSet::from_iter(candidate_symbols);
unmatched_symbols.retain(|unmatched_symbol| {
for sym in obj.symbols() {
if sym.name_bytes().unwrap() == unmatched_symbol.as_bytes() {
return false;
}
}
true
});
if unmatched_symbols.is_empty() {
ContainsAllSymbolsOutcome::Ok
} else {
ContainsAllSymbolsOutcome::MissingSymbols(unmatched_symbols)
}
}

View file

@ -885,9 +885,9 @@ dependencies = [
[[package]]
name = "mdbook"
version = "0.4.51"
version = "0.4.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a87e65420ab45ca9c1b8cdf698f95b710cc826d373fa550f0f7fad82beac9328"
checksum = "93c284d2855916af7c5919cf9ad897cfc77d3c2db6f55429c7cfb769182030ec"
dependencies = [
"ammonia",
"anyhow",

View file

@ -15,6 +15,6 @@ mdbook-i18n-helpers = "0.3.3"
mdbook-spec = { path = "../../doc/reference/mdbook-spec" }
[dependencies.mdbook]
version = "0.4.51"
version = "0.4.52"
default-features = false
features = ["search"]

View file

@ -1,8 +0,0 @@
[package]
name = "suggest-tests"
version = "0.1.0"
edition = "2021"
[dependencies]
glob = "0.3.0"
build_helper = { version = "0.1.0", path = "../../build_helper" }

View file

@ -1,32 +0,0 @@
use std::path::Path;
use crate::Suggestion;
type DynamicSuggestion = fn(&Path) -> Vec<Suggestion>;
pub(crate) const DYNAMIC_SUGGESTIONS: &[DynamicSuggestion] = &[
|path: &Path| -> Vec<Suggestion> {
if path.starts_with("compiler/") || path.starts_with("library/") {
let path = path.components().take(2).collect::<Vec<_>>();
vec![Suggestion::with_single_path(
"test",
None,
&format!(
"{}/{}",
path[0].as_os_str().to_str().unwrap(),
path[1].as_os_str().to_str().unwrap()
),
)]
} else {
Vec::new()
}
},
|path: &Path| -> Vec<Suggestion> {
if path.starts_with("compiler/rustc_pattern_analysis") {
vec![Suggestion::new("test", None, &["tests/ui", "--test-args", "pattern"])]
} else {
Vec::new()
}
},
];

View file

@ -1,96 +0,0 @@
use std::fmt::{self, Display};
use std::path::Path;
use dynamic_suggestions::DYNAMIC_SUGGESTIONS;
use glob::Pattern;
use static_suggestions::static_suggestions;
mod dynamic_suggestions;
mod static_suggestions;
#[cfg(test)]
mod tests;
macro_rules! sug {
($cmd:expr) => {
Suggestion::new($cmd, None, &[])
};
($cmd:expr, $paths:expr) => {
Suggestion::new($cmd, None, $paths.as_slice())
};
($cmd:expr, $stage:expr, $paths:expr) => {
Suggestion::new($cmd, Some($stage), $paths.as_slice())
};
}
pub(crate) use sug;
pub fn get_suggestions<T: AsRef<str>>(modified_files: &[T]) -> Vec<Suggestion> {
let mut suggestions = Vec::new();
// static suggestions
for (globs, sugs) in static_suggestions().iter() {
let globs = globs
.iter()
.map(|glob| Pattern::new(glob).expect("Found invalid glob pattern!"))
.collect::<Vec<_>>();
let matches_some_glob = |file: &str| globs.iter().any(|glob| glob.matches(file));
if modified_files.iter().map(AsRef::as_ref).any(matches_some_glob) {
suggestions.extend_from_slice(sugs);
}
}
// dynamic suggestions
for sug in DYNAMIC_SUGGESTIONS {
for file in modified_files {
let sugs = sug(Path::new(file.as_ref()));
suggestions.extend_from_slice(&sugs);
}
}
suggestions.sort();
suggestions.dedup();
suggestions
}
#[derive(Clone, PartialOrd, Ord, PartialEq, Eq, Debug)]
pub struct Suggestion {
pub cmd: String,
pub stage: Option<u32>,
pub paths: Vec<String>,
}
impl Suggestion {
pub fn new(cmd: &str, stage: Option<u32>, paths: &[&str]) -> Self {
Self { cmd: cmd.to_owned(), stage, paths: paths.iter().map(|p| p.to_string()).collect() }
}
pub fn with_single_path(cmd: &str, stage: Option<u32>, path: &str) -> Self {
Self::new(cmd, stage, &[path])
}
}
impl Display for Suggestion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{} ", self.cmd)?;
for path in &self.paths {
write!(f, "{} ", path)?;
}
if let Some(stage) = self.stage {
write!(f, "{}", stage)?;
} else {
// write a sentinel value here (in place of a stage) to be consumed
// by the shim in bootstrap, it will be read and ignored.
write!(f, "N/A")?;
}
Ok(())
}
}

View file

@ -1,40 +0,0 @@
use std::process::ExitCode;
use build_helper::git::{GitConfig, get_git_modified_files};
use suggest_tests::get_suggestions;
fn main() -> ExitCode {
let modified_files = get_git_modified_files(
&GitConfig {
nightly_branch: &env("SUGGEST_TESTS_NIGHTLY_BRANCH"),
git_merge_commit_email: &env("SUGGEST_TESTS_MERGE_COMMIT_EMAIL"),
},
None,
&Vec::new(),
);
let modified_files = match modified_files {
Ok(files) => files,
Err(err) => {
eprintln!("Could not get modified files from git: \"{err}\"");
return ExitCode::FAILURE;
}
};
let suggestions = get_suggestions(&modified_files);
for sug in &suggestions {
println!("{sug}");
}
ExitCode::SUCCESS
}
fn env(key: &str) -> String {
match std::env::var(key) {
Ok(var) => var,
Err(err) => {
eprintln!("suggest-tests: failed to read environment variable {key}: {err}");
std::process::exit(1);
}
}
}

View file

@ -1,40 +0,0 @@
use std::sync::OnceLock;
use crate::{Suggestion, sug};
// FIXME: perhaps this could use `std::lazy` when it is stabilized
macro_rules! static_suggestions {
($( [ $( $glob:expr ),* $(,)? ] => [ $( $suggestion:expr ),* $(,)? ] ),* $(,)? ) => {
pub(crate) fn static_suggestions() -> &'static [(Vec<&'static str>, Vec<Suggestion>)]
{
static S: OnceLock<Vec<(Vec<&'static str>, Vec<Suggestion>)>> = OnceLock::new();
S.get_or_init(|| vec![ $( (vec![ $($glob),* ], vec![ $($suggestion),* ]) ),*])
}
}
}
static_suggestions! {
["*.md"] => [
sug!("test", 0, ["linkchecker"]),
],
["compiler/*"] => [
sug!("check"),
sug!("test", 1, ["tests/ui", "tests/run-make"]),
],
["compiler/rustc_mir_transform/*"] => [
sug!("test", 1, ["mir-opt"]),
],
[
"compiler/rustc_mir_transform/src/coverage/*",
"compiler/rustc_codegen_llvm/src/coverageinfo/*",
] => [
sug!("test", 1, ["coverage"]),
],
["src/librustdoc/*"] => [
sug!("test", 1, ["rustdoc"]),
],
}

View file

@ -1,21 +0,0 @@
macro_rules! sugg_test {
( $( $name:ident: $paths:expr => $suggestions:expr ),* ) => {
$(
#[test]
fn $name() {
let suggestions = crate::get_suggestions(&$paths).into_iter().map(|s| s.to_string()).collect::<Vec<_>>();
assert_eq!(suggestions, $suggestions);
}
)*
};
}
sugg_test! {
test_error_code_docs: ["compiler/rustc_error_codes/src/error_codes/E0000.md"] =>
["check N/A", "test compiler/rustc_error_codes N/A", "test linkchecker 0", "test tests/ui tests/run-make 1"],
test_rustdoc: ["src/librustdoc/src/lib.rs"] => ["test rustdoc 1"],
test_rustdoc_and_libstd: ["src/librustdoc/src/lib.rs", "library/std/src/lib.rs"] =>
["test library/std N/A", "test rustdoc 1"]
}

View file

@ -0,0 +1,40 @@
//! Tidy check to ensure that there are no filenames containing forbidden characters
//! checked into the source tree by accident:
//! - Non-UTF8 filenames
//! - Control characters such as CR or TAB
//! - Filenames containing ":" as they are not supported on Windows
//!
//! Only files added to git are checked, as it may be acceptable to have temporary
//! invalid filenames in the local directory during development.
use std::path::Path;
use std::process::Command;
pub fn check(root_path: &Path, bad: &mut bool) {
let stat_output = Command::new("git")
.arg("-C")
.arg(root_path)
.args(["ls-files", "-z"])
.output()
.unwrap()
.stdout;
for filename in stat_output.split(|&b| b == 0) {
match str::from_utf8(filename) {
Err(_) => tidy_error!(
bad,
r#"non-UTF8 file names are not supported: "{}""#,
String::from_utf8_lossy(filename),
),
Ok(name) if name.chars().any(|c| c.is_control()) => tidy_error!(
bad,
r#"control characters are not supported in file names: "{}""#,
String::from_utf8_lossy(filename),
),
Ok(name) if name.contains(':') => tidy_error!(
bad,
r#"":" is not supported in file names because of Windows compatibility: "{name}""#,
),
_ => (),
}
}
}

View file

@ -2338,7 +2338,6 @@ ui/issues/issue-50415.rs
ui/issues/issue-50442.rs
ui/issues/issue-50471.rs
ui/issues/issue-50518.rs
ui/issues/issue-50571.rs
ui/issues/issue-50581.rs
ui/issues/issue-50582.rs
ui/issues/issue-50585.rs

View file

@ -167,6 +167,7 @@ pub mod error_codes;
pub mod ext_tool_checks;
pub mod extdeps;
pub mod features;
pub mod filenames;
pub mod fluent_alphabetical;
pub mod fluent_period;
mod fluent_used;

View file

@ -155,6 +155,8 @@ fn main() {
check!(triagebot, &root_path);
check!(filenames, &root_path);
let collected = {
drain_handles(&mut handles);

View file

@ -17,7 +17,7 @@ use ignore::Walk;
const ENTRY_LIMIT: u32 = 901;
// FIXME: The following limits should be reduced eventually.
const ISSUES_ENTRY_LIMIT: u32 = 1619;
const ISSUES_ENTRY_LIMIT: u32 = 1616;
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
"rs", // test source files