Repository: paritytech/substrate
File: frame/support/procedural/src/pallet/parse/pallet_struct.rs (Rust)

Code before:
		match self {
			Self::GenerateStore { span, .. } => *span,
			Self::WithoutStorageInfoTrait(span) => *span,
			Self::StorageVersion { span, .. } => *span,
		}
	}
}

impl syn::parse::Parse for PalletStructAttr {
	fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
		input.parse::<syn::Token![#]>()?;
		let content;
		syn::bracketed!(content in input);
		content.parse::<keyword::pallet>()?;
		content.parse::<syn::Token![::]>()?;

		let lookahead = content.lookahead1();
		if lookahead.peek(keyword::generate_store) {
			let span = content.parse::<keyword::generate_store>()?.span();

			let generate_content;
			syn::parenthesized!(generate_content in content);
			let vis = generate_content.parse::<syn::Visibility>()?;
			generate_content.parse::<syn::Token![trait]>()?;
			let mut keyword = generate_content.parse::<keyword::Store>()?;
			// set span of Store keyword same to attirbute macro `generate_store`
			// so that deprecated warning highlights use of macro.
			keyword.span = content.span();
			Ok(Self::GenerateStore { vis, keyword, span })
		} else if lookahead.peek(keyword::without_storage_info) {
			let span = content.parse::<keyword::without_storage_info>()?.span();
			Ok(Self::WithoutStorageInfoTrait(span))
		} else if lookahead.peek(keyword::storage_version) {
			let span = content.parse::<keyword::storage_version>()?.span();

			let version_content;
			syn::parenthesized!(version_content in content);
			let storage_version = version_content.parse::<syn::Path>()?;

			Ok(Self::StorageVersion { storage_version, span })
		} else {
			Err(lookahead.error())
		}
	}
}

impl PalletStructDef {
	pub fn try_from(
		attr_span: proc_macro2::Span,
		index: usize,
		item: &mut syn::Item,

Review comment (suggestion):
If anything, this `span` variable should be updated to the span of the entire attribute, and not by mutating the span of the `Store` keyword`.

In general, it's best not to modify the meaning of what the fields represent. A span in the keyword means a span for the keyword; modifying it to represent anything else to solve a problem is considered a hack.

Code after:
		match self {
			Self::GenerateStore { span, .. } => *span,
			Self::WithoutStorageInfoTrait(span) => *span,
			Self::StorageVersion { span, .. } => *span,
		}
	}
}

impl syn::parse::Parse for PalletStructAttr {
	fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
		input.parse::<syn::Token![#]>()?;
		let content;
		syn::bracketed!(content in input);
		content.parse::<keyword::pallet>()?;
		content.parse::<syn::Token![::]>()?;

		let lookahead = content.lookahead1();
		if lookahead.peek(keyword::generate_store) {
			content.parse::<keyword::generate_store>()?;
			let generate_content;
			syn::parenthesized!(generate_content in content);
			let vis = generate_content.parse::<syn::Visibility>()?;
			generate_content.parse::<syn::Token![trait]>()?;
			let keyword = generate_content.parse::<keyword::Store>()?;
			let span = content.span();
			Ok(Self::GenerateStore { vis, keyword, span })
		} else if lookahead.peek(keyword::without_storage_info) {
			let span = content.parse::<keyword::without_storage_info>()?.span();
			Ok(Self::WithoutStorageInfoTrait(span))
		} else if lookahead.peek(keyword::storage_version) {
			let span = content.parse::<keyword::storage_version>()?.span();

			let version_content;
			syn::parenthesized!(version_content in content);
			let storage_version = version_content.parse::<syn::Path>()?;

			Ok(Self::StorageVersion { storage_version, span })
		} else {
			Err(lookahead.error())
		}
	}
}

impl PalletStructDef {
	pub fn try_from(
		attr_span: proc_macro2::Span,
		index: usize,
		item: &mut syn::Item,
	) -> syn::Result<Self> {
		let item = if let syn::Item::Struct(item) = item {
			item