aws / aws-nitro-enclaves-cli

Tooling for Nitro Enclave Management
Apache License 2.0
121 stars 81 forks source link

documents_errors: Fix clippy warn format_push_string #391

Closed sabin-rapan closed 2 years ago

sabin-rapan commented 2 years ago

Rust 1.62.0 comes with a new clippy warn: https://rust-lang.github.io/rust-clippy/master/index.html#format_push_string.

It complains about code like:

let mut s = String::new();
s += &format!("0x{:X}", 1024);
s.push_str(&format!("0x{:X}", 1024));

which does one extra heap allocation than necessary. Since we promote all warnings to errors, builds on 1.62.0 will fail.

We refactor construct_backtrace() to allocate, format and return the backtrace string in a single go and add a test to ensure the format stays consistent.

Signed-off-by: Sabin Rapan sabrapan@amazon.com

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.