mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Add test for #8855
This commit is contained in:
committed by
Samuel Moelius
parent
5820addb24
commit
6f3d398e13
@@ -122,3 +122,27 @@ fn issue8643(vendor_id: usize, product_id: usize, name: &str) {
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/8855
|
||||
mod issue_8855 {
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct A {}
|
||||
|
||||
impl std::fmt::Display for A {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "test")
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = A {};
|
||||
let b = A {};
|
||||
|
||||
let x = format!("{} {}", a, b);
|
||||
dbg!(x);
|
||||
|
||||
let x = format!("{:>6} {:>6}", a, b.to_string());
|
||||
dbg!(x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,3 +122,27 @@ fn issue8643(vendor_id: usize, product_id: usize, name: &str) {
|
||||
name
|
||||
);
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/8855
|
||||
mod issue_8855 {
|
||||
#![allow(dead_code)]
|
||||
|
||||
struct A {}
|
||||
|
||||
impl std::fmt::Display for A {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "test")
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = A {};
|
||||
let b = A {};
|
||||
|
||||
let x = format!("{} {}", a, b.to_string());
|
||||
dbg!(x);
|
||||
|
||||
let x = format!("{:>6} {:>6}", a, b.to_string());
|
||||
dbg!(x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,5 +126,11 @@ error: `to_string` applied to a type that implements `Display` in `println!` arg
|
||||
LL | println!("{foo}{bar}", bar = "bar", foo = "foo".to_string());
|
||||
| ^^^^^^^^^^^^ help: remove this
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
error: `to_string` applied to a type that implements `Display` in `format!` args
|
||||
--> $DIR/format_args.rs:142:38
|
||||
|
|
||||
LL | let x = format!("{} {}", a, b.to_string());
|
||||
| ^^^^^^^^^^^^ help: remove this
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user