Skip to content

Rollup of 7 pull requests #140788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fcc63ac
Add tests for `-Zremap-path-scope` and paths in diagnostics with deps
Urgau May 6, 2025
e534797
Rework `-Zremap-path-scope` macro test with dependency check
Urgau May 6, 2025
f46806f
Add ui test suggest-remove-deref-issue-140166
xizheyin May 7, 2025
bd88f3e
Check `&` before suggest remove deref when trait_selection
xizheyin May 7, 2025
3286d4a
[win][arm64] Disable various DebugInfo tests that don't work on Arm64…
dpaoliello May 7, 2025
742aaf9
[arm64] Pointer auth test should link with C static library statically
dpaoliello May 7, 2025
0cacc05
[win][arm64] Disable FS tests that require symlinks
dpaoliello May 7, 2025
75ca6c6
[win][arm64] Disable MSVC Linker 'Arm Hazard' warning
dpaoliello May 7, 2025
34c42c8
do not allow stage > 0 on `x fmt`
onur-ozkan May 7, 2025
1a18da5
implement `x run rustfmt`
onur-ozkan May 7, 2025
e85d014
add change-entry for `x run rustfmt`
onur-ozkan May 7, 2025
c800ddd
Rollup merge of #140716 - Urgau:improve-remap_scope-tests, r=jieyouxu
matthiaskrgr May 8, 2025
2595e15
Rollup merge of #140732 - onur-ozkan:use-in-tree-rustfmt, r=Kobzol
matthiaskrgr May 8, 2025
d2acdb1
Rollup merge of #140736 - xizheyin:issue-140166, r=petrochenkov
matthiaskrgr May 8, 2025
39bedf4
Rollup merge of #140755 - dpaoliello:arm64windebuginfo, r=jieyouxu
matthiaskrgr May 8, 2025
5cd2d03
Rollup merge of #140756 - dpaoliello:paclink, r=jieyouxu
matthiaskrgr May 8, 2025
0e47f67
Rollup merge of #140758 - dpaoliello:armhazard, r=jieyouxu
matthiaskrgr May 8, 2025
ba6f590
Rollup merge of #140759 - dpaoliello:symlink, r=workingjubilee
matthiaskrgr May 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use crate::spec::{Target, TargetMetadata, base};
use crate::spec::{LinkerFlavor, Lld, Target, TargetMetadata, base};

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

// MSVC emits a warning about code that may trip "Cortex-A53 MPCore processor bug #843419" (see
// https://developer.arm.com/documentation/epm048406/latest) which is sometimes emitted by LLVM.
// Since Arm64 Windows 10+ isn't supported on that processor, it's safe to disable the warning.
base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/arm64hazardfree"]);

