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

uninlined_format_args doesn't seem to provide better code in assert #10281

Closed
BusyJay opened this issue Feb 3, 2023 · 1 comment
Closed

uninlined_format_args doesn't seem to provide better code in assert #10281

BusyJay opened this issue Feb 3, 2023 · 1 comment

Comments

@BusyJay
Copy link

BusyJay commented Feb 3, 2023

Description

Consider following:

assert!(
    self.value_type_str(),
    "key \"{}\" does not refer to a string",
    a
);

Clippy suggest to write it as:

assert!(
    self.value_type_str(),
    "{}",
    "key \"{a}\" does not refer to a string"
);

To me, the second one is quite confusing as it inline formatting but requires additional {} format arg. I suppose this is due to the implementation of assert macro, but it's really not better than the first one.

Version

rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: aarch64-apple-darwin
release: 1.67.0
LLVM version: 15.0.6

Additional Labels

No response

@Alexendoo
Copy link
Member

Should be fixed by #10055, it's a bug that panic/assert macros were linted in code that isn't using the 2021 edition, which then caused the rustc non_fmt_panics lint to fire

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

No branches or pull requests

2 participants