From 82fcefce69d36e78301936c5af91f005d6a24357 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 4 Jan 2024 09:11:11 -0800 Subject: [PATCH] Fix error message on unexpected token after 'else' --- src/expr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index a267a2e687..7fb0f7b4e2 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -2142,9 +2142,9 @@ pub(crate) mod parsing { let else_token: Token![else] = input.parse()?; let lookahead = input.lookahead1(); - let else_branch = if input.peek(Token![if]) { + let else_branch = if lookahead.peek(Token![if]) { input.parse().map(Expr::If)? - } else if input.peek(token::Brace) { + } else if lookahead.peek(token::Brace) { Expr::Block(ExprBlock { attrs: Vec::new(), label: None,