Skip to content

Commit fedd370

Browse files
allow unreachable code in a branch of a cfg_if_expr!
1 parent cb6dc8c commit fedd370

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

examples/write_dir.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,21 @@ fn real_main() -> i32 {
5151
#[cfg(feature = "bzip2")] => zip::CompressionMethod::Bzip2,
5252
_ => {
5353
println!("The `bzip2` feature is not enabled");
54-
std::process::exit(1);
54+
std::process::exit(1)
5555
}
5656
},
5757
CompressionMethod::Xz => cfg_if_expr! {
5858
#[cfg(feature = "xz")] => zip::CompressionMethod::Xz,
5959
_ => {
6060
println!("The `xz` feature is not enabled");
61-
std::process::exit(1);
61+
std::process::exit(1)
6262
}
6363
},
6464
CompressionMethod::Zstd => cfg_if_expr! {
6565
#[cfg(feature = "zstd")] => zip::CompressionMethod::Zstd,
6666
_ => {
6767
println!("The `zstd` feature is not enabled");
68-
std::process::exit(1);
68+
std::process::exit(1)
6969
}
7070
},
7171
};

src/macros.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ macro_rules! cfg_if_expr {
106106
$crate::cfg_if_expr! {
107107
@__items ();
108108
$(
109-
(( $i_meta ) ( return $i_val ; )) ,
109+
(( $i_meta ) (
110+
#[allow(unreachable_code)]
111+
return $i_val ;
112+
)) ,
110113
)+
111-
(() ( return $rem_val ; )) ,
114+
(() (
115+
#[allow(unreachable_code)]
116+
return $rem_val ;
117+
)) ,
112118
}
113119
})()
114120
};
@@ -121,7 +127,10 @@ macro_rules! cfg_if_expr {
121127
$crate::cfg_if_expr! {
122128
@__items ();
123129
$(
124-
(( $i_meta ) ( return $i_val ; )) ,
130+
(( $i_meta ) (
131+
#[allow(unreachable_code)]
132+
return $i_val ;
133+
)) ,
125134
)+
126135
}
127136
})()

src/read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ impl<'a, R: Read> CryptoReader<'a, R> {
172172
}
173173

174174
/// Returns `true` if the data is encrypted using AE2.
175+
#[allow(clippy::needless_return)]
175176
pub const fn is_ae2_encrypted(&self) -> bool {
176177
cfg_if! {
177178
if #[cfg(feature = "aes-crypto")] {
178-
#[allow(clippy::needless_return)]
179179
return matches!(
180180
self,
181181
CryptoReader::Aes {

0 commit comments

Comments
 (0)