dillon1000/react
Commit
Browse files [rust] General-purpose diagnostic type and helpers
This PR adapts the `Diagnostic` type and helpers from Relay Compiler to Forget. The main changes are: * Removing some fields it doesn't seem we'll use for a while, if ever (like machine-readable arbitrary key/value data) * Switching from Relay Compiler's `Location` type to our SourceRange type * Using the severity enum previously established in the `forget_build_hir` crate, with Todo/Unsupported/InvalidSyntax/InvalidReact/Invariant variants * Adding support for translating our `Diagnostic` into a `miette::Diagnostic` so we can use miette's pretty printing With the new Diagnostic type in place i updated the existing build_hir code to use it and confirmed that the errors are now even nicer (when we attach extra data to annotate labels): <img width="860" alt="Screenshot 2023-07-14 at 3 10 00 PM" src="https://github.com/facebook/react-forget/assets/6425824/9d29425a-938b-4872-b999-aa174a3c329a"> This addresses (or brings us closer to addressing) many of your comments on the last diagnostics PR, @poteto!
Changed paths12 files
First-parent comparisoncompiler/forget/Cargo.lock ModifiedM compiler/forget/Cargo.toml ModifiedM compiler/forget/crates/forget_build_hir/Cargo.toml ModifiedM compiler/forget/crates/forget_build_hir/src/build.rs ModifiedM compiler/forget/crates/forget_build_hir/src/builder.rs ModifiedM compiler/forget/crates/forget_build_hir/src/error.rs ModifiedA compiler/forget/crates/forget_diagnostics/Cargo.toml AddedA compiler/forget/crates/forget_diagnostics/README.md AddedA compiler/forget/crates/forget_diagnostics/src/diagnostic.rs AddedA compiler/forget/crates/forget_diagnostics/src/lib.rs AddedM compiler/forget/crates/forget_estree/src/range.rs ModifiedM compiler/forget/crates/forget_hir/src/terminal.rs ModifiedPatch
Files changed
Rendering syntax-highlighted changes…