Skip to content

Commit da378d7

Browse files
committed
Auto merge of rust-lang#140788 - matthiaskrgr:rollup-rgsbl0h, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#140716 (Improve `-Zremap-path-scope` tests with dependency) - rust-lang#140732 (make it possible to run in-tree rustfmt with `x run rustfmt`) - rust-lang#140736 (trait selection: check `&` before suggest remove deref) - rust-lang#140755 ([win][arm64] Disable various DebugInfo tests that don't work on Arm64 Windows) - rust-lang#140756 ([arm64] Pointer auth test should link with C static library statically) - rust-lang#140758 ([win][arm64] Disable MSVC Linker 'Arm Hazard' warning) - rust-lang#140759 ([win][arm64] Disable std::fs tests that require symlinks) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1973872 + ba6f590 commit da378d7

File tree

41 files changed

+443
-12
lines changed

Some content is hidden

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

41 files changed

+443
-12
lines changed

compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
use crate::spec::{Target, TargetMetadata, base};
1+
use crate::spec::{LinkerFlavor, Lld, Target, TargetMetadata, base};
22

33
pub(crate) fn target() -> Target {
44
let mut base = base::windows_msvc::opts();
55
base.max_atomic_width = Some(128);
66
base.features = "+v8a,+neon,+fp-armv8".into();
77

8+
// MSVC emits a warning about code that may trip "Cortex-A53 MPCore processor bug #843419" (see
9+
// https://developer.arm.com/documentation/epm048406/latest) which is sometimes emitted by LLVM.
10+
// Since Arm64 Windows 10+ isn't supported on that processor, it's safe to disable the warning.
11+
base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/arm64hazardfree"]);
12+
813
Target {
914
llvm_target: "aarch64-pc-windows-msvc".into(),
1015
metadata: TargetMetadata {

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
15161516
} else {
15171517
expr.span.with_hi(expr.span.lo() + BytePos(1))
15181518
};
1519+
1520+
match self.tcx.sess.source_map().span_to_snippet(span) {
1521+
Ok(snippet) if snippet.starts_with("&") => {}
1522+
_ => break 'outer,
1523+
}
1524+
15191525
suggestions.push((span, String::new()));
15201526

15211527
let ty::Ref(_, inner_ty, _) = suggested_ty.kind() else {

library/std/src/fs/tests.rs

+16
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,10 @@ fn recursive_mkdir_empty() {
730730
}
731731

732732
#[test]
733+
#[cfg_attr(
734+
all(windows, target_arch = "aarch64"),
735+
ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94"
736+
)]
733737
fn recursive_rmdir() {
734738
let tmpdir = tmpdir();
735739
let d1 = tmpdir.join("d1");
@@ -749,6 +753,10 @@ fn recursive_rmdir() {
749753
}
750754

751755
#[test]
756+
#[cfg_attr(
757+
all(windows, target_arch = "aarch64"),
758+
ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94"
759+
)]
752760
fn recursive_rmdir_of_symlink() {
753761
// test we do not recursively delete a symlink but only dirs.
754762
let tmpdir = tmpdir();
@@ -1533,6 +1541,10 @@ fn file_open_not_found() {
15331541
}
15341542

15351543
#[test]
1544+
#[cfg_attr(
1545+
all(windows, target_arch = "aarch64"),
1546+
ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94"
1547+
)]
15361548
fn create_dir_all_with_junctions() {
15371549
let tmpdir = tmpdir();
15381550
let target = tmpdir.join("target");
@@ -2011,6 +2023,10 @@ fn test_rename_symlink() {
20112023

20122024
#[test]
20132025
#[cfg(windows)]
2026+
#[cfg_attr(
2027+
all(windows, target_arch = "aarch64"),
2028+
ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94"
2029+
)]
20142030
fn test_rename_junction() {
20152031
let tmpdir = tmpdir();
20162032
let original = tmpdir.join("original");

src/bootstrap/src/core/build_steps/format.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::sync::mpsc::SyncSender;
99
use build_helper::git::get_git_modified_files;
1010
use ignore::WalkBuilder;
1111

12-
use crate::core::builder::Builder;
12+
use crate::core::builder::{Builder, Kind};
1313
use crate::utils::build_stamp::BuildStamp;
1414
use crate::utils::exec::command;
1515
use crate::utils::helpers::{self, t};
@@ -122,6 +122,12 @@ fn print_paths(verb: &str, adjective: Option<&str>, paths: &[String]) {
122122
}
123123

124124
pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
125+
if build.kind == Kind::Format && build.top_stage != 0 {
126+
eprintln!("ERROR: `x fmt` only supports stage 0.");
127+
eprintln!("HELP: Use `x run rustfmt` to run in-tree rustfmt.");
128+
crate::exit!(1);
129+
}
130+
125131
if !paths.is_empty() {
126132
eprintln!(
127133
"fmt error: path arguments are no longer accepted; use `--all` to format everything"

src/bootstrap/src/core/build_steps/run.rs

+53
Original file line numberDiff line numberDiff line change
@@ -420,3 +420,56 @@ impl Step for CoverageDump {
420420
cmd.run(builder);
421421
}
422422
}
423+
424+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
425+
pub struct Rustfmt;
426+
427+
impl Step for Rustfmt {
428+
type Output = ();
429+
const ONLY_HOSTS: bool = true;
430+
431+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
432+
run.path("src/tools/rustfmt")
433+
}
434+
435+
fn make_run(run: RunConfig<'_>) {
436+
run.builder.ensure(Rustfmt);
437+
}
438+
439+
fn run(self, builder: &Builder<'_>) {
440+
let host = builder.build.build;
441+
442+
// `x run` uses stage 0 by default but rustfmt does not work well with stage 0.
443+
// Change the stage to 1 if it's not set explicitly.
444+
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
445+
builder.top_stage
446+
} else {
447+
1
448+
};
449+
450+
if stage == 0 {
451+
eprintln!("rustfmt cannot be run at stage 0");
452+
eprintln!("HELP: Use `x fmt` to use stage 0 rustfmt.");
453+
std::process::exit(1);
454+
}
455+
456+
let compiler = builder.compiler(stage, host);
457+
let rustfmt_build = builder.ensure(tool::Rustfmt { compiler, target: host });
458+
459+
let mut rustfmt = tool::prepare_tool_cargo(
460+
builder,
461+
rustfmt_build.build_compiler,
462+
Mode::ToolRustc,
463+
host,
464+
Kind::Run,
465+
"src/tools/rustfmt",
466+
SourceType::InTree,
467+
&[],
468+
);
469+
470+
rustfmt.args(["--bin", "rustfmt", "--"]);
471+
rustfmt.args(builder.config.args());
472+
473+
rustfmt.into_cmd().run(builder);
474+
}
475+
}

