Skip to content

Commit 04bc555

Browse files
committed
.data.rs
1 parent 186f0f7 commit 04bc555

File tree

206 files changed

+703
-503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+703
-503
lines changed

provider/datagen/src/baked_exporter.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl BakedExporter {
193193
relative_path: P,
194194
data: TokenStream,
195195
) -> Result<(), DataError> {
196-
let path = self.mod_directory.join(&relative_path).with_extension("rs");
196+
let path = self.mod_directory.join(&relative_path);
197197

198198
let mut formatted = if self.pretty {
199199
use std::process::{Command, Stdio};
@@ -428,7 +428,7 @@ impl DataExporter for BakedExporter {
428428
);
429429
let prefixed_macro_ident = format!("__impl_{ident}").parse::<TokenStream>().unwrap();
430430
self.write_to_file(
431-
PathBuf::from(format!("macros/{}", ident)),
431+
PathBuf::from(format!("macros/{}.data.rs", ident)),
432432
quote!{
433433
#[doc = #doc]
434434
/// hardcoded in this file. This allows the struct to be used with
@@ -514,6 +514,10 @@ impl DataExporter for BakedExporter {
514514
.values()
515515
.map(|data| data.mod_ident.parse::<TokenStream>().unwrap())
516516
.collect::<Vec<_>>();
517+
let file_paths = data
518+
.values()
519+
.map(|data| format!("macros/{}.data.rs", data.mod_ident))
520+
.collect::<Vec<_>>();
517521

518522
// We prefix all macros with `__`, as these will be automatically exported at the crate root, which is annoying
519523
// for crates that include the data but don't want it to be public. We then reexport them as items that use
@@ -558,18 +562,13 @@ impl DataExporter for BakedExporter {
558562
};
559563

560564
self.write_to_file(
561-
PathBuf::from("macros"),
565+
PathBuf::from("macros.rs"),
562566
quote! {
563567

564-
#[macro_use]
565-
mod macros {
566-
#(
567-
#[macro_use]
568-
mod #mod_idents;
569-
)*
570-
}
571-
572568
#(
569+
#[macro_use]
570+
#[path = #file_paths]
571+
mod #mod_idents;
573572
#[doc(inline)]
574573
pub use #prefixed_macro_idents as #macro_idents;
575574
)*
@@ -624,7 +623,7 @@ impl DataExporter for BakedExporter {
624623

625624
// For backwards compatibility
626625
self.write_to_file(
627-
PathBuf::from("mod"),
626+
PathBuf::from("mod.rs"),
628627
quote! {
629628
include!("macros.rs");
630629
#[clippy::msrv = "1.61"]
@@ -635,7 +634,7 @@ impl DataExporter for BakedExporter {
635634

636635
// For backwards compatibility
637636
self.write_to_file(
638-
PathBuf::from("any"),
637+
PathBuf::from("any.rs"),
639638
quote! {
640639
// This assumes that `mod.rs` is already included.
641640
impl_any_provider!(BakedDataProvider);

0 commit comments

Comments
 (0)