Skip to content

Commit 57aceee

Browse files
Rollup merge of #51636 - oli-obk:const_diagnostics, r=eddyb
Refactor error reporting of constants cc @eddyb This PR should not change any behaviour. It solely simplifies the internal handling of the errors
2 parents e3bf634 + 2a55d2f commit 57aceee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+483
-784
lines changed

src/librustc/dep_graph/dep_node.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
//! user of the `DepNode` API of having to know how to compute the expected
6161
//! fingerprint for a given set of node parameters.
6262
63-
use mir::interpret::{GlobalId, ConstValue};
63+
use mir::interpret::GlobalId;
6464
use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX};
6565
use hir::map::DefPathHash;
6666
use hir::{HirId, ItemLocalId};
@@ -75,7 +75,7 @@ use traits::query::{
7575
CanonicalPredicateGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal,
7676
};
7777
use ty::{TyCtxt, FnSig, Instance, InstanceDef,
78-
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty};
78+
ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty, self};
7979
use ty::subst::Substs;
8080

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

637637
[input] Freevars(DefId),
638638
[input] MaybeUnusedTraitImport(DefId),

src/librustc/ich/impls_ty.rs

+8-45
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,11 @@ impl_stable_hash_for!(struct ty::FieldDef {
364364
});
365365

366366
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
367-
for ::middle::const_val::ConstVal<'gcx> {
367+
for ::mir::interpret::ConstValue<'gcx> {
368368
fn hash_stable<W: StableHasherResult>(&self,
369369
hcx: &mut StableHashingContext<'a>,
370370
hasher: &mut StableHasher<W>) {
371-
use middle::const_val::ConstVal::*;
371+
use mir::interpret::ConstValue::*;
372372

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

@@ -377,23 +377,6 @@ for ::middle::const_val::ConstVal<'gcx> {
377377
def_id.hash_stable(hcx, hasher);
378378
substs.hash_stable(hcx, hasher);
379379
}
380-
Value(ref value) => {
381-
value.hash_stable(hcx, hasher);
382-
}
383-
}
384-
}
385-
}
386-
387-
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
388-
for ::mir::interpret::ConstValue<'gcx> {
389-
fn hash_stable<W: StableHasherResult>(&self,
390-
hcx: &mut StableHashingContext<'a>,
391-
hasher: &mut StableHasher<W>) {
392-
use mir::interpret::ConstValue::*;
393-
394-
mem::discriminant(self).hash_stable(hcx, hasher);
395-
396-
match *self {
397380
Scalar(val) => {
398381
val.hash_stable(hcx, hasher);
399382
}
@@ -497,40 +480,18 @@ impl_stable_hash_for!(struct ty::Const<'tcx> {
497480
val
498481
});
499482

500-
impl_stable_hash_for!(struct ::middle::const_val::ConstEvalErr<'tcx> {
483+
impl_stable_hash_for!(struct ::mir::interpret::ConstEvalErr<'tcx> {
501484
span,
502-
kind
485+
stacktrace,
486+
error
503487
});
504488

505-
impl_stable_hash_for!(struct ::middle::const_val::FrameInfo {
489+
impl_stable_hash_for!(struct ::mir::interpret::FrameInfo {
506490
span,
507491
lint_root,
508492
location
509493
});
510494

511-
impl<'a, 'gcx> HashStable<StableHashingContext<'a>>
512-
for ::middle::const_val::ErrKind<'gcx> {
513-
fn hash_stable<W: StableHasherResult>(&self,
514-
hcx: &mut StableHashingContext<'a>,
515-
hasher: &mut StableHasher<W>) {
516-
use middle::const_val::ErrKind::*;
517-
518-
mem::discriminant(self).hash_stable(hcx, hasher);
519-
520-
match *self {
521-
TypeckError |
522-
CouldNotResolve |
523-
CheckMatchError => {
524-
// nothing to do
525-
}
526-
Miri(ref err, ref trace) => {
527-
err.hash_stable(hcx, hasher);
528-
trace.hash_stable(hcx, hasher);
529-
},
530-
}
531-
}
532-
}
533-
534495
impl_stable_hash_for!(struct ty::ClosureSubsts<'tcx> { substs });
535496
impl_stable_hash_for!(struct ty::GeneratorSubsts<'tcx> { substs });
536497

@@ -579,6 +540,8 @@ for ::mir::interpret::EvalErrorKind<'gcx, O> {
579540
ReadFromReturnPointer |
580541
UnimplementedTraitSelection |
581542
TypeckError |
543+
TooGeneric |
544+
CheckMatchError |
582545
DerefFunctionPointer |
583546
ExecuteMemory |
584547
OverflowNeg |

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ pub mod middle {
132132
pub mod allocator;
133133
pub mod borrowck;
134134
pub mod expr_use_visitor;
135-
pub mod const_val;
136135
pub mod cstore;
137136
pub mod dataflow;
138137
pub mod dead;

src/librustc/middle/const_val.rs

-178
This file was deleted.

0 commit comments

Comments
 (0)