Skip to content

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
Copy link
Collaborator

rustbot commented Feb 1, 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.

@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
- 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 c639215 to a393b01 Compare February 1, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

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