From 22708052f9fa3f2623b42d1e9d3fbeb2f002f91d Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 18 Feb 2026 11:52:04 +0100 Subject: [PATCH 1/2] Correctly set the span of abstract type identifiers --- crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs | 7 +++++-- crates/cgp-macro-lib/src/cgp_fn/use_type.rs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs b/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs index dbcd2d0c..b69b2360 100644 --- a/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs +++ b/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs @@ -34,9 +34,12 @@ pub fn substitute_abstract_type( && let Some(replacement_ident) = type_spec.replace_ident(&ident) { let trait_path = &type_spec.trait_path; - out.extend(quote! { + + let replaced = quote! { < #context_type as #trait_path > :: #replacement_ident - }); + }; + + out.extend(replaced); replaced_ident = true; break; } diff --git a/crates/cgp-macro-lib/src/cgp_fn/use_type.rs b/crates/cgp-macro-lib/src/cgp_fn/use_type.rs index 1cf7aa0d..08901872 100644 --- a/crates/cgp-macro-lib/src/cgp_fn/use_type.rs +++ b/crates/cgp-macro-lib/src/cgp_fn/use_type.rs @@ -18,7 +18,9 @@ impl UseTypeSpec { pub fn replace_ident(&self, ident: &Ident) -> Option { for type_ident in &self.type_idents { if type_ident.replacement_ident() == ident { - return Some(type_ident.type_ident.clone()); + let mut new_ident = type_ident.type_ident.clone(); + new_ident.set_span(ident.span()); + return Some(new_ident); } } From ca709f010738af44ac9470bc12128175f16930d1 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 18 Feb 2026 11:53:37 +0100 Subject: [PATCH 2/2] Restore formatting --- crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs b/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs index b69b2360..b078e2d9 100644 --- a/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs +++ b/crates/cgp-macro-lib/src/cgp_fn/substitute_type.rs @@ -35,11 +35,10 @@ pub fn substitute_abstract_type( { let trait_path = &type_spec.trait_path; - let replaced = quote! { + out.extend(quote! { < #context_type as #trait_path > :: #replacement_ident - }; + }); - out.extend(replaced); replaced_ident = true; break; }