mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Don't lint exlipicit_auto_deref
when other adjustments are needed
This commit is contained in:
parent
84e03b6215
commit
d602ab1445
3 changed files with 31 additions and 1 deletions
|
@ -357,7 +357,11 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing {
|
||||||
}),
|
}),
|
||||||
StateData { span: expr.span, hir_id: expr.hir_id, position },
|
StateData { span: expr.span, hir_id: expr.hir_id, position },
|
||||||
));
|
));
|
||||||
} else if position.is_deref_stable() {
|
} else if position.is_deref_stable()
|
||||||
|
// Auto-deref doesn't combine with other adjustments
|
||||||
|
&& next_adjust.map_or(true, |a| matches!(a.kind, Adjust::Deref(_) | Adjust::Borrow(_)))
|
||||||
|
&& iter.all(|a| matches!(a.kind, Adjust::Deref(_) | Adjust::Borrow(_)))
|
||||||
|
{
|
||||||
self.state = Some((
|
self.state = Some((
|
||||||
State::Borrow { mutability },
|
State::Borrow { mutability },
|
||||||
StateData {
|
StateData {
|
||||||
|
|
|
@ -242,4 +242,17 @@ fn main() {
|
||||||
fn ret_any(x: &Box<dyn std::any::Any>) -> &dyn std::any::Any {
|
fn ret_any(x: &Box<dyn std::any::Any>) -> &dyn std::any::Any {
|
||||||
&**x
|
&**x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let x = String::new();
|
||||||
|
let _: *const str = &*x;
|
||||||
|
|
||||||
|
struct S7([u32; 1]);
|
||||||
|
impl core::ops::Deref for S7 {
|
||||||
|
type Target = [u32; 1];
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let x = S7([0]);
|
||||||
|
let _: &[u32] = &*x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,4 +242,17 @@ fn main() {
|
||||||
fn ret_any(x: &Box<dyn std::any::Any>) -> &dyn std::any::Any {
|
fn ret_any(x: &Box<dyn std::any::Any>) -> &dyn std::any::Any {
|
||||||
&**x
|
&**x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let x = String::new();
|
||||||
|
let _: *const str = &*x;
|
||||||
|
|
||||||
|
struct S7([u32; 1]);
|
||||||
|
impl core::ops::Deref for S7 {
|
||||||
|
type Target = [u32; 1];
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let x = S7([0]);
|
||||||
|
let _: &[u32] = &*x;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue