1
Fork 0

Use unused_generic_params from crate metadata

This commit is contained in:
Michael Goulet 2023-03-14 00:35:34 +00:00
parent f1b1ed7e18
commit ee2d42882f
5 changed files with 28 additions and 10 deletions

View file

@ -36,6 +36,8 @@ fn unused_generic_params<'tcx>(
tcx: TyCtxt<'tcx>,
instance: ty::InstanceDef<'tcx>,
) -> UnusedGenericParams {
assert!(instance.def_id().is_local());
if !tcx.sess.opts.unstable_opts.polymorphize {
// If polymorphization disabled, then all parameters are used.
return UnusedGenericParams::new_all_used();
@ -100,13 +102,6 @@ fn should_polymorphize<'tcx>(
return false;
}
// Polymorphization results are stored in cross-crate metadata only when there are unused
// parameters, so assume that non-local items must have only used parameters (else this query
// would not be invoked, and the cross-crate metadata used instead).
if !def_id.is_local() {
return false;
}
// Foreign items have no bodies to analyze.
if tcx.is_foreign_item(def_id) {
return false;