-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
In the following code, after (use<>
, while still inside parenthesized content, the parser successfully parses the function body and tuple struct, oblivious that these were supposed to have been outside )
.
fn repro() -> impl (use<> {
println!("?");
}
#[derive(Debug)]
struct Struct<F>(i32, F)
where
T: Fn() -> i32;
)
error: expected item, found `)`
--> src/lib.rs:10:1
|
10 | )
| ^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
It seems pretty clear to me that this is unintended behavior, not some kind of intentional parsing recovery. The same bug does not occur for a mismatched parenthesis around lifetime bound or trait bound.
error: expected `)`, found `{`
--> src/lib.rs:1:24
|
1 | fn repro() -> impl ('a {
| ^ expected `)`
error: expected one of `(`, `)`, `::`, or `<`, found `{`
--> src/lib.rs:1:27
|
1 | fn repro() -> impl (Trait {
| ^ expected one of `(`, `)`, `::`, or `<`
compiler-errors
Metadata
Metadata
Assignees
Labels
A-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.