Skip to content

Commit 4646b3d

Browse files
committed
Use BoundTy and BoundRegion instead of kind of PlaceholderTy and PlaceholderRegion
1 parent c934ce9 commit 4646b3d

File tree

20 files changed

+121
-75
lines changed

20 files changed

+121
-75
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ trait TypeOpInfo<'tcx> {
181181
};
182182

183183
let placeholder_region = tcx.mk_re_placeholder(ty::Placeholder {
184-
name: placeholder.name,
185184
universe: adjusted_universe.into(),
185+
bound: placeholder.bound,
186186
});
187187

188188
let error_region =
@@ -191,8 +191,8 @@ trait TypeOpInfo<'tcx> {
191191
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
192192
adjusted_universe.map(|adjusted| {
193193
tcx.mk_re_placeholder(ty::Placeholder {
194-
name: error_placeholder.name,
195194
universe: adjusted.into(),
195+
bound: error_placeholder.bound,
196196
})
197197
})
198198
} else {

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
467467
if let ty::Ref(region, ..) = ty.kind() {
468468
match **region {
469469
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
470-
| ty::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
471-
printer.region_highlight_mode.highlighting_bound_region(br, counter)
472-
}
470+
| ty::RePlaceholder(ty::PlaceholderRegion {
471+
bound: ty::BoundRegion { kind: br, .. },
472+
..
473+
}) => printer.region_highlight_mode.highlighting_bound_region(br, counter),
473474
_ => {}
474475
}
475476
}
@@ -485,9 +486,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
485486
let region = if let ty::Ref(region, ..) = ty.kind() {
486487
match **region {
487488
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. })
488-
| ty::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {
489-
printer.region_highlight_mode.highlighting_bound_region(br, counter)
490-
}
489+
| ty::RePlaceholder(ty::PlaceholderRegion {
490+
bound: ty::BoundRegion { kind: br, .. },
491+
..
492+
}) => printer.region_highlight_mode.highlighting_bound_region(br, counter),
491493
_ => {}
492494
}
493495
region

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
207207
.regioncx
208208
.placeholders_contained_in(lower_bound)
209209
.map(|placeholder| {
210-
if let Some(id) = placeholder.name.get_id()
210+
if let Some(id) = placeholder.bound.kind.get_id()
211211
&& let Some(placeholder_id) = id.as_local()
212212
&& let gat_hir_id = hir.local_def_id_to_hir_id(placeholder_id)
213213
&& let Some(generics_impl) = hir.get_parent(gat_hir_id).generics()

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
123123
.constraints
124124
.placeholder_region(self.type_checker.infcx, placeholder);
125125

126-
let reg_info = match placeholder.name {
126+
let reg_info = match placeholder.bound.kind {
127127
ty::BoundRegionKind::BrAnon(_, Some(span)) => BoundRegionInfo::Span(span),
128128
ty::BoundRegionKind::BrAnon(..) => BoundRegionInfo::Name(Symbol::intern("anon")),
129129
ty::BoundRegionKind::BrNamed(_, name) => BoundRegionInfo::Name(name),

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,10 +2336,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23362336
FnMutDelegate {
23372337
regions: &mut |_| tcx.lifetimes.re_erased,
23382338
types: &mut |bv| {
2339-
tcx.mk_placeholder(ty::PlaceholderType { universe, name: bv.kind })
2339+
tcx.mk_placeholder(ty::PlaceholderType { universe, bound: bv })
23402340
},
23412341
consts: &mut |bv, ty| {
2342-
tcx.mk_const(ty::PlaceholderConst { universe, name: bv }, ty)
2342+
tcx.mk_const(ty::PlaceholderConst { universe, bound: bv }, ty)
23432343
},
23442344
},
23452345
);
@@ -2525,11 +2525,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25252525
regions: &mut |_| tcx.lifetimes.re_erased,
25262526
types: &mut |bv| tcx.mk_placeholder(ty::PlaceholderType {
25272527
universe,
2528-
name: bv.kind,
2528+
bound: bv,
25292529
}),
25302530
consts: &mut |bv, ty| tcx.mk_const(ty::PlaceholderConst {
25312531
universe,
2532-
name: bv
2532+
bound: bv,
25332533
}, ty),
25342534
})
25352535
)

compiler/rustc_infer/src/infer/canonical/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ impl<'tcx> InferCtxt<'tcx> {
125125
ty.into()
126126
}
127127

