Repository navigation
use thiserror + more translations - #16116
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
1 open issue
What changed in this PR
This PR migrates several error types across uucore and utilities to thiserror while expanding localization coverage for newly translated error messages.
Changes:
- Replace manual
Display/Errorimpls with#[derive(thiserror::Error)]and localized#[error(...)]messages - Add new Fluent translations for backup control, OsStr conversion, and mv hardlink errors (EN/FR)
- Update backup-control tests to initialize localization so translated messages resolve to English strings in test assertions
| File | Description |
|---|---|
| src/uucore/src/lib/lib.rs | Localize NonUtf8OsStrError via thiserror derive and translate!. |
| src/uucore/src/lib/features/ranges.rs | Convert RangeError to thiserror with message passthrough. |
| src/uucore/src/lib/features/parser/parse_size.rs | Convert ParseSizeError to thiserror; remove deprecated/manual error impls. |
| src/uucore/src/lib/features/mode.rs | Convert ModeError to thiserror with message passthrough. |
| src/uucore/src/lib/features/format/mod.rs | Convert FormatError to thiserror and move localized formatting into #[error] attributes. |
| src/uucore/src/lib/features/backup_control.rs | Convert BackupError to thiserror, localize messages, and adjust tests to load localization. |
| src/uucore/locales/fr-FR.ftl | Add FR translations for backup control + OsStr conversion errors. |
| src/uucore/locales/en-US.ftl | Add EN translations for backup control + OsStr conversion errors. |
| src/uu/tsort/src/tsort.rs | Convert LoopNode error type to thiserror. |
| src/uu/split/src/number.rs | Convert Overflow error type to thiserror and localize message. |
| src/uu/mv/src/hardlink.rs | Convert HardlinkError to thiserror and localize error messages. |
| src/uu/mv/locales/fr-FR.ftl | Add FR translations for hardlink preservation errors. |
| src/uu/mv/locales/en-US.ftl | Add EN translations for hardlink preservation errors. |
Review effort: Lite
|
|
||
| /// The error messages go through `translate!`, which needs the English | ||
| /// strings loaded to give back more than the message key. | ||
| fn load_english_messages() { | ||
| // SAFETY: test-only; like the uptime tests, it always sets the same value. | ||
| unsafe { | ||
| env::set_var("LANG", "en_US.UTF-8"); | ||
| } | ||
| let _ = crate::locale::setup_localization("mv"); |
Merging this PR will regress 7 benchmarks1 warning, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|

No description provided.