Skip to content

Commit a390aa7

Browse files
Upgrade to 2021 ed and inline panics (#538)
Panics and asserts do not work the same way with inlined format args, so this updates all crates to 2021 edition. Signed-off-by: Yuri Astrakhan <[email protected]>
2 parents 99faef8 + 4b29163 commit a390aa7

File tree

10 files changed

+23
-31
lines changed

10 files changed

+23
-31
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ 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/"]
18+
rust-version = "1.65.0"
1819

1920
[workspace]
2021
members = ['crates/cpp_smoke_test', 'crates/as-if-std']
@@ -118,12 +119,12 @@ required-features = ["std"]
118119
[[test]]
119120
name = "smoke"
120121
required-features = ["std"]
121-
edition = '2018'
122+
edition = '2021'
122123

123124
[[test]]
124125
name = "accuracy"
125126
required-features = ["std"]
126-
edition = '2018'
127+
edition = '2021'
127128

128129
[[test]]
129130
name = "concurrent-panics"

crates/as-if-std/Cargo.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 8 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 14 deletions
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)