about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-26 05:18:22 +0000
committerbors <bors@rust-lang.org>2025-04-26 05:18:22 +0000
commit5ae50d3b2182f81eea4e4d90e8da3653547215b5 (patch)
treeb7dd25708b89658c91cde6ae2b44582a867f370a /compiler/rustc_parse/src
parentd3508a8ad0163fab0c9b2188b3adf43c87200788 (diff)
parentc781c9ae94ef94a5b144b2ac6f5fd2075f16f854 (diff)
downloadrust-5ae50d3b2182f81eea4e4d90e8da3653547215b5.tar.gz
rust-5ae50d3b2182f81eea4e4d90e8da3653547215b5.zip
Auto merge of #140324 - matthiaskrgr:rollup-jlzvdre, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #139865 (Stabilize proc_macro::Span::{start,end,line,column}.)
 - #140086 (If creating a temporary directory fails with permission denied then retry with backoff)
 - #140216 (Document that "extern blocks must be unsafe" in Rust 2024)
 - #140253 (Add XtensaAsmPrinter)
 - #140272 (Improve error message for `||` (or) in let chains)
 - #140305 (Track per-obligation recursion depth only if there is inference in the new solver)
 - #140306 (handle specialization in the new trait solver)
 - #140308 (stall generator witness obligations: add regression test)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/errors.rs7
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs12
2 files changed, 15 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs
index 35cf4c1b00d..6a6fb0eb9b5 100644
--- a/compiler/rustc_parse/src/errors.rs
+++ b/compiler/rustc_parse/src/errors.rs
@@ -478,6 +478,13 @@ pub(crate) struct ExpectedExpressionFoundLet {
     pub comparison: Option<MaybeComparison>,
 }
 
+#[derive(Diagnostic)]
+#[diag(parse_or_in_let_chain)]
+pub(crate) struct OrInLetChain {
+    #[primary_span]
+    pub span: Span,
+}
+
 #[derive(Subdiagnostic, Clone, Copy)]
 #[multipart_suggestion(
     parse_maybe_missing_let,
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 370eb3f402d..f3b53971b29 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -4073,14 +4073,18 @@ impl MutVisitor for CondChecker<'_> {
         match e.kind {
             ExprKind::Let(_, _, _, ref mut recovered @ Recovered::No) => {
                 if let Some(reason) = self.forbid_let_reason {
-                    *recovered = Recovered::Yes(self.parser.dcx().emit_err(
-                        errors::ExpectedExpressionFoundLet {
+                    let error = match reason {
+                        NotSupportedOr(or_span) => {
+                            self.parser.dcx().emit_err(errors::OrInLetChain { span: or_span })
+                        }
+                        _ => self.parser.dcx().emit_err(errors::ExpectedExpressionFoundLet {
                             span,
                             reason,
                             missing_let: self.missing_let,
                             comparison: self.comparison,
-                        },
-                    ));
+                        }),
+                    };
+                    *recovered = Recovered::Yes(error);
                 } else if self.depth > 1 {
                     // Top level `let` is always allowed; only gate chains
                     match self.let_chains_policy {