Skip to content
Myr

Eliminate Arguments::as_str call on old toolchain

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent f8d849b · Browse files · 2 files+13 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−4 removed

  • other:+13 added−4 removed

2 files+13 added−4 removed

modified:src/lib.rs+9 added-4 removed
624 unmodified lines
625 pub fn format_err<M>(message: M, args: Arguments) -> Error626 where627 M: Display + Debug + Send + Sync + 'static,628 {629 if args.as_str().is_some() {630 // anyhow!("literal"), can downcast to &'static str631 Error::msg(message)632 } else {629 #[cfg(anyhow_no_fmt_arguments_as_str)]630 let has_interpolated_format_args = false;631 #[cfg(not(anyhow_no_fmt_arguments_as_str))]632 let has_interpolated_format_args = args.as_str().is_none();633634 if has_interpolated_format_args {635 // anyhow!("interpolate {var}"), can downcast to String636 Error::msg(fmt::format(args))637 } else {638 // anyhow!("literal"), can downcast to &'static str639 Error::msg(message)640 }641 }642}
modified:build.rs+4 added
56 unmodified lines
5758 if rustc < 51 {59 println!("cargo:rustc-cfg=anyhow_no_ptr_addr_of");60 }6162 if rustc < 52 {63 println!("cargo:rustc-cfg=anyhow_no_fmt_arguments_as_str");64 }65}6667fn compile_probe() -> Option<ExitStatus> {68 let rustc = env::var_os("RUSTC")?;
45 unmodified lines