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

Fix build with fmt 11 #1871

Merged
merged 1 commit into from
Feb 26, 2025
Merged

Conversation

malucard
Copy link
Contributor

Needed this to build on Arch Linux

Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

Walkthrough

The change updates the method signature of fmt::formatter<PCSX::IEC60908b::MSF>::format in the header file to include the const qualifier. This enhancement enforces const-correctness, allowing the method to be invoked on const instances without altering the state of the object.

Changes

File Change Summary
src/supportpsx/iec-60908b.h Updated the format method in fmt::formatter<PCSX::IEC60908b::MSF> to include the const qualifier, ensuring const-correctness.

Poem

I hop through lines of code so bright,
Updating methods with a joyful might.
Added const to keep our state so pure,
A fix that makes our functions secure.
With a carrot dance, I celebrate tonight!

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c30393d and 3b30707.

📒 Files selected for processing (1)
  • src/supportpsx/iec-60908b.h (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: pcsx-redux (x86_64-linux)
  • GitHub Check: pcsx-redux (aarch64-linux)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: build-openbios
  • GitHub Check: aur-build
  • GitHub Check: coverage
  • GitHub Check: toolchain
  • GitHub Check: build
  • GitHub Check: asan
  • GitHub Check: macos-build-and-test-toolchain
  • GitHub Check: cross-arm64
🔇 Additional comments (1)
src/supportpsx/iec-60908b.h (1)

162-162:

✅ Verification successful

Good change adding const qualifier to format method.

Adding the const qualifier to the format method correctly addresses compatibility with fmt 11, which requires formatter implementations to be const-correct. This change ensures that the method doesn't modify the formatter's state, which aligns with fmt's design principles and interface requirements.


🌐 Web query:

Does fmt 11 require the format method to be const in formatter specializations?

💡 Result:

Yes, starting with {fmt} 8.0 and continuing through later versions (including 11), the format method in custom formatter specializations must be declared const when using compile-time format string validation via FMT_COMPILE or similar features[2][4][10]. This requirement ensures compatibility with compile-time checks and optimizations.

Key Details:

  1. Requirement Origin:

    • Introduced in {fmt} 8.0 to enforce safety during compile-time format string processing[2].
    • Affects scenarios where FMT_COMPILE, FMT_STRING, or other compile-time validation is used[4].
  2. Error Example:

    // Pre-8.0 code without 'const' qualifier causes errors:
    template <>
    struct fmt::formatter<MyType> {
      auto format(MyType obj, format_context& ctx) { // Missing 'const'
        // ...
      }
    };

    Results in compilation failures like:

    candidate function not viable: 'this' argument has type 'const formatter<...>', but method is not marked const
    
  3. Fix:
    Add const to the format method:

    template <>
    struct fmt::formatter<MyType> {
      auto format(MyType obj, format_context& ctx) const { // Note 'const'
        // ...
      }
    };
  4. Scope:

    • Applies to user-defined formatters and certain internal {fmt} components (e.g., fmt::join had to be updated for compatibility)[2][10].
    • Required even if indirectly using compile-time features (e.g., via fmt::join with FMT_COMPILE)[2].

Why This Matters:

  • Compile-Time Safety: Ensures formatted output generation adheres to constraints verified during compilation[4].
  • Backward Compatibility: Code without const may still work without compile-time checks (e.g., using fmt::runtime)[7], but modern practices favor explicit const qualification for robustness[10].

For new code targeting {fmt} 11+, always declare format as const in custom formatters[2][3][10].

Citations:


Const Correctness Confirmed for Format Method

The addition of the const qualifier to the format method in src/supportpsx/iec-60908b.h is correct. As confirmed by {fmt} documentation (starting from version 8.0 through 11), custom formatter implementations must declare format as const to meet compile-time validation requirements. No further changes are needed.

✨ Finishing Touches
  • 📝 Generate Docstrings

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 generate docstrings to generate docstrings for this 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.

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.

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 9.25%. Comparing base (b7996cd) to head (3b30707).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/supportpsx/iec-60908b.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1871   +/-   ##
=======================================
  Coverage    9.25%    9.25%           
=======================================
  Files         467      467           
  Lines      144360   144360           
=======================================
  Hits        13362    13362           
  Misses     130998   130998           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@nicolasnoble nicolasnoble left a comment

Choose a reason for hiding this comment

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

Hah, the amount of time fmt upgrades breaks the build... Thanks.

@nicolasnoble nicolasnoble merged commit b67ae6f into grumpycoders:main Feb 26, 2025
22 of 24 checks passed
@malucard malucard deleted the fmt-11-build-fix branch February 26, 2025 04:18
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