Auto merge of #120919 - oli-obk:impl_polarity, r=compiler-errors
Merge `impl_polarity` and `impl_trait_ref` queries Hopefully this is perf neutral. I want to finish https://github.com/rust-lang/rust/pull/120835 and stop using the HIR in `coherent_trait`, which should then give us a perf improvement.
This commit is contained in:
commit
d26b417112
22 changed files with 156 additions and 131 deletions
|
@ -1347,8 +1347,11 @@ fn create_mono_items_for_default_impls<'tcx>(
|
|||
item: hir::ItemId,
|
||||
output: &mut MonoItems<'tcx>,
|
||||
) {
|
||||
let polarity = tcx.impl_polarity(item.owner_id);
|
||||
if matches!(polarity, ty::ImplPolarity::Negative) {
|
||||
let Some(impl_) = tcx.impl_trait_header(item.owner_id) else {
|
||||
return;
|
||||
};
|
||||
|
||||
if matches!(impl_.skip_binder().polarity, ty::ImplPolarity::Negative) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1356,10 +1359,6 @@ fn create_mono_items_for_default_impls<'tcx>(
|
|||
return;
|
||||
}
|
||||
|
||||
let Some(trait_ref) = tcx.impl_trait_ref(item.owner_id) else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Lifetimes never affect trait selection, so we are allowed to eagerly
|
||||
// instantiate an instance of an impl method if the impl (and method,
|
||||
// which we check below) is only parameterized over lifetime. In that case,
|
||||
|
@ -1376,7 +1375,7 @@ fn create_mono_items_for_default_impls<'tcx>(
|
|||
}
|
||||
};
|
||||
let impl_args = GenericArgs::for_item(tcx, item.owner_id.to_def_id(), only_region_params);
|
||||
let trait_ref = trait_ref.instantiate(tcx, impl_args);
|
||||
let trait_ref = impl_.instantiate(tcx, impl_args).trait_ref;
|
||||
|
||||
// Unlike 'lazy' monomorphization that begins by collecting items transitively
|
||||
// called by `main` or other global items, when eagerly monomorphizing impl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue