diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-04-25 15:55:44 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-04-25 17:02:59 +0500 |
| commit | f072d3074170f1e70a6f6a1b309fa43f62c25a3c (patch) | |
| tree | 51537a73b5ef7cf7a5a4072b2bd821e64d7ad932 /compiler/rustc_parse | |
| parent | 847e3ee6b0e614937eee4e6d8f61094411eadcc0 (diff) | |
| download | rust-f072d3074170f1e70a6f6a1b309fa43f62c25a3c.tar.gz rust-f072d3074170f1e70a6f6a1b309fa43f62c25a3c.zip | |
resolved conflict
Diffstat (limited to 'compiler/rustc_parse')
| -rw-r--r-- | compiler/rustc_parse/messages.ftl | 2 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/errors.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 12 |
3 files changed, 17 insertions, 4 deletions
diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index ae9143486ee..ac4f7ed64e2 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -675,6 +675,8 @@ parse_note_pattern_alternatives_use_single_vert = alternatives in or-patterns ar parse_nul_in_c_str = null characters in C string literals are not supported +parse_or_in_let_chain = `||` operators are not supported in let chain conditions + parse_or_pattern_not_allowed_in_fn_parameters = top-level or-patterns are not allowed in function parameters parse_or_pattern_not_allowed_in_let_binding = top-level or-patterns are not allowed in `let` bindings parse_out_of_range_hex_escape = out of range hex escape 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 { |
