Skip to content

Commit 23008d7

Browse files
committed
Clean up unfinished parts
1 parent c0290e0 commit 23008d7

File tree

12 files changed

+22
-51
lines changed

12 files changed

+22
-51
lines changed

src/librustc/infer/combine.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
146146
// All other cases of inference with other variables are errors.
147147
(ConstValue::Infer(InferConst::Var(_)), ConstValue::Infer(_)) |
148148
(ConstValue::Infer(_), ConstValue::Infer(InferConst::Var(_))) => {
149-
unimplemented!()
150-
// TODO(const_generics): relate
151-
// Err(TypeError::ConstError(
152-
// ConstError::Mismatch(ty::relate::expected_found(relation, &a, &b))))
149+
bug!("tried to combine ConstValue::Infer/ConstValue::Infer(InferConst::Var)")
153150
}
154151

155152

src/librustc/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
914914
}
915915

916916
pub fn next_const_var_id(&self, _origin: ConstVariableOrigin) -> ConstVid<'tcx> {
917-
// TODO(const_generics): integrate _origin
917+
// TODO(const_generics): integrate _origin.
918918
self.const_unification_table
919919
.borrow_mut()
920920
.new_key(None)

src/librustc/ty/context.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use ty::query;
5151
use ty::steal::Steal;
5252
use ty::BindingMode;
5353
use ty::CanonicalTy;
54-
use ty::fold::TypeFoldable;
5554
use util::nodemap::{DefIdSet, ItemLocalMap};
5655
use util::nodemap::{FxHashMap, FxHashSet};
5756
use rustc_data_structures::accumulate_vec::AccumulateVec;
@@ -2277,11 +2276,8 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
22772276

22782277
direct_interners!('tcx,
22792278
region: mk_region(|r: &RegionKind| r.keep_in_local_tcx()) -> RegionKind,
2280-
// TODO(const_generics): self.has_type_flags(TypeFlags::HAS_CT_INFER)
2281-
const_: mk_const(|c: &Const| {
2282-
assert!(c.ty.is_global(), "mk_const({:?}): non-global type", c);
2283-
keep_local(&c.ty) || keep_local(&c.val)
2284-
}) -> Const<'tcx>
2279+
// TODO(const_generics): we might want to change this.
2280+
const_: mk_const(|c: &Const| keep_local(&c.ty) || keep_local(&c.val)) -> Const<'tcx>
22852281
);
22862282