Target {
llvm_target: "aarch64-pc-windows-msvc".into(),
metadata: TargetMetadata {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
} else {
expr.span.with_hi(expr.span.lo() + BytePos(1))
};

match self.tcx.sess.source_map().span_to_snippet(span) {
Ok(snippet) if snippet.starts_with("&") => {}
_ => break 'outer,
}

suggestions.push((span, String::new()));

let ty::Ref(_, inner_ty, _) = suggested_ty.kind() else {
Expand Down
16 changes: 16 additions & 0 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,10 @@ fn recursive_mkdir_empty() {
}

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

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

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

#[test]
#[cfg(windows)]
#[cfg_attr(
all(windows, target_arch = "aarch64"),
ignore = "SymLinks not enabled on Arm64 Windows runners https://github.com/actions/partner-runner-images/issues/94"
)]
fn test_rename_junction() {
let tmpdir = tmpdir();
let original = tmpdir.join("original");
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/src/core/build_steps/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::mpsc::SyncSender;
use build_helper::git::get_git_modified_files;
use ignore::WalkBuilder;

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

pub fn format(build: &Builder<'_>, check: bool, all: bool, paths: &[PathBuf]) {
if build.kind == Kind::Format && build.top_stage != 0 {
eprintln!("ERROR: `x fmt` only supports stage 0.");
eprintln!("HELP: Use `x run rustfmt` to run in-tree rustfmt.");
crate::exit!(1);
}

if !paths.is_empty() {
eprintln!(
"fmt error: path arguments are no longer accepted; use `--all` to format everything"
Expand Down
53 changes: 53 additions & 0 deletions src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,56 @@ impl Step for CoverageDump {
cmd.run(builder);
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Rustfmt;

impl Step for Rustfmt {
type Output = ();
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/tools/rustfmt")
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Rustfmt);
}

fn run(self, builder: &Builder<'_>) {
let host = builder.build.build;

// `x run` uses stage 0 by default but rustfmt does not work well with stage 0.
// Change the stage to 1 if it's not set explicitly.
let stage = if builder.config.is_explicit_stage() || builder.top_stage >= 1 {
builder.top_stage
} else {
1
};

if stage == 0 {
eprintln!("rustfmt cannot be run at stage 0");
eprintln!("HELP: Use `x fmt` to use stage 0 rustfmt.");
std::process::exit(1);
}

let compiler = builder.compiler(stage, host);
let rustfmt_build = builder.ensure(tool::Rustfmt { compiler, target: host });

let mut rustfmt = tool::prepare_tool_cargo(
builder,
rustfmt_build.build_compiler,
Mode::ToolRustc,
host,
Kind::Run,
"src/tools/rustfmt",
SourceType::InTree,
&[],
);

rustfmt.args(["--bin", "rustfmt", "--"]);
rustfmt.args(builder.config.args());

rustfmt.into_cmd().run(builder);
}
}
1 change: 1 addition & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ impl<'a> Builder<'a> {
run::FeaturesStatusDump,
run::CyclicStep,
run::CoverageDump,
run::Rustfmt,
),
Kind::Setup => {
describe!(setup::Profile, setup::Hook, setup::Link, setup::Editor)
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "Added a new option `rust.debug-assertions-tools` to control debug asssertions for tools.",
},
ChangeInfo {
change_id: 140732,
severity: ChangeSeverity::Info,
summary: "`./x run` now supports running in-tree `rustfmt`, e.g., `./x run rustfmt -- --check /path/to/file.rs`.",
},
];
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directive-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-32bit",
"ignore-64bit",
"ignore-aarch64",
"ignore-aarch64-pc-windows-msvc",
"ignore-aarch64-unknown-linux-gnu",
"ignore-aix",
"ignore-android",
Expand Down
4 changes: 4 additions & 0 deletions tests/debuginfo/step-into-match.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
//@ compile-flags: -g
//@ ignore-android: FIXME(#10381)

// On Arm64 Windows, stepping at the end of a function on goes to the callsite, not the instruction
// after it.
//@ ignore-aarch64-pc-windows-msvc: Stepping out of functions behaves differently.

// === GDB TESTS ==============================================================

// gdb-command: r
Expand Down
2 changes: 2 additions & 0 deletions tests/debuginfo/type-names.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ ignore-lldb

//@ ignore-aarch64-pc-windows-msvc: Arm64 Windows cdb doesn't support JavaScript extensions.

// GDB changed the way that it formatted Foreign types
//@ min-gdb-version: 9.2

Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/pointer-auth-link-with-c/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[link(name = "test")]
#[link(name = "test", kind = "static")]
extern "C" {
fn foo() -> i32;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/errors/auxiliary/file-debuginfo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=debuginfo

#[macro_export]
macro_rules! my_file {
() => { file!() }
}

pub fn file() -> &'static str {
file!()
}
11 changes: 11 additions & 0 deletions tests/ui/errors/auxiliary/file-diag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=diagnostics

#[macro_export]
macro_rules! my_file {
() => { file!() }
}

pub fn file() -> &'static str {
file!()
}
11 changes: 11 additions & 0 deletions tests/ui/errors/auxiliary/file-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=macro

#[macro_export]
macro_rules! my_file {
() => { file!() }
}

pub fn file() -> &'static str {
file!()
}
8 changes: 8 additions & 0 deletions tests/ui/errors/auxiliary/file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#[macro_export]
macro_rules! my_file {
() => { file!() }
}

pub fn file() -> &'static str {
file!()
}
4 changes: 4 additions & 0 deletions tests/ui/errors/auxiliary/trait-debuginfo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=debuginfo

pub trait Trait: std::fmt::Display {}
4 changes: 4 additions & 0 deletions tests/ui/errors/auxiliary/trait-diag.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=diagnostics

pub trait Trait: std::fmt::Display {}
4 changes: 4 additions & 0 deletions tests/ui/errors/auxiliary/trait-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//@ compile-flags: --remap-path-prefix={{src-base}}=remapped
//@ compile-flags: -Zremap-path-scope=macro

