diff --git a/build.rs b/build.rs index 9534a79b80d..53a7c0b7f86 100644 --- a/build.rs +++ b/build.rs @@ -62,11 +62,14 @@ pub fn main() { let mut mf = File::create(Path::new(&out_dir).join("uutils_map.rs")).unwrap(); mf.write_all( - "type UtilityMap = phf::OrderedMap<&'static str, (fn(T) -> i32, fn() -> Command)>;\n\ + "use ::clap::Command;\n\ + use ::uucore::Args;\n\ + \n\ + pub(crate) type UtilityMap = phf::OrderedMap<&'static str, (fn(T) -> i32, fn() -> Command)>;\n\ \n\ #[allow(clippy::too_many_lines)] #[allow(clippy::unreadable_literal)] - fn util_map() -> UtilityMap {\n" + pub(crate) fn util_map() -> UtilityMap {\n" .as_bytes(), ) .unwrap(); diff --git a/src/bin/coreutils.rs b/src/bin/coreutils.rs index 59634849a6b..d9e762ff6a3 100644 --- a/src/bin/coreutils.rs +++ b/src/bin/coreutils.rs @@ -3,19 +3,21 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use clap::Command; +mod uutils_map { + include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); +} + +use crate::uutils_map::UtilityMap; +use crate::uutils_map::util_map; use coreutils::validation; use itertools::Itertools as _; use std::cmp; use std::ffi::OsString; use std::io::{self, Write}; use std::process; -use uucore::Args; const VERSION: &str = env!("CARGO_PKG_VERSION"); -include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); - fn usage(utils: &UtilityMap, name: &str) { println!("{name} {VERSION} (multi-call binary)\n"); println!("Usage: {name} [function [arguments...]]"); diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs index 76f04774ec7..95389d2fefa 100644 --- a/src/bin/uudoc.rs +++ b/src/bin/uudoc.rs @@ -5,6 +5,10 @@ // spell-checker:ignore mangen tldr +mod uutils_map { + include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); +} + use std::{ collections::HashMap, ffi::OsString, @@ -21,11 +25,11 @@ use fluent_syntax::parser; use textwrap::{fill, indent, termwidth}; use zip::ZipArchive; +use crate::uutils_map::UtilityMap; +use crate::uutils_map::util_map; use coreutils::validation; use uucore::Args; -include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); - /// Print usage information for uudoc fn usage(utils: &UtilityMap) { println!("uudoc - Documentation generator for uutils coreutils"); diff --git a/src/uucore/src/lib/mods/locale.rs b/src/uucore/src/lib/mods/locale.rs index b670f897620..5998089c6af 100644 --- a/src/uucore/src/lib/mods/locale.rs +++ b/src/uucore/src/lib/mods/locale.rs @@ -4,7 +4,14 @@ // file that was distributed with this source code. // spell-checker:disable +#[expect(clippy::match_same_arms)] +mod embedded_locales { + // Include embedded locale files as fallback + include!(concat!(env!("OUT_DIR"), "/embedded_locales.rs")); +} + use crate::error::UError; +use crate::locale::embedded_locales::get_embedded_locale; use fluent::{FluentArgs, FluentBundle, FluentResource}; use fluent_syntax::parser::ParserError; @@ -59,9 +66,6 @@ impl UError for LocalizationError { pub const DEFAULT_LOCALE: &str = "en-US"; -// Include embedded locale files as fallback -include!(concat!(env!("OUT_DIR"), "/embedded_locales.rs")); - // A struct to handle localization with optional English fallback struct Localizer { primary_bundle: FluentBundle,