Skip to content

refactor: avoid thiserror::Error imports - #12037

Draft
xtqqczze wants to merge 1 commit into
uutils:mainfrom
xtqqczze:error-import
Draft

xtqqczze wants to merge 1 commit into
uutils:mainfrom
xtqqczze:error-import

Conversation

@xtqqczze

@xtqqczze xtqqczze commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Avoid importing Error from thiserror directly and prefer fully-qualified paths.

@github-actions

github-actions Bot commented Apr 27, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)

@codspeed

codspeed Bot commented Apr 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 377 untouched benchmarks
⏩ 54 skipped benchmarks1


Comparing xtqqczze:error-import (df3a2b5) with main (ea21b10)2

Open in CodSpeed

Footnotes

  1. 54 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.

  2. No successful run was found on main (47df573) during the generation of this report, so ea21b10 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@xtqqczze
xtqqczze marked this pull request as ready for review April 27, 2026 16:12
@sylvestre
sylvestre requested a review from Copilot April 28, 2026 07:30

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.

Pull request overview

This PR refactors error-related imports and trait paths to reduce reliance on importing Error types directly (from std, clap, and thiserror), favoring fully-qualified paths and core::error::Error where applicable to improve refactor-safety.

Changes:

  • Replace use ... Error imports with fully-qualified references (e.g., std::io::Error::..., clap::error::Error).
  • Update many custom error derives to #[derive(..., thiserror::Error)] without importing thiserror::Error.
  • Switch various trait bounds/return types/impls from std::error::Error to core::error::Error.

Reviewed changes