src/bootstrap/src/core/builder/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ impl<'a> Builder<'a> {
11161116
run::FeaturesStatusDump,
11171117
run::CyclicStep,
11181118
run::CoverageDump,
1119+
run::Rustfmt,
11191120
),
11201121
Kind::Setup => {
11211122
describe!(setup::Profile, setup::Hook, setup::Link, setup::Editor)

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
406406
severity: ChangeSeverity::Info,
407407
summary: "Added a new option `rust.debug-assertions-tools` to control debug asssertions for tools.",
408408
},
409+
ChangeInfo {
410+
change_id: 140732,
411+
severity: ChangeSeverity::Info,
412+
summary: "`./x run` now supports running in-tree `rustfmt`, e.g., `./x run rustfmt -- --check /path/to/file.rs`.",
413+
},
409414
];

src/tools/compiletest/src/directive-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
3535
"ignore-32bit",
3636
"ignore-64bit",
3737
"ignore-aarch64",
38+
"ignore-aarch64-pc-windows-msvc",
3839
"ignore-aarch64-unknown-linux-gnu",
3940
"ignore-aix",
4041
"ignore-android",

tests/debuginfo/step-into-match.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
//@ compile-flags: -g
22
//@ ignore-android: FIXME(#10381)
33

4+
// On Arm64 Windows, stepping at the end of a function on goes to the callsite, not the instruction
5+
// after it.
6+
//@ ignore-aarch64-pc-windows-msvc: Stepping out of functions behaves differently.
7+
48
// === GDB TESTS ==============================================================
59

610
// gdb-command: r

tests/debuginfo/type-names.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ ignore-lldb
22

3+
//@ ignore-aarch64-pc-windows-msvc: Arm64 Windows cdb doesn't support JavaScript extensions.
4+
35
// GDB changed the way that it formatted Foreign types
46
//@ min-gdb-version: 9.2
57

tests/run-make/pointer-auth-link-with-c/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[link(name = "test")]
1+
#[link(name = "test", kind = "static")]
22
extern "C" {
33
fn foo() -> i32;
44
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
//@ compile-flags: -Zremap-path-scope=debuginfo
3+
4+
#[macro_export]
5+
macro_rules! my_file {
6+
() => { file!() }
7+
}
8+
9+
pub fn file() -> &'static str {
10+
file!()
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
//@ compile-flags: -Zremap-path-scope=diagnostics
3+
4+
#[macro_export]
5+
macro_rules! my_file {
6+
() => { file!() }
7+
}
8+
9+
pub fn file() -> &'static str {
10+
file!()
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
//@ compile-flags: -Zremap-path-scope=macro
3+
4+
#[macro_export]
5+
macro_rules! my_file {
6+
() => { file!() }
7+
}
8+
9+
pub fn file() -> &'static str {
10+
file!()
11+
}

