Skip to content

use thiserror + more translations - #16116

Merged
sylvestre merged 9 commits into
uutils:mainfrom
sylvestre:tsort-split-thiserror
Nov 2, 2026
Merged

sylvestre merged 9 commits into
uutils:mainfrom
sylvestre:tsort-split-thiserror

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings November 1, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/Error impls 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

Comment on lines 531 to +539

/// 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");
@codspeed

codspeed Bot commented Nov 1, 2026

Copy link
Copy Markdown

Merging this PR will regress 7 benchmarks

1 warning, 1 note

⚠️ 121 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 3 improved benchmarks
❌ 7 regressed benchmarks
✅ 391 untouched benchmarks
⏩ 70 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory tee_stdin_file[10000000] 75.7 KB 78.7 KB -3.75%
❌ CPU Simulation cksum_default 32.4 ms 33.6 ms -3.7%
❌ Memory timer_expiry_latency[0.001] 85.9 KB 88.9 KB -3.32%
❌ Memory cat_default[10000] 87.5 KB 90.4 KB -3.26%
❌ CPU Simulation tee_stdin_file[10000000] 352.6 µs 364.1 µs -3.16%
❌ CPU Simulation cksum_multiple_files 49.2 ms 50.8 ms -3.05%
❌ Memory hostname_basic 93.8 KB 96.7 KB -3.05%
⚡ CPU Simulation mv_force_overwrite 154.4 ms 128.1 ms +20.58%
⚡ CPU Simulation cksum_crc32b 33.7 ms 32.4 ms +3.93%
⚡ CPU Simulation sort_long_line[10000] 1.1 ms 1 ms +3.33%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing sylvestre:tsort-split-thiserror (0b48f97) with main (9cc868b)

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@sylvestre
sylvestre merged commit 43eb620 into uutils:main Nov 2, 2026
230 of 232 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants