diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index ddb9de2e3d356..327a4c25a5903 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -776,15 +776,9 @@ parse_unexpected_expr_in_pat = expected {$is_bound -> [true] a pattern range bound *[false] a pattern - }, found {$is_method_call -> - [true] a method call - *[false] an expression - } + }, found an expression - .label = {$is_method_call -> - [true] method calls - *[false] arbitrary expressions - } are not allowed in patterns + .label = arbitrary expressions are not allowed in patterns parse_unexpected_expr_in_pat_const_pat_sugg = wrap the expression in a inline const (requires `{"#"}![feature(inline_const)]`) diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 7495614a2af65..f6c1784dcaa39 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -2439,8 +2439,6 @@ pub(crate) struct UnexpectedExpressionInPattern { pub span: Span, /// Was a `RangePatternBound` expected? pub is_bound: bool, - /// Was the unexpected expression a `MethodCallExpression`? - pub is_method_call: bool, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 3a822356f7453..7dc302f9f18ad 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -407,8 +407,6 @@ impl<'a> Parser<'a> { ) .map_err(|err| err.cancel()) { - let non_assoc_span = expr.span; - // Parse an associative expression such as `+ expr`, `% expr`, ... // Assignements, ranges and `|` are disabled by [`Restrictions::IS_PAT`]. if let Ok(expr) = @@ -424,16 +422,10 @@ impl<'a> Parser<'a> { || self.token.kind == token::CloseDelim(Delimiter::Parenthesis) && self.look_ahead(1, Token::is_range_separator); - // Check that `parse_expr_assoc_with` didn't eat a rhs. - let is_method_call = false && non_assoc_span == expr.span; - let span = expr.span; - let mut err = self.dcx().create_err(UnexpectedExpressionInPattern { - span, - is_bound, - is_method_call, - }); + let mut err = + self.dcx().create_err(UnexpectedExpressionInPattern { span, is_bound }); // FIXME(inline_const): once stabilized, remove this check and remove the `(requires #[feature(inline_const])` note from the message if self.psess.unstable_features.is_nightly_build() {