File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -980,6 +980,10 @@ fn needless_borrow_impl_arg_position<'tcx>(
980
980
return None ;
981
981
}
982
982
983
+ if !matches ! ( child_arg_ty. kind( ) , ty:: Param ( _) ) {
984
+ return None ;
985
+ }
986
+
983
987
// If `child_arg_ty` is a type parameter that appears in more than one place, then substituting
984
988
// it with `T` instead of `&T` could cause a type error.
985
989
if cx
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ fn main() {
132
132
let _ = std::path::Path::new(".").join(".");
133
133
134
134
let _ = Box::new(&""); // Don't lint. Type parameter has no trait bounds
135
+ ref_as_ref_path(&""); // Don't lint. Argument type is not a type parameter
135
136
}
136
137
137
138
#[allow(clippy::needless_borrowed_reference)]
@@ -163,3 +164,9 @@ fn check_expect_suppression() {
163
164
#[expect(clippy::needless_borrow)]
164
165
let _ = x(&&a);
165
166
}
167
+
168
+ fn ref_as_ref_path<T: 'static>(_: &'static T)
169
+ where
170
+ &'static T: AsRef<std::path::Path>,
171
+ {
172
+ }
Original file line number Diff line number Diff line change @@ -132,6 +132,7 @@ fn main() {
132
132
let _ = std:: path:: Path :: new ( "." ) . join ( & & "." ) ;
133
133
134
134
let _ = Box :: new ( & "" ) ; // Don't lint. Type parameter has no trait bounds
135
+ ref_as_ref_path ( & "" ) ; // Don't lint. Argument type is not a type parameter
135
136
}
136
137
137
138
#[ allow( clippy:: needless_borrowed_reference) ]
@@ -163,3 +164,9 @@ fn check_expect_suppression() {
163
164
#[ expect( clippy:: needless_borrow) ]
164
165
let _ = x ( & & a) ;
165
166
}
167
+
168
+ fn ref_as_ref_path < T : ' static > ( _: & ' static T )
169
+ where
170
+ & ' static T : AsRef < std:: path:: Path > ,
171
+ {
172
+ }
You can’t perform that action at this time.
0 commit comments