Skip to content

Commit

Permalink
Auto merge of rust-lang#9813 - Jarcho:issue_9811, r=xFrednet
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 9, 2022
2 parents c4fbe54 + 5b1e445 commit 432baf7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ fn ty_auto_deref_stability<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, precedenc
continue;
},
ty::Param(_) => TyPosition::new_deref_stable_for_result(precedence, ty),
ty::Projection(_) if ty.has_non_region_param() => TyPosition::new_deref_stable_for_result(precedence, ty),
ty::Infer(_) | ty::Error(_) | ty::Bound(..) | ty::Opaque(..) | ty::Placeholder(_) | ty::Dynamic(..) => {
Position::ReborrowStable(precedence).into()
},
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/explicit_auto_deref.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,15 @@ fn main() {
}
x
};

trait WithAssoc {
type Assoc: ?Sized;
}
impl WithAssoc for String {
type Assoc = str;
}
fn takes_assoc<T: WithAssoc>(_: &T::Assoc) -> T {
unimplemented!()
}
let _: String = takes_assoc(&*String::new());
}
11 changes: 11 additions & 0 deletions tests/ui/explicit_auto_deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,15 @@ fn main() {
}
*x
};

trait WithAssoc {
type Assoc: ?Sized;
}
impl WithAssoc for String {
type Assoc = str;
}
fn takes_assoc<T: WithAssoc>(_: &T::Assoc) -> T {
unimplemented!()
}
let _: String = takes_assoc(&*String::new());
}

0 comments on commit 432baf7

Please sign in to comment.