Skip to content

Conversation

@nyurik
Copy link
Member

@nyurik nyurik commented Jan 26, 2026

while the previous method was accurate, it created some mismatches with the future quote/syn method of code generation. The new one avoids escaping characters that do not need to be escaped.

Note that quote is not a new dependency - it was already used as a sub-dependency. We just declare it explicitly.

while the previous method was accurate, it created some mismatches with the future quote/syn method of code generation. The new one avoids escaping characters that do not need to be escaped.
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib.rs 50.00% 0 Missing and 2 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 refactors string escaping in the code generator to use the quote crate's ToTokens trait instead of escape_default(). The change improves consistency with standard Rust code generation practices and avoids unnecessarily escaping characters like single quotes (') in generated string literals.

Changes:

  • Replaced escape_default() with quote::ToTokens::to_token_stream() for generating string literals
  • Added explicit dependency on the quote crate (version 1.0) to Cargo.toml
  • Updated snapshot tests to reflect the cleaner string escaping (e.g., ' instead of \')

Reviewed changes

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

Show a summary per file
File Description
src/lib.rs Replaced escape_default() with to_token_stream() for DBC_FILE_NAME and DBC_FILE_VERSION constants; added use quote::ToTokens
Cargo.toml Added explicit quote = "1.0" dependency
Cargo.lock Updated to include quote as a direct dependency of dbc-codegen
tests-snapshots/dbc-cantools/no_signals.snap.rs Updated snapshot to show unescaped single quote in version string
tests-snapshots/dbc-cantools/floating_point.snap.rs Updated snapshot to show unescaped single quote in version string
tests-snapshots/dbc-cantools/emc32.snap.rs Updated snapshot to show unescaped single quote in version string
tests-snapshots/dbc-cantools/dump_signal_choices.snap.rs Updated snapshot to show unescaped single quote in version string

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

@nyurik nyurik merged commit 3b1381b into oxibus:main Jan 27, 2026
13 checks passed
@nyurik nyurik deleted the lit-escape branch January 27, 2026 22:15
@nyurik nyurik mentioned this pull request Jan 26, 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