visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor as _},
Mutability,
};
-use rustc_middle::ty::{self, fold::TypeVisitor, Ty};
-use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
+use rustc_middle::ty::{self, fold::TypeVisitor, Ty, TyCtxt};
+use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::{BytePos, Span};
use rustc_span::sym;
let from_borrow = match_def_path(cx, fn_def_id, &paths::CLONE_TRAIT_METHOD)
|| match_def_path(cx, fn_def_id, &paths::TO_OWNED_METHOD)
|| (match_def_path(cx, fn_def_id, &paths::TO_STRING_METHOD)
- && is_type_diagnostic_item(cx, arg_ty, sym::string_type));
+ && is_type_diagnostic_item(cx, arg_ty, sym::String));
let from_deref = !from_borrow
&& (match_def_path(cx, fn_def_id, &paths::PATH_TO_PATH_BUF)
self.possible_borrower.add(borrowed.local, lhs);
},
other => {
- if ContainsRegion
+ if ContainsRegion(self.cx.tcx)
.visit_ty(place.ty(&self.body.local_decls, self.cx.tcx).ty)
.is_continue()
{
.flat_map(HybridBitSet::iter)
.collect();
- if ContainsRegion.visit_ty(self.body.local_decls[*dest].ty).is_break() {
+ if ContainsRegion(self.cx.tcx)
+ .visit_ty(self.body.local_decls[*dest].ty)
+ .is_break()
+ {
mutable_variables.push(*dest);
}
}
}
-struct ContainsRegion;
+struct ContainsRegion<'tcx>(TyCtxt<'tcx>);
-impl TypeVisitor<'_> for ContainsRegion {
+impl<'tcx> TypeVisitor<'tcx> for ContainsRegion<'tcx> {
type BreakTy = ();
+ fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
+ Some(self.0)
+ }
- fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
+ fn visit_region(&mut self, _: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
ControlFlow::BREAK
}
}
BinaryOp(_, box (lhs, rhs)) | CheckedBinaryOp(_, box (lhs, rhs)) => {
visit_op(lhs);
visit_op(rhs);
- }
+ },
_ => (),
}
}