Skip to content

Commit 82e82b8

Browse files
committed
Do some housekeeping
1 parent d88ad97 commit 82e82b8

File tree

13 files changed

+28
-47
lines changed

13 files changed

+28
-47
lines changed

src/librustc/hir/pat_util.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,6 @@ impl hir::Pat {
7474
}
7575
}
7676

77-
pub fn is_const(&self) -> bool {
78-
match self.node {
79-
PatKind::Path(hir::QPath::TypeRelative(..)) => true,
80-
PatKind::Path(hir::QPath::Resolved(_, ref path)) => {
81-
match path.def {
82-
Def::Const(..) |
83-
Def::ConstParam(..) |
84-
Def::AssociatedConst(..) => true,
85-
_ => false
86-
}
87-
}
88-
_ => false
89-
}
90-
}
91-
9277
/// Call `f` on every "binding" in a pattern, e.g., on `a` in
9378
/// `match foo() { Some(a) => (), None => () }`
9479
pub fn each_binding<F>(&self, mut f: F)

src/librustc/infer/combine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
149149
bug!("tried to combine ConstValue::Infer/ConstValue::Infer(InferConst::Var)")
150150
}
151151

152-
153152
(ConstValue::Infer(InferConst::Var(vid)), _) => {
154153
self.unify_const_variable(a_is_expected, vid, b)
155154
}
@@ -592,7 +591,8 @@ pub fn const_unification_error<'tcx>(
592591
{
593592
let (a, b) = v;
594593
TypeError::ConstError(
595-
ConstError::Mismatch(ty::relate::expected_found_bool(a_is_expected, &a, &b)))
594+
ConstError::Mismatch(ty::relate::expected_found_bool(a_is_expected, &a, &b))
595+
)
596596
}
597597

598598
fn int_unification_error<'tcx>(a_is_expected: bool, v: (ty::IntVarValue, ty::IntVarValue))

src/librustc/infer/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,8 +994,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
994994
}
995995
}
996996

997-
/// Given a set of generics defined on a type or impl, returns a substitution mapping each
998-
/// type/const/lifetime parameter to a fresh inference variable.
997+
/// Given a set of generics defined on a type or impl, returns a substitution
998+
/// mapping each generic parameter to a fresh inference variable.
999999
pub fn fresh_substs_for_item(&self,
10001000
span: Span,
10011001
def_id: DefId)

src/librustc/ty/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ impl<'a, 'gcx, 'tcx> TypeRelation<'a, 'gcx, 'tcx> for Match<'a, 'gcx, 'tcx> {
101101

102102
(ConstValue::Infer(_), _) | (_, ConstValue::Infer(_)) => {
103103
Err(TypeError::ConstError(
104-
ConstError::Mismatch(relate::expected_found(self, &a, &b))))
104+
ConstError::Mismatch(relate::expected_found(self, &a, &b))
105+
))
105106
}
106107

107108
_ => {

src/librustc/ty/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
128128
}
129129

130130
/// Indicates whether this value references only 'global'
131-
/// types/lifetimes/consts that are the same regardless of what fn we are
131+
/// generic params that are the same regardless of what fn we are
132132
/// in. This is used for caching.
133133
fn is_global(&self) -> bool {
134134
!self.has_type_flags(TypeFlags::HAS_FREE_LOCAL_NAMES)

src/librustc/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use middle::resolve_lifetime::ObjectLifetimeDefault;
2828
use mir::Mir;
2929
use mir::interpret::GlobalId;
3030
use mir::GeneratorLayout;
31-
// use mir::interpret::ConstValue;
3231
use session::CrateDisambiguator;
3332
use traits::{self, Reveal};
3433
use ty;

src/librustc/ty/structural_impls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,9 +1165,9 @@ impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> {
11651165
ConstValue::Param(param) => ConstValue::Param(param),
11661166
ConstValue::Infer(infer) => {
11671167
ConstValue::Infer(match infer {
1168-
InferConst::Var(vid) =>InferConst::Var(vid),
1169-
InferConst::Fresh(i) =>InferConst::Fresh(i),
1170-
InferConst::Canonical(var) =>InferConst::Canonical(var),
1168+
InferConst::Var(vid) => InferConst::Var(vid),
1169+
InferConst::Fresh(i) => InferConst::Fresh(i),
1170+
InferConst::Canonical(var) => InferConst::Canonical(var),
11711171
})
11721172
}
11731173
}

src/librustc/ty/subst.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
277277
}
278278

