Skip to content

Commit fa9f629

Browse files
committed
Fix forward compatibility of panicking
The panic macro will change in edition2021 such that it is consistent between core and std. Currently, only one permits a single formattable value as the only argument. Instead, it will work more like write and format itself. This also means that format itself is unnecessary. Fixed like it should be suggested for: rust-lang/rust#82110
1 parent 450787d commit fa9f629

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/codecs/webp/vp8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ impl<R: Read> Vp8Decoder<R> {
14361436
i16::from(DCT_CAT_BASE[(category - DCT_CAT1) as usize]) + extra
14371437
}
14381438

1439-
c => panic!(format!("unknown token: {}", c)),
1439+
c => panic!("unknown token: {}", c),
14401440
});
14411441

14421442
skip = false;

tests/reference_images.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn render_images() {
5454
println!("UNSUPPORTED {}: {}", path.display(), e);
5555
return;
5656
}
57-
Err(err) => panic!(format!("decoding of {:?} failed with: {}", path, err)),
57+
Err(err) => panic!("decoding of {:?} failed with: {}", path, err),
5858
};
5959
let mut crc = Crc32::new();
6060
crc.update(&*img);
@@ -161,7 +161,7 @@ fn check_references() {
161161
// This might happen because the testsuite contains unsupported images
162162
// or because a specific decoder included via a feature.
163163
Err(image::ImageError::Unsupported(_)) => return,
164-
Err(err) => panic!(format!("{}", err)),
164+
Err(err) => panic!("{}", err),
165165
};
166166

167167
let (filename, testsuite) = {
@@ -199,17 +199,17 @@ fn check_references() {
199199
Ok(decoder) => decoder,
200200
Err(image::ImageError::Unsupported(_)) => return,
201201
Err(err) => {
202-
panic!(format!("decoding of {:?} failed with: {}", img_path, err))
202+
panic!("decoding of {:?} failed with: {}", img_path, err)
203203
}
204204
};
205205

206206
let mut frames = match decoder.into_frames().collect_frames() {
207207
Ok(frames) => frames,
208208
Err(image::ImageError::Unsupported(_)) => return,
209-
Err(err) => panic!(format!(
209+
Err(err) => panic!(
210210
"collecting frames of {:?} failed with: {}",
211211
img_path, err
212-
)),
212+
),
213213
};
214214

215215
// Select a single frame
@@ -228,17 +228,17 @@ fn check_references() {
228228
Ok(decoder) => decoder.apng(),
229229
Err(image::ImageError::Unsupported(_)) => return,
230230
Err(err) => {
231-
panic!(format!("decoding of {:?} failed with: {}", img_path, err))
231+
panic!("decoding of {:?} failed with: {}", img_path, err)
232232
}
233233
};
234234

235235
let mut frames = match decoder.into_frames().collect_frames() {
236236
Ok(frames) => frames,
237237
Err(image::ImageError::Unsupported(_)) => return,
238-
Err(err) => panic!(format!(
238+
Err(err) => panic!(
239239
"collecting frames of {:?} failed with: {}",
240240
img_path, err
241-
)),
241+
),
242242
};
243243

244244
// Select a single frame
@@ -262,7 +262,7 @@ fn check_references() {
262262
// This might happen because the testsuite contains unsupported images
263263
// or because a specific decoder included via a feature.
264264
Err(image::ImageError::Unsupported(_)) => return,
265-
Err(err) => panic!(format!("decoding of {:?} failed with: {}", img_path, err)),
265+
Err(err) => panic!("decoding of {:?} failed with: {}", img_path, err),
266266
};
267267
}
268268
}

0 commit comments

Comments
 (0)