From b9edb1b31f98103a93e5b53fb3318a2681ac731a Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sun, 2 Jul 2023 15:41:27 +0200 Subject: [PATCH 1/2] 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. --- Cargo.toml | 6 +++--- crates/as-if-std/Cargo.toml | 2 +- crates/debuglink/Cargo.toml | 2 +- crates/dylib-dep/Cargo.toml | 2 +- crates/line-tables-only/Cargo.toml | 2 +- crates/line-tables-only/src/lib.rs | 15 ++++++++------- crates/macos_frames_test/Cargo.toml | 2 +- crates/without_debuginfo/Cargo.toml | 2 +- tests/accuracy/main.rs | 2 +- tests/smoke.rs | 18 ++++-------------- 10 files changed, 22 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6714b3b7d..03deefdb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ A library to acquire a stack trace (backtrace) at runtime in a Rust program. """ autoexamples = true autotests = true -edition = "2018" +edition = "2021" exclude = ["/ci/"] [workspace] @@ -118,12 +118,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" diff --git a/crates/as-if-std/Cargo.toml b/crates/as-if-std/Cargo.toml index bcbcfe159..1d8d066f1 100644 --- a/crates/as-if-std/Cargo.toml +++ b/crates/as-if-std/Cargo.toml @@ -2,7 +2,7 @@ name = "as-if-std" version = "0.1.0" authors = ["Alex Crichton "] -edition = "2018" +edition = "2021" publish = false [lib] diff --git a/crates/debuglink/Cargo.toml b/crates/debuglink/Cargo.toml index 6b55b1394..5e62abd37 100644 --- a/crates/debuglink/Cargo.toml +++ b/crates/debuglink/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "debuglink" version = "0.1.0" -edition = "2018" +edition = "2021" [dependencies] backtrace = { path = "../.." } diff --git a/crates/dylib-dep/Cargo.toml b/crates/dylib-dep/Cargo.toml index c3d4a8c2f..e6cc9c23b 100644 --- a/crates/dylib-dep/Cargo.toml +++ b/crates/dylib-dep/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dylib-dep" version = "0.1.0" -edition = "2018" +edition = "2021" authors = [] publish = false diff --git a/crates/line-tables-only/Cargo.toml b/crates/line-tables-only/Cargo.toml index e2967d3d3..8d17db58c 100644 --- a/crates/line-tables-only/Cargo.toml +++ b/crates/line-tables-only/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "line-tables-only" version = "0.1.0" -edition = "2018" +edition = "2021" [build-dependencies] cc = "1.0" diff --git a/crates/line-tables-only/src/lib.rs b/crates/line-tables-only/src/lib.rs index bd5afcb3a..b292b8441 100644 --- a/crates/line-tables-only/src/lib.rs +++ b/crates/line-tables-only/src/lib.rs @@ -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); @@ -15,11 +15,12 @@ mod tests { unsafe { *(data as *mut Option) = 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() { @@ -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 diff --git a/crates/macos_frames_test/Cargo.toml b/crates/macos_frames_test/Cargo.toml index 278d51e79..849e76414 100644 --- a/crates/macos_frames_test/Cargo.toml +++ b/crates/macos_frames_test/Cargo.toml @@ -2,7 +2,7 @@ name = "macos_frames_test" version = "0.1.0" authors = ["Aaron Hill "] -edition = "2018" +edition = "2021" [dependencies.backtrace] path = "../.." diff --git a/crates/without_debuginfo/Cargo.toml b/crates/without_debuginfo/Cargo.toml index 19d76cbec..38e559971 100644 --- a/crates/without_debuginfo/Cargo.toml +++ b/crates/without_debuginfo/Cargo.toml @@ -2,7 +2,7 @@ name = "without_debuginfo" version = "0.1.0" authors = ["Alex Crichton "] -edition = "2018" +edition = "2021" [dependencies.backtrace] path = "../.." diff --git a/tests/accuracy/main.rs b/tests/accuracy/main.rs index 149203a1b..7570b2784 100644 --- a/tests/accuracy/main.rs +++ b/tests/accuracy/main.rs @@ -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() { diff --git a/tests/smoke.rs b/tests/smoke.rs index 683a6f0db..299cb820c 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -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}`" ); } @@ -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}" ); } @@ -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}", ); } } From 4b291636ada00a1641f557e640e1c102a433daa9 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sun, 2 Jul 2023 19:58:06 +0200 Subject: [PATCH 2/2] Specify MSRV in cargo.toml --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 03deefdb8..5a715e15d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ autoexamples = true autotests = true edition = "2021" exclude = ["/ci/"] +rust-version = "1.65.0" [workspace] members = ['crates/cpp_smoke_test', 'crates/as-if-std']