279279
#[inline]
280-
pub fn types(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
280+
pub fn types(&'a self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> + 'a {
281281
self.iter().filter_map(|k| {
282282
if let UnpackedKind::Type(ty) = k.unpack() {
283283
Some(ty)
@@ -288,7 +288,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
288288
}
289289

290290
#[inline]
291-
pub fn regions(&'a self) -> impl DoubleEndedIterator<Item=ty::Region<'tcx>> + 'a {
291+
pub fn regions(&'a self) -> impl DoubleEndedIterator<Item = ty::Region<'tcx>> + 'a {
292292
self.iter().filter_map(|k| {
293293
if let UnpackedKind::Lifetime(lt) = k.unpack() {
294294
Some(lt)
@@ -299,7 +299,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
299299
}
300300

301301
#[inline]
302-
pub fn consts(&'a self) -> impl DoubleEndedIterator<Item=&'tcx ty::Const<'tcx>> + 'a {
302+
pub fn consts(&'a self) -> impl DoubleEndedIterator<Item = &'tcx ty::Const<'tcx>> + 'a {
303303
self.iter().filter_map(|k| {
304304
if let UnpackedKind::Const(ct) = k.unpack() {
305305
Some(ct)

src/librustc_codegen_llvm/mir/constant.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ impl FunctionCx<'a, 'll, 'tcx> {
156156
promoted: None,
157157
};
158158
tcx.const_eval(param_env.and(cid))
159-
},
160-
// TODO(const_generics:param/infer)
159+
}
160+
ConstValue::Param(_) => bug!(),
161+
ConstValue::Infer(_) => bug!(),
161162
_ => Ok(constant),
162163
}
163164
}

src/librustc_codegen_llvm/mir/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl OperandRef<'ll, 'tcx> {
9090

9191
let val = match val.val {
9292
ConstValue::Unevaluated(..) => bug!(),
93-
ConstValue::Param(_) => bug!(),
93+
ConstValue::Param(_) => bug!("encountered a ConstValue::Param in codegen"),
9494
ConstValue::Infer(_) => bug!(),
9595
ConstValue::Scalar(x) => {
9696
let scalar = match layout.abi {

src/librustc_mir/build/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
4545
hir::map::NodeStructCtor(ctor) =>
4646
return create_constructor_shim(tcx, id, ctor),
4747

48-
_ => match tcx.hir.maybe_body_owned_by(id) {
48+
x => match tcx.hir.maybe_body_owned_by(id) {
4949
Some(body) => body,
50-
None => {
51-
span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id)
52-
}
50+
None => span_bug!(tcx.hir.span(id), "can't build MIR for {:?} ({:?}", def_id, x),
5351
},
5452
};
5553

src/librustc_typeck/collect.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,23 +1188,20 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11881188
Def::Fn(def_id) => {
11891189
let generics = tcx.generics_of(def_id);
11901190
for param in &generics.params {
1191-
// if param.id == node_id {
1192-
// generics.param_def_id_to_index
1193-
return tcx.type_of(param.def_id);
1194-
// }
1191+
// TODO(const_generics): this should obviously pick the correct
1192+
// parameter, and not just the first one.
1193+
return tcx.type_of(param.def_id);
11951194
}
1196-
bug!("no such param");
1195+
bug!("there was no generic parameter associated with the arg");
11971196
}
1198-
x => bug!("other def {:?}", x),
1197+
x => bug!("unexpected const parent path def {:?}", x),
11991198
}
12001199
}
1201-
_ => bug!("other path"),
1200+
x => bug!("unexpected const parent path {:?}", x),
12021201
}
12031202
}
12041203

1205-
x => {
1206-
bug!("unexpected const parent in type_of_def_id(): {:?}", x);
1207-
}
1204+
x => bug!("unexpected const parent in type_of_def_id(): {:?}", x),
12081205
},
12091206

12101207
NodeGenericParam(param) => {

src/libsyntax/feature_gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ declare_features! (
429429
// `existential type`
430430
(active, existential_type, "1.28.0", Some(34511), None),
431431

432-
// const generic types
433-
(active, const_generics, "1.29.0", Some(44580), None),
432+
// Const generic types
433+
(active, const_generics, "1.30.0", Some(44580), None),
434434

435435
// unstable #[target_feature] directives
436436
(active, arm_target_feature, "1.27.0", Some(44839), None),

0 commit comments

Comments
 (0)