Fix span when linting explicit_auto_deref
immediately after needless_borrow
This commit is contained in:
parent
d9e6aac8bb
commit
82f2e52469
@ -609,12 +609,14 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
adjusted_ty,
|
||||
},
|
||||
));
|
||||
} else if stability.is_deref_stable() {
|
||||
} else if stability.is_deref_stable()
|
||||
&& let Some(parent) = get_parent_expr(cx, expr)
|
||||
{
|
||||
self.state = Some((
|
||||
State::ExplicitDeref { mutability: None },
|
||||
StateData {
|
||||
span: expr.span,
|
||||
hir_id: expr.hir_id,
|
||||
span: parent.span,
|
||||
hir_id: parent.hir_id,
|
||||
adjusted_ty,
|
||||
},
|
||||
));
|
||||
|
@ -205,7 +205,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
f_str(&&ref_str); // `needless_borrow` will suggest removing both references
|
||||
f_str(&ref_str); // `needless_borrow` will suggest removing both references
|
||||
f_str(&ref_str); // `needless_borrow` will suggest removing only one reference
|
||||
|
||||
let x = &&40;
|
||||
@ -293,4 +293,10 @@ fn main() {
|
||||
fn return_dyn_assoc<'a>(x: &'a &'a u32) -> &'a <&'a u32 as WithAssoc>::Assoc {
|
||||
*x
|
||||
}
|
||||
|
||||
// Issue #11366
|
||||
let _: &mut u32 = match &mut Some(&mut 0u32) {
|
||||
Some(x) => x,
|
||||
None => panic!(),
|
||||
};
|
||||
}
|
||||
|
@ -293,4 +293,10 @@ fn to_assoc(&self) -> &Self::Assoc {
|
||||
fn return_dyn_assoc<'a>(x: &'a &'a u32) -> &'a <&'a u32 as WithAssoc>::Assoc {
|
||||
*x
|
||||
}
|
||||
|
||||
// Issue #11366
|
||||
let _: &mut u32 = match &mut Some(&mut 0u32) {
|
||||
Some(x) => &mut *x,
|
||||
None => panic!(),
|
||||
};
|
||||
}
|
||||
|
@ -193,10 +193,10 @@ LL | let _ = f_str(**ref_ref_str);
|
||||
| ^^^^^^^^^^^^^ help: try: `ref_ref_str`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:208:13
|
||||
--> $DIR/explicit_auto_deref.rs:208:12
|
||||
|
|
||||
LL | f_str(&&*ref_str); // `needless_borrow` will suggest removing both references
|
||||
| ^^^^^^^^ help: try: `ref_str`
|
||||
| ^^^^^^^^^ help: try: `ref_str`
|
||||
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:209:12
|
||||
@ -234,5 +234,11 @@ error: deref which would be done by auto-deref
|
||||
LL | *x
|
||||
| ^^ help: try: `x`
|
||||
|
||||
error: aborting due to 39 previous errors
|
||||
error: deref which would be done by auto-deref
|
||||
--> $DIR/explicit_auto_deref.rs:299:20
|
||||
|
|
||||
LL | Some(x) => &mut *x,
|
||||
| ^^^^^^^ help: try: `x`
|
||||
|
||||
error: aborting due to 40 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user