fix: `let-and-return` suggests invalid cast (#16135)
Simple PR that handles a special case where a raw pointer was invalidly cast via as _.
First PR, would appreciate feedback.
changelog: [let_and_return]: fix lint suggestion for invalid cast to raw pointer.
r? @Jarcho
rustbot has assigned @Jarcho. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
:warning: Warning :warning:
- There are issue links (such as
#123) in the commit messages of the following commits. Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.- 8a0f8d1547967d2eb12517fa4cda2680d2dc4c68
The test you have still works with the extra cast, it's just unnecessary. The type cast is needed to work around deficiencies in type inference:
struct S;
trait T {}
impl T for S {}
fn f(x: *const S) -> *const dyn T {
Clone::clone(&x) as _
}
Reminder, once the PR becomes ready for a review, use @rustbot ready.