128-
CanonicalVarKind::PlaceholderTy(ty::PlaceholderType { universe, name }) => {
128+
CanonicalVarKind::PlaceholderTy(ty::PlaceholderType { universe, bound }) => {
129129
let universe_mapped = universe_map(universe);
130-
let placeholder_mapped = ty::PlaceholderType { universe: universe_mapped, name };
130+
let placeholder_mapped = ty::PlaceholderType { universe: universe_mapped, bound };
131131
self.tcx.mk_placeholder(placeholder_mapped).into()
132132
}
133133

@@ -138,9 +138,9 @@ impl<'tcx> InferCtxt<'tcx> {
138138
)
139139
.into(),
140140

141-
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, name }) => {
141+
CanonicalVarKind::PlaceholderRegion(ty::PlaceholderRegion { universe, bound }) => {
142142
let universe_mapped = universe_map(universe);
143-
let placeholder_mapped = ty::PlaceholderRegion { universe: universe_mapped, name };
143+
let placeholder_mapped = ty::PlaceholderRegion { universe: universe_mapped, bound };
144144
self.tcx.mk_re_placeholder(placeholder_mapped).into()
145145
}
146146

@@ -152,9 +152,9 @@ impl<'tcx> InferCtxt<'tcx> {
152152
)
153153
.into(),
154154

155-
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }, ty) => {
155+
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, bound }, ty) => {
156156
let universe_mapped = universe_map(universe);
157-
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, name };
157+
let placeholder_mapped = ty::PlaceholderConst { universe: universe_mapped, bound };
158158
self.tcx.mk_const(placeholder_mapped, ty).into()
159159
}
160160
}

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ fn msg_span_from_named_region<'tcx>(
170170
}
171171
ty::ReStatic => ("the static lifetime".to_owned(), alt_span),
172172
ty::RePlaceholder(ty::PlaceholderRegion {
173-
name: ty::BoundRegionKind::BrNamed(def_id, name),
173+
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrNamed(def_id, name), .. },
174174
..
175175
}) => (format!("the lifetime `{name}` as defined here"), Some(tcx.def_span(def_id))),
176176
ty::RePlaceholder(ty::PlaceholderRegion {
177-
name: ty::BoundRegionKind::BrAnon(_, Some(span)),
177+
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(_, Some(span)), .. },
178178
..
179179
}) => (format!("the anonymous lifetime defined here"), Some(span)),
180180
ty::RePlaceholder(ty::PlaceholderRegion {
181-
name: ty::BoundRegionKind::BrAnon(_, None),
181+
bound: ty::BoundRegion { kind: ty::BoundRegionKind::BrAnon(_, None), .. },
182182
..
183183
}) => (format!("an anonymous lifetime"), None),
184184
_ => bug!("{:?}", region),

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/placeholder_relation.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@ impl<'tcx> NiceRegionError<'_, 'tcx> {
1616
match &self.error {
1717
Some(RegionResolutionError::ConcreteFailure(
1818
SubregionOrigin::RelateRegionParamBound(span),
19-
Region(Interned(RePlaceholder(ty::Placeholder { name: sub_name, .. }), _)),
20-
Region(Interned(RePlaceholder(ty::Placeholder { name: sup_name, .. }), _)),
19+
Region(Interned(
20+
RePlaceholder(ty::Placeholder {
21+
bound: ty::BoundRegion { kind: sub_name, .. },
22+
..
23+
}),
24+
_,
25+
)),
26+
Region(Interned(
27+
RePlaceholder(ty::Placeholder {
28+
bound: ty::BoundRegion { kind: sup_name, .. },
29+
..
30+
}),
31+
_,
32+
)),
2133
)) => {
2234
let span = *span;
2335
let (sub_span, sub_symbol) = match sub_name {

compiler/rustc_infer/src/infer/higher_ranked/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,20 @@ impl<'tcx> InferCtxt<'tcx> {
8282

8383
let delegate = FnMutDelegate {
8484
regions: &mut |br: ty::BoundRegion| {
85-
self.tcx.mk_re_placeholder(ty::PlaceholderRegion {
86-
universe: next_universe,
87-
name: br.kind,
88-
})
85+
self.tcx
86+
.mk_re_placeholder(ty::PlaceholderRegion { universe: next_universe, bound: br })
8987
},
9088
types: &mut |bound_ty: ty::BoundTy| {
9189
self.tcx.mk_placeholder(ty::PlaceholderType {
9290
universe: next_universe,
93-
name: bound_ty.kind,
91+
bound: bound_ty,
9492
})
9593
},
9694
consts: &mut |bound_var: ty::BoundVar, ty| {
97-
self.tcx
98-
.mk_const(ty::PlaceholderConst { universe: next_universe, name: bound_var }, ty)
95+
self.tcx.mk_const(
96+
ty::PlaceholderConst { universe: next_universe, bound: bound_var },
97+
ty,
98+
)
9999
},
100100
};
101101

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,13 +2130,17 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
21302130

21312131
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
21322132
if let ty::Infer(_) = t.kind() {
2133+
let idx = {
2134+
let idx = self.idx;
2135+
self.idx += 1;
2136+
idx
2137+
};
21332138
self.tcx.mk_placeholder(ty::PlaceholderType {
21342139
universe: ty::UniverseIndex::ROOT,
2135-
name: ty::BoundTyKind::Anon({
2136-
let idx = self.idx;
2137-
self.idx += 1;
2138-
idx
2139-
}),
2140+
bound: ty::BoundTy {
2141+
var: ty::BoundVar::from_u32(idx),
2142+
kind: ty::BoundTyKind::Anon(idx),
2143+
},
21402144
})
21412145
} else {
21422146
t.super_fold_with(self)
@@ -2153,7 +2157,7 @@ fn replace_param_and_infer_substs_with_placeholder<'tcx>(
21532157
self.tcx.mk_const(
21542158
ty::PlaceholderConst {
21552159
universe: ty::UniverseIndex::ROOT,
2156-
name: ty::BoundVar::from_u32({
2160+
bound: ty::BoundVar::from_u32({
21572161
let idx = self.idx;
21582162
self.idx += 1;
21592163
idx

0 commit comments

Comments
 (0)