Skip to content

Commit

Permalink
Fix baked if rustfmt fails (#5102)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jun 21, 2024
1 parent ba0bcd1 commit 2de3123
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
21 changes: 16 additions & 5 deletions provider/baked/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,22 @@ impl BakedExporter {
};

if !self.use_separate_crates {
formatted = formatted
.replace("icu_", "icu::")
.replace("icu::provider", "icu_provider")
.replace("icu::locale_core", "icu_locale_core")
.replace("icu::pattern", "icu_pattern");
// Don't search the whole file, there should be a macro in the first 300 bytes
if formatted[..300].contains("macro_rules!") || formatted[..100].contains("include!") {
// Formatted, otherwise it'd be `macro_rules !`
formatted = formatted
.replace("icu_", "icu::")
.replace("icu::provider", "icu_provider")
.replace("icu::locale_core", "icu_locale_core")
.replace("icu::pattern", "icu_pattern");
} else {
// Unformatted
formatted = formatted
.replace("icu_", "icu :: ")
.replace("icu :: provider", "icu_provider")
.replace("icu :: locale_core", "icu_locale_core")
.replace("icu :: pattern", "icu_pattern");
}
}

std::fs::create_dir_all(path.parent().unwrap())?;
Expand Down

Large diffs are not rendered by default.

0 comments on commit 2de3123

Please sign in to comment.