-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Try to recover more from struct field parse error #127426
Closed
chenyukang
wants to merge
1
commit into
rust-lang:master
from
chenyukang:yukang-fix-parse-recover-struct
Closed
Try to recover more from struct field parse error #127426
chenyukang
wants to merge
1
commit into
rust-lang:master
from
chenyukang:yukang-fix-parse-recover-struct
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I tested on some local projects, the typical change is like this: Current: mini-redis git:(master) ✗ cargo build
Compiling mini-redis v0.4.1 (/Users/yukang/code/playground/mini-redis)
error: struct fields are separated by `,`
--> src/server.rs:29:26
|
18 | struct Listener {
| -------- while parsing this struct
...
29 | listener: TcpListener;
| ^ help: replace `;` with `,`
error[E0609]: no field `limit_connections` on type `&mut Listener`
--> src/server.rs:229:18
|
229 | .limit_connections
| ^^^^^^^^^^^^^^^^^ unknown field
|
= note: available field is: `db_holder`
error[E0609]: no field `notify_shutdown` on type `&mut Listener`
--> src/server.rs:250:46
|
250 | shutdown: Shutdown::new(self.notify_shutdown.subscribe()),
| ^^^^^^^^^^^^^^^ unknown field
|
= note: available field is: `db_holder`
error[E0609]: no field `shutdown_complete_tx` on type `&mut Listener`
--> src/server.rs:254:42
|
254 | _shutdown_complete: self.shutdown_complete_tx.clone(),
| ^^^^^^^^^^^^^^^^^^^^ unknown field
|
= note: available field is: `db_holder`
error[E0609]: no field `listener` on type `&mut Listener`
--> src/server.rs:285:24
|
285 | match self.listener.accept().await {
| ^^^^^^^^ unknown field
|
= note: available field is: `db_holder`
For more information about this error, try `rustc --explain E0609`.
error: could not compile `mini-redis` (lib) due to 5 previous errors With fix: ➜ mini-redis git:(master) ✗ cargo +dev2 build
Compiling mini-redis v0.4.1 (/Users/yukang/code/playground/mini-redis)
error: struct fields are separated by `,`
--> src/server.rs:29:26
|
18 | struct Listener {
| -------- while parsing this struct
...
29 | listener: TcpListener;
| ^ help: replace `;` with `,`
error[E0609]: no field `listener` on type `&mut Listener`
--> src/server.rs:285:24
|
285 | match self.listener.accept().await {
| ^^^^^^^^ unknown field
|
= note: available fields are: `db_holder`, `limit_connections`, `notify_shutdown`, `shutdown_complete_tx`
For more information about this error, try `rustc --explain E0609`.
error: could not compile `mini-redis` (lib) due to 2 previous errors |
Got a better solution |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 10, 2024
…ice, r=<try> Avoid no field error and ice no recovered struct variant Fixes rust-lang#126744 Fixes rust-lang#126344, a more general fix compared with rust-lang#127426 r? `@oli-obk` From `@compiler-errors` 's comment rust-lang#127502 (comment) Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jul 11, 2024
…ice, r=compiler-errors Avoid "no field" error and ICE on recovered ADT variant Fixes rust-lang#126744 Fixes rust-lang#126344, a more general fix compared with rust-lang#127426 r? `@oli-obk` From `@compiler-errors` 's comment rust-lang#127502 (comment) Seems most of the ADTs don't have taint, so maybe it's not proper to change `TyCtxt::type_of` query.
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Partially fixes #126344
I tried to recover more from parsing struct field error, instead of skipping the whole struct, we may continue to parse the other fields, this can help to reduce some noises when there is only one struct field is not parsed correctly, we will not report
unknown field
for all the other fields.But this PR can not remove all later diagnostics from the
struct
, I'm not sure whether is worth to solve it, I think the main noise comes from too many fields are ignored, while the left one is trivial.r? @estebank