Skip to content

Commit 42872bb

Browse files
committed
Continue addressing review comments
1 parent c624684 commit 42872bb

File tree

13 files changed

+29
-21
lines changed

13 files changed

+29
-21
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ for ::mir::interpret::ConstValue<'gcx> {
379379
hcx: &mut StableHashingContext<'a>,
380380
hasher: &mut StableHasher<W>) {
381381
use mir::interpret::ConstValue::*;
382-
use mir::interpret::InferConst::*;
383382

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

@@ -403,6 +402,8 @@ for ::mir::interpret::ConstValue<'gcx> {
403402
param.hash_stable(hcx, hasher);
404403
}
405404
Infer(infer) => {
405+
use ty::InferConst::*;
406+
406407
match infer {
407408
Var(vid) => vid.hash_stable(hcx, hasher),
408409
Fresh(i) => i.hash_stable(hcx, hasher),

src/librustc/infer/canonical/query_result.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ use traits::{FulfillmentContext, TraitEngine};
3636
use traits::{Obligation, ObligationCause, PredicateObligation};
3737
use ty::fold::TypeFoldable;
3838
use ty::subst::{Kind, UnpackedKind};
39-
use ty::{self, CanonicalVar, Lift, TyCtxt};
39+
use ty::{self, CanonicalVar, Lift, TyCtxt, InferConst};
40+
use mir::interpret::ConstValue;
4041

4142
impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> {
4243
/// The "main method" for a canonicalized trait query. Given the
@@ -434,7 +435,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
434435
}
435436
}
436437
UnpackedKind::Const(_) => {
437-
if let &ty::ConstValue(ty::InferConst::Canonical(index)) = result_value {
438+
if let &ConstValue(InferConst::Canonical(index)) = result_value {
438439
opt_values[index] = Some(*original_value);
439440
}
440441
}

src/librustc/infer/combine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ use super::type_variable::TypeVariableValue;
4141

4242
use hir::def_id::DefId;
4343
use ty::{IntType, UintType};
44-
use ty::{self, Ty, TyCtxt, Const};
44+
use ty::{self, Ty, TyCtxt, Const, InferConst};
4545
use ty::error::{TypeError, ConstError};
4646
use ty::relate::{self, Relate, RelateResult, TypeRelation};
47-
use mir::interpret::{ConstValue, InferConst};
47+
use mir::interpret::ConstValue;
4848
use ty::subst::Substs;
4949
use traits::{Obligation, PredicateObligations};
5050

src/librustc/infer/equate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use super::{Subtype};
1313

1414
use hir::def_id::DefId;
1515

16-
use ty::{self, Ty, TyCtxt};
16+
use ty::{self, Ty, TyCtxt, InferConst};
1717
use ty::TyVar;
1818
use ty::subst::Substs;
1919
use ty::relate::{self, Relate, RelateResult, TypeRelation};
20-
use mir::interpret::{ConstValue, InferConst};
20+
use mir::interpret::ConstValue;
2121

2222
/// Ensures `a` is made equal to `b`. Returns `a` on success.
2323
pub struct Equate<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> {

src/librustc/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use self::region_constraints::{RegionConstraintCollector, RegionSnapshot};
4545
use self::region_constraints::{GenericKind, VerifyBound, RegionConstraintData, VarInfos};
4646
use self::lexical_region_resolve::LexicalRegionResolutions;
4747
use self::outlives::env::OutlivesEnvironment;
48-
use self::type_variable::TypeVariableOrigin;
48+
use self::type_variable::{TypeVariableOrigin, ConstVariableOrigin};
4949
use self::unify_key::ToType;
5050

5151
pub mod anon_types;

src/librustc/infer/sub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use super::SubregionOrigin;
1212
use super::combine::{CombineFields, RelationDir, const_unification_error};
1313

1414
use traits::Obligation;
15-
use ty::{self, Ty, TyCtxt};
15+
use ty::{self, Ty, TyCtxt, InferConst};
1616
use ty::TyVar;
1717
use ty::fold::TypeFoldable;
1818
use ty::relate::{Cause, Relate, RelateResult, TypeRelation};
19-
use mir::interpret::{ConstValue, InferConst};
19+
use mir::interpret::ConstValue;
2020
use std::mem;
2121

2222
/// Ensures `a` is made a subtype of `b`. Returns `a` on success.

src/librustc/infer/type_variable.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ pub enum TypeVariableOrigin {
6868
Generalized(ty::TyVid),
6969
}
7070

71+
/// Reasons to create a type inference variable
72+
// TODO(const_generics): move this somewhere more sensible
73+
#[derive(Copy, Clone, Debug)]
74+
pub enum ConstVariableOrigin {
75+
ConstInference(Span),
76+
ConstParameterDefinition(Span, InternedString),
77+
}
78+
7179
pub type TypeVariableMap = FxHashMap<ty::TyVid, TypeVariableOrigin>;
7280

7381
struct TypeVariableData {
@@ -462,4 +470,3 @@ impl ut::UnifyKey for ty::TyVid {
462470
fn from_index(i: u32) -> ty::TyVid { ty::TyVid { index: i } }
463471
fn tag() -> &'static str { "TyVid" }
464472
}
465-

src/librustc/mir/interpret/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub use self::error::{
1313
FrameInfo, ConstEvalResult,
1414
};
1515

16-
pub use self::value::{Scalar, ConstValue, ScalarMaybeUndef, InferConst};
16+
pub use self::value::{Scalar, ConstValue, ScalarMaybeUndef};
1717

1818
use std::fmt;
1919
use mir;

src/librustc/mir/interpret/value.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use ty::layout::{HasDataLayout, Size};
44
use ty::subst::Substs;
55
use hir::def_id::DefId;
6-
use ty::CanonicalVar;
76

87
use super::{EvalResult, Pointer, PointerArithmetic, Allocation};
98

@@ -18,7 +17,7 @@ pub enum ConstValue<'tcx> {
1817
/// A const generic parameter.
1918
Param(ty::ParamConst),
2019
/// Infer the value of the const.
21-
Infer(InferConst),
20+
Infer(ty::InferConst),
2221
/// Used only for types with layout::abi::Scalar ABI and ZSTs
2322
///
2423
/// Not using the enum `Value` to encode that this must not be `Undef`

src/librustc/ty/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use ty::{self, Ty, TyCtxt};
11+
use ty::{self, Ty, TyCtxt, InferConst};
1212
use ty::error::{TypeError, ConstError};
1313
use ty::relate::{self, Relate, TypeRelation, RelateResult};
14-
use mir::interpret::{ConstValue, InferConst};
14+
use mir::interpret::ConstValue;
1515

1616
/// A type "A" *matches* "B" if the fresh types in B could be
1717
/// substituted with values so as to make it equal to A. Matching is

0 commit comments

Comments
 (0)