Skip to content

Commit 432baf7

Browse files
committed
Auto merge of rust-lang#9813 - Jarcho:issue_9811, r=xFrednet
Fix `explicit_auto_deref` fp fixes rust-lang#9763 fixes rust-lang#9811 changelog: `explicit_auto_deref`: Don't lint when the target type is a projection with generic arguments
2 parents c4fbe54 + 5b1e445 commit 432baf7

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

clippy_lints/src/dereference.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,7 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
13851385
continue;
13861386
},
13871387
ty::Param(_) => TyPosition::new_deref_stable_for_result(precedence, ty),
1388+
ty::Projection(_) if ty.has_non_region_param() => TyPosition::new_deref_stable_for_result(precedence, ty),
13881389
ty::Infer(_) | ty::Error(_) | ty::Bound(..) | ty::Opaque(..) | ty::Placeholder(_) | ty::Dynamic(..) => {
13891390
Position::ReborrowStable(precedence).into()
13901391
},

tests/ui/explicit_auto_deref.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,15 @@ fn main() {
266266
}
267267
x
268268
};
269+
270+
trait WithAssoc {
271+
type Assoc: ?Sized;
272+
}
273+
impl WithAssoc for String {
274+
type Assoc = str;
275+
}
276+
fn takes_assoc<T: WithAssoc>(_: &T::Assoc) -> T {
277+
unimplemented!()
278+
}
279+
let _: String = takes_assoc(&*String::new());
269280
}

tests/ui/explicit_auto_deref.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,15 @@ fn main() {
266266
}
267267
*x
268268
};
269+
270+
trait WithAssoc {
271+
type Assoc: ?Sized;
272+
}
273+
impl WithAssoc for String {
274+
type Assoc = str;
275+
}
276+
fn takes_assoc<T: WithAssoc>(_: &T::Assoc) -> T {
277+
unimplemented!()
278+
}
279+
let _: String = takes_assoc(&*String::new());
269280
}

0 commit comments

Comments
 (0)