Repository: rust-lang/rust
File: compiler/rustc_ast_lowering/src/item.rs (Rust)

Code before:
                    hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id)),
                    true,
                )
            }
            AssocItemKind::Type(box TyAlias {
                ident,
                generics,
                after_where_clause,
                bounds,
                ty,
                ..
            }) => {
                let mut generics = generics.clone();
                add_ty_alias_where_clause(&mut generics, after_where_clause, false);
                let (generics, kind) = self.lower_generics(
                    &generics,
                    i.id,
                    ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
                    |this| {
                        let mut ty = ty.as_ref().map(|x| {
                            this.lower_ty_alloc(
                                x,
                                ImplTraitContext::Disallowed(ImplTraitPosition::AssocTy),
                            )
                        });
                        if matches!(i.kind.defaultness(), Defaultness::Final(..)) {
                            let guar = this.dcx().span_delayed_bug(
                                i.span,
                                "expected to lower associated type, but it is wrongly marked as `final`",
                            );
                            ty = Some(this.arena.alloc(this.ty(i.span, hir::TyKind::Err(guar))));
                        };
                        hir::TraitItemKind::Type(
                            this.lower_param_bounds(
                                bounds,
                                RelaxedBoundPolicy::Allowed,
                                ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
                            ),
                            ty,
                        )
                    },
                );
                (*ident, generics, kind, ty.is_some())
            }
            AssocItemKind::Delegation(box delegation) => {
                let delegation_results = self.lower_delegation(delegation, i.id);
                let item_kind = hir::TraitItemKind::Fn(
                    delegation_results.sig,
                    hir::TraitFn::Provided(delegation_results.body_id),
                );
                (delegation.ident, delegation_results.generics, item_kind, true)

Review comment (suggestion):
I think lowering `final` to `Default { .. }` when lowering defaultness for assoc types and consts maybe better?

https://github.com/rust-lang/rust/blob/main/compiler/rustc_ast_lowering/src/item.rs#L1088-L1090

Code after:
                    hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id)),
                    true,
                )
            }
            AssocItemKind::Type(box TyAlias {
                ident,
                generics,
                after_where_clause,
                bounds,
                ty,
                ..
            }) => {
                let mut generics = generics.clone();
                add_ty_alias_where_clause(&mut generics, after_where_clause, false);
                let (generics, kind) = self.lower_generics(
                    &generics,
                    i.id,
                    ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
                    |this| {
                        let ty = ty.as_ref().map(|x| {
                            this.lower_ty_alloc(
                                x,
                                ImplTraitContext::Disallowed(ImplTraitPosition::AssocTy),
                            )
                        });
                        hir::TraitItemKind::Type(
                            this.lower_param_bounds(
                                bounds,
                                RelaxedBoundPolicy::Allowed,
                                ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
                            ),
                            ty,
                        )
                    },
                );
                (*ident, generics, kind, ty.is_some())
            }
            AssocItemKind::Delegation(box delegation) => {
                let delegation_results = self.lower_delegation(delegation, i.id);
                let item_kind = hir::TraitItemKind::Fn(
                    delegation_results.sig,
                    hir::TraitFn::Provided(delegation_results.body_id),
                );
                (delegation.ident, delegation_results.generics, item_kind, true)
            }
            AssocItemKind::MacCall(..) | AssocItemKind::DelegationMac(..) => {
                panic!("macros should have been expanded by now")
            }
        };

        let defaultness = match i.kind.defaultness() {