diff options
| author | bors <bors@rust-lang.org> | 2019-06-14 06:46:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-06-14 06:46:01 +0000 |
| commit | 42503d57907ca13e062ee614b1753ab818c7b016 (patch) | |
| tree | 59d6fba52e518a7e3e337a506c78d1c6bad1e80a | |
| parent | bcc568f27b8064354238972dc41d59428b0e3abc (diff) | |
| parent | a17e9182844004179958983c7dc6514035ad015f (diff) | |
| download | rust-42503d57907ca13e062ee614b1753ab818c7b016.tar.gz rust-42503d57907ca13e062ee614b1753ab818c7b016.zip | |
Auto merge of #61803 - Centril:write_resolution, r=petrochenkov
typeck: small refactoring, add 'fn write_resolution'
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d62536ccb46..966ed58a412 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2208,15 +2208,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.tables.borrow_mut().field_indices_mut().insert(hir_id, index); } + fn write_resolution(&self, hir_id: hir::HirId, r: Result<(DefKind, DefId), ErrorReported>) { + self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, r); + } + pub fn write_method_call(&self, hir_id: hir::HirId, method: MethodCallee<'tcx>) { debug!("write_method_call(hir_id={:?}, method={:?})", hir_id, method); - self.tables - .borrow_mut() - .type_dependent_defs_mut() - .insert(hir_id, Ok((DefKind::Method, method.def_id))); - + self.write_resolution(hir_id, Ok((DefKind::Method, method.def_id))); self.write_substs(hir_id, method.substs); // When the method is confirmed, the `method.substs` includes @@ -4724,7 +4724,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let result = result.map(|(_, kind, def_id)| (kind, def_id)); // Write back the new resolution. - self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, result); + self.write_resolution(hir_id, result); (result.map(|(kind, def_id)| Res::Def(kind, def_id)).unwrap_or(Res::Err), ty) } @@ -4777,7 +4777,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }); // Write back the new resolution. - self.tables.borrow_mut().type_dependent_defs_mut().insert(hir_id, result); + self.write_resolution(hir_id, result); ( result.map(|(kind, def_id)| Res::Def(kind, def_id)).unwrap_or(Res::Err), Some(ty), |
