Skip to content
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

Emit lints using a diagnostic builder #121

Merged
merged 8 commits into from
Mar 24, 2023

Conversation

xFrednet
Copy link
Member

@xFrednet xFrednet commented Mar 8, 2023

This PR adds a new DiagnosticBuilder to the API to create beautiful diagnostics with help and note messages. This will also allow us to include the expression span, in the print tests. Generally, I'm pretty happy with the concept :)


Adding new context callbacks to the API currently requires a lot of boilerplate code. I doubt that we can avoid that right now, but I'll try to look at options to generate a part of it. That would at least help with the implementation and review part.


r? @Niki4tap Sorry for requesting this review direction after the last one. You are welcome to take your time or pass the review if you don't have time. It's also totally fine, if you just review the API and doc changes. The backend is mostly verified by the tests :)

Closes #47
Closes #92 (This PR adds the id() and span() method to StmtKind)

@xFrednet xFrednet added C-enhancement Category: New feature or request A-api Area: Stable API D-rustc-driver Driver: Rustc Driver S-waiting-on-review Status: Awaiting review labels Mar 8, 2023
@xFrednet xFrednet added this to the v0.0.1 milestone Mar 8, 2023
@xFrednet
Copy link
Member Author

xFrednet commented Mar 9, 2023

I've rebased on master, after the nightly bump 🙃

There was a small conflict, but nothing changed :)

Copy link
Member

@Niki4tap Niki4tap left a comment

Choose a reason for hiding this comment

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

I like the new API, left a few small comments, but I'm a bit concerned about the foo field lint going away in the tests, even though the code for it is still there. My best guess is that try_to_hir_id_from_emission_node is returning None, but I'm not sure

marker_api/src/ast/common/id.rs Outdated Show resolved Hide resolved
marker_api/src/context.rs Outdated Show resolved Hide resolved
marker_api/src/diagnostic.rs Outdated Show resolved Hide resolved
marker_api/src/diagnostic.rs Outdated Show resolved Hide resolved
Comment on lines 23 to 28
warning: a field named `foo`, consider using a more meaningful name
--> $DIR/foo_items.rs:7:9
|
7 | foo: i32,
| ^^^^^^^^

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this lint went away, maybe try_to_hir_id_from_emission_node is failing for FieldId?

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good catch 💪

@xFrednet
Copy link
Member Author

Thank you for the review. ❤️ I had a busy week and now I'm catching up with all the fires I left burning. I'll probably get to this on the weekend. 🙃

Co-authored-by: Niki4tap <[email protected]>

I should almost create an alias for this specific message
@xFrednet
Copy link
Member Author

The PR should be ready now. I'll probably do some cleanup and maintenance now, to get back into the flow, after a short break :)

@Niki4tap
Copy link
Member

Nice, I left some things too, will try to come back soon

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 24, 2023

@bors bors bot merged commit bf43d45 into rust-marker:master Mar 24, 2023
@xFrednet xFrednet deleted the 047-diagnostics branch June 3, 2023 22:04
bors bot added a commit that referenced this pull request Jun 4, 2023
136: Test: Use `emit_lint` instead of `println!` in tests r=xFrednet a=xFrednet

Follow up of #121

Not much more to say. I'll r+ this directly, as these are automatically generated and would be a pain to review.

r? `@ghost`

Co-authored-by: xFrednet <[email protected]>
bors bot added a commit that referenced this pull request Jun 4, 2023
136: Test: Use `emit_lint` instead of `println!` in tests r=xFrednet a=xFrednet

Follow up of #121

Not much more to say. I'll r+ this directly, as these are automatically generated and would be a pain to review.

r? `@ghost`

Co-authored-by: xFrednet <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-api Area: Stable API C-enhancement Category: New feature or request D-rustc-driver Driver: Rustc Driver S-waiting-on-review Status: Awaiting review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add common methods to StmtKind enum, similar to the ItemData trait Add Diagnostic object for lint emissions
2 participants