22872283
macro_rules! slice_interners {

src/librustc/ty/relate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
478478
return Ok(s);
479479
}
480480
match x.val {
481+
// TODO(const_generics): make sure this works.
481482
ConstValue::Unevaluated(def_id, substs) => {
482-
// TODO(const_generics)
483483
// FIXME(eddyb) get the right param_env.
484484
let param_env = ty::ParamEnv::empty();
485485
match tcx.lift_to_global(&substs) {
@@ -493,7 +493,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
493493
if let Some(instance) = instance {
494494
let cid = GlobalId {
495495
instance,
496-
promoted: None
496+
promoted: None,
497497
};
498498
if let Some(s) = tcx.const_eval(param_env.and(cid))
499499
.ok()
@@ -598,7 +598,6 @@ pub fn super_relate_consts<'a, 'gcx, 'tcx, R>(relation: &mut R,
598598
// implement both `PartialEq` and `Eq`, corresponding to
599599
// `structural_match` types.
600600
// FIXME(const_generics): check for `structural_match` synthetic attribute.
601-
// TODO(const_generics): possibly need indirection for ByRef?
602601
match (a.val, b.val) {
603602
(ConstValue::Infer(_), _) | (_, ConstValue::Infer(_)) => {
604603
// The caller should handle these cases!
@@ -609,6 +608,7 @@ pub fn super_relate_consts<'a, 'gcx, 'tcx, R>(relation: &mut R,
609608
}
610609
(ConstValue::Scalar(_), _) |
611610
(ConstValue::ScalarPair(..), _) |
611+
// TODO(const_generics): possibly need indirection for ByRef?
612612
(ConstValue::ByRef(..), _)
613613
if a == b =>
614614
{

src/librustc/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub enum TyKind<'tcx> {
114114
Str,
115115

116116
/// An array with the given length. Written as `[T; n]`.
117-
// TODO(const_generics): clean up handling of TyArray with const generics
117+
// TODO(const_generics): clean up handling of Array with const generics
118118
Array(Ty<'tcx>, &'tcx ty::Const<'tcx>),
119119

120120
/// The pointee of an array slice. Written as `[T]`.

src/librustc/ty/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for SubstFolder<'a, 'gcx, 'tcx> {
505505
return t1;
506506
}
507507

508-
// TODO(const_generics): fold const?
508+
// TODO(const_generics): do we need fold_const?
509509
}
510510

511511
impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {

src/librustc_mir/interpret/eval_context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
391391
self.param_env,
392392
&substs,
393393
);
394-
// TODO(const_generics): should bug!() on Infer and error on Param
395394
ty::Instance::resolve(
396395
*self.tcx,
397396
self.param_env,

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5187,7 +5187,9 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
51875187
ty
51885188
);
51895189

5190-
if own_counts.types + own_counts.consts == 0 {
5190+
// TODO(const_generics): we probably want to check the bounds for const parameters too.
5191+
5192+
if own_counts.types == 0 {
51915193
return;
51925194
}
51935195

@@ -5219,24 +5221,6 @@ pub fn check_bounds_are_used<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
52195221
.emit();
52205222
}
52215223
}
5222-
5223-
// TODO(const_generics): is there even a way to walk all consts?
5224-
// let mut consts_used = vec![false; own_counts.types];
5225-
5226-
// let consts = generics.params.iter().filter(|param| match param.kind {
5227-
// ty::GenericParamDefKind::Const => true,
5228-
// _ => false,
5229-
// });
5230-
// for (&used, param) in consts_used.iter().zip(consts) {
5231-
// if !used {
5232-
// let id = tcx.hir.as_local_node_id(param.def_id).unwrap();
5233-
// let span = tcx.hir.span(id);
5234-
// // TODO(const_generics): new error code
5235-
// struct_span_err!(tcx.sess, span, E0091, "const parameter `{}` is unused", param.name)
5236-
// .span_label(span, "unused const parameter")
5237-
// .emit();
5238-
// }
5239-
// }
52405224
}
52415225

52425226
fn fatally_break_rust(sess: &Session) {

src/librustc_typeck/check/wfcheck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,9 @@ fn check_variances_for_type_defn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
829829
.collect();
830830

831831
identify_constrained_type_params(tcx,
832-
ty_predicates.predicates.as_slice(),
833-
None,
834-
&mut constrained_parameters);
832+
ty_predicates.predicates.as_slice(),
833+
None,
834+
&mut constrained_parameters);
835835

836836
for (index, _) in variances.iter().enumerate() {
837837
if constrained_parameters.contains(&Parameter(index as u32)) {

src/librustc_typeck/constrained_type_params.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
9393
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
9494
match c.val {
9595
ConstValue::Param(data) => {
96-
debug!("ParameterCollector::visit_const: visit const param: {}", data);
9796
self.parameters.push(Parameter::from(data));
9897
}
9998
_ => {}

src/librustc_typeck/impl_wf_check.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,13 @@ fn enforce_impl_params_are_constrained<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
136136
}
137137
}
138138
ty::GenericParamDefKind::Const => {
139-
// TODO(const_generics): This is all right, but the collection
140-
// of const params in input_parameters is wrong
141-
// let param_ct = ty::ParamConst::for_def(param);
142-
// if !input_parameters.contains(&ctp::Parameter::from(param_ct)) {
143-
// report_unused_parameter(tcx,
144-
// tcx.def_span(param.def_id),
145-
// "const",
146-
// &param_ct.to_string());
147-
// }
139+
let param_ct = ty::ParamConst::for_def(param);
140+
if !input_parameters.contains(&ctp::Parameter::from(param_ct)) {
141+
report_unused_parameter(tcx,
142+
tcx.def_span(param.def_id),
143+
"const",
144+
&param_ct.to_string());
145+
}
148146
}
149147
}
150148
}

src/libsyntax/parse/parser.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5827,8 +5827,6 @@ impl<'a> Parser<'a> {
58275827
}
58285828
}
58295829

5830-
// TODO(const_generics): const generics introduces expressions to the list of
5831-
// things we can see after '<'.
58325830
fn choose_generics_over_qpath(&self, param: bool) -> bool {
58335831
// There's an ambiguity between generic parameters and qualified paths in impls.
58345832
// If we see `<` it may start both, so we have to inspect some following tokens.

0 commit comments

Comments
 (0)