Conversation
Reviewer's GuideRefactor kind_to_raw to use expect for unreachable cases and annotate it with a Clippy attribute to suppress the expect_used lint. Class diagram for updated DdlogLanguage implementationclassDiagram
class DdlogLanguage {
+SyntaxKind raw_kind_to_kind(RowanSyntaxKind raw)
+RowanSyntaxKind kind_to_raw(SyntaxKind kind)
}
class SyntaxKind {
+u16 to_u16()
+from_u16(u16)
N_ERROR
}
class RowanSyntaxKind {
+u16 0
}
DdlogLanguage --> SyntaxKind : uses
DdlogLanguage --> RowanSyntaxKind : returns
SyntaxKind <.. RowanSyntaxKind : conversion
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughSimplify the Changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rsInstructions used from: Sources:
⚙️ CodeRabbit Configuration File 🔇 Additional comments (2)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/language.rs:187` </location>
<code_context>
- kind.to_u16()
- .unwrap_or_else(|| unreachable!("all SyntaxKind variants map to u16")),
- )
+ RowanSyntaxKind(kind.to_u16().expect("all SyntaxKind variants map to u16"))
}
}
</code_context>
<issue_to_address>
Direct use of expect improves clarity, but may obscure the source of panics.
Consider adding the specific SyntaxKind value to the expect message to aid debugging if a panic occurs.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
RowanSyntaxKind(kind.to_u16().expect("all SyntaxKind variants map to u16"))
=======
RowanSyntaxKind(
kind.to_u16().expect(&format!(
"all SyntaxKind variants map to u16; failed for SyntaxKind::{:?}",
kind
))
)
>>>>>>> REPLACE
</suggested_fix>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/language.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENTS.md
⚙️ CodeRabbit Configuration File
Summary
unwrap_or_elsecall withexpectinkind_to_rawexpectis acceptable using a Clippy#[expect]attributeTesting
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_68764340b3388322a358388cb3fb737b
Summary by Sourcery
Simplify error handling in the kind_to_raw implementation by switching to expect for unreachable branches and suppress the Clippy expect_used lint with an explicit attribute
Enhancements: