Skip to content
Myr

Fix anyhow_kind dispatch on owned value

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 d0c25a6 · Browse files · 3 files+6 added−2 removed
This commit

State

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

Diff stats

3 files+6 added−2 removed

  • tests:+4 added−0 removed
  • other:+2 added−2 removed

3 files+6 added−2 removed

modified:src/kind.rs+1 added-1 removed
40 unmodified lines
41//42// #[allow(unused_imports)]43// use $crate::private::{AdhocKind, TraitKind};44// let error = $msg;45// error.anyhow_kind().new(error)45// (&error).anyhow_kind().new(error)4647use crate::Error;48use std::error::Error as StdError;49use std::fmt::{Debug, Display};
43 unmodified lines
modified:src/lib.rs+1 added-1 removed
402 unmodified lines
403 ($err:expr $(,)?) => ({404 #[allow(unused_imports)]405 use $crate::private::{AdhocKind, TraitKind};406 let error = $err;407 error.anyhow_kind().new(error)407 (&error).anyhow_kind().new(error)408 });409 ($fmt:expr, $($arg:tt)*) => {410 $crate::private::new_adhoc(format!($fmt, $($arg)*))411 };
20 unmodified lines
modified:tests/test_source.rs+4 added
33 unmodified lines
34fn test_variable_source() {35 let msg = "oh no!";36 let error = anyhow!(msg);37 assert!(error.source().is_none());3839 let msg = msg.to_owned();40 let error = anyhow!(msg);41 assert!(error.source().is_none());42}4344#[test]45fn test_fmt_source() {
10 unmodified lines