This commit is contained in:
Yuki Okushi
2019-12-27 16:12:26 +09:00
parent b0c4744d57
commit e2636729ec
109 changed files with 735 additions and 655 deletions

View File

@@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_typeck::expr_use_visitor::*;
/// Returns a set of mutated local variable IDs, or `None` if mutations could not be determined.
pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<HirId>> {
pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr<'_>, cx: &'a LateContext<'a, 'tcx>) -> Option<FxHashSet<HirId>> {
let mut delegate = MutVarsDelegate {
used_mutably: FxHashSet::default(),
skip: false,
@@ -22,7 +22,11 @@ pub fn mutated_variables<'a, 'tcx>(expr: &'tcx Expr, cx: &'a LateContext<'a, 'tc
Some(delegate.used_mutably)
}
pub fn is_potentially_mutated<'a, 'tcx>(variable: &'tcx Path, expr: &'tcx Expr, cx: &'a LateContext<'a, 'tcx>) -> bool {
pub fn is_potentially_mutated<'a, 'tcx>(
variable: &'tcx Path,
expr: &'tcx Expr<'_>,
cx: &'a LateContext<'a, 'tcx>,
) -> bool {
if let Res::Local(id) = variable.res {
mutated_variables(expr, cx).map_or(true, |mutated| mutated.contains(&id))
} else {