Repository: paritytech/substrate
File: frame/support/procedural/src/derive_impl.rs (Rust)

Code before:
			.cloned()
			.partition(|impl_item| impl_item_ident(impl_item).is_some());
	let existing_local_keys: HashSet<Ident> = existing_local_keys
		.into_iter()
		.filter_map(|item| impl_item_ident(&item).cloned())
		.collect();
	let mut final_impl = local_impl;
	let extended_items = foreign_impl.items.into_iter().filter_map(|item| {
		if let Some(ident) = impl_item_ident(&item) {
			if existing_local_keys.contains(&ident) {
				// do not copy colliding items that have an ident
				return None
			}
			if let ImplItem::Type(item) = item.clone() {
				let mut item = item.clone();
				if let Ok(Some(pallet_attr)) = take_first_item_pallet_attr::<PalletAttr>(&mut item)
				{
					match pallet_attr.typ {
						PalletAttrType::Verbatim(_) => {
							let modified_item: ImplItem = parse_quote! {
								type #ident = #ident;
							};
							return Some(modified_item)
						},
					}
				}
				// modify and insert uncolliding type items
				let modified_item: ImplItem = parse_quote! {
					type #ident = <#default_impl_path as #disambiguation_path>::#ident;
				};
				return Some(modified_item)
			}
			// copy uncolliding non-type items that have an ident
			Some(item)
		} else {
			// do not copy colliding items that lack an ident
			(!existing_unsupported_items.contains(&item))
				// copy uncolliding items without an ident verbatim
				.then_some(item)
		}
	});
	final_impl.items.extend(extended_items);
	final_impl
}

/// Internal implementation behind [`#[derive_impl(..)]`](`macro@crate::derive_impl`).
///
/// `default_impl_path`: the module path of the external `impl` statement whose tokens we are
///	                     importing via `macro_magic`
///
/// `foreign_tokens`: the tokens for the external `impl` statement

Review comment (suggestion):
```suggestion
				if let Ok(Some(PalletAttr { typ: PalletAttrType::Verbatim(_) })) = take_first_item_pallet_attr::<PalletAttr>(&mut item)
				{
					let modified_item: ImplItem = parse_quote! {
						type #ident = #ident;
					};
					return Some(modified_item)
				},
```

Code after:
			.items
			.iter()
			.cloned()
			.partition(|impl_item| impl_item_ident(impl_item).is_some());
	let existing_local_keys: HashSet<Ident> = existing_local_keys
		.into_iter()
		.filter_map(|item| impl_item_ident(&item).cloned())
		.collect();
	let mut final_impl = local_impl;
	let extended_items = foreign_impl.items.into_iter().filter_map(|item| {
		if let Some(ident) = impl_item_ident(&item) {
			if existing_local_keys.contains(&ident) {
				// do not copy colliding items that have an ident
				return None
			}
			if let ImplItem::Type(typ) = item.clone() {
				let mut typ = typ.clone();
				if let Ok(Some(PalletAttr { typ: PalletAttrType::RuntimeType(_), .. })) =
					get_first_item_pallet_attr::<PalletAttr>(&mut typ)
				{
					let item: ImplItem = if inject_runtime_types {
						parse_quote! {
							type #ident = #ident;
						}
					} else {
						item
					};
					return Some(item)
				}
				// modify and insert uncolliding type items
				let modified_item: ImplItem = parse_quote! {
					type #ident = <#default_impl_path as #disambiguation_path>::#ident;
				};
				return Some(modified_item)
			}
			// copy uncolliding non-type items that have an ident
			Some(item)
		} else {
			// do not copy colliding items that lack an ident
			(!existing_unsupported_items.contains(&item))
				// copy uncolliding items without an ident verbatim
				.then_some(item)
		}
	});
	final_impl.items.extend(extended_items);
	final_impl
}

/// Internal implementation behind [`#[derive_impl(..)]`](`macro@crate::derive_impl`).
///
/// `default_impl_path`: the module path of the external `impl` statement whose tokens we are