summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/ptr_arg.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:11:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:13:23 +0000
commit20431706a863f92cb37dc512fef6e48d192aaf2c (patch)
tree2867f13f5fd5437ba628c67d7f87309ccadcd286 /src/tools/clippy/tests/ui/ptr_arg.rs
parentReleasing progress-linux version 1.65.0+dfsg1-2~progress7.99u1. (diff)
downloadrustc-20431706a863f92cb37dc512fef6e48d192aaf2c.tar.xz
rustc-20431706a863f92cb37dc512fef6e48d192aaf2c.zip
Merging upstream version 1.66.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/ptr_arg.rs')
-rw-r--r--src/tools/clippy/tests/ui/ptr_arg.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/ptr_arg.rs b/src/tools/clippy/tests/ui/ptr_arg.rs
index fd15001e5..5f54101ca 100644
--- a/src/tools/clippy/tests/ui/ptr_arg.rs
+++ b/src/tools/clippy/tests/ui/ptr_arg.rs
@@ -3,7 +3,7 @@
#![warn(clippy::ptr_arg)]
use std::borrow::Cow;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
fn do_vec(x: &Vec<i64>) {
//Nothing here
@@ -207,3 +207,31 @@ fn cow_conditional_to_mut(a: &mut Cow<str>) {
a.to_mut().push_str("foo");
}
}
+
+// Issue #9542
+fn dyn_trait_ok(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
+ trait T {}
+ impl<U> T for Vec<U> {}
+ impl T for String {}
+ impl T for PathBuf {}
+ fn takes_dyn(_: &mut dyn T) {}
+
+ takes_dyn(a);
+ takes_dyn(b);
+ takes_dyn(c);
+}
+
+fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
+ trait T {}
+ impl<U> T for Vec<U> {}
+ impl<U> T for [U] {}
+ impl T for String {}
+ impl T for str {}
+ impl T for PathBuf {}
+ impl T for Path {}
+ fn takes_dyn(_: &mut dyn T) {}
+
+ takes_dyn(a);
+ takes_dyn(b);
+ takes_dyn(c);
+}