Skip to content

Commit 1b70638

Browse files
oli-obkfee1-dead
authored andcommitted
Port some more crates
1 parent 67e3eb3 commit 1b70638

File tree

10 files changed

+39
-12
lines changed

10 files changed

+39
-12
lines changed

compiler/rustc_typeck/src/check/compare_method.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,15 @@ fn compare_synthetic_generics<'tcx>(
834834
let trait_m_generics = tcx.generics_of(trait_m.def_id);
835835
let impl_m_type_params = impl_m_generics.params.iter().filter_map(|param| match param.kind {
836836
GenericParamDefKind::Type { synthetic, .. } => Some((param.def_id, synthetic)),
837-
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None,
837+
GenericParamDefKind::Constness
838+
| GenericParamDefKind::Lifetime
839+
| GenericParamDefKind::Const { .. } => None,
838840
});
839841
let trait_m_type_params = trait_m_generics.params.iter().filter_map(|param| match param.kind {
840842
GenericParamDefKind::Type { synthetic, .. } => Some((param.def_id, synthetic)),
841-
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => None,
843+
GenericParamDefKind::Constness
844+
| GenericParamDefKind::Lifetime
845+
| GenericParamDefKind::Const { .. } => None,
842846
});
843847
for ((impl_def_id, impl_synthetic), (trait_def_id, trait_synthetic)) in
844848
iter::zip(impl_m_type_params, trait_m_type_params)

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14331433
self.fcx.var_for_def(self.span, param)
14341434
}
14351435
}
1436+
GenericParamDefKind::Constness => self.fcx.var_for_def(self.span, param),
14361437
}
14371438
}
14381439
}

compiler/rustc_typeck/src/check/method/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
284284
// Construct a trait-reference `self_ty : Trait<input_tys>`
285285
let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| {
286286
match param.kind {
287-
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => {}
287+
GenericParamDefKind::Constness
288+
| GenericParamDefKind::Lifetime
289+
| GenericParamDefKind::Const { .. } => {}
288290
GenericParamDefKind::Type { .. } => {
289291
if param.index == 0 {
290292
return self_ty.into();
@@ -323,7 +325,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
323325
// Construct a trait-reference `self_ty : Trait<input_tys>`
324326
let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| {
325327
match param.kind {
326-
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => {}
328+
GenericParamDefKind::Constness
329+
| GenericParamDefKind::Lifetime
330+
| GenericParamDefKind::Const { .. } => {}
327331
GenericParamDefKind::Type { .. } => {
328332
if param.index == 0 {
329333
return self_ty.into();

compiler/rustc_typeck/src/check/method/probe.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,9 +1796,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
17961796
// In general, during probe we erase regions.
17971797
self.tcx.lifetimes.re_erased.into()
17981798
}
1799-
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
1800-
self.var_for_def(self.span, param)
1801-
}
1799+
GenericParamDefKind::Constness
1800+
| GenericParamDefKind::Type { .. }
1801+
| GenericParamDefKind::Const { .. } => self.var_for_def(self.span, param),
18021802
}
18031803
}
18041804
});
@@ -1833,6 +1833,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
18331833
};
18341834
self.next_const_var(self.tcx.type_of(param.def_id), origin).into()
18351835
}
1836+
GenericParamDefKind::Constness => ty::ConstnessArg::Param.into(),
18361837
})
18371838
}
18381839

compiler/rustc_typeck/src/check/wfcheck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ fn check_where_clauses<'tcx, 'fcx>(
12811281
| GenericParamDefKind::Const { has_default } => {
12821282
has_default && def.index >= generics.parent_count as u32
12831283
}
1284-
GenericParamDefKind::Lifetime => unreachable!(),
1284+
GenericParamDefKind::Constness | GenericParamDefKind::Lifetime => unreachable!(),
12851285
};
12861286

12871287
// Check that concrete defaults are well-formed. See test `type-check-defaults.rs`.
@@ -1323,8 +1323,8 @@ fn check_where_clauses<'tcx, 'fcx>(
13231323
}
13241324
}
13251325
}
1326-
// Doesn't have defaults.
1327-
GenericParamDefKind::Lifetime => {}
1326+
// Don't have defaults.
1327+
GenericParamDefKind::Constness | GenericParamDefKind::Lifetime => {}
13281328
}
13291329
}
13301330

@@ -1338,7 +1338,7 @@ fn check_where_clauses<'tcx, 'fcx>(
13381338
// First we build the defaulted substitution.
13391339
let substs = InternalSubsts::for_item(tcx, def_id.to_def_id(), |param, _| {
13401340
match param.kind {
1341-
GenericParamDefKind::Lifetime => {
1341+
GenericParamDefKind::Constness | GenericParamDefKind::Lifetime => {
13421342
// All regions are identity.
13431343
tcx.mk_param_from_def(param)
13441344
}

compiler/rustc_typeck/src/impl_wf_check.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
155155
);
156156
}
157157
}
158+
ty::GenericParamDefKind::Constness => {
159+
// TODO: users can't write these, do we have to do anything here?
160+
}
158161
}
159162
}
160163

compiler/rustc_typeck/src/outlives/implicit_infer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ fn insert_required_predicates_to_be_wf<'tcx>(
9999

100100
// No predicates from lifetimes or constants, except potentially
101101
// constants' types, but `walk` will get to them as well.
102-
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => continue,
102+
GenericArgKind::Constness(_)
103+
| GenericArgKind::Lifetime(_)
104+
| GenericArgKind::Const(_) => {
105+
continue;
106+
}
103107
};
104108

105109
match *ty.kind() {

compiler/rustc_typeck/src/outlives/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
119119
// Generic consts don't impose any constraints.
120120
None
121121
}
122+
GenericArgKind::Constness(_) => {
123+
// Constness effect doesn't impose any constraints.
124+
None
125+
}
122126
}
123127
},
124128
));

compiler/rustc_typeck/src/outlives/utils.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
128128
GenericArgKind::Const(_) => {
129129
// Generic consts don't impose any constraints.
130130
}
131+
GenericArgKind::Constness(_) => {
132+
// Constness effect doesn't impose any constraints.
133+
}
131134
}
132135
}
133136

compiler/rustc_typeck/src/variance/constraints.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
189189
GenericArgKind::Const(val) => {
190190
self.add_constraints_from_const(current, val, variance_i)
191191
}
192+
// Does not contain anything with constraints
193+
GenericArgKind::Constness(_) => {}
192194
}
193195
}
194196
}
@@ -354,6 +356,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
354356
GenericArgKind::Const(val) => {
355357
self.add_constraints_from_const(current, val, variance)
356358
}
359+
GenericArgKind::Constness(_) => {}
357360
}
358361
}
359362
}

0 commit comments

Comments
 (0)