From 1f2536f365342c23ac2a745e37ec0b19774ea6d9 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Tue, 18 Mar 2025 13:37:40 +0800 Subject: [PATCH 1/6] Partially stabilize LoongArch target features --- compiler/rustc_target/src/target_features.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index a96caf227f747..0ccace56038fb 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -602,17 +602,17 @@ static CSKY_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-start - ("d", Unstable(sym::loongarch_target_feature), &["f"]), + ("d", Stable, &["f"]), ("div32", Unstable(sym::loongarch_target_feature), &[]), - ("f", Unstable(sym::loongarch_target_feature), &[]), - ("frecipe", Unstable(sym::loongarch_target_feature), &[]), + ("f", Stable, &[]), + ("frecipe", Stable, &[]), ("lam-bh", Unstable(sym::loongarch_target_feature), &[]), ("lamcas", Unstable(sym::loongarch_target_feature), &[]), - ("lasx", Unstable(sym::loongarch_target_feature), &["lsx"]), - ("lbt", Unstable(sym::loongarch_target_feature), &[]), + ("lasx", Stable, &["lsx"]), + ("lbt", Stable, &[]), ("ld-seq-sa", Unstable(sym::loongarch_target_feature), &[]), - ("lsx", Unstable(sym::loongarch_target_feature), &["d"]), - ("lvz", Unstable(sym::loongarch_target_feature), &[]), + ("lsx", Stable, &["d"]), + ("lvz", Stable, &[]), ("relax", Unstable(sym::loongarch_target_feature), &[]), ("scq", Unstable(sym::loongarch_target_feature), &[]), ("ual", Unstable(sym::loongarch_target_feature), &[]), From c0f0b5157f89dad5169a75d2475be408d800aafa Mon Sep 17 00:00:00 2001 From: xizheyin Date: Thu, 8 May 2025 21:06:45 +0800 Subject: [PATCH 2/6] Add ui test for for-loops-over-falibles Signed-off-by: xizheyin --- .../macro-issue-140747.rs | 10 ++++++ .../macro-issue-140747.stderr | 32 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs create mode 100644 tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr diff --git a/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs new file mode 100644 index 0000000000000..0e6b88cbdc085 --- /dev/null +++ b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs @@ -0,0 +1,10 @@ +#![forbid(for_loops_over_fallibles)] + +fn main() { + macro_rules! x { + () => { + None:: //~ ERROR for loop over an `Option`. This is more readably written as an `if let` statement [for_loops_over_fallibles] + }; + } + for _ in x! {} {} +} diff --git a/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr new file mode 100644 index 0000000000000..1dc5f3207734a --- /dev/null +++ b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr @@ -0,0 +1,32 @@ +error: for loop over an `Option`. This is more readably written as an `if let` statement + --> $DIR/macro-issue-140747.rs:6:13 + | +LL | None:: + | ^^^^^^^^^^^ +... +LL | for _ in x! {} {} + | ----- in this macro invocation + | +note: the lint level is defined here + --> $DIR/macro-issue-140747.rs:1:11 + | +LL | #![forbid(for_loops_over_fallibles)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `x` (in Nightly builds, run with -Z macro-backtrace for more info) +help: to check pattern in a loop use `while let` + | +LL ~ ) = +LL | }; +LL | } +LL ~ while let Some(_ in x! {} {} + | +help: consider using `if let` to clear intent + | +LL ~ ) = +LL | }; +LL | } +LL ~ if let Some(_ in x! {} {} + | + +error: aborting due to 1 previous error + From 88c1796384cca81ca80e728d45f6673f601493ff Mon Sep 17 00:00:00 2001 From: xizheyin Date: Thu, 8 May 2025 21:12:02 +0800 Subject: [PATCH 3/6] Use span before macro expansion in lint for-loops-over-falibles Signed-off-by: xizheyin --- .../src/for_loops_over_fallibles.rs | 12 ++++++----- .../macro-issue-140747.rs | 4 ++-- .../macro-issue-140747.stderr | 20 ++++++------------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs index 757fc1f58bd51..a56b753bda726 100644 --- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs +++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs @@ -49,6 +49,8 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { let Some((pat, arg)) = extract_for_loop(expr) else { return }; + let arg_span = arg.span.source_callsite(); + let ty = cx.typeck_results().expr_ty(arg); let (adt, args, ref_mutability) = match ty.kind() { @@ -78,27 +80,27 @@ impl<'tcx> LateLintPass<'tcx> for ForLoopsOverFallibles { && let Ok(recv_snip) = cx.sess().source_map().span_to_snippet(recv.span) { ForLoopsOverFalliblesLoopSub::RemoveNext { - suggestion: recv.span.between(arg.span.shrink_to_hi()), + suggestion: recv.span.between(arg_span.shrink_to_hi()), recv_snip, } } else { ForLoopsOverFalliblesLoopSub::UseWhileLet { start_span: expr.span.with_hi(pat.span.lo()), - end_span: pat.span.between(arg.span), + end_span: pat.span.between(arg_span), var, } }; let question_mark = suggest_question_mark(cx, adt, args, expr.span) - .then(|| ForLoopsOverFalliblesQuestionMark { suggestion: arg.span.shrink_to_hi() }); + .then(|| ForLoopsOverFalliblesQuestionMark { suggestion: arg_span.shrink_to_hi() }); let suggestion = ForLoopsOverFalliblesSuggestion { var, start_span: expr.span.with_hi(pat.span.lo()), - end_span: pat.span.between(arg.span), + end_span: pat.span.between(arg_span), }; cx.emit_span_lint( FOR_LOOPS_OVER_FALLIBLES, - arg.span, + arg_span, ForLoopsOverFalliblesDiag { article, ref_prefix, ty, sub, question_mark, suggestion }, ); } diff --git a/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs index 0e6b88cbdc085..33a89ced963e9 100644 --- a/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs +++ b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs @@ -3,8 +3,8 @@ fn main() { macro_rules! x { () => { - None:: //~ ERROR for loop over an `Option`. This is more readably written as an `if let` statement [for_loops_over_fallibles] + None:: }; } - for _ in x! {} {} + for _ in x! {} {} //~ ERROR for loop over an `Option`. This is more readably written as an `if let` statement [for_loops_over_fallibles] } diff --git a/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr index 1dc5f3207734a..550d26045fbc9 100644 --- a/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr +++ b/tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr @@ -1,31 +1,23 @@ error: for loop over an `Option`. This is more readably written as an `if let` statement - --> $DIR/macro-issue-140747.rs:6:13 + --> $DIR/macro-issue-140747.rs:9:14 | -LL | None:: - | ^^^^^^^^^^^ -... LL | for _ in x! {} {} - | ----- in this macro invocation + | ^^^^^ | note: the lint level is defined here --> $DIR/macro-issue-140747.rs:1:11 | LL | #![forbid(for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `x` (in Nightly builds, run with -Z macro-backtrace for more info) help: to check pattern in a loop use `while let` | -LL ~ ) = -LL | }; -LL | } -LL ~ while let Some(_ in x! {} {} +LL - for _ in x! {} {} +LL + while let Some(_) = x! {} {} | help: consider using `if let` to clear intent | -LL ~ ) = -LL | }; -LL | } -LL ~ if let Some(_ in x! {} {} +LL - for _ in x! {} {} +LL + if let Some(_) = x! {} {} | error: aborting due to 1 previous error From eff20bfd29c22cbb2a21b325b420f2cf3fef3ad0 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Fri, 9 May 2025 00:08:40 +0800 Subject: [PATCH 4/6] Fix `tests/rustdoc-json` path --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 57153f1d98ab5..3f6cf2e5c4f43 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1002,7 +1002,7 @@ message = "This PR changes a file inside `tests/crashes`. If a crash was fixed, [mentions."tests/rustdoc-json"] message = """ -These commits modify `test/rustdoc-json`. +These commits modify `tests/rustdoc-json`. rustdoc-json is a **public** (but unstable) interface. Please ensure that if you've changed the output: From 0326a2c3158bd1905bf82861a6be26b2d106e9f3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 8 May 2025 20:07:23 +0200 Subject: [PATCH 5/6] bootstrap: more consistent use of `...` when citing configuration snippets --- src/bootstrap/src/bin/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index cbfe00a757ce4..833f80279517a 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -163,7 +163,7 @@ fn check_version(config: &Config) -> Option { msg.push_str("WARNING: The `change-id` is missing in the `bootstrap.toml`. This means that you will not be able to track the major changes made to the bootstrap configurations.\n"); msg.push_str("NOTE: to silence this warning, "); msg.push_str(&format!( - "add `change-id = {latest_change_id}` or change-id = \"ignore\" at the top of `bootstrap.toml`" + "add `change-id = {latest_change_id}` or `change-id = \"ignore\"` at the top of `bootstrap.toml`" )); return Some(msg); } @@ -195,7 +195,7 @@ fn check_version(config: &Config) -> Option { msg.push_str("NOTE: to silence this warning, "); msg.push_str(&format!( - "update `bootstrap.toml` to use `change-id = {latest_change_id}` or change-id = \"ignore\" instead" + "update `bootstrap.toml` to use `change-id = {latest_change_id}` or `change-id = \"ignore\"` instead" )); if io::stdout().is_terminal() { From d951c41a684c886900477b7087c9de51ddba03bd Mon Sep 17 00:00:00 2001 From: Daniel Paoliello Date: Thu, 8 May 2025 13:08:31 -0700 Subject: [PATCH 6/6] Enable non-leaf Frame Pointers for Arm64 Windows --- .../src/spec/targets/aarch64_pc_windows_msvc.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs index 0d25b19f3fcf3..c5704c574483f 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs @@ -1,10 +1,16 @@ -use crate::spec::{LinkerFlavor, Lld, Target, TargetMetadata, base}; +use crate::spec::{FramePointer, 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(); + // Microsoft recommends enabling frame pointers on Arm64 Windows. + // From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers + // "The frame pointer (x29) is required for compatibility with fast stack walking used by ETW + // and other services. It must point to the previous {x29, x30} pair on the stack." + base.frame_pointer = FramePointer::NonLeaf; + // 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.