[unnecessary_unwrap]: lint on .as_ref().unwrap()
This commit is contained in:
parent
4932d05733
commit
42c6492ebc
4 changed files with 210 additions and 9 deletions
|
|
@ -4,7 +4,7 @@ use core::ops::ControlFlow;
|
|||
use hir::def::Res;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{self as hir, Expr, ExprKind, HirId, HirIdSet};
|
||||
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
|
||||
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, Place, PlaceBase, PlaceWithHirId};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
|
|
@ -37,6 +37,17 @@ pub fn is_potentially_mutated<'tcx>(variable: HirId, expr: &'tcx Expr<'_>, cx: &
|
|||
mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&variable))
|
||||
}
|
||||
|
||||
pub fn is_potentially_local_place(local_id: HirId, place: &Place<'_>) -> bool {
|
||||
match place.base {
|
||||
PlaceBase::Local(id) => id == local_id,
|
||||
PlaceBase::Upvar(_) => {
|
||||
// Conservatively assume yes.
|
||||
true
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
struct MutVarsDelegate {
|
||||
used_mutably: HirIdSet,
|
||||
skip: bool,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue