1
Fork 0

Make GATs object safe under generic_associated_types_extended feature

This commit is contained in:
Jack Huey 2022-03-13 11:56:18 -04:00
parent 0677edc86e
commit 52b00db235
19 changed files with 240 additions and 44 deletions

View file

@ -131,16 +131,18 @@ fn object_safety_violations_for_trait(
}),
);
violations.extend(
tcx.associated_items(trait_def_id)
.in_definition_order()
.filter(|item| item.kind == ty::AssocKind::Type)
.filter(|item| !tcx.generics_of(item.def_id).params.is_empty())
.map(|item| {
let ident = item.ident(tcx);
ObjectSafetyViolation::GAT(ident.name, ident.span)
}),
);
if !tcx.features().generic_associated_types_extended {
violations.extend(
tcx.associated_items(trait_def_id)
.in_definition_order()
.filter(|item| item.kind == ty::AssocKind::Type)
.filter(|item| !tcx.generics_of(item.def_id).params.is_empty())
.map(|item| {
let ident = item.ident(tcx);
ObjectSafetyViolation::GAT(ident.name, ident.span)
}),
);
}
debug!(
"object_safety_violations_for_trait(trait_def_id={:?}) = {:?}",