mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-14 15:22:41 +00:00
Remove redundant expect_local()
call
This commit is contained in:
parent
fd62c180fe
commit
d5713898ac
4 changed files with 7 additions and 11 deletions
|
@ -579,9 +579,8 @@ fn is_mutable_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, tys: &mut FxHashSet<
|
||||||
if let hir::PatKind::Wild = pat.kind {
|
if let hir::PatKind::Wild = pat.kind {
|
||||||
return false; // ignore `_` patterns
|
return false; // ignore `_` patterns
|
||||||
}
|
}
|
||||||
let def_id = pat.hir_id.owner.to_def_id();
|
if cx.tcx.has_typeck_results(pat.hir_id.owner.to_def_id()) {
|
||||||
if cx.tcx.has_typeck_results(def_id) {
|
is_mutable_ty(cx, &cx.tcx.typeck(pat.hir_id.owner).pat_ty(pat), pat.span, tys)
|
||||||
is_mutable_ty(cx, &cx.tcx.typeck(def_id.expect_local()).pat_ty(pat), pat.span, tys)
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -694,11 +693,10 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for StaticMutVisitor<'a, 'tcx> {
|
||||||
Call(_, args) | MethodCall(_, _, args, _) => {
|
Call(_, args) | MethodCall(_, _, args, _) => {
|
||||||
let mut tys = FxHashSet::default();
|
let mut tys = FxHashSet::default();
|
||||||
for arg in args {
|
for arg in args {
|
||||||
let def_id = arg.hir_id.owner.to_def_id();
|
if self.cx.tcx.has_typeck_results(arg.hir_id.owner.to_def_id())
|
||||||
if self.cx.tcx.has_typeck_results(def_id)
|
|
||||||
&& is_mutable_ty(
|
&& is_mutable_ty(
|
||||||
self.cx,
|
self.cx,
|
||||||
self.cx.tcx.typeck(def_id.expect_local()).expr_ty(arg),
|
self.cx.tcx.typeck(arg.hir_id.owner).expr_ty(arg),
|
||||||
arg.span,
|
arg.span,
|
||||||
&mut tys,
|
&mut tys,
|
||||||
)
|
)
|
||||||
|
|
|
@ -2051,12 +2051,11 @@ fn check_for_mutation<'tcx>(
|
||||||
span_low: None,
|
span_low: None,
|
||||||
span_high: None,
|
span_high: None,
|
||||||
};
|
};
|
||||||
let def_id = body.hir_id.owner.to_def_id();
|
|
||||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||||
ExprUseVisitor::new(
|
ExprUseVisitor::new(
|
||||||
&mut delegate,
|
&mut delegate,
|
||||||
&infcx,
|
&infcx,
|
||||||
def_id.expect_local(),
|
body.hir_id.owner,
|
||||||
cx.param_env,
|
cx.param_env,
|
||||||
cx.typeck_results(),
|
cx.typeck_results(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -299,7 +299,7 @@ pub fn qpath_res(cx: &LateContext<'_>, qpath: &hir::QPath<'_>, id: hir::HirId) -
|
||||||
hir::QPath::Resolved(_, path) => path.res,
|
hir::QPath::Resolved(_, path) => path.res,
|
||||||
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
|
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
|
||||||
if cx.tcx.has_typeck_results(id.owner.to_def_id()) {
|
if cx.tcx.has_typeck_results(id.owner.to_def_id()) {
|
||||||
cx.tcx.typeck(id.owner.to_def_id().expect_local()).qpath_res(qpath, id)
|
cx.tcx.typeck(id.owner).qpath_res(qpath, id)
|
||||||
} else {
|
} else {
|
||||||
Res::Err
|
Res::Err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,11 @@ pub fn mutated_variables<'tcx>(expr: &'tcx Expr<'_>, cx: &LateContext<'tcx>) ->
|
||||||
used_mutably: FxHashSet::default(),
|
used_mutably: FxHashSet::default(),
|
||||||
skip: false,
|
skip: false,
|
||||||
};
|
};
|
||||||
let def_id = expr.hir_id.owner.to_def_id();
|
|
||||||
cx.tcx.infer_ctxt().enter(|infcx| {
|
cx.tcx.infer_ctxt().enter(|infcx| {
|
||||||
ExprUseVisitor::new(
|
ExprUseVisitor::new(
|
||||||
&mut delegate,
|
&mut delegate,
|
||||||
&infcx,
|
&infcx,
|
||||||
def_id.expect_local(),
|
expr.hir_id.owner,
|
||||||
cx.param_env,
|
cx.param_env,
|
||||||
cx.typeck_results(),
|
cx.typeck_results(),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue