@@ -149,6 +149,17 @@ macro_rules! static_sym {
149149/// Put a call to this macro somewhere in the root of each crate that uses the
150150/// `sym!(...)` macro.
151151///
152+ /// The second variant reuses the symbol table of another crate, and this is
153+ /// particularly needed due to the way external tests (in the `tests/`
154+ /// subdirectory of the project) are compiled. Test files `tests/foo.rs`, are
155+ /// compiled as "pseudo-crates", so they are semantically a separate crate from
156+ /// the main library crate. But they are compiled into the same binary, so just
157+ /// using `stringleton::enable!()` without arguments will cause linker errors
158+ /// (`duplicate #[distributed_slice] with name "TABLE"`).
159+ ///
160+ /// In external tests using [`sym!()`], the test file should instead use
161+ /// `stringleton::enable!(main_library_crate)`.
162+ ///
152163/// ## Details
153164///
154165/// This creates a "distributed slice" containing all symbols in this crate, as
@@ -184,11 +195,11 @@ macro_rules! enable {
184195 ( ) => {
185196 #[ doc( hidden) ]
186197 #[ cfg( not( any( miri, target_arch = "wasm32" ) ) ) ]
187- pub ( crate ) mod _stringleton_enabled {
198+ pub mod _stringleton_enabled {
188199 #[ $crate:: internal:: linkme:: distributed_slice]
189200 #[ linkme( crate = $crate:: internal:: linkme) ]
190201 #[ doc( hidden) ]
191- pub ( crate ) static TABLE : [ $crate:: internal:: Site ] = [ ..] ;
202+ pub static TABLE : [ $crate:: internal:: Site ] = [ ..] ;
192203
193204 $crate:: internal:: ctor:: declarative:: ctor! {
194205 #[ ctor]
@@ -207,10 +218,10 @@ macro_rules! enable {
207218 #[ cfg( not( any( miri, target_arch = "wasm32" ) ) ) ]
208219 pub use _stringleton_enabled:: _stringleton_register_symbols;
209220 } ;
210- ( $krate: path ) => {
221+ ( $( $ krate: tt ) + ) => {
211222 #[ doc( hidden) ]
212223 #[ cfg( not( any( miri, target_arch = "wasm32" ) ) ) ]
213- pub ( crate ) use $krate:: _stringleton_enabled;
224+ pub use $( $ krate) * :: _stringleton_enabled;
214225 } ;
215226}
216227
0 commit comments