Skip to content

Rollup of 5 pull requests #140835

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 11 commits into from
Closed
12 changes: 7 additions & 5 deletions compiler/rustc_lint/src/for_loops_over_fallibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 },
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,17 +693,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), &[]),
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn check_version(config: &Config) -> Option<String> {
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);
}
Expand Down Expand Up @@ -195,7 +195,7 @@ fn check_version(config: &Config) -> Option<String> {

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() {
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/lint/for-loops-over-falibles/macro-issue-140747.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![forbid(for_loops_over_fallibles)]

fn main() {
macro_rules! x {
() => {
None::<i32>
};
}
for _ in x! {} {} //~ ERROR for loop over an `Option`. This is more readably written as an `if let` statement [for_loops_over_fallibles]
}
24 changes: 24 additions & 0 deletions tests/ui/lint/for-loops-over-falibles/macro-issue-140747.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
error: for loop over an `Option`. This is more readably written as an `if let` statement
--> $DIR/macro-issue-140747.rs:9:14
|
LL | for _ in x! {} {}
| ^^^^^
|
note: the lint level is defined here
--> $DIR/macro-issue-140747.rs:1:11
|
LL | #![forbid(for_loops_over_fallibles)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: to check pattern in a loop use `while let`
|
LL - for _ in x! {} {}
LL + while let Some(_) = x! {} {}
|
help: consider using `if let` to clear intent
|
LL - for _ in x! {} {}
LL + if let Some(_) = x! {} {}
|

error: aborting due to 1 previous error

2 changes: 1 addition & 1 deletion triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading