diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-02-09 19:21:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-09 19:21:17 +0100 |
| commit | 8f00ffc901badd27e7d58641daecb30b8cd76a74 (patch) | |
| tree | 0e2ee84c7547d469c7668fa811a0cfeb2f1d9a66 /tests/ui/to_string_trait_impl.rs | |
| parent | e0caf3980711f8f911f45a6710aa5f2560aaafa2 (diff) | |
| parent | f3b3d23416f1da77103bb74788f23b4f9c78ee7e (diff) | |
Rollup merge of #120806 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update r? `@Manishearth`
Diffstat (limited to 'tests/ui/to_string_trait_impl.rs')
| -rw-r--r-- | tests/ui/to_string_trait_impl.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/to_string_trait_impl.rs b/tests/ui/to_string_trait_impl.rs new file mode 100644 index 00000000000..b0731632d45 --- /dev/null +++ b/tests/ui/to_string_trait_impl.rs @@ -0,0 +1,31 @@ +#![warn(clippy::to_string_trait_impl)] + +use std::fmt::{self, Display}; + +struct Point { + x: usize, + y: usize, +} + +impl ToString for Point { + fn to_string(&self) -> String { + format!("({}, {})", self.x, self.y) + } +} + +struct Foo; + +impl Display for Foo { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Foo") + } +} + +struct Bar; + +impl Bar { + #[allow(clippy::inherent_to_string)] + fn to_string(&self) -> String { + String::from("Bar") + } +} |