tests/ui/errors/auxiliary/file.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#[macro_export]
2+
macro_rules! my_file {
3+
() => { file!() }
4+
}
5+
6+
pub fn file() -> &'static str {
7+
file!()
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
//@ compile-flags: -Zremap-path-scope=debuginfo
3+
4+
pub trait Trait: std::fmt::Display {}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
//@ compile-flags: -Zremap-path-scope=diagnostics
3+
4+
pub trait Trait: std::fmt::Display {}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
//@ compile-flags: -Zremap-path-scope=macro
3+
4+
pub trait Trait: std::fmt::Display {}

tests/ui/errors/auxiliary/trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub trait Trait: std::fmt::Display {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: `A` doesn't implement `std::fmt::Display`
2+
--> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL
3+
|
4+
LL | impl r#trait::Trait for A {}
5+
| ^ `A` cannot be formatted with the default formatter
6+
|
7+
= help: the trait `std::fmt::Display` is not implemented for `A`
8+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9+
note: required by a bound in `Trait`
10+
--> $DIR/auxiliary/trait.rs:LL:COL
11+
|
12+
LL | pub trait Trait: std::fmt::Display {}
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: `A` doesn't implement `std::fmt::Display`
2+
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
3+
|
4+
LL | impl r#trait::Trait for A {}
5+
| ^ `A` cannot be formatted with the default formatter
6+
|
7+
= help: the trait `std::fmt::Display` is not implemented for `A`
8+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9+
note: required by a bound in `Trait`
10+
--> $DIR/auxiliary/trait-debuginfo.rs:LL:COL
11+
|
12+
LL | pub trait Trait: std::fmt::Display {}
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: `A` doesn't implement `std::fmt::Display`
2+
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
3+
|
4+
LL | impl r#trait::Trait for A {}
5+
| ^ `A` cannot be formatted with the default formatter
6+
|
7+
= help: the trait `std::fmt::Display` is not implemented for `A`
8+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9+
note: required by a bound in `Trait`
10+
--> $DIR/auxiliary/trait-diag.rs:LL:COL
11+
|
12+
LL | pub trait Trait: std::fmt::Display {}
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: `A` doesn't implement `std::fmt::Display`
2+
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
3+
|
4+
LL | impl r#trait::Trait for A {}
5+
| ^ `A` cannot be formatted with the default formatter
6+
|
7+
= help: the trait `std::fmt::Display` is not implemented for `A`
8+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9+
note: required by a bound in `Trait`
10+
--> $DIR/auxiliary/trait-macro.rs:LL:COL
11+
|
12+
LL | pub trait Trait: std::fmt::Display {}
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// This test exercises `-Zremap-path-scope`, diagnostics printing paths and dependency.
2+
//
3+
// We test different combinations with/without remap in deps, with/without remap in this
4+
// crate but always in deps and always here but never in deps.
5+
6+
//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps
7+
//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps
8+
//@ revisions: not-diag-in-deps
9+
10+
//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
11+
//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
12+
//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
13+
//@[not-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
14+
15+
//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
16+
//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
17+
//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
18+
//@[not-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
19+
20+
//@[with-diag-in-deps] aux-build:trait-diag.rs
21+
//@[with-macro-in-deps] aux-build:trait-macro.rs
22+
//@[with-debuginfo-in-deps] aux-build:trait-debuginfo.rs
23+
//@[only-diag-in-deps] aux-build:trait-diag.rs
24+
//@[only-macro-in-deps] aux-build:trait-macro.rs
25+
//@[only-debuginfo-in-deps] aux-build:trait-debuginfo.rs
26+
//@[not-diag-in-deps] aux-build:trait.rs
27+
28+
// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically
29+
// as the remapped revision will not begin with $SRC_DIR_REAL,
30+
// so we have to do it ourselves.
31+
//@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:COL"
32+
33+
#[cfg(any(with_diag_in_deps, only_diag_in_deps))]
34+
extern crate trait_diag as r#trait;
35+
36+
#[cfg(any(with_macro_in_deps, only_macro_in_deps))]
37+
extern crate trait_macro as r#trait;
38+
39+
#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
40+
extern crate trait_debuginfo as r#trait;
41+
42+
#[cfg(not_diag_in_deps)]
43+
extern crate r#trait as r#trait;
44+
45+
struct A;
46+
47+
impl r#trait::Trait for A {}
48+
//[with-macro-in-deps]~^ ERROR `A` doesn't implement `std::fmt::Display`
49+
//[with-debuginfo-in-deps]~^^ ERROR `A` doesn't implement `std::fmt::Display`
50+
//[only-diag-in-deps]~^^^ ERROR `A` doesn't implement `std::fmt::Display`
51+
//[only-macro-in-deps]~^^^^ ERROR `A` doesn't implement `std::fmt::Display`
52+
//[only-debuginfo-in-deps]~^^^^^ ERROR `A` doesn't implement `std::fmt::Display`
53+
54+
//[with-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display`
55+
//[not-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display`
56+
57+
fn main() {}

0 commit comments

Comments
 (0)