Skip to content

Refactor error reporting of constants #51636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 29, 2018
6 changes: 3 additions & 3 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
//! user of the `DepNode` API of having to know how to compute the expected
//! fingerprint for a given set of node parameters.

use mir::interpret::{GlobalId, ConstValue};
use mir::interpret::GlobalId;
use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX};
use hir::map::DefPathHash;
use hir::{HirId, ItemLocalId};
Expand All @@ -75,7 +75,7 @@ use traits::query::{
CanonicalPredicateGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal,
};
use ty::{TyCtxt, FnSig, Instance, InstanceDef,
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty};
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty, self};
use ty::subst::Substs;

// erase!() just makes tokens go away. It's used to specify which macro argument
Expand Down Expand Up @@ -632,7 +632,7 @@ define_dep_nodes!( <'tcx>
// queries). Making them anonymous avoids hashing the result, which
// may save a bit of time.
[anon] EraseRegionsTy { ty: Ty<'tcx> },
[anon] ConstValueToAllocation { val: ConstValue<'tcx>, ty: Ty<'tcx> },
[anon] ConstValueToAllocation { val: &'tcx ty::Const<'tcx> },

[input] Freevars(DefId),
[input] MaybeUnusedTraitImport(DefId),
Expand Down
53 changes: 8 additions & 45 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,11 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::FieldDef {
}

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ::middle::const_val::ConstVal<'gcx> {
for ::mir::interpret::ConstValue<'gcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
use middle::const_val::ConstVal::*;
use mir::interpret::ConstValue::*;

mem::discriminant(self).hash_stable(hcx, hasher);

Expand All @@ -383,23 +383,6 @@ for ::middle::const_val::ConstVal<'gcx> {
def_id.hash_stable(hcx, hasher);
substs.hash_stable(hcx, hasher);
}
Value(ref value) => {
value.hash_stable(hcx, hasher);
}
}
}
}

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ::mir::interpret::ConstValue<'gcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
use mir::interpret::ConstValue::*;

mem::discriminant(self).hash_stable(hcx, hasher);

match *self {
Scalar(val) => {
val.hash_stable(hcx, hasher);
}
Expand Down Expand Up @@ -503,40 +486,18 @@ impl_stable_hash_for!(struct ty::Const<'tcx> {
val
});

impl_stable_hash_for!(struct ::middle::const_val::ConstEvalErr<'tcx> {
impl_stable_hash_for!(struct ::mir::interpret::ConstEvalErr<'tcx> {
span,
kind
stacktrace,
error
});

impl_stable_hash_for!(struct ::middle::const_val::FrameInfo {
impl_stable_hash_for!(struct ::mir::interpret::FrameInfo {
span,
lint_root,
location
});

impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
for ::middle::const_val::ErrKind<'gcx> {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
use middle::const_val::ErrKind::*;

mem::discriminant(self).hash_stable(hcx, hasher);

match *self {
TypeckError |
CouldNotResolve |
CheckMatchError => {
// nothing to do
}
Miri(ref err, ref trace) => {
err.hash_stable(hcx, hasher);
trace.hash_stable(hcx, hasher);
},
}
}
}

impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
impl_stable_hash_for!(struct ty::GeneratorSubsts<'tcx> { substs });

Expand Down Expand Up @@ -593,6 +554,8 @@ for ::mir::interpret::EvalErrorKind<'gcx, O> {
ReadFromReturnPointer |
UnimplementedTraitSelection |
TypeckError |
TooGeneric |
CheckMatchError |
DerefFunctionPointer |
ExecuteMemory |
OverflowNeg |
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ pub mod middle {
pub mod allocator;
pub mod borrowck;
pub mod expr_use_visitor;
pub mod const_val;
pub mod cstore;
pub mod dataflow;
pub mod dead;
Expand Down
178 changes: 0 additions & 178 deletions src/librustc/middle/const_val.rs

This file was deleted.

Loading