-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Try to recover from over-parsing in const item with missing semicolon #151247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
b1dcdd1
68d28b5
471b929
2c3d8d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
chenyukang marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| #![feature(const_trait_impl)] | ||
|
|
||
| const trait ConstDefault { | ||
| fn const_default() -> Self; | ||
| } | ||
|
|
||
| impl const ConstDefault for u8 { | ||
| fn const_default() -> Self { 0 } | ||
| } | ||
|
|
||
| const fn val() -> u8 { | ||
| 42 | ||
| } | ||
|
|
||
| const fn foo() -> &'static u8 { //~ ERROR mismatched types | ||
| const C: u8 = u8::const_default() //~ ERROR expected `;` | ||
| &C | ||
| } | ||
|
|
||
| const fn bar() -> u8 { //~ ERROR mismatched types | ||
| const C: u8 = 1 | ||
| + 2 //~ ERROR expected `;` | ||
| } | ||
|
|
||
| const fn baz() -> u8 { //~ ERROR mismatched types | ||
| const C: u8 = 1 | ||
| + val() //~ ERROR expected `;` | ||
| } | ||
|
|
||
| fn main() {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| error: expected `;`, found `}` | ||
| --> $DIR/const-recover-semi-issue-151149.rs:16:38 | ||
| | | ||
| LL | const C: u8 = u8::const_default() | ||
| | ^ help: add `;` here | ||
| LL | &C | ||
| LL | } | ||
| | - unexpected token | ||
chenyukang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| error: expected `;`, found `}` | ||
| --> $DIR/const-recover-semi-issue-151149.rs:22:9 | ||
| | | ||
| LL | + 2 | ||
| | ^ help: add `;` here | ||
| LL | } | ||
| | - unexpected token | ||
chenyukang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| error: expected `;`, found `}` | ||
| --> $DIR/const-recover-semi-issue-151149.rs:27:13 | ||
| | | ||
| LL | + val() | ||
| | ^ help: add `;` here | ||
| LL | } | ||
| | - unexpected token | ||
|
|
||
| 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 | ||
|
||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/const-recover-semi-issue-151149.rs:20:19 | ||
| | | ||
| LL | const fn bar() -> u8 { | ||
| | --- ^^ expected `u8`, found `()` | ||
| | | | ||
| | implicitly returns `()` as its body has no tail or `return` expression | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/const-recover-semi-issue-151149.rs:25:19 | ||
| | | ||
| LL | const fn baz() -> u8 { | ||
| | --- ^^ expected `u8`, found `()` | ||
| | | | ||
| | implicitly returns `()` as its body has no tail or `return` expression | ||
|
|
||
| error: aborting due to 6 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0308`. | ||
Uh oh!
There was an error while loading. Please reload this page.