Update MSRV to 1.58

This commit is contained in:
Luke Street 2023-02-02 15:59:55 -05:00
parent c595c9dc86
commit 53a5797881
5 changed files with 24 additions and 24 deletions

View File

@ -10,6 +10,7 @@ description = """
CodeWarrior C++ symbol demangler CodeWarrior C++ symbol demangler
""" """
categories = ["command-line-utilities"] categories = ["command-line-utilities"]
rust-version = "1.58"
[dependencies] [dependencies]
argh = "0.1.8" argh = "0.1.8"

View File

@ -6,7 +6,7 @@
[crates.io]: https://crates.io/crates/cwdemangle [crates.io]: https://crates.io/crates/cwdemangle
[Api Rustdoc]: https://img.shields.io/badge/api-rustdoc-blue.svg [Api Rustdoc]: https://img.shields.io/badge/api-rustdoc-blue.svg
[rustdoc]: https://docs.rs/cwdemangle [rustdoc]: https://docs.rs/cwdemangle
[Rust Version]: https://img.shields.io/badge/rust-1.51+-blue.svg?maxAge=3600 [Rust Version]: https://img.shields.io/badge/rust-1.58+-blue.svg?maxAge=3600
A CodeWarrior C++ symbol demangler. A CodeWarrior C++ symbol demangler.

View File

@ -42,8 +42,7 @@ where T: FromArgs
}; };
Err(argh::EarlyExit { Err(argh::EarlyExit {
output: format!( output: format!(
"{} -V, --version print version information and exit", "{help} -V, --version print version information and exit"
help
), ),
status: Ok(()), status: Ok(()),
}) })

View File

@ -86,14 +86,14 @@ fn demangle_name<'a>(str: &'a str, options: &DemangleOptions) -> Option<(String,
let (size, rest) = parse_digits(str)?; let (size, rest) = parse_digits(str)?;
// hack for template argument constants // hack for template argument constants
if rest.is_empty() || rest.starts_with(',') { if rest.is_empty() || rest.starts_with(',') {
let out = format!("{}", size); let out = format!("{size}");
return Some((out.clone(), out, rest)); return Some((out.clone(), out, rest));
} }
if rest.len() < size { if rest.len() < size {
return None; return None;
} }
let (name, args) = demangle_template_args(&rest[..size], options)?; let (name, args) = demangle_template_args(&rest[..size], options)?;
Some((name.to_string(), format!("{}{}", name, args), &rest[size..])) Some((name.to_string(), format!("{name}{args}"), &rest[size..]))
} }
fn demangle_qualified_name<'a>( fn demangle_qualified_name<'a>(
@ -142,7 +142,7 @@ fn demangle_arg<'a>(
if str.starts_with('M') { if str.starts_with('M') {
is_member = true; is_member = true;
let (_, member, rest) = demangle_qualified_name(&str[1..], options)?; let (_, member, rest) = demangle_qualified_name(&str[1..], options)?;
pre = format!("{}::*{}", member, pre); pre = format!("{member}::*{pre}");
if !rest.starts_with('F') { if !rest.starts_with('F') {
return None; return None;
} }
@ -162,7 +162,7 @@ fn demangle_arg<'a>(
} }
} else if post.starts_with('*') { } else if post.starts_with('*') {
post = post[1..].trim_start().to_string(); post = post[1..].trim_start().to_string();
pre = format!("*{}", pre); pre = format!("*{pre}");
} else { } else {
return None; return None;
} }
@ -172,8 +172,8 @@ fn demangle_arg<'a>(
} }
let (ret_pre, ret_post, rest) = demangle_arg(&rest[1..], options)?; let (ret_pre, ret_post, rest) = demangle_arg(&rest[1..], options)?;
let const_str = if const_member { " const" } else { "" }; let const_str = if const_member { " const" } else { "" };
let res_pre = format!("{} ({}{}", ret_pre, pre, post); let res_pre = format!("{ret_pre} ({pre}{post}");
let res_post = format!(")({}){}{}", args, const_str, ret_post); let res_post = format!(")({args}){const_str}{ret_post}");
return Some((res_pre, res_post, rest)); return Some((res_pre, res_post, rest));
} }
if let Some(rest) = str.strip_prefix('A') { if let Some(rest) = str.strip_prefix('A') {
@ -183,10 +183,10 @@ fn demangle_arg<'a>(
} }
let (arg_pre, arg_post, rest) = demangle_arg(&rest[1..], options)?; let (arg_pre, arg_post, rest) = demangle_arg(&rest[1..], options)?;
if !post.is_empty() { if !post.is_empty() {
post = format!("({})", post); post = format!("({post})");
} }
result = format!("{}{}{}", pre, arg_pre, post); result = format!("{pre}{arg_pre}{post}");
let ret_post = format!("[{}]{}", count, arg_post); let ret_post = format!("[{count}]{arg_post}");
return Some((result, ret_post, rest)); return Some((result, ret_post, rest));
} }
result.push_str(match str.chars().next()? { result.push_str(match str.chars().next()? {
@ -235,13 +235,13 @@ fn demangle_special_function(
) -> Option<String> { ) -> Option<String> {
if let Some(rest) = str.strip_prefix("op") { if let Some(rest) = str.strip_prefix("op") {
let (arg_pre, arg_post, _) = demangle_arg(rest, options)?; let (arg_pre, arg_post, _) = demangle_arg(rest, options)?;
return Some(format!("operator {}{}", arg_pre, arg_post)); return Some(format!("operator {arg_pre}{arg_post}"));
} }
let (op, args) = demangle_template_args(str, options)?; let (op, args) = demangle_template_args(str, options)?;
Some(format!( Some(format!(
"{}{}", "{}{}",
match op { match op {
"dt" => return Some(format!("~{}{}", class_name, args)), "dt" => return Some(format!("~{class_name}{args}")),
"ct" => class_name, "ct" => class_name,
"nw" => "operator new", "nw" => "operator new",
"nwa" => "operator new[]", "nwa" => "operator new[]",
@ -286,7 +286,7 @@ fn demangle_special_function(
"cl" => "operator()", "cl" => "operator()",
"vc" => "operator[]", "vc" => "operator[]",
"vt" => "__vtable", "vt" => "__vtable",
_ => return Some(format!("__{}{}", op, args)), _ => return Some(format!("__{op}{args}")),
}, },
args args
)) ))
@ -337,7 +337,7 @@ pub fn demangle(mut str: &str, options: &DemangleOptions) -> Option<String> {
} }
} else { } else {
let (name, args) = demangle_template_args(fn_name_out, options)?; let (name, args) = demangle_template_args(fn_name_out, options)?;
fn_name = format!("{}{}", name, args); fn_name = format!("{name}{args}");
} }
// Handle old static function variables (GC CW) // Handle old static function variables (GC CW)
@ -350,7 +350,7 @@ pub fn demangle(mut str: &str, options: &DemangleOptions) -> Option<String> {
} }
if var == "init" { if var == "init" {
// Sadly, $localstatic doesn't provide the variable name in guard/init // Sadly, $localstatic doesn't provide the variable name in guard/init
static_var = format!("{} guard", var_type); static_var = format!("{var_type} guard");
} else { } else {
static_var = var.to_string(); static_var = var.to_string();
} }
@ -377,9 +377,9 @@ pub fn demangle(mut str: &str, options: &DemangleOptions) -> Option<String> {
str = &str[1..]; str = &str[1..];
let (args, rest) = demangle_function_args(str, options)?; let (args, rest) = demangle_function_args(str, options)?;
if options.omit_empty_parameters && args == "void" { if options.omit_empty_parameters && args == "void" {
fn_name = format!("{}()", fn_name); fn_name = format!("{fn_name}()");
} else { } else {
fn_name = format!("{}({})", fn_name, args); fn_name = format!("{fn_name}({args})");
} }
str = rest; str = rest;
} }
@ -394,16 +394,16 @@ pub fn demangle(mut str: &str, options: &DemangleOptions) -> Option<String> {
return None; return None;
} }
if cnst { if cnst {
fn_name = format!("{} const", fn_name); fn_name = format!("{fn_name} const");
} }
if !qualified.is_empty() { if !qualified.is_empty() {
fn_name = format!("{}::{}", qualified, fn_name); fn_name = format!("{qualified}::{fn_name}");
} }
if !return_type_pre.is_empty() { if !return_type_pre.is_empty() {
fn_name = format!("{} {}{}", return_type_pre, fn_name, return_type_post); fn_name = format!("{return_type_pre} {fn_name}{return_type_post}");
} }
if !static_var.is_empty() { if !static_var.is_empty() {
fn_name = format!("{}::{}", fn_name, static_var); fn_name = format!("{fn_name}::{static_var}");
} }
Some(fn_name) Some(fn_name)
} }

View File

@ -21,7 +21,7 @@ fn main() -> Result<(), &'static str> {
return if let Some(symbol) = return if let Some(symbol) =
demangle(args.symbol.as_str(), &DemangleOptions { omit_empty_parameters: !args.keep_void }) demangle(args.symbol.as_str(), &DemangleOptions { omit_empty_parameters: !args.keep_void })
{ {
println!("{}", symbol); println!("{symbol}");
Ok(()) Ok(())
} else { } else {
Err("Failed to demangle symbol") Err("Failed to demangle symbol")