summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-28 10:11:20 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:13 +0300
commit800ccc2149d018d5e29c25e89265c563885f32d0 (patch)
treed3ffd9a88de7d7932ecfa5162a5c54c59d91e9b6
parent18ab269a0e6967d78df8527679f2479c39650250 (diff)
Allow ::new to not return Self
It is Rust custom that the new method for a type returns an instance of that type. However, sometimes that's not wanted. Tell clippy that these cases are OK. I opted to not do this globally, because that would prevent clippy from catching future cases. Found by clippy warning new_ret_no_self: https://rust-lang.github.io/rust-clippy/master/index.html#new_ret_no_self
-rw-r--r--buffered-reader/src/file_error.rs1
-rw-r--r--openpgp/src/crypto/backend/nettle/symmetric.rs1
-rw-r--r--openpgp/src/serialize/stream.rs1
-rw-r--r--openpgp/src/serialize/stream/dash_escape.rs1
-rw-r--r--openpgp/src/serialize/stream/partial_body.rs1
-rw-r--r--openpgp/src/serialize/stream/trim_whitespace.rs1
-rw-r--r--openpgp/src/serialize/stream/writer/mod.rs5
-rw-r--r--openpgp/src/serialize/stream/writer/writer_bzip2.rs1
-rw-r--r--openpgp/src/serialize/stream/writer/writer_deflate.rs2
9 files changed, 14 insertions, 0 deletions
diff --git a/buffered-reader/src/file_error.rs b/buffered-reader/src/file_error.rs
index eba444cd..add00e6b 100644
--- a/buffered-reader/src/file_error.rs
+++ b/buffered-reader/src/file_error.rs
@@ -12,6 +12,7 @@ pub(crate) struct FileError {
source: io::Error,
}
+#[allow(clippy::new_ret_no_self)]
impl FileError {
/// Returns a new `io::Error` backed by a `FileError`.
pub fn new<P: AsRef<Path>>(path: P, source: io::Error) -> io::Error {
diff --git a/openpgp/src/crypto/backend/nettle/symmetric.rs b/openpgp/src/crypto/backend/nettle/symmetric.rs
index b75eaa0d..b9dd2703 100644
--- a/openpgp/src/crypto/backend/nettle/symmetric.rs
+++ b/openpgp/src/crypto/backend/nettle/symmetric.rs
@@ -13,6 +13,7 @@ struct ModeWrapper<M>
iv: Protected,
}
+#[allow(clippy::new_ret_no_self)]
impl<M> ModeWrapper<M>
where
M: nettle::mode::Mode + Send + Sync + 'static,
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs
index cbfa1117..019138b3 100644
--- a/openpgp/src/serialize/stream.rs
+++ b/openpgp/src/serialize/stream.rs
@@ -530,6 +530,7 @@ pub struct ArbitraryWriter<'a> {
}
assert_send_and_sync!(ArbitraryWriter<'_>);
+#[allow(clippy::new_ret_no_self)]
impl<'a> ArbitraryWriter<'a> {
/// Creates a new writer with the given tag.
///
diff --git a/openpgp/src/serialize/stream/dash_escape.rs b/openpgp/src/serialize/stream/dash_escape.rs
index b34cb314..35d6acf0 100644
--- a/openpgp/src/serialize/stream/dash_escape.rs
+++ b/openpgp/src/serialize/stream/dash_escape.rs
@@ -33,6 +33,7 @@ pub(super) struct DashEscapeFilter<'a, C: 'a> {
}
assert_send_and_sync!(DashEscapeFilter<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> DashEscapeFilter<'a, Cookie> {
/// Returns a new filter applying dash-escaping to all lines.
pub fn new(inner: Message<'a>, cookie: Cookie)
diff --git a/openpgp/src/serialize/stream/partial_body.rs b/openpgp/src/serialize/stream/partial_body.rs
index 298b97d2..c12a4218 100644
--- a/openpgp/src/serialize/stream/partial_body.rs
+++ b/openpgp/src/serialize/stream/partial_body.rs
@@ -52,6 +52,7 @@ const PARTIAL_BODY_FILTER_MAX_CHUNK_SIZE : usize = 1 << 30;
// lots of small partial body packets, which is annoying.
const PARTIAL_BODY_FILTER_BUFFER_THRESHOLD : usize = 4 * 1024 * 1024;
+#[allow(clippy::new_ret_no_self)]
impl<'a> PartialBodyFilter<'a, Cookie> {
/// Returns a new partial body encoder.
pub fn new(inner: Message<'a>, cookie: Cookie)
diff --git a/openpgp/src/serialize/stream/trim_whitespace.rs b/openpgp/src/serialize/stream/trim_whitespace.rs
index b77d9951..86e9791a 100644
--- a/openpgp/src/serialize/stream/trim_whitespace.rs
+++ b/openpgp/src/serialize/stream/trim_whitespace.rs
@@ -33,6 +33,7 @@ pub(super) struct TrailingWSFilter<'a, C: 'a> {
}
assert_send_and_sync!(TrailingWSFilter<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> TrailingWSFilter<'a, Cookie> {
/// Returns a new filter trimming spaces and tabs from lines.
pub fn new(inner: Message<'a>, cookie: Cookie)
diff --git a/openpgp/src/serialize/stream/writer/mod.rs b/openpgp/src/serialize/stream/writer/mod.rs
index 9b1de127..6141cfa6 100644
--- a/openpgp/src/serialize/stream/writer/mod.rs
+++ b/openpgp/src/serialize/stream/writer/mod.rs
@@ -191,6 +191,7 @@ pub struct Identity<'a, C> {
}
assert_send_and_sync!(Identity<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> Identity<'a, Cookie> {
/// Makes an identity writer.
pub fn new(inner: Message<'a>, cookie: Cookie)
@@ -272,6 +273,7 @@ pub struct Generic<W: io::Write + Send + Sync, C> {
}
assert_send_and_sync!(Generic<W, C> where W: io::Write, C);
+#[allow(clippy::new_ret_no_self)]
impl<'a, W: 'a + io::Write + Send + Sync> Generic<W, Cookie> {
/// Wraps an `io::Write`r.
pub fn new(inner: W, cookie: Cookie) -> Message<'a> {
@@ -357,6 +359,7 @@ pub struct Armorer<'a, C: 'a> {
}
assert_send_and_sync!(Armorer<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> Armorer<'a, Cookie> {
/// Makes an armoring writer.
pub fn new<I, K, V>(inner: Message<'a>, cookie: Cookie,
@@ -430,6 +433,7 @@ pub struct Encryptor<'a, C: 'a> {
}
assert_send_and_sync!(Encryptor<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> Encryptor<'a, Cookie> {
/// Makes an encrypting writer.
pub fn new(inner: Message<'a>, cookie: Cookie, algo: SymmetricAlgorithm,
@@ -502,6 +506,7 @@ pub struct AEADEncryptor<'a, C: 'a> {
}
assert_send_and_sync!(AEADEncryptor<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> AEADEncryptor<'a, Cookie> {
/// Makes an encrypting writer.
pub fn new(inner: Message<'a>, cookie: Cookie,
diff --git a/openpgp/src/serialize/stream/writer/writer_bzip2.rs b/openpgp/src/serialize/stream/writer/writer_bzip2.rs
index 7db8cf89..f30605d5 100644
--- a/openpgp/src/serialize/stream/writer/writer_bzip2.rs
+++ b/openpgp/src/serialize/stream/writer/writer_bzip2.rs
@@ -12,6 +12,7 @@ pub struct BZ<'a, C: 'a> {
}
assert_send_and_sync!(BZ<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> BZ<'a, Cookie> {
/// Makes a BZ compressing writer.
pub fn new<L>(inner: Message<'a>, cookie: Cookie, level: L) -> Message<'a>
diff --git a/openpgp/src/serialize/stream/writer/writer_deflate.rs b/openpgp/src/serialize/stream/writer/writer_deflate.rs
index e254e49c..1be85d15 100644
--- a/openpgp/src/serialize/stream/writer/writer_deflate.rs
+++ b/openpgp/src/serialize/stream/writer/writer_deflate.rs
@@ -12,6 +12,7 @@ pub struct ZIP<'a, C: 'a> {
}
assert_send_and_sync!(ZIP<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> ZIP<'a, Cookie> {
/// Makes a ZIP compressing writer.
pub fn new<L>(inner: Message<'a>, cookie: Cookie, level: L) -> Message<'a>
@@ -81,6 +82,7 @@ pub struct ZLIB<'a, C: 'a> {
}
assert_send_and_sync!(ZLIB<'_, C> where C);
+#[allow(clippy::new_ret_no_self)]
impl<'a> ZLIB<'a, Cookie> {
/// Makes a ZLIB compressing writer.
pub fn new<L>(inner: Message<'a>, cookie: Cookie, level: L) -> Message<'a>