This example compiles on 1.35 but not 1.36 or later:
pub fn foo() -> &'static &'static bool {
{} // equivalent to {}; or ();
&&false
}
(The example above was reduced from one involving match ... {...} && false, found by @digama0)
This regression was likely introduced by #60188, due to the definition of can_continue_expr_unambiguously:
|
/// This operator could be used to follow a block unambiguously. |
|
/// |
|
/// This is used for error recovery at the moment, providing a suggestion to wrap blocks with |
|
/// parentheses while having a high degree of confidence on the correctness of the suggestion. |
|
pub fn can_continue_expr_unambiguously(&self) -> bool { |
|
use AssocOp::*; |
|
match self { |
|
BitXor | // `{ 42 } ^ 3` |
|
Assign | // `{ 42 } = { 42 }` |
|
Divide | // `{ 42 } / 42` |
|
Modulus | // `{ 42 } % 2` |
|
ShiftRight | // `{ 42 } >> 2` |
|
LessEqual | // `{ 42 } <= 3` |
|
Greater | // `{ 42 } > 3` |
|
GreaterEqual | // `{ 42 } >= 3` |
|
AssignOp(_) | // `{ 42 } +=` |
|
LAnd | // `{ 42 } &&foo` |
|
As | // `{ 42 } as usize` |
|
// Equal | // `{ 42 } == { 42 }` Accepting these here would regress incorrect |
|
// NotEqual | // `{ 42 } != { 42 } struct literals parser recovery. |
|
Colon => true, // `{ 42 }: usize` |
|
_ => false, |
|
} |
|
} |
That function lists all of the operators that can't start an expression, but only continue it.
LAnd (&&) is incorrectly included, as &&expr is parsed the same as & &expr at the start of an expression.
cc @estebank
This example compiles on 1.35 but not 1.36 or later:
(The example above was reduced from one involving
match ... {...} && false, found by @digama0)This regression was likely introduced by #60188, due to the definition of
can_continue_expr_unambiguously:rust/src/librustc_ast/util/parser.rs
Lines 209 to 232 in daecab3
That function lists all of the operators that can't start an expression, but only continue it.
LAnd(&&) is incorrectly included, as&&expris parsed the same as& &exprat the start of an expression.cc @estebank