Try to recover from over-parsing in const item with missing semicolon#151247
Try to recover from over-parsing in const item with missing semicolon#151247chenyukang wants to merge 4 commits intorust-lang:mainfrom
Conversation
0851ad6 to
b1dcdd1
Compare
| error[E0308]: mismatched types | ||
| --> $DIR/const-recover-semi-issue-151149.rs:15:19 | ||
| | | ||
| LL | const fn foo() -> &'static u8 { | ||
| | --- ^^^^^^^^^^^ expected `&u8`, found `()` | ||
| | | | ||
| | implicitly returns `()` as its body has no tail or `return` expression |
There was a problem hiding this comment.
It'd be lovely if we could mark the function's tail expr as TyKind::Err so that we didn't emit a second error...
There was a problem hiding this comment.
is there any flag from parser we can set it directly?
There was a problem hiding this comment.
commit 471b929 will remove the later mismatched error, not sure there is any simpler solution, seems a little over engineering for a corner case.
acb4b6a to
68d28b5
Compare
This comment has been minimized.
This comment has been minimized.
| --> $DIR/const-recover-semi-issue-151149.rs:19:38 | ||
| | | ||
| LL | const C: u8 = u8::const_default() | ||
| | ______________________________________^ |
There was a problem hiding this comment.
The span should start where the const starts (as the label is talking about it but pointing at the rhs of the binop).
| @@ -0,0 +1,38 @@ | |||
| #![feature(const_trait_impl)] | |||
There was a problem hiding this comment.
Can we make this //@ run-rustfix?
2c3d8d3 to
c639215
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. |
|
i'd like to see whether there is a performance regression. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…=<try> Try to recover from over-parsing in const item with missing semicolon
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
|
❗ You can only retry pull requests that are approved and have a previously failed auto build. |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (f37f3df): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -5.1%, secondary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 476.042s -> 475.011s (-0.22%) |
- Change error span to start from 'const' keyword instead of binop RHS - Add decl_lo parameter to missing_semi_from_binop() for better spans - Add run-rustfix directive to test file - Simplify test to focus on const item recovery cases
c639215 to
a393b01
Compare

Fixes #151149
r? @estebank