What changed, and why it matters
This commit only turns on a code-style lint (clippy::use_self) and updates a few return types and constructor calls to use the preferred 'Self' shorthand. It does not change behavior, fix a bug, or alter any security-relevant logic.
No security action needed. Treat as a normal code-quality/style change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds use_self = "warn" in io/Cargo.toml and mechanically replaces explicit type names (Error, Cursor, std::io::Error) with Self in return types and constructors. These are purely idiomatic refactorings with no functional or security impact.
Changed components
io/src/error.rsio/src/lib.rsio/Cargo.tomlInspect captured patch +10 / −7
diff --git a/io/Cargo.toml b/io/Cargo.toml
index e29e6cd4..6faf58d4 100644
--- a/io/Cargo.toml
+++ b/io/Cargo.toml
@@ -33,3 +33,6 @@ rustdoc-args = ["--cfg", "docsrs"]
[lints.rust]
unexpected_cfgs = { level = "deny" }
+
+[lints.clippy]
+use_self = "warn"
diff --git a/io/src/error.rs b/io/src/error.rs
index a79725cf..61a574d5 100644
--- a/io/src/error.rs
+++ b/io/src/error.rs
@@ -24,7 +24,7 @@ pub struct Error {
impl Error {
/// Constructs a new I/O error.
#[cfg(feature = "std")]
- pub fn new<E>(kind: ErrorKind, error: E) -> Error
+ pub fn new<E>(kind: ErrorKind, error: E) -> Self
where
E: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
{
@@ -33,7 +33,7 @@ impl Error {
/// Constructs a new I/O error.
#[cfg(all(feature = "alloc", not(feature = "std")))]
- pub fn new<E: sealed::IntoBoxDynDebug>(kind: ErrorKind, error: E) -> Error {
+ pub fn new<E: sealed::IntoBoxDynDebug>(kind: ErrorKind, error: E) -> Self {
Self { kind, _not_unwind_safe: core::marker::PhantomData, error: Some(error.into()) }
}
@@ -54,7 +54,7 @@ impl Error {
}
impl From<ErrorKind> for Error {
- fn from(kind: ErrorKind) -> Error {
+ fn from(kind: ErrorKind) -> Self {
Self {
kind,
_not_unwind_safe: core::marker::PhantomData,
@@ -84,7 +84,7 @@ impl std::error::Error for Error {
#[cfg(feature = "std")]
impl From<std::io::Error> for Error {
- fn from(o: std::io::Error) -> Error {
+ fn from(o: std::io::Error) -> Self {
Self {
kind: ErrorKind::from_std(o.kind()),
_not_unwind_safe: core::marker::PhantomData,
@@ -95,9 +95,9 @@ impl From<std::io::Error> for Error {
#[cfg(feature = "std")]
impl From<Error> for std::io::Error {
- fn from(o: Error) -> std::io::Error {
+ fn from(o: Error) -> Self {
if let Some(err) = o.error {
- std::io::Error::new(o.kind.to_std(), err)
+ Self::new(o.kind.to_std(), err)
} else {
o.kind.to_std().into()
}
diff --git a/io/src/lib.rs b/io/src/lib.rs
index d2d4ee00..78f21f2a 100644
--- a/io/src/lib.rs
+++ b/io/src/lib.rs
@@ -238,7 +238,7 @@ pub struct Cursor<T> {
impl<T: AsRef<[u8]>> Cursor<T> {
/// Constructs a new `Cursor` by wrapping `inner`.
#[inline]
- pub const fn new(inner: T) -> Self { Cursor { inner, pos: 0 } }
+ pub const fn new(inner: T) -> Self { Self { inner, pos: 0 } }
/// Returns the position read or written up to thus far.
#[inline]
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.