Skip to content

Commit c624684

Browse files
committed
Address review comments and add notes
1 parent ab0e186 commit c624684

File tree

23 files changed

+63
-249
lines changed

23 files changed

+63
-249
lines changed

src/librustc/hir/def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ pub enum Def {
6060
AssociatedExistential(DefId),
6161
PrimTy(hir::PrimTy),
6262
TyParam(DefId),
63-
ConstParam(DefId),
6463
SelfTy(Option<DefId> /* trait */, Option<DefId> /* impl */),
6564
ToolMod, // e.g. `rustfmt` in `#[rustfmt::skip]`
6665

6766
// Value namespace
6867
Fn(DefId),
6968
Const(DefId),
69+
ConstParam(DefId),
7070
Static(DefId, bool /* is_mutbl */),
7171
StructCtor(DefId, CtorKind), // DefId refers to NodeId of the struct's constructor
7272
VariantCtor(DefId, CtorKind),

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,7 @@ impl<'a> LoweringContext<'a> {
22662266
mut itctx: ImplTraitContext)
22672267
-> hir::GenericParam {
22682268
let mut bounds = self.lower_param_bounds(&param.bounds, itctx.reborrow());
2269+
// TODO(const_generics): only create `hir::GenericParam` once.
22692270
match param.kind {
22702271
GenericParamKind::Lifetime => {
22712272
let was_collecting_in_band = self.is_collecting_in_band_lifetimes;

src/librustc/hir/map/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ impl<'hir> MapEntry<'hir> {
241241
}
242242
}
243243

244-
EntryGenericParam(_, _, _) => {
245-
// TODO(const_generics): defaults
246-
None
247-
}
248-
249244
_ => None
250245
}
251246
}

src/librustc/hir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ pub enum BodyOwnerKind {
13031303
/// These are usually found nested inside types (e.g. array lengths)
13041304
/// or expressions (e.g. repeat counts), and also used to define
13051305
/// explicit discriminant values for enum variants.
1306-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
1306+
#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
13071307
pub struct AnonConst {
13081308
pub id: NodeId,
13091309
pub hir_id: HirId,

src/librustc/infer/canonical/query_result.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
434434
}
435435
}
436436
UnpackedKind::Const(_) => {
437-
unimplemented!() // TODO(const_generics)
437+
if let &ty::ConstValue(ty::InferConst::Canonical(index)) = result_value {
438+
opt_values[index] = Some(*original_value);
439+
}
438440
}
439441
}
440442
}

src/librustc/infer/combine.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
170170
fn unify_const_variable(&self,
171171
vid_is_expected: bool,
172172
vid: ty::ConstVid,
173-
val: ty::ConstVarValue)
173+
val: &'tcx ty::Const<'tcx>)
174174
-> RelateResult<'tcx, &'tcx Const<'tcx>>
175175
{
176176
self.const_unification_table
177177
.borrow_mut()
178178
.unify_var_value(vid, Some(val))
179179
.map_err(|e| const_unification_error(vid_is_expected, e))?;
180-
Ok(self.tcx.mk_mach_const(val))
180+
Ok(val)
181181
}
182182

183183
fn unify_integral_variable(&self,
@@ -574,8 +574,10 @@ impl<'tcx, T:Clone + PartialEq> RelateResultCompare<'tcx, T> for RelateResult<'t
574574
}
575575
}
576576

577-
pub fn const_unification_error<'tcx>(a_is_expected: bool, v: (ty::ConstVarValue, ty::ConstVarValue))
578-
-> TypeError<'tcx>
577+
pub fn const_unification_error<'tcx>(
578+
a_is_expected: bool,
579+
v: (&'tcx ty::Const<'tcx>, &'tcx ty::Const<'tcx>)
580+
) -> TypeError<'tcx>
579581
{
580582
let (a, b) = v;
581583
TypeError::ConstError(

src/librustc/infer/equate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
112112

113113
fn consts(&mut self, a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>)
114114
-> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
115+
// TODO(const_generics): missing handling for when only one side is an InferVar
115116
debug!("{}.consts({:?}, {:?})", self.tag(), a, b);
116117
if a == b { return Ok(a); }
117118

src/librustc/infer/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
902902
self.tcx.mk_ty_var(self.next_ty_var_id(true, origin))
903903
}
904904

905-
pub fn next_const_var(&self, ty: Ty<'tcx>) -> &'tcx ty::Const<'tcx> {
906-
// TODO(const_generics): do we need this function?
907-
self.tcx.mk_const_var(self.next_const_var_id(), ty)
905+
pub fn next_const_var(
906+
&self,
907+
ty: Ty<'tcx>,
908+
origin: ConstVariableOrigin
909+
) -> &'tcx ty::Const<'tcx> {
910+
self.tcx.mk_const_var(self.next_const_var_id(origin), ty)
908911
}
909912

910913
pub fn next_const_var_id(&self) -> ConstVid {

src/librustc/infer/region_constraints/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ pub struct Verify<'tcx> {
149149
pub bound: VerifyBound<'tcx>,
150150
}
151151

152-
//TODO:const generics?
153152
#[derive(Copy, Clone, PartialEq, Eq)]
154153
pub enum GenericKind<'tcx> {
155154
Param(ty::ParamTy),

src/librustc/infer/sub.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
146146

147147
fn consts(&mut self, a: &'tcx ty::Const<'tcx>, b: &'tcx ty::Const<'tcx>)
148148
-> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
149+
// TODO(const_generics): missing handling for when only one side is an InferVar
149150
debug!("{}.consts({:?}, {:?})", self.tag(), a, b);
150151
if a == b { return Ok(a); }
151152

0 commit comments

Comments
 (0)