Skip to content

Commit 6f66428

Browse files
committed
refactor: avoid std::error::Error imports
1 parent 5316f58 commit 6f66428

17 files changed

Lines changed: 46 additions & 56 deletions

File tree

src/uu/chcon/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Error {
8686
}
8787
}
8888

89-
pub(crate) fn report_full_error(mut err: &dyn std::error::Error) -> String {
89+
pub(crate) fn report_full_error(mut err: &dyn core::error::Error) -> String {
9090
let mut desc = String::with_capacity(256);
9191
write!(desc, "{err}").unwrap();
9292
while let Some(source) = err.source() {

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl Display for BackupError {
128128
}
129129
}
130130

131-
impl std::error::Error for BackupError {}
131+
impl core::error::Error for BackupError {}
132132

133133
impl UError for CpError {
134134
fn code(&self) -> i32 {

src/uu/more/src/more.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl std::fmt::Display for MoreError {
7878
}
7979
}
8080

81-
impl std::error::Error for MoreError {}
81+
impl core::error::Error for MoreError {}
8282

8383
const BELL: char = '\x07'; // Printing this character will ring the bell
8484

src/uu/mv/src/hardlink.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ impl std::fmt::Display for HardlinkError {
7171
}
7272
}
7373

74-
impl std::error::Error for HardlinkError {
75-
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
74+
impl core::error::Error for HardlinkError {
75+
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
7676
match self {
7777
Self::Io(e) => Some(e),
7878
Self::Metadata { error, .. } => Some(error),

src/uu/runcon/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl Error {
8181
}
8282
}
8383

84-
pub(crate) fn write_full_error<W>(writer: &mut W, err: &dyn std::error::Error) -> std::fmt::Result
84+
pub(crate) fn write_full_error<W>(writer: &mut W, err: &dyn core::error::Error) -> std::fmt::Result
8585
where
8686
W: Write,
8787
{
@@ -110,7 +110,7 @@ impl RunconError {
110110
}
111111
}
112112

113-
impl std::error::Error for RunconError {}
113+
impl core::error::Error for RunconError {}
114114
impl UError for RunconError {
115115
fn code(&self) -> i32 {
116116
self.code

src/uu/split/src/number.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//!
1515
//! [radix]: https://en.wikipedia.org/wiki/Radix
1616
//! [positional notation]: https://en.wikipedia.org/wiki/Positional_notation
17-
use std::error::Error;
1817
use std::fmt::{self, Display, Formatter, Write};
1918
use uucore::translate;
2019

@@ -28,7 +27,7 @@ impl Display for Overflow {
2827
}
2928
}
3029

31-
impl Error for Overflow {}
30+
impl core::error::Error for Overflow {}
3231

3332
/// A number in arbitrary radix expressed in a positional notation.
3433
///

src/uu/tr/src/operation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use nom::{
1717
};
1818
use std::{
1919
char,
20-
error::Error,
2120
fmt::{Debug, Display},
2221
io::{BufRead, Write},
2322
};
@@ -136,7 +135,7 @@ impl Display for BadSequence {
136135
}
137136
}
138137

139-
impl Error for BadSequence {}
138+
impl core::error::Error for BadSequence {}
140139
impl UError for BadSequence {}
141140

142141
#[derive(Debug, Clone, Copy)]

src/uucore/build.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::fs::File;
88
use std::io::Write;
99
use std::path::{Path, PathBuf};
1010

11-
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
11+
pub fn main() -> Result<(), Box<dyn core::error::Error>> {
1212
let out_dir = env::var("OUT_DIR")?;
1313

1414
let mut embedded_file = File::create(Path::new(&out_dir).join("embedded_locales.rs"))?;
@@ -63,7 +63,7 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
6363
///
6464
/// Returns an error if the `CARGO_MANIFEST_DIR` environment variable is not set
6565
/// or if the current directory structure does not allow determining the project root.
66-
fn project_root() -> Result<PathBuf, Box<dyn std::error::Error>> {
66+
fn project_root() -> Result<PathBuf, Box<dyn core::error::Error>> {
6767
let manifest_dir = env::var("CARGO_MANIFEST_DIR")?;
6868
let uucore_path = Path::new(&manifest_dir);
6969

@@ -135,7 +135,7 @@ fn embed_single_utility_locale(
135135
project_root: &Path,
136136
util_name: &str,
137137
locales_to_embed: &(String, Option<String>),
138-
) -> Result<(), Box<dyn std::error::Error>> {
138+
) -> Result<(), Box<dyn core::error::Error>> {
139139
// Embed utility-specific locales
140140
embed_component_locales(embedded_file, locales_to_embed, util_name, |locale| {
141141
project_root
@@ -171,7 +171,7 @@ fn embed_all_utility_locales(
171171
embedded_file: &mut File,
172172
project_root: &Path,
173173
locales_to_embed: &(String, Option<String>),
174-
) -> Result<(), Box<dyn std::error::Error>> {
174+
) -> Result<(), Box<dyn core::error::Error>> {
175175
use std::fs;
176176

177177
// Discover all uu_* directories
@@ -221,7 +221,7 @@ fn embed_all_utility_locales(
221221
fn embed_static_utility_locales(
222222
embedded_file: &mut File,
223223
locales_to_embed: &(String, Option<String>),
224-
) -> Result<(), Box<dyn std::error::Error>> {
224+
) -> Result<(), Box<dyn core::error::Error>> {
225225
use std::env;
226226

227227
writeln!(
@@ -294,9 +294,9 @@ fn get_locales_to_embed() -> (String, Option<String>) {
294294
fn for_each_locale<F>(
295295
locales: &(String, Option<String>),
296296
mut f: F,
297-
) -> Result<(), Box<dyn std::error::Error>>
297+
) -> Result<(), Box<dyn core::error::Error>>
298298
where
299-
F: FnMut(&str) -> Result<(), Box<dyn std::error::Error>>,
299+
F: FnMut(&str) -> Result<(), Box<dyn core::error::Error>>,
300300
{
301301
f(&locales.0)?;
302302
if let Some(ref system_locale) = locales.1 {
@@ -317,7 +317,7 @@ fn embed_locale_file(
317317
locale_key: &str,
318318
locale: &str,
319319
component: &str,
320-
) -> Result<(), Box<dyn std::error::Error>> {
320+
) -> Result<(), Box<dyn core::error::Error>> {
321321
use std::fs;
322322

323323
if locale_path.exists() || locale_path.is_file() {
@@ -359,7 +359,7 @@ fn embed_all_locales_for_component<F>(
359359
embedded_file: &mut File,
360360
component_name: &str,
361361
path_builder: &F,
362-
) -> Result<(), Box<dyn std::error::Error>>
362+
) -> Result<(), Box<dyn core::error::Error>>
363363
where
364364
F: Fn(&str) -> PathBuf,
365365
{
@@ -391,7 +391,7 @@ fn embed_component_locales<F>(
391391
locales: &(String, Option<String>),
392392
component_name: &str,
393393
path_builder: F,
394-
) -> Result<(), Box<dyn std::error::Error>>
394+
) -> Result<(), Box<dyn core::error::Error>>
395395
where
396396
F: Fn(&str) -> PathBuf,
397397
{

src/uucore/src/lib/features/backup_control.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ use crate::{
8888
use clap::ArgMatches;
8989
use std::{
9090
env,
91-
error::Error,
9291
ffi::{OsStr, OsString},
9392
fmt::{Debug, Display},
9493
path::{Path, PathBuf},
@@ -169,7 +168,7 @@ impl UError for BackupError {
169168
}
170169
}
171170

172-
impl Error for BackupError {}
171+
impl core::error::Error for BackupError {}
173172

174173
impl Display for BackupError {
175174
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

src/uucore/src/lib/features/buf_copy/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl std::fmt::Display for Error {
2121
}
2222
}
2323

24-
impl std::error::Error for Error {}
24+
impl core::error::Error for Error {}
2525

2626
impl UError for Error {
2727
fn code(&self) -> i32 {

0 commit comments

Comments
 (0)