Use ItemLocalId as key for TypeckTables::cast_kinds.
This commit is contained in:
parent
801dd07a95
commit
fbc7398bad
5 changed files with 16 additions and 7 deletions
|
|
@ -658,7 +658,7 @@ for ty::TypeckTables<'gcx> {
|
|||
ich::hash_stable_itemlocalmap(hcx, hasher, closure_kinds);
|
||||
ich::hash_stable_itemlocalmap(hcx, hasher, liberated_fn_sigs);
|
||||
ich::hash_stable_itemlocalmap(hcx, hasher, fru_field_types);
|
||||
ich::hash_stable_nodemap(hcx, hasher, cast_kinds);
|
||||
ich::hash_stable_itemlocalmap(hcx, hasher, cast_kinds);
|
||||
|
||||
ich::hash_stable_hashset(hcx, hasher, used_trait_imports, |hcx, def_id| {
|
||||
hcx.def_path_hash(*def_id)
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ pub struct TypeckTables<'tcx> {
|
|||
|
||||
/// Maps a cast expression to its kind. This is keyed on the
|
||||
/// *from* expression of the cast, not the cast itself.
|
||||
pub cast_kinds: NodeMap<ty::cast::CastKind>,
|
||||
pub cast_kinds: ItemLocalMap<ty::cast::CastKind>,
|
||||
|
||||
/// Set of trait imports actually used in the method resolution.
|
||||
/// This is used for warning unused imports.
|
||||
|
|
@ -287,7 +287,8 @@ impl<'tcx> TypeckTables<'tcx> {
|
|||
closure_kinds: ItemLocalMap(),
|
||||
liberated_fn_sigs: ItemLocalMap(),
|
||||
fru_field_types: ItemLocalMap(),
|
||||
cast_kinds: NodeMap(),
|
||||
cast_kinds: ItemLocalMap(),
|
||||
lints: lint::LintTable::new(),
|
||||
used_trait_imports: DefIdSet(),
|
||||
tainted_by_errors: false,
|
||||
free_region_map: FreeRegionMap::new(),
|
||||
|
|
|
|||
|
|
@ -551,7 +551,10 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
|||
hir::ExprCast(ref source, _) => {
|
||||
// Check to see if this cast is a "coercion cast", where the cast is actually done
|
||||
// using a coercion (or is a no-op).
|
||||
if let Some(&TyCastKind::CoercionCast) = cx.tables().cast_kinds.get(&source.id) {
|
||||
cx.tables().validate_hir_id(source.hir_id);
|
||||
if let Some(&TyCastKind::CoercionCast) = cx.tables()
|
||||
.cast_kinds
|
||||
.get(&source.hir_id.local_id) {
|
||||
// Convert the lexpr to a vexpr.
|
||||
ExprKind::Use { source: source.to_ref() }
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -320,7 +320,8 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
|
|||
}
|
||||
hir::ExprCast(ref from, _) => {
|
||||
debug!("Checking const cast(id={})", from.id);
|
||||
match v.tables.cast_kinds.get(&from.id) {
|
||||
v.tables.validate_hir_id(from.hir_id);
|
||||
match v.tables.cast_kinds.get(&from.hir_id.local_id) {
|
||||
None => span_bug!(e.span, "no kind for cast"),
|
||||
Some(&CastKind::PtrAddrCast) | Some(&CastKind::FnPtrAddrCast) => {
|
||||
v.promotable = false;
|
||||
|
|
|
|||
|
|
@ -330,12 +330,16 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
|||
} else if self.try_coercion_cast(fcx) {
|
||||
self.trivial_cast_lint(fcx);
|
||||
debug!(" -> CoercionCast");
|
||||
fcx.tables.borrow_mut().cast_kinds.insert(self.expr.id, CastKind::CoercionCast);
|
||||
let mut tables = fcx.tables.borrow_mut();
|
||||
tables.validate_hir_id(self.expr.hir_id);
|
||||
tables.cast_kinds.insert(self.expr.hir_id.local_id, CastKind::CoercionCast);
|
||||
} else {
|
||||
match self.do_check(fcx) {
|
||||
Ok(k) => {
|
||||
debug!(" -> {:?}", k);
|
||||
fcx.tables.borrow_mut().cast_kinds.insert(self.expr.id, k);
|
||||
let mut tables = fcx.tables.borrow_mut();
|
||||
tables.validate_hir_id(self.expr.hir_id);
|
||||
tables.cast_kinds.insert(self.expr.hir_id.local_id, k);
|
||||
}
|
||||
Err(e) => self.report_cast_error(fcx, e),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue