1
Fork 0

Fix incorrect use mut diagnostics

This commit is contained in:
Aman Arora 2020-12-13 00:11:15 -05:00
parent 604cbdcfdd
commit c748f32ee4
14 changed files with 129 additions and 72 deletions

View file

@ -674,6 +674,15 @@ pub struct CapturedPlace<'tcx> {
pub mutability: hir::Mutability,
}
impl CapturedPlace<'tcx> {
pub fn get_root_variable(&self) -> hir::HirId {
match self.place.base {
HirPlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id,
base => bug!("Expected upvar, found={:?}", base),
}
}
}
pub fn place_to_string_for_capture(tcx: TyCtxt<'tcx>, place: &HirPlace<'tcx>) -> String {
let name = match place.base {
HirPlaceBase::Upvar(upvar_id) => tcx.hir().name(upvar_id.var_path.hir_id).to_string(),