From a010cc6588ffc555722dc91cf98416a59f0426d9 Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Fri, 2 Oct 2026 11:28:15 -0500 Subject: [PATCH 1/9] Add option to pass --frontend-threads to rustc-perf --- src/bootstrap/src/core/build_steps/perf.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/perf.rs b/src/bootstrap/src/core/build_steps/perf.rs index e01ff61eb6f86..2ee8f1e921c1e 100644 --- a/src/bootstrap/src/core/build_steps/perf.rs +++ b/src/bootstrap/src/core/build_steps/perf.rs @@ -94,6 +94,11 @@ struct SharedOpts { #[clap(long, global = true)] database_path: Option, + + /// Comma-separated list of thread counts for the parallel frontend. Maps directly to the + /// `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1. + #[clap(long, global = true, value_delimiter = ',')] + frontend_threads: Vec, } #[derive(Clone, Copy, Debug, PartialEq, clap::ValueEnum)] @@ -257,4 +262,8 @@ fn apply_shared_opts(cmd: &mut BootstrapCommand, opts: &SharedOpts) { cmd.arg("--scenarios") .arg(opts.scenarios.iter().map(|p| p.to_string()).collect::>().join(",")); } + if !opts.frontend_threads.is_empty() { + cmd.arg("--frontend-threads") + .arg(opts.frontend_threads.iter().map(|p| p.to_string()).collect::>().join(",")); + } } From 0050bb2a1795a542f12fa20695d5da174347af14 Mon Sep 17 00:00:00 2001 From: itsjunetime Date: Fri, 2 Oct 2026 11:32:29 -0500 Subject: [PATCH 2/9] Regenerate completions --- src/etc/completions/x.fish | 4 ++++ src/etc/completions/x.ps1 | 4 ++++ src/etc/completions/x.py.fish | 4 ++++ src/etc/completions/x.py.ps1 | 4 ++++ src/etc/completions/x.py.sh | 24 ++++++++++++++++++++---- src/etc/completions/x.py.zsh | 4 ++++ src/etc/completions/x.sh | 24 ++++++++++++++++++++---- src/etc/completions/x.zsh | 4 ++++ 8 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/etc/completions/x.fish b/src/etc/completions/x.fish index 4ce38dd42033a..9a9142f3540ba 100644 --- a/src/etc/completions/x.fish +++ b/src/etc/completions/x.fish @@ -921,6 +921,7 @@ complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_fro complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l database-path -r +complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l config -d 'TOML configuration file for build' -r -F complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -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 perf; and __fish_seen_subcommand_from eprintln" -l build -d 'host target of the stage0 compiler' -r -f @@ -961,6 +962,7 @@ complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_fro complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from samply" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from samply" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from samply" -l database-path -r +complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from samply" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from samply" -l config -d 'TOML configuration file for build' -r -F complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from samply" -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 perf; and __fish_seen_subcommand_from samply" -l build -d 'host target of the stage0 compiler' -r -f @@ -1001,6 +1003,7 @@ complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_fro complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l database-path -r +complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l config -d 'TOML configuration file for build' -r -F complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -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 perf; and __fish_seen_subcommand_from cachegrind" -l build -d 'host target of the stage0 compiler' -r -f @@ -1041,6 +1044,7 @@ complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_fro complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l database-path -r +complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l config -d 'TOML configuration file for build' -r -F complete -c x -n "__fish_x_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -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 perf; and __fish_seen_subcommand_from benchmark" -l build -d 'host target of the stage0 compiler' -r -f diff --git a/src/etc/completions/x.ps1 b/src/etc/completions/x.ps1 index 61a4d0d65de91..9fe020c8e1cf6 100644 --- a/src/etc/completions/x.ps1 +++ b/src/etc/completions/x.ps1 @@ -1094,6 +1094,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') @@ -1142,6 +1143,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') @@ -1190,6 +1192,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') @@ -1238,6 +1241,7 @@ Register-ArgumentCompleter -Native -CommandName 'x' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') diff --git a/src/etc/completions/x.py.fish b/src/etc/completions/x.py.fish index 28b1767fc0e96..9f3056fdb3b63 100644 --- a/src/etc/completions/x.py.fish +++ b/src/etc/completions/x.py.fish @@ -921,6 +921,7 @@ complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcomma complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l database-path -r +complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -l config -d 'TOML configuration file for build' -r -F complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from eprintln" -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 perf; and __fish_seen_subcommand_from eprintln" -l build -d 'host target of the stage0 compiler' -r -f @@ -961,6 +962,7 @@ complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcomma complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from samply" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from samply" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from samply" -l database-path -r +complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from samply" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from samply" -l config -d 'TOML configuration file for build' -r -F complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from samply" -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 perf; and __fish_seen_subcommand_from samply" -l build -d 'host target of the stage0 compiler' -r -f @@ -1001,6 +1003,7 @@ complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcomma complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l database-path -r +complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -l config -d 'TOML configuration file for build' -r -F complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from cachegrind" -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 perf; and __fish_seen_subcommand_from cachegrind" -l build -d 'host target of the stage0 compiler' -r -f @@ -1041,6 +1044,7 @@ complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcomma complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l scenarios -d 'Select the scenarios that should be benchmarked' -r -f -a "{Full\t'',IncrFull\t'',IncrUnchanged\t'',IncrPatched\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l profiles -d 'Select the profiles that should be benchmarked' -r -f -a "{Check\t'',Debug\t'',Doc\t'',DocJson\t'',Opt\t'',Clippy\t''}" complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l database-path -r +complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l frontend-threads -d 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1' -r complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -l config -d 'TOML configuration file for build' -r -F complete -c x.py -n "__fish_x.py_using_subcommand perf; and __fish_seen_subcommand_from benchmark" -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 perf; and __fish_seen_subcommand_from benchmark" -l build -d 'host target of the stage0 compiler' -r -f diff --git a/src/etc/completions/x.py.ps1 b/src/etc/completions/x.py.ps1 index 7178833189ac6..189b69df3c6f1 100644 --- a/src/etc/completions/x.py.ps1 +++ b/src/etc/completions/x.py.ps1 @@ -1094,6 +1094,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') @@ -1142,6 +1143,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') @@ -1190,6 +1192,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') @@ -1238,6 +1241,7 @@ Register-ArgumentCompleter -Native -CommandName 'x.py' -ScriptBlock { [CompletionResult]::new('--scenarios', '--scenarios', [CompletionResultType]::ParameterName, 'Select the scenarios that should be benchmarked') [CompletionResult]::new('--profiles', '--profiles', [CompletionResultType]::ParameterName, 'Select the profiles that should be benchmarked') [CompletionResult]::new('--database-path', '--database-path', [CompletionResultType]::ParameterName, 'database-path') + [CompletionResult]::new('--frontend-threads', '--frontend-threads', [CompletionResultType]::ParameterName, 'Comma-separated list of thread counts for the parallel frontend. Maps directly to the `-Zthreads` rustc option. If unspecified, `rustc-perf` uses only 1') [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') diff --git a/src/etc/completions/x.py.sh b/src/etc/completions/x.py.sh index f1b35e4cbc894..7bc3da600c2fe 100644 --- a/src/etc/completions/x.py.sh +++ b/src/etc/completions/x.py.sh @@ -3094,7 +3094,7 @@ _x.py() { return 0 ;; x.py__perf__benchmark) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3120,6 +3120,10 @@ _x.py() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then @@ -3296,7 +3300,7 @@ _x.py() { return 0 ;; x.py__perf__cachegrind) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3322,6 +3326,10 @@ _x.py() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then @@ -3688,7 +3696,7 @@ _x.py() { return 0 ;; x.py__perf__eprintln) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3714,6 +3722,10 @@ _x.py() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then @@ -3890,7 +3902,7 @@ _x.py() { return 0 ;; x.py__perf__samply) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3916,6 +3928,10 @@ _x.py() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then diff --git a/src/etc/completions/x.py.zsh b/src/etc/completions/x.py.zsh index 8376e44746052..c06d0f316053a 100644 --- a/src/etc/completions/x.py.zsh +++ b/src/etc/completions/x.py.zsh @@ -1124,6 +1124,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ @@ -1174,6 +1175,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ @@ -1224,6 +1226,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ @@ -1274,6 +1277,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ diff --git a/src/etc/completions/x.sh b/src/etc/completions/x.sh index be81e2e743e7c..a60e9083730e3 100644 --- a/src/etc/completions/x.sh +++ b/src/etc/completions/x.sh @@ -3094,7 +3094,7 @@ _x() { return 0 ;; x__perf__benchmark) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3120,6 +3120,10 @@ _x() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then @@ -3296,7 +3300,7 @@ _x() { return 0 ;; x__perf__cachegrind) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3322,6 +3326,10 @@ _x() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then @@ -3688,7 +3696,7 @@ _x() { return 0 ;; x__perf__eprintln) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3714,6 +3722,10 @@ _x() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then @@ -3890,7 +3902,7 @@ _x() { return 0 ;; x__perf__samply) - opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --verbose --quiet --incremental --config --build-dir --build --host --target --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]..." + opts="-v -q -i -j -h --include --exclude --scenarios --profiles --database-path --frontend-threads --verbose --quiet --incremental --config --build-dir --build --host --target --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 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3916,6 +3928,10 @@ _x() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + --frontend-threads) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --config) local oldifs if [ -n "${IFS+x}" ]; then diff --git a/src/etc/completions/x.zsh b/src/etc/completions/x.zsh index 3159859c1ea8e..21857db8899ab 100644 --- a/src/etc/completions/x.zsh +++ b/src/etc/completions/x.zsh @@ -1124,6 +1124,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ @@ -1174,6 +1175,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ @@ -1224,6 +1226,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ @@ -1274,6 +1277,7 @@ _arguments "${_arguments_options[@]}" : \ '*--scenarios=[Select the scenarios that should be benchmarked]:SCENARIOS:(Full IncrFull IncrUnchanged IncrPatched)' \ '*--profiles=[Select the profiles that should be benchmarked]:PROFILES:(Check Debug Doc DocJson Opt Clippy)' \ '--database-path=[]:DATABASE_PATH:_default' \ +'*--frontend-threads=[Comma-separated list of thread counts for the parallel frontend. Maps directly to the \`-Zthreads\` rustc option. If unspecified, \`rustc-perf\` uses only 1]:FRONTEND_THREADS:_default' \ '--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:' \ From 6749841b633242f94c75fdda849a41304ddbac56 Mon Sep 17 00:00:00 2001 From: ltdk Date: Sat, 3 Oct 2026 13:25:28 -0400 Subject: [PATCH 3/9] Stabilize CStr::display --- library/core/src/ffi/c_str.rs | 12 ++++-------- library/coretests/tests/lib.rs | 1 - library/std/src/ffi/c_str.rs | 2 +- library/std/src/lib.rs | 1 - 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index d79af3afbc56e..daa68e885d893 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -650,12 +650,10 @@ impl CStr { /// # Examples /// /// ``` - /// #![feature(cstr_display)] - /// /// let cstr = c"Hello, world!"; /// println!("{}", cstr.display()); /// ``` - #[unstable(feature = "cstr_display", issue = "139984")] + #[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this does not display the `CStr`; \ it returns an object that can be displayed"] #[inline] @@ -870,27 +868,25 @@ impl FusedIterator for Bytes<'_> {} /// # Examples /// /// ``` -/// #![feature(cstr_display)] -/// /// let s = c"Hello, world!"; /// println!("{}", s.display()); /// ``` /// /// [`Display`]: fmt::Display /// [`format!`]: ../../../std/macro.format.html -#[unstable(feature = "cstr_display", issue = "139984")] +#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] pub struct Display<'a> { c_str: &'a CStr, } -#[unstable(feature = "cstr_display", issue = "139984")] +#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.c_str, f) } } -#[unstable(feature = "cstr_display", issue = "139984")] +#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(crate::bstr::ByteStr::from_bytes(self.c_str.to_bytes()), f) diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index fc2430a10edb4..ffa717aa4aa4d 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -47,7 +47,6 @@ #![feature(core_io_borrowed_buf)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] -#![feature(cstr_display)] #![feature(debug_closure_helpers)] #![feature(dec2flt)] #![feature(duration_constants)] diff --git a/library/std/src/ffi/c_str.rs b/library/std/src/ffi/c_str.rs index 9c3a6758929a8..e35acce2fef81 100644 --- a/library/std/src/ffi/c_str.rs +++ b/library/std/src/ffi/c_str.rs @@ -8,7 +8,7 @@ pub use alloc::ffi::c_str::IntoStringError; pub use alloc::ffi::c_str::{CString, NulError}; #[stable(feature = "rust1", since = "1.0.0")] pub use core::ffi::c_str::CStr; -#[unstable(feature = "cstr_display", issue = "139984")] +#[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] pub use core::ffi::c_str::Display; #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] pub use core::ffi::c_str::FromBytesUntilNulError; diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index baa9f8d769c82..52a87540ac0f0 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -333,7 +333,6 @@ #![feature(core_io)] #![feature(core_io_borrowed_buf)] #![feature(core_io_internals)] -#![feature(cstr_display)] #![feature(cursor_split)] #![feature(derive_const)] #![feature(duration_constants)] From 4cc87c17ff1050c77fb4fcb4b1cae5d152b3c7a0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 3 Oct 2026 12:02:52 +0200 Subject: [PATCH 4/9] c_str_alloc_error test: mention why this is mostly Miri-only --- library/alloctests/tests/c_str_alloc_error.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/alloctests/tests/c_str_alloc_error.rs b/library/alloctests/tests/c_str_alloc_error.rs index 669a783645baa..1e7d54d75b332 100644 --- a/library/alloctests/tests/c_str_alloc_error.rs +++ b/library/alloctests/tests/c_str_alloc_error.rs @@ -3,7 +3,7 @@ //! rust-lang/rust#70201 gave `::clone_into` a path that moved the //! target `CString`'s buffer out before growing a `Vec`; if that growth's allocation //! failed and unwound, the target was left without its nul terminator. This only -//! reproduces under Miri: in a normal build the `#[global_allocator]` below can't +//! reproduces under Miri: in a normal build, the `#[global_allocator]` below can't //! intercept the reallocation inside `CString::clone_into` (it lives in libstd, which //! library tests link with `-C prefer-dynamic`), so as a regular test it just checks //! the happy path. @@ -46,6 +46,8 @@ unsafe impl GlobalAlloc for OneShotFailingAlloc { } } +// This doesn't actually do anything outside Miri because of `-C prefer-dynamic` which effectively +// hard-codes the default allocator. #[global_allocator] static ALLOC: OneShotFailingAlloc = OneShotFailingAlloc; From 17f3f9cae9fb6eb1ea980340f04c0f3ae2be12b9 Mon Sep 17 00:00:00 2001 From: Davlat Davydov Date: Fri, 2 Oct 2026 02:26:15 +0300 Subject: [PATCH 5/9] Add documentation for the and attributes Fix test-tidy review changes review changes review changes fix llvm build ignore attribute documentation example fix tidy use no_run instead of ignore --- library/core/src/attribute_docs.rs | 98 ++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/library/core/src/attribute_docs.rs b/library/core/src/attribute_docs.rs index 584e1583c9bdb..1f7504255b408 100644 --- a/library/core/src/attribute_docs.rs +++ b/library/core/src/attribute_docs.rs @@ -406,6 +406,104 @@ const _: () = (); /// [the `no_std` attribute]: ../reference/names/preludes.html#the-no_std-attribute const _: () = (); +#[doc(attribute = "no_main")] +/// Prevents emitting the `main` entrypoint symbol. +/// +/// Written as an inner attribute at the top of the crate root, the `no_main` attribute prevents +/// the compiler from generating the program's standard Rust entrypoint, leaving that up to you. +/// This is useful when some other object being linked into the program defines the entrypoint, +/// or when you want to define the platform's `main` symbol yourself. +/// +/// If you define an entry point symbol that is suitable for your target, it must also be exported +/// under an unmangled name using the [`no_mangle` attribute]: +/// +/// ```no_run +/// #![no_main] +/// +/// use std::ffi::{c_char, c_int}; +/// +/// #[unsafe(no_mangle)] +/// pub extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int { +/// println!("Hello world!"); +/// 0 +/// } +/// ``` +/// +/// Unlike `no_std`, the `no_main` attribute does not prevent the compiler from generating +/// the startup routine or linking the standard library provided by the operating system's executable [ABI]. +/// +/// [ABI]: https://en.wikipedia.org/wiki/Application_binary_interface +/// [`no_mangle` attribute]: ../reference/abi.html#the-no_mangle-attribute +const _: () = (); + +#[doc(attribute = "repr")] +/// Specifies the [representation] of a type. +/// +/// Written as an outer attribute on a `struct`, `enum` or `union`, `repr` controls how the +/// type is laid out in memory. This is needed when passing types across an [FFI] boundary +/// or whenever you rely on a specific layout. +/// +/// The available representations are: +/// +/// * [`Rust`] (the default): the layout is unspecified and may change between compilations. +/// * [`C`]: the layout follows the rules of the C language for the target platform. +/// * The [primitive representations] (`u8`, `i32`, `usize`, ...): set the discriminant +/// type of an enum. +/// * [`transparent`]: the type has the same layout and ABI as its only non-zero-sized field. +/// +/// The `align(N)` and `packed(N)` modifiers raise or lower the alignment of a type, respectively. +/// `N` must be a power of two no greater than 229. The two modifiers cannot be +/// applied to the same type, and references to fields of a `packed` type cannot be created, +/// since they may be unaligned. +/// +/// # Examples +/// +/// ``` +/// #[repr(C, align(16))] +/// struct Foo { +/// first: u32, +/// second: u32, +/// third: u32, +/// } +/// +/// assert_eq!(align_of::(), 16); +/// // 12 bytes of fields, rounded up to a multiple of the alignment. +/// assert_eq!(size_of::(), 16); +/// ``` +/// +/// ``` +/// #[repr(C, packed(2))] +/// struct Foo { +/// first: u32, +/// second: u32, +/// third: u32, +/// } +/// +/// assert_eq!(align_of::(), 2); +/// assert_eq!(size_of::(), 12); +/// ``` +/// +/// ``` +/// #[repr(C)] +/// struct Foo { +/// item: T, +/// } +/// ``` +/// +/// `Foo` is laid out according to the C rules and is guaranteed to be 16-byte aligned. +/// +/// The representation is a property of the type definition, so it does +/// parameters: below, `Foo` and `Foo` both use the `C` representation. Their actual +/// layouts still differ, because they depend on `T`. +/// +/// [representation]: ../reference/type-layout.html#representations +/// [`Rust`]: ../reference/type-layout.html#the-rust-representation +/// [`C`]: ../reference/type-layout.html#the-c-representation +/// [primitive representations]: ../reference/type-layout.html#primitive-representations +/// [`transparent`]: ../reference/type-layout.html#the-transparent-representation +/// [FFI]: https://en.wikipedia.org/wiki/Foreign_function_interface +const _: () = (); + #[doc(attribute = "inline")] // /// Suggest that the compiler inline a function at its call sites. From 59a24269b1b1c3e30e8a693d4f2796c52fadcb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 3 Oct 2026 21:36:35 +0000 Subject: [PATCH 6/9] Remove useless `.into()` calls --- .../rustc_middle/src/ptrauth/discriminator.rs | 4 +--- compiler/rustc_parse/src/parser/diagnostics.rs | 2 +- compiler/rustc_privacy/src/lib.rs | 3 +-- .../src/error_reporting/infer/mod.rs | 18 +++++++++--------- .../src/normalize_projection_ty.rs | 2 +- library/alloc/src/raw_vec/mod.rs | 2 +- src/librustdoc/clean/utils.rs | 10 +++++----- 7 files changed, 19 insertions(+), 22 deletions(-) diff --git a/compiler/rustc_middle/src/ptrauth/discriminator.rs b/compiler/rustc_middle/src/ptrauth/discriminator.rs index 7501f1b072188..d44ecafb775ef 100644 --- a/compiler/rustc_middle/src/ptrauth/discriminator.rs +++ b/compiler/rustc_middle/src/ptrauth/discriminator.rs @@ -282,9 +282,7 @@ fn compute_fn_ptr_type_discriminator<'tcx>( enc.push(b'E'); - let hash = enc.finish(); - - hash.into() + enc.finish() } // Clang disc type. diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 0b3af1e2e3cd0..8113a020ef1ca 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -2322,7 +2322,7 @@ impl<'a> Parser<'a> { Applicability::MaybeIncorrect, ); } - Err(err.into()) + Err(err) } /// Handle encountering a symbol in a generic argument list that is not a `,` or `>`. In this diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 9406f23155399..16a2ee9f22eaf 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -518,8 +518,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { max_vis: Option, level: Level, ) -> bool { - let private_vis = - ty::Visibility::Restricted(self.tcx.parent_module_from_def_id(def_id).into()); + let private_vis = ty::Visibility::Restricted(self.tcx.parent_module_from_def_id(def_id)); if max_vis != Some(private_vis) { return self.effective_visibilities.update( def_id, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs index d83df2dfdf291..b2b57e018a7cf 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs @@ -1608,15 +1608,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ValuePairs::TraitRefs(_) => (false, Mismatch::Fixed("trait")), ValuePairs::Aliases(ExpectedFound { expected, .. }) => { let def_id = match expected.kind { - ty::AliasTermKind::ProjectionTy { def_id } => def_id.into(), - ty::AliasTermKind::InherentTy { def_id } => def_id.into(), - ty::AliasTermKind::OpaqueTy { def_id } => def_id.into(), - ty::AliasTermKind::FreeTy { def_id } => def_id.into(), - ty::AliasTermKind::AnonConst { def_id } => def_id.into(), - ty::AliasTermKind::ProjectionConst { def_id } => def_id.into(), - ty::AliasTermKind::FreeConst { def_id } => def_id.into(), - ty::AliasTermKind::InherentConstSelf { def_id } => def_id.into(), - ty::AliasTermKind::InherentConstImpl { def_id } => def_id.into(), + ty::AliasTermKind::ProjectionTy { def_id } + | ty::AliasTermKind::InherentTy { def_id } + | ty::AliasTermKind::OpaqueTy { def_id } + | ty::AliasTermKind::FreeTy { def_id } + | ty::AliasTermKind::AnonConst { def_id } + | ty::AliasTermKind::ProjectionConst { def_id } + | ty::AliasTermKind::FreeConst { def_id } + | ty::AliasTermKind::InherentConstSelf { def_id } + | ty::AliasTermKind::InherentConstImpl { def_id } => def_id, }; (false, Mismatch::Fixed(self.tcx.def_descr(def_id))) } diff --git a/compiler/rustc_traits/src/normalize_projection_ty.rs b/compiler/rustc_traits/src/normalize_projection_ty.rs index c3fe949d29d64..d2ab9298657a2 100644 --- a/compiler/rustc_traits/src/normalize_projection_ty.rs +++ b/compiler/rustc_traits/src/normalize_projection_ty.rs @@ -139,7 +139,7 @@ fn normalize_canonicalized_inherent_projection<'tcx>( let normalized_term = traits::normalize_inherent_projection( selcx, param_env, - goal.into(), + goal, cause, 0, &mut obligations, diff --git a/library/alloc/src/raw_vec/mod.rs b/library/alloc/src/raw_vec/mod.rs index 2a1c30509ebaf..2f284bb4229eb 100644 --- a/library/alloc/src/raw_vec/mod.rs +++ b/library/alloc/src/raw_vec/mod.rs @@ -663,7 +663,7 @@ impl RawVecInner { unsafe { let alloc_size = elem_layout.size().unchecked_mul(self.cap.as_inner()); let layout = Layout::from_size_align_unchecked(alloc_size, elem_layout.align()); - Some((self.ptr.into(), layout)) + Some((self.ptr, layout)) } } } diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index d8a3fa6bed22c..57e5ec2c4f0fb 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -356,11 +356,11 @@ pub(crate) fn print_const(tcx: TyCtxt<'_>, n: ty::Const<'_>) -> String { match n.kind() { ty::ConstKind::Alias(_, ty::AliasConst { kind, .. }) => { let def_id: DefId = match kind { - ty::AliasConstKind::Projection { def_id } => def_id.into(), - ty::AliasConstKind::InherentSelf { def_id } => def_id.into(), - ty::AliasConstKind::InherentImpl { def_id } => def_id.into(), - ty::AliasConstKind::Free { def_id } => def_id.into(), - ty::AliasConstKind::Anon { def_id } => def_id.into(), + ty::AliasConstKind::Projection { def_id } + | ty::AliasConstKind::InherentSelf { def_id } + | ty::AliasConstKind::InherentImpl { def_id } + | ty::AliasConstKind::Free { def_id } + | ty::AliasConstKind::Anon { def_id } => def_id, }; if let Some(local_def_id) = def_id.as_local() && let Some(body_id) = tcx.hir_maybe_body_owned_by(local_def_id) From 8cb6fcaa8fa7a3becf5e5c52dd82307ff6997757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 4 Oct 2026 00:12:30 +0000 Subject: [PATCH 7/9] Another useless into --- compiler/rustc_const_eval/src/interpret/intrinsics/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics/atomic.rs b/compiler/rustc_const_eval/src/interpret/intrinsics/atomic.rs index 3c45550016851..6eee95eb2750d 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics/atomic.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics/atomic.rs @@ -127,7 +127,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { _ => return interp_ok(false), } - trace!("{:?}", self.dump_place(&dest.clone().into())); + trace!("{:?}", self.dump_place(&dest)); self.return_to_block(ret)?; interp_ok(true) } From c7ebf416c75e15a511e45a4d690690b0547cb14b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 4 Oct 2026 00:58:38 +0000 Subject: [PATCH 8/9] Another useless into --- compiler/rustc_borrowck/src/type_check/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 0e8565aef3f0b..ab0d786c6f264 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1848,7 +1848,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { assert_eq!(tcx.trait_impl_of_assoc(def_id), None); self.prove_clauses( - args.terms().map(|t| ty::ClauseKind::WellFormed(t.into())), + args.terms().map(|t| ty::ClauseKind::WellFormed(t)), locations, ConstraintCategory::Boring, ); From 0ed52fadf48869a111a0b4e580271e53312914bd Mon Sep 17 00:00:00 2001 From: "Tim (Theemathas Chirananthavat)" Date: Fri, 18 Sep 2026 22:30:45 +0700 Subject: [PATCH 9/9] FCW for `#[panic_handler]` on `unsafe fn`. --- compiler/rustc_hir_typeck/src/check.rs | 17 ++++++++ compiler/rustc_hir_typeck/src/diagnostics.rs | 4 ++ compiler/rustc_lint_defs/src/builtin.rs | 39 +++++++++++++++++++ .../ui/codegen/no-mangle-on-panic-handler.rs | 2 +- .../codegen/no-mangle-on-panic-handler.stderr | 4 +- .../ui/panic-handler/unsafe_panic_handler.rs | 12 ++++++ .../panic-handler/unsafe_panic_handler.stderr | 12 ++++++ 7 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 tests/ui/panic-handler/unsafe_panic_handler.rs create mode 100644 tests/ui/panic-handler/unsafe_panic_handler.stderr diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs index 4f6345e04070b..35ec1fbaf207d 100644 --- a/compiler/rustc_hir_typeck/src/check.rs +++ b/compiler/rustc_hir_typeck/src/check.rs @@ -6,6 +6,7 @@ use rustc_hir::def::DefKind; use rustc_hir_analysis::check::check_function_signature; use rustc_infer::infer::RegionVariableOrigin; use rustc_infer::traits::WellFormedLoc; +use rustc_lint_defs::builtin::UNSAFE_PANIC_HANDLERS; use rustc_middle::ty::{self, Binder, Ty, TyCtxt}; use rustc_span::def_id::LocalDefId; use rustc_span::sym; @@ -13,6 +14,7 @@ use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; use tracing::{debug, instrument}; use crate::coercion::CoerceMany; +use crate::diagnostics::UnsafePanicHandlers; use crate::gather_locals::GatherLocalsVisitor; use crate::{CoroutineTypes, Diverges, FnCtxt}; @@ -177,6 +179,21 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_> tcx.dcx().span_err(span, "should have no const parameters"); } + if fn_sig.safety().is_unsafe() { + let hir_id = tcx.local_def_id_to_hir_id(fn_id); + let span = tcx.def_span(fn_id); + // If the function is implicitly "unsafe" because it has a `#[target_feature]` attribute, + // then we should already have emitted an error. Don't also emit a warning. + // See `tests/ui/panic-handler/panic-handler-with-target-feature.rs` + if let Some(hir_fn_sig) = tcx.hir_fn_sig_by_hir_id(hir_id) + && hir_fn_sig.header.safety == hir::HeaderSafety::SafeTargetFeatures + { + tcx.dcx().span_delayed_bug(span, "`unsafe_panic_handlers` lint suppressed because there should already be an error for `#[target_feature]`"); + } else { + tcx.emit_node_span_lint(UNSAFE_PANIC_HANDLERS, hir_id, span, UnsafePanicHandlers); + } + } + let panic_info_did = tcx.require_lang_item(LangItem::PanicInfo, span); // build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !` diff --git a/compiler/rustc_hir_typeck/src/diagnostics.rs b/compiler/rustc_hir_typeck/src/diagnostics.rs index 5c296fd665945..12e1006cc734f 100644 --- a/compiler/rustc_hir_typeck/src/diagnostics.rs +++ b/compiler/rustc_hir_typeck/src/diagnostics.rs @@ -1345,3 +1345,7 @@ impl ExprParenthesesNeeded { ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() } } } + +#[derive(Diagnostic)] +#[diag("`#[panic_handler]` functions can't be `unsafe`")] +pub(crate) struct UnsafePanicHandlers; diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 34c7e3f19a631..d1dc5e05a0f09 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -5883,3 +5883,42 @@ declare_lint! { report_in_deps: true, }; } + +declare_lint! { + /// The `unsafe_panic_handlers` lint detects unsafe functions with + /// the `#[panic_handler]` attribute. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// #![no_std] + /// + /// use core::panic::PanicInfo; + /// + /// #[panic_handler] + /// unsafe fn handle(_: &PanicInfo<'_>) -> ! { + /// loop {} + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Unsafe functions (declared as `unsafe fn`) are functions that can only be called + /// when the caller ensures that their safety requirements are met. On the other hand, + /// `#[panic_handler]` functions get called automatically by the compiler without + /// checking for any preconditions. Therefore, using the `#[panic_handler]` attribute + /// on unsafe functions is either incorrect or a misuse of `unsafe fn`. + /// + /// This is a [future-incompatible] lint to transition this to a hard + /// error in the future. See [issue #163263] for more details. + /// + /// [issue #163263]: https://github.com/rust-lang/rust/issues/163263 + pub UNSAFE_PANIC_HANDLERS, + Warn, + "detects unsafe functions with the `#[panic_handler]` attribute", + @future_incompatible = FutureIncompatibleInfo { + reason: fcw!(FutureReleaseError #163263), + }; +} diff --git a/tests/ui/codegen/no-mangle-on-panic-handler.rs b/tests/ui/codegen/no-mangle-on-panic-handler.rs index 1dc0cce0a2ece..4ef9fd2b8d372 100644 --- a/tests/ui/codegen/no-mangle-on-panic-handler.rs +++ b/tests/ui/codegen/no-mangle-on-panic-handler.rs @@ -9,6 +9,6 @@ use core::panic::PanicInfo; #[unsafe(no_mangle)] //~ ERROR `#[no_mangle]` cannot be used on internal language items #[panic_handler] -pub unsafe fn panic_fmt(pi: &PanicInfo) -> ! { +pub fn panic_fmt(pi: &PanicInfo) -> ! { loop {} } diff --git a/tests/ui/codegen/no-mangle-on-panic-handler.stderr b/tests/ui/codegen/no-mangle-on-panic-handler.stderr index dc88b66d1b5d7..46cf8e8aec5e9 100644 --- a/tests/ui/codegen/no-mangle-on-panic-handler.stderr +++ b/tests/ui/codegen/no-mangle-on-panic-handler.stderr @@ -4,8 +4,8 @@ error: `#[no_mangle]` cannot be used on internal language items LL | #[unsafe(no_mangle)] | ^^^^^^^^^^^^^^^^^^^^ LL | #[panic_handler] -LL | pub unsafe fn panic_fmt(pi: &PanicInfo) -> ! { - | -------------------------------------------- should be the internal language item +LL | pub fn panic_fmt(pi: &PanicInfo) -> ! { + | ------------------------------------- should be the internal language item | = note: Rustc requires this item to have a specific mangled name. = note: If you are trying to prevent mangling to ease debugging, many diff --git a/tests/ui/panic-handler/unsafe_panic_handler.rs b/tests/ui/panic-handler/unsafe_panic_handler.rs new file mode 100644 index 0000000000000..95ecad168d42d --- /dev/null +++ b/tests/ui/panic-handler/unsafe_panic_handler.rs @@ -0,0 +1,12 @@ +//@ check-pass +#![crate_type = "lib"] +#![no_std] + +use core::panic::PanicInfo; + +#[panic_handler] +unsafe fn handle(_: &PanicInfo) -> ! { + //~^ WARN `#[panic_handler]` functions can't be `unsafe` + //~| WARN this was previously accepted by the compiler but is being phased out + loop {} +} diff --git a/tests/ui/panic-handler/unsafe_panic_handler.stderr b/tests/ui/panic-handler/unsafe_panic_handler.stderr new file mode 100644 index 0000000000000..7111d313b6148 --- /dev/null +++ b/tests/ui/panic-handler/unsafe_panic_handler.stderr @@ -0,0 +1,12 @@ +warning: `#[panic_handler]` functions can't be `unsafe` + --> $DIR/unsafe_panic_handler.rs:8:1 + | +LL | unsafe fn handle(_: &PanicInfo) -> ! { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #163263 + = note: `#[warn(unsafe_panic_handlers)]` on by default + +warning: 1 warning emitted +