Skip to content

Commit 852a851

Browse files
check associated types too
1 parent 453d2db commit 852a851

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

compiler/rustc_typeck/src/check/wfcheck.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,6 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
281281

282282
let mut new_required_bounds: Option<FxHashSet<ty::Predicate<'_>>> = None;
283283
for item in associated_items {
284-
if !matches!(&item.kind, hir::AssocItemKind::Fn { .. }) {
285-
// FIXME: next commit will add items...
286-
continue;
287-
}
288-
289284
let item_def_id = item.id.def_id;
290285
// Skip our own GAT, since it would blow away the required bounds
291286
if item_def_id == gat_def_id {
@@ -295,28 +290,33 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, associated_items: &[hir::TraitItemRe
295290
let item_hir_id = item.id.hir_id();
296291
let param_env = tcx.param_env(item_def_id);
297292

298-
// Get the signature using placeholders. In our example, this would
299-
// convert the late-bound 'a into a free region.
300-
let sig = tcx.liberate_late_bound_regions(
301-
item_def_id.to_def_id(),
302-
tcx.fn_sig(item_def_id.to_def_id()),
303-
);
304-
305-
// The types we can assume to be well-formed. In our example, this
306-
// would be &'a mut Self, from the first argument.
307-
let mut wf_tys = FxHashSet::default();
308-
wf_tys.extend(sig.inputs());
309-
310-
// The clauses we that we would require from this function
311-
let item_required_bounds = gather_gat_bounds(
312-
tcx,
313-
param_env,
314-
item_hir_id,
315-
sig.output(),
316-
&wf_tys,
317-
gat_def_id,
318-
gat_generics,
319-
);
293+
let item_required_bounds = match item.kind {
294+
hir::AssocItemKind::Fn { .. } => {
295+
let sig: ty::FnSig<'_> = tcx.liberate_late_bound_regions(
296+
item_def_id.to_def_id(),
297+
tcx.fn_sig(item_def_id),
298+
);
299+
gather_gat_bounds(
300+
tcx,
301+
param_env,
302+
item_hir_id,
303+
sig.output(),
304+
&sig.inputs().iter().copied().collect(),
305+
gat_def_id,
306+
gat_generics,
307+
)
308+
}
309+
hir::AssocItemKind::Type => gather_gat_bounds(
310+
tcx,
311+
param_env,
312+
item_hir_id,
313+
tcx.explicit_item_bounds(item_def_id).iter().copied().collect::<Vec<_>>(),
314+
&FxHashSet::default(),
315+
gat_def_id,
316+
gat_generics,
317+
),
318+
hir::AssocItemKind::Const => None,
319+
};
320320

321321
if let Some(item_required_bounds) = item_required_bounds {
322322
// Take the intersection of the new_required_bounds and the item_required_bounds

0 commit comments

Comments
 (0)