Copilot reviewed 76 out of 76 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/by-util/test_cat.rs Avoid importing std::io::Error; use fully-qualified constructor.
src/uucore/src/lib/mods/locale.rs Remove thiserror::Error import; use thiserror::Error in derive path.
src/uucore/src/lib/mods/error.rs Prefer core::error::Error in docs/trait bounds/impls to avoid std::error::Error import.
src/uucore/src/lib/mods/clap_localization.rs Bring core::error::Error trait into scope without naming conflicts.
src/uucore/src/lib/lib.rs Implement core::error::Error for a local error type.
src/uucore/src/lib/features/uptime.rs Remove thiserror::Error import; qualify derive.
src/uucore/src/lib/features/systemd_logind.rs Return Box<dyn core::error::Error> instead of std path.
src/uucore/src/lib/features/smack.rs Remove thiserror::Error import; qualify derive.
src/uucore/src/lib/features/selinux.rs Use core::error::Error in error-chain formatting API.
src/uucore/src/lib/features/safe_traversal.rs Normalize derive order with qualified thiserror::Error.
src/uucore/src/lib/features/perms.rs Avoid importing std::io::Error alias; fully qualify last_os_error.
src/uucore/src/lib/features/parser/parse_size.rs Implement core::error::Error instead of importing std::error::Error.
src/uucore/src/lib/features/fsext.rs Remove IOError alias; fully qualify std::io::Error::last_os_error.
src/uucore/src/lib/features/fs.rs Avoid importing std::io::Error; use fully-qualified constructors.
src/uucore/src/lib/features/format/mod.rs Implement core::error::Error without importing std::error::Error.
src/uucore/src/lib/features/entries.rs Remove IOError alias; fully qualify std::io::Error constructors.
src/uucore/src/lib/features/checksum/mod.rs Remove thiserror::Error import; qualify derive.
src/uucore/src/lib/features/buf_copy/common.rs Implement core::error::Error for local error type.
src/uucore/src/lib/features/backup_control.rs Implement core::error::Error without importing std::error::Error.
src/uucore/build.rs Use Box<dyn core::error::Error> for build-script error types.
src/uu/wc/src/wc.rs Remove thiserror::Error import; qualify derive.
src/uu/wc/src/utf8/read.rs Remove thiserror::Error import; qualify derive.
src/uu/uptime/src/uptime.rs Remove thiserror::Error import; qualify derive.
src/uu/uniq/src/uniq.rs Avoid importing clap’s Error; use fully-qualified clap::error::Error.
src/uu/unexpand/src/unexpand.rs Remove thiserror::Error import; qualify derive.
src/uu/tsort/src/tsort.rs Remove thiserror::Error import; qualify derive.
src/uu/tr/src/operation.rs Implement core::error::Error without importing std::error::Error.
src/uu/touch/src/touch.rs Avoid importing std::io::Error; use fully-qualified constructors.
src/uu/touch/src/error.rs Remove thiserror::Error import; qualify derive.
src/uu/test/src/error.rs Remove thiserror::Error import; qualify derive.
src/uu/tee/src/tee.rs Avoid importing std::io::Error; fully qualify error creation and parameter types.
src/uu/tac/src/error.rs Remove thiserror::Error import; qualify derive.
src/uu/stdbuf/src/stdbuf.rs Remove thiserror::Error import; qualify derive.
src/uu/stat/src/stat.rs Remove thiserror::Error import; qualify derive.
src/uu/split/src/strategy.rs Remove thiserror::Error import; qualify derive.
src/uu/split/src/split.rs Remove thiserror::Error import; qualify derive.
src/uu/split/src/platform/windows.rs Avoid importing std::io::Error; fully qualify Error::other.
src/uu/split/src/platform/unix.rs Avoid importing std::io::Error; fully qualify Error::other.
src/uu/split/src/number.rs Implement core::error::Error without importing std::error::Error.
src/uu/split/src/filenames.rs Remove thiserror::Error import; qualify derive.
src/uu/sort/src/sort.rs Remove thiserror::Error import; qualify derive.
src/uu/seq/src/error.rs Remove thiserror::Error import; qualify derive.
src/uu/runcon/src/errors.rs Use core::error::Error for error-chain formatting and impls.
src/uu/rm/src/rm.rs Remove thiserror::Error import; qualify derive.
src/uu/ptx/src/ptx.rs Remove thiserror::Error import; qualify derive.
src/uu/pr/src/pr.rs Remove thiserror::Error import; qualify derive.
src/uu/od/src/mockstream.rs Avoid importing std::io::Error; use fully-qualified constructor.
src/uu/numfmt/src/numfmt.rs Avoid importing std::io::Error; use fully-qualified error type and constructor.
src/uu/numfmt/src/errors.rs Remove thiserror::Error import; qualify derive.
src/uu/nohup/src/nohup.rs Avoid importing std::io::Error; fully qualify error types and last_os_error.
src/uu/mv/src/hardlink.rs Implement core::error::Error and update source() signature accordingly.
src/uu/mv/src/error.rs Remove thiserror::Error import; qualify derive.
src/uu/more/src/more.rs Implement core::error::Error for local error type.
src/uu/mktemp/src/mktemp.rs Remove thiserror::Error import; qualify derive.
src/uu/ls/src/ls.rs Remove thiserror::Error import; qualify derive.
src/uu/ln/src/ln.rs Remove thiserror::Error import; qualify derive.
src/uu/kill/src/kill.rs Avoid importing std::io::Error; fully qualify from_raw_os_error.
src/uu/join/src/join.rs Remove thiserror::Error import; qualify derive.
src/uu/install/src/install.rs Remove thiserror::Error import; qualify derive.
src/uu/head/src/head.rs Remove thiserror::Error import; qualify derive.
src/uu/groups/src/groups.rs Remove thiserror::Error import; qualify derive.
src/uu/fmt/src/fmt.rs Remove thiserror::Error import; qualify derive.
src/uu/expr/src/expr.rs Remove thiserror::Error import; qualify derive.
src/uu/expand/src/expand.rs Remove thiserror::Error import; qualify derive.
src/uu/env/src/env.rs Remove thiserror::Error import; qualify derive.
src/uu/du/src/du.rs Remove thiserror::Error import; qualify derive.
src/uu/df/src/df.rs Remove thiserror::Error import; qualify derive.
src/uu/df/src/columns.rs Remove thiserror::Error import; qualify derive.
src/uu/dd/src/parseargs.rs Remove thiserror::Error import; qualify derive.
src/uu/csplit/src/csplit_error.rs Remove thiserror::Error import; qualify derive.
src/uu/cp/src/cp.rs Remove thiserror::Error import; qualify derive and implement core::error::Error for BackupError.
src/uu/chroot/src/error.rs Avoid importing std::io::Error; fully qualify error types in variants and derive.
src/uu/chroot/src/chroot.rs Avoid importing std::io::Error; fully qualify last_os_error usage.
src/uu/chmod/src/chmod.rs Remove thiserror::Error import; qualify derive.
src/uu/chcon/src/errors.rs Remove thiserror::Error import; use core::error::Error for error-chain formatting.
src/uu/cat/src/cat.rs Remove thiserror::Error import; qualify derive.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/uucore/src/lib/features/fs.rs Outdated
@xtqqczze
xtqqczze marked this pull request as draft April 28, 2026 12:20
@xtqqczze xtqqczze changed the title refactor: avoid cross-crate Error type imports refactor: use fully-qualified paths for Error types Apr 29, 2026
@xtqqczze xtqqczze changed the title refactor: use fully-qualified paths for Error types refactor: use fully-qualified syntax for Error types Apr 29, 2026
@xtqqczze
xtqqczze marked this pull request as ready for review April 29, 2026 15:07
@xtqqczze
xtqqczze force-pushed the error-import branch 2 times, most recently from 75e617c to 38fd4d0 Compare May 14, 2026 12:06
@xtqqczze
xtqqczze marked this pull request as draft May 21, 2026 17:48
@xtqqczze

This comment was marked as outdated.

@xtqqczze

This comment was marked as outdated.

@xtqqczze
xtqqczze marked this pull request as ready for review May 24, 2026 03:02
@xtqqczze
xtqqczze marked this pull request as draft August 2, 2026 23:19
@xtqqczze xtqqczze changed the title refactor: use fully-qualified syntax for Error types refactor: avoid thiserror::Error imports Sep 19, 2026
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