pub trait Trait: std::fmt::Display {}
1 change: 1 addition & 0 deletions tests/ui/errors/auxiliary/trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub trait Trait: std::fmt::Display {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0277]: `A` doesn't implement `std::fmt::Display`
--> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | impl r#trait::Trait for A {}
| ^ `A` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `A`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `Trait`
--> $DIR/auxiliary/trait.rs:LL:COL
|
LL | pub trait Trait: std::fmt::Display {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0277]: `A` doesn't implement `std::fmt::Display`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | impl r#trait::Trait for A {}
| ^ `A` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `A`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `Trait`
--> $DIR/auxiliary/trait-debuginfo.rs:LL:COL
|
LL | pub trait Trait: std::fmt::Display {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0277]: `A` doesn't implement `std::fmt::Display`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | impl r#trait::Trait for A {}
| ^ `A` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `A`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `Trait`
--> $DIR/auxiliary/trait-diag.rs:LL:COL
|
LL | pub trait Trait: std::fmt::Display {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0277]: `A` doesn't implement `std::fmt::Display`
--> $DIR/remap-path-prefix-diagnostics.rs:LL:COL
|
LL | impl r#trait::Trait for A {}
| ^ `A` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `A`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
note: required by a bound in `Trait`
--> $DIR/auxiliary/trait-macro.rs:LL:COL
|
LL | pub trait Trait: std::fmt::Display {}
| ^^^^^^^^^^^^^^^^^ required by this bound in `Trait`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
57 changes: 57 additions & 0 deletions tests/ui/errors/remap-path-prefix-diagnostics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// This test exercises `-Zremap-path-scope`, diagnostics printing paths and dependency.
//
// We test different combinations with/without remap in deps, with/without remap in this
// crate but always in deps and always here but never in deps.

//@ revisions: with-diag-in-deps with-macro-in-deps with-debuginfo-in-deps
//@ revisions: only-diag-in-deps only-macro-in-deps only-debuginfo-in-deps
//@ revisions: not-diag-in-deps

//@[with-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-macro-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[with-debuginfo-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped
//@[not-diag-in-deps] compile-flags: --remap-path-prefix={{src-base}}=remapped

//@[with-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics
//@[with-macro-in-deps] compile-flags: -Zremap-path-scope=macro
//@[with-debuginfo-in-deps] compile-flags: -Zremap-path-scope=debuginfo
//@[not-diag-in-deps] compile-flags: -Zremap-path-scope=diagnostics

//@[with-diag-in-deps] aux-build:trait-diag.rs
//@[with-macro-in-deps] aux-build:trait-macro.rs
//@[with-debuginfo-in-deps] aux-build:trait-debuginfo.rs
//@[only-diag-in-deps] aux-build:trait-diag.rs
//@[only-macro-in-deps] aux-build:trait-macro.rs
//@[only-debuginfo-in-deps] aux-build:trait-debuginfo.rs
//@[not-diag-in-deps] aux-build:trait.rs

// The $SRC_DIR*.rs:LL:COL normalisation doesn't kick in automatically
// as the remapped revision will not begin with $SRC_DIR_REAL,
// so we have to do it ourselves.
//@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:COL"

#[cfg(any(with_diag_in_deps, only_diag_in_deps))]
extern crate trait_diag as r#trait;

#[cfg(any(with_macro_in_deps, only_macro_in_deps))]
extern crate trait_macro as r#trait;

#[cfg(any(with_debuginfo_in_deps, only_debuginfo_in_deps))]
extern crate trait_debuginfo as r#trait;

#[cfg(not_diag_in_deps)]
extern crate r#trait as r#trait;

struct A;

impl r#trait::Trait for A {}
//[with-macro-in-deps]~^ ERROR `A` doesn't implement `std::fmt::Display`
//[with-debuginfo-in-deps]~^^ ERROR `A` doesn't implement `std::fmt::Display`
//[only-diag-in-deps]~^^^ ERROR `A` doesn't implement `std::fmt::Display`
//[only-macro-in-deps]~^^^^ ERROR `A` doesn't implement `std::fmt::Display`
//[only-debuginfo-in-deps]~^^^^^ ERROR `A` doesn't implement `std::fmt::Display`

//[with-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display`
//[not-diag-in-deps]~? ERROR `A` doesn't implement `std::fmt::Display`

fn main() {}
Loading
Loading