Skip to content

refactor: use fully-qualified syntax for Error types#12037

Open
xtqqczze wants to merge 4 commits intouutils:mainfrom
xtqqczze:error-import
Open

refactor: use fully-qualified syntax for Error types#12037
xtqqczze wants to merge 4 commits intouutils:mainfrom
xtqqczze:error-import

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@xtqqczze xtqqczze commented Apr 27, 2026

  • Replace direct imports of Error types from external crates with locally defined or fully qualified error handling paths.
  • Improve maintainability and refactor safety

cc: @cakebaker

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/printf/printf-surprise is now passing!
Skip an intermittent issue tests/cut/bounded-memory (was skipped on 'main', now failing)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 27, 2026

Merging this PR will not alter performance

✅ 311 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing xtqqczze:error-import (a38a2d6) with main (5316f58)

Open in CodSpeed

Footnotes

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

@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
Copy link
Copy Markdown

Copilot AI left a comment

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
@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
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