convert user-provided signatures into def-id

This commit is contained in:
Niko Matsakis 2018-10-19 17:19:29 -04:00
parent 167b460961
commit a8f3d6dafc
2 changed files with 6 additions and 26 deletions

View File

@ -51,7 +51,7 @@ use ty::steal::Steal;
use ty::BindingMode;
use ty::CanonicalTy;
use ty::CanonicalPolyFnSig;
use util::nodemap::{DefIdSet, ItemLocalMap};
use util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap};
use util::nodemap::{FxHashMap, FxHashSet};
use smallvec::SmallVec;
use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
@ -362,7 +362,7 @@ pub struct TypeckTables<'tcx> {
/// Stores the canonicalized types provided by the user. See also
/// `AscribeUserType` statement in MIR.
user_provided_sigs: ItemLocalMap<CanonicalPolyFnSig<'tcx>>,
pub user_provided_sigs: DefIdMap<CanonicalPolyFnSig<'tcx>>,
/// Stores the substitutions that the user explicitly gave (if any)
/// attached to `id`. These will not include any inferred
@ -519,20 +519,6 @@ impl<'tcx> TypeckTables<'tcx> {
}
}
pub fn user_provided_sigs(&self) -> LocalTableInContext<'_, CanonicalPolyFnSig<'tcx>> {
LocalTableInContext {
local_id_root: self.local_id_root,
data: &self.user_provided_sigs
}
}
pub fn user_provided_sigs_mut(&mut self) -> LocalTableInContextMut<'_, CanonicalPolyFnSig<'tcx>> {
LocalTableInContextMut {
local_id_root: self.local_id_root,
data: &mut self.user_provided_sigs
}
}
pub fn node_types(&self) -> LocalTableInContext<'_, Ty<'tcx>> {
LocalTableInContext {
local_id_root: self.local_id_root,

View File

@ -392,27 +392,21 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
fn visit_user_provided_sigs(&mut self) {
let fcx_tables = self.fcx.tables.borrow();
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);
let common_local_id_root = fcx_tables.local_id_root.unwrap();
for (&local_id, c_sig) in fcx_tables.user_provided_sigs().iter() {
let hir_id = hir::HirId {
owner: common_local_id_root.index,
local_id,
};
for (&def_id, c_sig) in fcx_tables.user_provided_sigs.iter() {
let c_sig = if let Some(c_sig) = self.tcx().lift_to_global(c_sig) {
c_sig
} else {
span_bug!(
hir_id.to_span(&self.fcx.tcx),
self.fcx.tcx.hir.span_if_local(def_id).unwrap(),
"writeback: `{:?}` missing from the global type context",
c_sig
);
};
self.tables
.user_provided_sigs_mut()
.insert(hir_id, c_sig.clone());
.user_provided_sigs
.insert(def_id, c_sig.clone());
}
}