Remove incorrect parse error recovery code that mistakes as casts for the long removed type ascription - #162700
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
link #101728 |
|
maybe add a ui test for it since there is a observable change on diagnostics. |
I'm usually pro tests (of course) but in cases like here (or over there: #162704) I'm less in favor since the larger context is me being on a spree to dejank the parser trying to shave off as much crusty code as possible (cc #162269, #161796). How likely would it be for |
This comment has been minimized.
This comment has been minimized.
…or the long removed type ascription
f97a732 to
e224f8f
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Sorry for the late reply, LGTM! @bors r+ rollup |
…dead Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription Back when we still had type ascription syntax `$expr : $ty`, `parse_assoc_op_cast` would parse both `as` casts & type ascription. During that time (namely in commit rust-lang@8c5dafd), parse error recovery from code like `label: loop {}` was added (label lacks leading apostrophe). However, it never checked if we did actually parse a `:` and not an `as` meaning *to this day* we emit a nonsensical diagnostic for expressions like `label as loop {}`! This PR does away with this code & further cleans up in the area (thanks to type ascription being gone). In case you're wondering, we do still recover from expr *stmts* like `label: loop {}` as we have some code in the stmt parser for this. Since the removal of the type ascription syntax we do indeed no longer provide that recovery for arbitrary exprs (e.g, `(label: loop {})`) which I find absolutely acceptable. <sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
Rollup of 13 pull requests Successful merges: - #158515 (Make let-else respect macro_rules expr metavariable grouping) - #160097 (fix const_item_mutation lint to use needs_drop instead of has_dtor) - #161435 (Provide a `supertrait_def_ids()` function in rustc_type_ir's interner) - #161894 (Do not suppress the fn item uniqueness note for late bound lifetimes) - #162990 (post GH comment on types nominations) - #154665 (add safety section for mem::zeroed) - #162700 ( Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription) - #162705 (Trigger "C array" parse error recovery in far fewer cases) - #162875 (Add .seek_read_exact(), .seek_write_all() to std::os::windows::fs::FileExt) - #162988 (recover `true` and `false` in type position as `bool`) - #162995 (Constify `impl FromStr for NonZero<T>`) - #163006 (Use `end_point` for trailing brace in `let...else` diagnostics) - #163007 (add Dir::try_clone)
…dead Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription Back when we still had type ascription syntax `$expr : $ty`, `parse_assoc_op_cast` would parse both `as` casts & type ascription. During that time (namely in commit rust-lang@8c5dafd), parse error recovery from code like `label: loop {}` was added (label lacks leading apostrophe). However, it never checked if we did actually parse a `:` and not an `as` meaning *to this day* we emit a nonsensical diagnostic for expressions like `label as loop {}`! This PR does away with this code & further cleans up in the area (thanks to type ascription being gone). In case you're wondering, we do still recover from expr *stmts* like `label: loop {}` as we have some code in the stmt parser for this. Since the removal of the type ascription syntax we do indeed no longer provide that recovery for arbitrary exprs (e.g, `(label: loop {})`) which I find absolutely acceptable. <sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
…uwer Rollup of 15 pull requests Successful merges: - #158515 (Make let-else respect macro_rules expr metavariable grouping) - #162726 (std: fix unix socket address panic on a full sun_path) - #160028 (Better account for `Self` that might be a typo of `self`) - #160097 (fix const_item_mutation lint to use needs_drop instead of has_dtor) - #161435 (Provide a `supertrait_def_ids()` function in rustc_type_ir's interner) - #161894 (Do not suppress the fn item uniqueness note for late bound lifetimes) - #162990 (post GH comment on types nominations) - #154665 (add safety section for mem::zeroed) - #162700 ( Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription) - #162705 (Trigger "C array" parse error recovery in far fewer cases) - #162875 (Add .seek_read_exact(), .seek_write_all() to std::os::windows::fs::FileExt) - #162988 (recover `true` and `false` in type position as `bool`) - #162995 (Constify `impl FromStr for NonZero<T>`) - #163006 (Use `end_point` for trailing brace in `let...else` diagnostics) - #163007 (add Dir::try_clone)
Rollup of 17 pull requests Successful merges: - #158515 (Make let-else respect macro_rules expr metavariable grouping) - #160028 (Better account for `Self` that might be a typo of `self`) - #160097 (fix const_item_mutation lint to use needs_drop instead of has_dtor) - #161435 (Provide a `supertrait_def_ids()` function in rustc_type_ir's interner) - #161894 (Do not suppress the fn item uniqueness note for late bound lifetimes) - #162990 (post GH comment on types nominations) - #153662 (Suggest fully qualified path on method name collision) - #154665 (add safety section for mem::zeroed) - #159787 (Prefer ModId in more places) - #162700 ( Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription) - #162705 (Trigger "C array" parse error recovery in far fewer cases) - #162875 (Add .seek_read_exact(), .seek_write_all() to std::os::windows::fs::FileExt) - #162988 (recover `true` and `false` in type position as `bool`) - #162995 (Constify `impl FromStr for NonZero<T>`) - #163006 (Use `end_point` for trailing brace in `let...else` diagnostics) - #163007 (add Dir::try_clone) - #163039 (Use verbose suggestion for parenthetical `Fn` notation and fully-qualified path on ambiguous assoc item)
Rollup of 17 pull requests Successful merges: - #158515 (Make let-else respect macro_rules expr metavariable grouping) - #160028 (Better account for `Self` that might be a typo of `self`) - #160097 (fix const_item_mutation lint to use needs_drop instead of has_dtor) - #161435 (Provide a `supertrait_def_ids()` function in rustc_type_ir's interner) - #161894 (Do not suppress the fn item uniqueness note for late bound lifetimes) - #162990 (post GH comment on types nominations) - #153662 (Suggest fully qualified path on method name collision) - #154665 (add safety section for mem::zeroed) - #159787 (Prefer ModId in more places) - #162700 ( Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription) - #162705 (Trigger "C array" parse error recovery in far fewer cases) - #162875 (Add .seek_read_exact(), .seek_write_all() to std::os::windows::fs::FileExt) - #162988 (recover `true` and `false` in type position as `bool`) - #162995 (Constify `impl FromStr for NonZero<T>`) - #163006 (Use `end_point` for trailing brace in `let...else` diagnostics) - #163007 (add Dir::try_clone) - #163039 (Use verbose suggestion for parenthetical `Fn` notation and fully-qualified path on ambiguous assoc item)
Rollup merge of #162700 - fmease:rm-dead-ascr-recov, r=fee1-dead Remove incorrect parse error recovery code that mistakes `as` casts for the long removed type ascription Back when we still had type ascription syntax `$expr : $ty`, `parse_assoc_op_cast` would parse both `as` casts & type ascription. During that time (namely in commit 8c5dafd), parse error recovery from code like `label: loop {}` was added (label lacks leading apostrophe). However, it never checked if we did actually parse a `:` and not an `as` meaning *to this day* we emit a nonsensical diagnostic for expressions like `label as loop {}`! This PR does away with this code & further cleans up in the area (thanks to type ascription being gone). In case you're wondering, we do still recover from expr *stmts* like `label: loop {}` as we have some code in the stmt parser for this. Since the removal of the type ascription syntax we do indeed no longer provide that recovery for arbitrary exprs (e.g, `(label: loop {})`) which I find absolutely acceptable. <sub>(No LLM was or will be used by me during the entire creation process of this PR)</sub>
Back when we still had type ascription syntax
$expr : $ty,parse_assoc_op_castwould parse bothascasts & type ascription.During that time (namely in commit 8c5dafd), parse error recovery from code like
label: loop {}was added (label lacks leading apostrophe). However, it never checked if we did actually parse a:and not anasmeaning to this day we emit a nonsensical diagnostic for expressions likelabel as loop {}! This PR does away with this code & further cleans up in the area (thanks to type ascription being gone).In case you're wondering, we do still recover from expr stmts like
label: loop {}as we have some code in the stmt parser for this.Since the removal of the type ascription syntax we do indeed no longer provide that recovery for arbitrary exprs (e.g,
(label: loop {})) which I find absolutely acceptable.(No LLM was or will be used by me during the entire creation process of this PR)