提交 a8f3d6da 编写于 作者: N Niko Matsakis

convert user-provided signatures into def-id

上级 167b4609
......@@ -51,7 +51,7 @@
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 @@ pub fn user_provided_tys_mut(&mut self) -> LocalTableInContextMut<'_, CanonicalT
}
}
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,
......
......@@ -392,27 +392,21 @@ fn visit_user_provided_tys(&mut self) {
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());
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册