Skip to content

Commit a8f3d6d

Browse files
committed
convert user-provided signatures into def-id
1 parent 167b460 commit a8f3d6d

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

src/librustc/ty/context.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use ty::steal::Steal;
5151
use ty::BindingMode;
5252
use ty::CanonicalTy;
5353
use ty::CanonicalPolyFnSig;
54-
use util::nodemap::{DefIdSet, ItemLocalMap};
54+
use util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap};
5555
use util::nodemap::{FxHashMap, FxHashSet};
5656
use smallvec::SmallVec;
5757
use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
@@ -362,7 +362,7 @@ pub struct TypeckTables<'tcx> {
362362

363363
/// Stores the canonicalized types provided by the user. See also
364364
/// `AscribeUserType` statement in MIR.
365-
user_provided_sigs: ItemLocalMap<CanonicalPolyFnSig<'tcx>>,
365+
pub user_provided_sigs: DefIdMap<CanonicalPolyFnSig<'tcx>>,
366366

367367
/// Stores the substitutions that the user explicitly gave (if any)
368368
/// attached to `id`. These will not include any inferred
@@ -519,20 +519,6 @@ impl<'tcx> TypeckTables<'tcx> {
519519
}
520520
}
521521

522-
pub fn user_provided_sigs(&self) -> LocalTableInContext<'_, CanonicalPolyFnSig<'tcx>> {
523-
LocalTableInContext {
524-
local_id_root: self.local_id_root,
525-
data: &self.user_provided_sigs
526-
}
527-
}
528-
529-
pub fn user_provided_sigs_mut(&mut self) -> LocalTableInContextMut<'_, CanonicalPolyFnSig<'tcx>> {
530-
LocalTableInContextMut {
531-
local_id_root: self.local_id_root,
532-
data: &mut self.user_provided_sigs
533-
}
534-
}
535-
536522
pub fn node_types(&self) -> LocalTableInContext<'_, Ty<'tcx>> {
537523
LocalTableInContext {
538524
local_id_root: self.local_id_root,

src/librustc_typeck/check/writeback.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,27 +392,21 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
392392
fn visit_user_provided_sigs(&mut self) {
393393
let fcx_tables = self.fcx.tables.borrow();
394394
debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root);
395-
let common_local_id_root = fcx_tables.local_id_root.unwrap();
396-
397-
for (&local_id, c_sig) in fcx_tables.user_provided_sigs().iter() {
398-
let hir_id = hir::HirId {
399-
owner: common_local_id_root.index,
400-
local_id,
401-
};
402395

396+
for (&def_id, c_sig) in fcx_tables.user_provided_sigs.iter() {
403397
let c_sig = if let Some(c_sig) = self.tcx().lift_to_global(c_sig) {
404398
c_sig
405399
} else {
406400
span_bug!(
407-
hir_id.to_span(&self.fcx.tcx),
401+
self.fcx.tcx.hir.span_if_local(def_id).unwrap(),
408402
"writeback: `{:?}` missing from the global type context",
409403
c_sig
410404
);
411405
};
412406

413407
self.tables
414-
.user_provided_sigs_mut()
415-
.insert(hir_id, c_sig.clone());
408+
.user_provided_sigs
409+
.insert(def_id, c_sig.clone());
416410
}
417411
}
418412

0 commit comments

Comments
 (0)