Skip to content

Commit

Permalink
Upgrade to 2021 ed and inline panics (#538)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
workingjubilee authored Aug 19, 2023
2 parents 99faef8 + 4b29163 commit a390aa7
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 31 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ A library to acquire a stack trace (backtrace) at runtime in a Rust program.
"""
autoexamples = true
autotests = true
edition = "2018"
edition = "2021"
exclude = ["/ci/"]
rust-version = "1.65.0"

[workspace]
members = ['crates/cpp_smoke_test', 'crates/as-if-std']
Expand Down Expand Up @@ -118,12 +119,12 @@ required-features = ["std"]
[[test]]
name = "smoke"
required-features = ["std"]
edition = '2018'
edition = '2021'

[[test]]
name = "accuracy"
required-features = ["std"]
edition = '2018'
edition = '2021'

[[test]]
name = "concurrent-panics"
Expand Down
2 changes: 1 addition & 1 deletion crates/as-if-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "as-if-std"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2018"
edition = "2021"
publish = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion crates/debuglink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "debuglink"
version = "0.1.0"
edition = "2018"
edition = "2021"

[dependencies]
backtrace = { path = "../.." }
2 changes: 1 addition & 1 deletion crates/dylib-dep/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dylib-dep"
version = "0.1.0"
edition = "2018"
edition = "2021"
authors = []
publish = false

Expand Down
2 changes: 1 addition & 1 deletion crates/line-tables-only/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "line-tables-only"
version = "0.1.0"
edition = "2018"
edition = "2021"

[build-dependencies]
cc = "1.0"
Expand Down
15 changes: 8 additions & 7 deletions crates/line-tables-only/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[cfg(test)]
mod tests {
use std::path::Path;
use backtrace::Backtrace;
use libc::c_void;
use std::path::Path;

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

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

fn assert_contains(backtrace: &Backtrace,
expected_name: &str,
expected_file: &str,
expected_line: u32) {

fn assert_contains(
backtrace: &Backtrace,
expected_name: &str,
expected_file: &str,
expected_line: u32,
) {
let expected_file = Path::new(expected_file);

for frame in backtrace.frames() {
Expand All @@ -34,7 +35,7 @@ mod tests {
}
}

panic!("symbol {:?} not found in backtrace: {:?}", expected_name, backtrace);
panic!("symbol {expected_name:?} not found in backtrace: {backtrace:?}");
}

/// Verifies that when debug info includes only lines tables the generated
Expand Down
2 changes: 1 addition & 1 deletion crates/macos_frames_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "macos_frames_test"
version = "0.1.0"
authors = ["Aaron Hill <[email protected]>"]
edition = "2018"
edition = "2021"

[dependencies.backtrace]
path = "../.."
2 changes: 1 addition & 1 deletion crates/without_debuginfo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "without_debuginfo"
version = "0.1.0"
authors = ["Alex Crichton <[email protected]>"]
edition = "2018"
edition = "2021"

[dependencies.backtrace]
path = "../.."
Expand Down
2 changes: 1 addition & 1 deletion tests/accuracy/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn verify(filelines: &[Pos]) {
loop {
let sym = match symbols.next() {
Some(sym) => sym,
None => panic!("failed to find {}:{}", file, line),
None => panic!("failed to find {file}:{line}"),
};
if let Some(filename) = sym.filename() {
if let Some(lineno) = sym.lineno() {
Expand Down
18 changes: 4 additions & 14 deletions tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,7 @@ fn smoke_test_frames() {
if cfg!(debug_assertions) {
assert!(
name.contains(expected_name),
"didn't find `{}` in `{}`",
expected_name,
name
"didn't find `{expected_name}` in `{name}`"
);
}

Expand All @@ -164,18 +162,13 @@ fn smoke_test_frames() {
if !expected_file.is_empty() {
assert!(
file.ends_with(expected_file),
"{:?} didn't end with {:?}",
file,
expected_file
"{file:?} didn't end with {expected_file:?}"
);
}
if expected_line != 0 {
assert!(
line == expected_line,
"bad line number on frame for `{}`: {} != {}",
expected_name,
line,
expected_line
"bad line number on frame for `{expected_name}`: {line} != {expected_line}"
);
}

Expand All @@ -185,10 +178,7 @@ fn smoke_test_frames() {
if expected_col != 0 {
assert!(
col == expected_col,
"bad column number on frame for `{}`: {} != {}",
expected_name,
col,
expected_col
"bad column number on frame for `{expected_name}`: {col} != {expected_col}",
);
}
}
Expand Down

0 comments on commit a390aa7

Please sign in to comment.