Skip to content

Incorrect fix for uninlined_format_args with unicode character #9727

Closed
rust-lang/rust
#103651
@cgzones

Description

@cgzones

Summary

Nightly clippy fixes ``uninlined_format_args` incorrectly when a unicode character is involved:

Reproducer

I tried this code (https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=795eeb30bacb8129ad8b2d07cfd2703c):

pub fn foo() {
    let a = "a";
    let b = "b";

    println!("{}\u{2794}{}", a, b);
}
warning: variables can be used directly in the `format!` string
 --> src/lib.rs:5:5
  |
5 |     println!("{}\u{2794}{}", a, b);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args
  = note: `#[warn(clippy::uninlined_format_args)]` on by default
help: change this to
  |
5 -     println!("{}\u{2794}{}", a, b);
5 +     println!("{a}\u{2794}{}"b, a);
  |

warning: `playground` (lib) generated 1 warning

Version

rustc 1.66.0-nightly (bed4ad65b 2022-10-25)
binary: rustc
commit-hash: bed4ad65bf7a1cef39e3d66b3670189581b3b073
commit-date: 2022-10-25
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Additional Labels

No response

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions