nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: zhiburt/tabled
Pull request #315 (2023-03-22 15:34:03)

fix(macro hygiene): use the absolute path in Tabled derive macro
and the caller doesn't need to import Tabled trait

zhiburt: Hi @zjp-CN thanks for the commitment.

Indeed you're correct.

PS: I actually encountered this issue a few days ago, and was perplexed... and didn't payed a necessary attention.

Patch:
diff --git a/tabled_derive/src/lib.rs b/tabled_derive/src/lib.rs
index e50a145..e1fa632 100644
--- a/tabled_derive/src/lib.rs
+++ b/tabled_derive/src/lib.rs
@@ -45,7 +45,7 @@ fn impl_tabled(ast: &DeriveInput) -> TokenStream {
     let name = &ast.ident;
     let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
     let expanded = quote! {
-        impl #impl_generics Tabled for #name #ty_generics #where_clause {
+        impl #impl_generics ::tabled::Tabled for #name #ty_generics #where_clause {
             const LENGTH: usize = #length;
 
             fn fields(&self) -> Vec<::std::borrow::Cow<'_, str>> {


Test patch:
diff --git a/tabled/tests/derive_test.rs b/tabled/tests/derive_test.rs
index 34ec8ca..d27e43e 100644
--- a/tabled/tests/derive_test.rs
+++ b/tabled/tests/derive_test.rs
@@ -1080,3 +1080,11 @@ fn test_skip_enum_0() {
     assert_eq!(Letters::Consonant('c').fields(), vec!["", "+"]);
     assert_eq!(Letters::Digit.fields(), vec!["", ""]);
 }
+
+mod __ {
+    #[test]
+    fn dont_import_the_trait() {
+        #[derive(tabled::Tabled)]
+        struct __;
+    }
+}