Skip to content

Try to recover from over-parsing in const item with missing semicolon#151247

Merged
rust-bors[bot] merged 4 commits intorust-lang:mainfrom
chenyukang:yukang-fix-const-recover-151149
Feb 27, 2026
Merged

Try to recover from over-parsing in const item with missing semicolon#151247
rust-bors[bot] merged 4 commits intorust-lang:mainfrom
chenyukang:yukang-fix-const-recover-151149

Conversation

@chenyukang
Copy link
Member

@chenyukang chenyukang commented Jan 17, 2026

Fixes #151149

r? @estebank

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2026
@chenyukang chenyukang force-pushed the yukang-fix-const-recover-151149 branch from 0851ad6 to b1dcdd1 Compare January 17, 2026 16:52
Comment on lines 26 to 32
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any flag from parser we can set it directly?

Copy link
Member Author

@chenyukang chenyukang Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit 471b929 will remove the later mismatched error, not sure there is any simpler solution, seems a little over engineering for a corner case.

@chenyukang chenyukang force-pushed the yukang-fix-const-recover-151149 branch 2 times, most recently from acb4b6a to 68d28b5 Compare January 19, 2026 07:25
@rust-bors

This comment has been minimized.

--> $DIR/const-recover-semi-issue-151149.rs:19:38
|
LL | const C: u8 = u8::const_default()
| ______________________________________^
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The span should start where the const starts (as the label is talking about it but pointing at the rhs of the binop).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed:

image

@@ -0,0 +1,38 @@
#![feature(const_trait_impl)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this //@ run-rustfix?

@chenyukang chenyukang force-pushed the yukang-fix-const-recover-151149 branch from 2c3d8d3 to c639215 Compare February 1, 2026 03:46
@rustbot

This comment has been minimized.

@chenyukang
Copy link
Member Author

i'd like to see whether there is a performance regression.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 1, 2026
…=<try>

Try to recover from over-parsing in const item with missing semicolon
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 1, 2026
@rust-log-analyzer

This comment has been minimized.

@chenyukang
Copy link
Member Author

@bors retry

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 1, 2026

❗ You can only retry pull requests that are approved and have a previously failed auto build.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 1, 2026

☀️ Try build successful (CI)
Build commit: f37f3df (f37f3dfb6a344f1fe12b003fdaeaf36417406168, parent: a1db344c0829cb682df4174e9370b60915751605)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f37f3df): comparison URL.

Overall result: ❌ regressions - no action needed

Benchmarking 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
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.1% [-5.1%, -5.1%] 1
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) -5.1% [-5.1%, -5.1%] 1

Cycles

Results (secondary -1.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.8% [-4.8%, -4.8%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 44
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.0%] 24
All ❌✅ (primary) -0.1% [-0.1%, -0.0%] 44

Bootstrap: 476.042s -> 475.011s (-0.22%)
Artifact size: 397.86 MiB -> 397.80 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 1, 2026
@chenyukang chenyukang force-pushed the yukang-fix-const-recover-151149 branch from c639215 to a393b01 Compare February 1, 2026 06:52
@rust-bors

This comment has been minimized.

- 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
@chenyukang chenyukang force-pushed the yukang-fix-const-recover-151149 branch from a393b01 to ba0e1c9 Compare February 12, 2026 10:50
@rustbot
Copy link
Collaborator

rustbot commented Feb 12, 2026

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.

@estebank
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 26, 2026

📌 Commit ba0e1c9 has been approved by estebank

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 27, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 27, 2026

☀️ Test successful - CI
Approved by: estebank
Duration: 3h 25m 14s
Pushing 6f54d59 to main...

@rust-bors rust-bors bot merged commit 6f54d59 into rust-lang:main Feb 27, 2026
12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 27, 2026
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 0ee5907 (parent) -> 6f54d59 (this PR)

Test differences

Show 6 test diffs

Stage 1

  • [ui] tests/ui/parser/const-recover-semi-issue-151149.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/parser/const-recover-semi-issue-151149.rs: [missing] -> pass (J1)

Additionally, 4 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 6f54d591c3116ee7f8ce9321ddeca286810cc142 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. aarch64-apple: 4h 49m -> 3h 18m (-31.4%)
  2. dist-x86_64-apple: 2h 17m -> 1h 56m (-15.0%)
  3. dist-aarch64-apple: 2h 6m -> 2h 23m (+13.0%)
  4. x86_64-gnu-tools: 1h 2m -> 54m 39s (-12.1%)
  5. x86_64-gnu-stable: 2h 27m -> 2h 9m (-12.0%)
  6. x86_64-gnu-miri: 1h 22m -> 1h 13m (-11.7%)
  7. pr-check-2: 43m 46s -> 39m 27s (-9.9%)
  8. dist-aarch64-llvm-mingw: 1h 33m -> 1h 42m (+8.8%)
  9. dist-apple-various: 1h 48m -> 1h 56m (+8.1%)
  10. pr-check-1: 32m 35s -> 30m 1s (-7.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6f54d59): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary -2.1%, secondary -5.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
-5.0% [-5.0%, -5.0%] 1
All ❌✅ (primary) -2.1% [-2.1%, -2.1%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 481.376s -> 481.449s (0.02%)
Artifact size: 395.63 MiB -> 397.59 MiB (0.50%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple errors on binding missing ; followed by implicitly returning a borrow of that binding

5 participants