Skip to content

Commit b9edb1b

Browse files
nyurikworkingjubilee
authored andcommitted
Upgrade to 2021 ed and inline panics
Panics and asserts do not work the same way with inlined format args, so this updates all crates to 2021 edition.
1 parent 99faef8 commit b9edb1b

File tree

10 files changed

+22
-31
lines changed

10 files changed

+22
-31
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A library to acquire a stack trace (backtrace) at runtime in a Rust program.
1313
"""
1414
autoexamples = true
1515
autotests = true
16-
edition = "2018"
16+
edition = "2021"
1717
exclude = ["/ci/"]
1818

1919
[workspace]
@@ -118,12 +118,12 @@ required-features = ["std"]
118118
[[test]]
119119
name = "smoke"
120120
required-features = ["std"]
121-
edition = '2018'
121+
edition = '2021'
122122

123123
[[test]]
124124
name = "accuracy"
125125
required-features = ["std"]
126-
edition = '2018'
126+
edition = '2021'
127127

128128
[[test]]
129129
name = "concurrent-panics"

crates/as-if-std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "as-if-std"
33
version = "0.1.0"
44
authors = ["Alex Crichton <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66
publish = false
77

88
[lib]

crates/debuglink/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "debuglink"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[dependencies]
77
backtrace = { path = "../.." }

crates/dylib-dep/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dylib-dep"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55
authors = []
66
publish = false
77

crates/line-tables-only/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "line-tables-only"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55

66
[build-dependencies]
77
cc = "1.0"

crates/line-tables-only/src/lib.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#[cfg(test)]
22
mod tests {
3-
use std::path::Path;
43
use backtrace::Backtrace;
54
use libc::c_void;
5+
use std::path::Path;
66

77
pub type Callback = extern "C" fn(data: *mut c_void);
88

@@ -15,11 +15,12 @@ mod tests {
1515
unsafe { *(data as *mut Option<Backtrace>) = Some(bt) };
1616
}
1717

18-
fn assert_contains(backtrace: &Backtrace,
19-
expected_name: &str,
20-
expected_file: &str,
21-
expected_line: u32) {
22-
18+
fn assert_contains(
19+
backtrace: &Backtrace,
20+
expected_name: &str,
21+
expected_file: &str,
22+
expected_line: u32,
23+
) {
2324
let expected_file = Path::new(expected_file);
2425

2526
for frame in backtrace.frames() {
@@ -34,7 +35,7 @@ mod tests {
3435
}
3536
}
3637

37-
panic!("symbol {:?} not found in backtrace: {:?}", expected_name, backtrace);
38+
panic!("symbol {expected_name:?} not found in backtrace: {backtrace:?}");
3839
}
3940

4041
/// Verifies that when debug info includes only lines tables the generated

crates/macos_frames_test/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "macos_frames_test"
33
version = "0.1.0"
44
authors = ["Aaron Hill <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66

77
[dependencies.backtrace]
88
path = "../.."

crates/without_debuginfo/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "without_debuginfo"
33
version = "0.1.0"
44
authors = ["Alex Crichton <[email protected]>"]
5-
edition = "2018"
5+
edition = "2021"
66

77
[dependencies.backtrace]
88
path = "../.."

tests/accuracy/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn verify(filelines: &[Pos]) {
103103
loop {
104104
let sym = match symbols.next() {
105105
Some(sym) => sym,
106-
None => panic!("failed to find {}:{}", file, line),
106+
None => panic!("failed to find {file}:{line}"),
107107
};
108108
if let Some(filename) = sym.filename() {
109109
if let Some(lineno) = sym.lineno() {

tests/smoke.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ fn smoke_test_frames() {
150150
if cfg!(debug_assertions) {
151151
assert!(
152152
name.contains(expected_name),
153-
"didn't find `{}` in `{}`",
154-
expected_name,
155-
name
153+
"didn't find `{expected_name}` in `{name}`"
156154
);
157155
}
158156

@@ -164,18 +162,13 @@ fn smoke_test_frames() {
164162
if !expected_file.is_empty() {
165163
assert!(
166164
file.ends_with(expected_file),
167-
"{:?} didn't end with {:?}",
168-
file,
169-
expected_file
165+
"{file:?} didn't end with {expected_file:?}"
170166
);
171167
}
172168
if expected_line != 0 {
173169
assert!(
174170
line == expected_line,
175-
"bad line number on frame for `{}`: {} != {}",
176-
expected_name,
177-
line,
178-
expected_line
171+
"bad line number on frame for `{expected_name}`: {line} != {expected_line}"
179172
);
180173
}
181174

@@ -185,10 +178,7 @@ fn smoke_test_frames() {
185178
if expected_col != 0 {
186179
assert!(
187180
col == expected_col,
188-
"bad column number on frame for `{}`: {} != {}",
189-
expected_name,
190-
col,
191-
expected_col
181+
"bad column number on frame for `{expected_name}`: {col} != {expected_col}",
192182
);
193183
}
194184
}

0 commit comments

Comments
 (0)