Skip to content

Conversation

@nyurik
Copy link
Member

@nyurik nyurik commented Jan 20, 2026

Prevent unreachable expression compiler warning generating from_can_message - simply return CanError::UnknownMessageId(id) error without the match statement.

Prevent `unreachable expression` compiler warning generating `from_can_message` - simply return `CanError::UnknownMessageId(id)` error without the match statement.
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 53.33333% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib.rs 53.33% 1 Missing and 6 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes unreachable code compiler warnings in the generated from_can_message function when DBC files contain no relevant messages. The fix detects empty message lists and generates a direct error return instead of a match statement with an unreachable Ok branch.

Changes:

  • Modified code generation logic to detect empty message lists and emit simplified error handling code
  • Updated snapshot tests to reflect the corrected generated code
  • Removed tests from the exclusion list that now pass without compiler warnings

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib.rs Added check for empty messages and conditional code generation to avoid unreachable expression warnings
tests/snapshots.rs Removed 4 tests from BAD_TESTS list that now compile successfully
tests-snapshots/dbc-cantools/issue_62.snap.rs Updated generated code to use direct error return instead of unreachable match
tests-snapshots/dbc-cantools/empty_ns.snap.rs Updated generated code to use direct error return instead of unreachable match
tests-snapshots/dbc-cantools/cp1252.snap.rs Updated generated code to use direct error return instead of unreachable match
tests-snapshots/dbc-cantools/bus_comment_bare_out.snap.rs Updated generated code to use direct error return instead of unreachable match
tests-snapshots/dbc-cantools/bus_comment_bare.snap.rs Updated generated code to use direct error return instead of unreachable match
tests-snapshots/dbc-cantools/issue_62.snap.stderr Removed error snapshot as the file now compiles without warnings
tests-snapshots/dbc-cantools/empty_ns.snap.stderr Removed error snapshot as the file now compiles without warnings
tests-snapshots/dbc-cantools/cp1252.snap.stderr Removed error snapshot as the file now compiles without warnings
tests-snapshots/dbc-cantools/bus_comment_bare_out.snap.stderr Removed error snapshot as the file now compiles without warnings
tests-snapshots/dbc-cantools/bus_comment_bare.snap.stderr Removed error snapshot as the file now compiles without warnings

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nyurik nyurik merged commit 5976ace into oxibus:main Jan 21, 2026
13 checks passed
@nyurik nyurik deleted the empty-rel-msg branch January 21, 2026 07:44
@nyurik nyurik mentioned this pull request Jan 21, 2026
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.

2 participants