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

feat: added upstream miette support #1038

Merged
merged 8 commits into from
Sep 11, 2024

Conversation

prsabahrami
Copy link
Contributor

@prsabahrami prsabahrami commented Sep 9, 2024

Reopening #582
Added tests as mentioned in #663 (comment)

Summary by CodeRabbit

  • New Features

    • Introduced enhanced error handling and reporting capabilities with the addition of the miette dependency.
    • Added a new method to transform errors into a miette::Diagnostic for improved diagnostics.
  • Bug Fixes

    • Improved error output formatting based on the presence of the miette feature, allowing for clearer error messages.
  • Documentation

    • Updated error handling documentation to reflect new features and usage of the miette library.

bobbbay and others added 6 commits July 24, 2022 18:15

Verified

This commit was signed with the committer’s verified signature.
…Error`

Verified

This commit was signed with the committer’s verified signature.
…ostic`

Verified

This commit was signed with the committer’s verified signature.
@prsabahrami prsabahrami requested a review from a team as a code owner September 9, 2024 15:50
@prsabahrami prsabahrami requested review from tomtau and removed request for a team September 9, 2024 15:50
Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

This pull request introduces changes to the Rust project's Cargo.toml file by removing the memchr dependency from the default feature set and adding an optional dependency on miette with the fancy feature enabled. The Error struct in pest/src/error.rs is updated to allow external access to its format method and includes a new method for integration with the miette library, along with a new adapter struct to enhance error reporting. Additionally, the example file pest/examples/parens.rs is updated to improve error handling based on the presence of the miette feature.

Changes

File Change Summary
pest/Cargo.toml Removed memchr from default features; added optional miette dependency with fancy feature.
pest/src/error.rs Changed format method visibility to pub; added into_miette method and MietteAdapter struct for miette integration.
pest/examples/parens.rs Enhanced error handling in main function to support miette feature for improved error reporting.

Poem

🐇 In the garden of code, we hop with delight,
New features and fixes, oh what a sight!
With miette in hand, errors now gleam,
A parser's sweet dance, like a soft, gentle dream.
Hopping along, we celebrate change,
In the world of Rust, we joyfully arrange! 🌼

Tip

Announcements
  • The review status is no longer posted as a separate comment when there are no actionable or nitpick comments. In such cases, the review status is included in the walkthrough comment.
  • We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord.
  • Possibly related PRs: Walkthrough comment now includes a list of potentially related PRs to help you recall past context. Please share any feedback in the discussion post on our Discord.
  • Suggested labels: CodeRabbit can now suggest labels by learning from your past PRs in the walkthrough comment. You can also provide custom labeling instructions in the UI or configuration file.
  • Possibly related PRs, automatic label suggestions based on past PRs, learnings, and possibly related issues require data opt-in (enabled by default).

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 205973b and fb3a32e.

Files selected for processing (3)
  • pest/Cargo.toml (1 hunks)
  • pest/examples/parens.rs (1 hunks)
  • pest/src/error.rs (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • pest/Cargo.toml
  • pest/examples/parens.rs
Additional comments not posted (5)
pest/src/error.rs (5)

674-679: LGTM!

The addition of the into_miette method enhances integration with the miette error reporting library, providing structured error diagnostics.


737-776: LGTM!

The introduction of the miette_adapter module and the MietteAdapter struct significantly enhances the error reporting mechanism by implementing the Diagnostic trait for the Error type.


1155-1183: LGTM!

The addition of the miette_error test case ensures that the integration with the miette library functions correctly and the error message formatting aligns with the miette diagnostic output.


675-677: LGTM!

The comment accurately describes the purpose of the into_miette method and provides useful information for users of the library.


748-750: LGTM!

The doc comment accurately describes the purpose of the MietteAdapter struct and provides useful information for users of the library.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@prsabahrami prsabahrami changed the title Parsa miette support feat: added upstream miette support Sep 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between da3fcfe and bd3c625.

Files selected for processing (3)
  • pest/Cargo.toml (2 hunks)
  • pest/examples/parens.rs (1 hunks)
  • pest/src/error.rs (4 hunks)
Additional comments not posted (6)
pest/Cargo.toml (2)

30-30: Verify the impact of removing memchr from default features.

Removing memchr could affect performance or functionality. Please ensure that this change is tested thoroughly, especially in parts of the codebase where fast string searching was critical.


30-34: Approve the addition of miette as an optional dependency.

The addition of miette is intended to enhance error reporting capabilities. Ensure that miette integrates well with existing error handling mechanisms and does not introduce any conflicts or issues.

pest/examples/parens.rs (1)

71-84: Approve enhanced error handling with conditional miette integration.

The changes to error handling in the main function improve flexibility and clarity. The use of conditional compilation ensures that these enhancements are only active when the "miette" feature is enabled. Consider adding comments explaining the use of map_err for future maintainers.

pest/src/error.rs (3)

603-603: Approve the increased visibility of the format method.

Changing the visibility of the format method to pub allows for broader usage, potentially with external libraries or other parts of the project. Ensure that the documentation reflects the intended use cases and any potential risks associated with broader access.


675-679: Approve the addition of the into_miette method with conditional compilation.

The into_miette method enhances error reporting by converting Error instances into miette::Diagnostic objects. This integration is well-aligned with the optional miette dependency specified in the Cargo.toml. Consider adding unit tests to ensure that this method functions as expected under various conditions.


737-773: Approve the addition of the miette_adapter module and its contents.

The MietteAdapter struct within the miette_adapter module effectively integrates the Error type with the miette library by implementing the Diagnostic trait. This implementation enhances error reporting by providing detailed diagnostic information. Ensure that the implementation covers all necessary aspects of the Diagnostic trait and consider adding more comprehensive tests to cover various error scenarios.

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

thanks!
cargo fmt should fix the small formatting issue: https://github.com/pest-parser/pest/actions/runs/10776713820/job/29909630226?pr=1038

pest/src/error.rs Outdated Show resolved Hide resolved
pest/Cargo.toml Outdated Show resolved Hide resolved
@prsabahrami
Copy link
Contributor Author

Fixed the issues.

@prsabahrami prsabahrami requested a review from tomtau September 10, 2024 14:24
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

the miette feature fails on some combination of feature flags: https://github.com/pest-parser/pest/actions/runs/10794522394/job/29941922867?pr=1038#step:4:141 (e.g. cargo check --lib --tests --no-default-features --features miette)

if miette needs std, you can perhaps define an explicit feature flag:

[features]
#...
miette-error = ["std", "dep:miette"]

and change those feature guards accordingly (#[cfg(feature = "miette-error")])

@prsabahrami prsabahrami requested a review from tomtau September 10, 2024 18:10
@prsabahrami
Copy link
Contributor Author

The dependencies for miette are fixed. I added std and pretty-print since the LineColLocation was being pretty-printed.

@tomtau tomtau merged commit 65e5b2b into pest-parser:master Sep 11, 2024
9 checks passed
@erhant
Copy link

erhant commented Sep 14, 2024

wow what a luck, I just came back to look at the miette integration after months, and 3 days ago this was merged <3 <3

great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants