Separate out a hir::Impl struct

This makes it possible to pass the `Impl` directly to functions, instead
of having to pass each of the many fields one at a time. It also
simplifies matches in many cases.
This commit is contained in:
Joshua Nelson 2020-11-22 17:46:21 -05:00
parent fd34606ddf
commit a8ff647deb
61 changed files with 258 additions and 246 deletions

View file

@ -126,7 +126,7 @@ fn is_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
matches!(
node,
hir::Node::Item(hir::Item {
kind: hir::ItemKind::Impl { constness: hir::Constness::Const, .. },
kind: hir::ItemKind::Impl(hir::Impl { constness: hir::Constness::Const, .. }),
..
})
)

View file

@ -1146,8 +1146,8 @@ fn create_mono_items_for_default_impls<'tcx>(
output: &mut Vec<Spanned<MonoItem<'tcx>>>,
) {
match item.kind {
hir::ItemKind::Impl { ref generics, ref items, .. } => {
for param in generics.params {
hir::ItemKind::Impl(ref impl_) => {
for param in impl_.generics.params {
match param.kind {
hir::GenericParamKind::Lifetime { .. } => {}
hir::GenericParamKind::Type { .. } | hir::GenericParamKind::Const { .. } => {
@ -1167,7 +1167,7 @@ fn create_mono_items_for_default_impls<'tcx>(
let param_env = ty::ParamEnv::reveal_all();
let trait_ref = tcx.normalize_erasing_regions(param_env, trait_ref);
let overridden_methods: FxHashSet<_> =
items.iter().map(|iiref| iiref.ident.normalize_to_macros_2_0()).collect();
impl_.items.iter().map(|iiref| iiref.ident.normalize_to_macros_2_0()).collect();
for method in tcx.provided_trait_methods(trait_ref.def_id) {
if overridden_methods.contains(&method.ident.normalize_to_macros_2_0()) {
continue;