1 //! [![github]](https://github.com/dtolnay/anyhow) [![crates-io]](https://crates.io/crates/anyhow) [![docs-rs]](https://docs.rs/anyhow) 2 //! 3 //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github 4 //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust 5 //! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K 6 //! 7 //! <br> 8 //! 9 //! This library provides [`anyhow::Error`][Error], a trait object based error 10 //! type for easy idiomatic error handling in Rust applications. 11 //! 12 //! <br> 13 //! 14 //! # Details 15 //! 16 //! - Use `Result<T, anyhow::Error>`, or equivalently `anyhow::Result<T>`, as 17 //! the return type of any fallible function. 18 //! 19 //! Within the function, use `?` to easily propagate any error that implements 20 //! the `std::error::Error` trait. 21 //! 22 //! ``` 23 //! # pub trait Deserialize {} 24 //! # 25 //! # mod serde_json { 26 //! # use super::Deserialize; 27 //! # use std::io; 28 //! # 29 //! # pub fn from_str<T: Deserialize>(json: &str) -> io::Result<T> { 30 //! # unimplemented!() 31 //! # } 32 //! # } 33 //! # 34 //! # struct ClusterMap; 35 //! # 36 //! # impl Deserialize for ClusterMap {} 37 //! # 38 //! use anyhow::Result; 39 //! 40 //! fn get_cluster_info() -> Result<ClusterMap> { 41 //! let config = std::fs::read_to_string("cluster.json")?; 42 //! let map: ClusterMap = serde_json::from_str(&config)?; 43 //! Ok(map) 44 //! } 45 //! # 46 //! # fn main() {} 47 //! ``` 48 //! 49 //! - Attach context to help the person troubleshooting the error understand 50 //! where things went wrong. A low-level error like "No such file or 51 //! directory" can be annoying to debug without more context about what higher 52 //! level step the application was in the middle of. 53 //! 54 //! ``` 55 //! # struct It; 56 //! # 57 //! # impl It { 58 //! # fn detach(&self) -> Result<()> { 59 //! # unimplemented!() 60 //! # } 61 //! # } 62 //! # 63 //! use anyhow::{Context, Result}; 64 //! 65 //! fn main() -> Result<()> { 66 //! # return Ok(()); 67 //! # 68 //! # const _: &str = stringify! { 69 //! ... 70 //! # }; 71 //! # 72 //! # let it = It; 73 //! # let path = "./path/to/instrs.json"; 74 //! # 75 //! it.detach().context("Failed to detach the important thing")?; 76 //! 77 //! let content = std::fs::read(path) 78 //! .with_context(|| format!("Failed to read instrs from {}", path))?; 79 //! # 80 //! # const _: &str = stringify! { 81 //! ... 82 //! # }; 83 //! # 84 //! # Ok(()) 85 //! } 86 //! ``` 87 //! 88 //! ```console 89 //! Error: Failed to read instrs from ./path/to/instrs.json 90 //! 91 //! Caused by: 92 //! No such file or directory (os error 2) 93 //! ``` 94 //! 95 //! - Downcasting is supported and can be by value, by shared reference, or by 96 //! mutable reference as needed. 97 //! 98 //! ``` 99 //! # use anyhow::anyhow; 100 //! # use std::fmt::{self, Display}; 101 //! # use std::task::Poll; 102 //! # 103 //! # #[derive(Debug)] 104 //! # enum DataStoreError { 105 //! # Censored(()), 106 //! # } 107 //! # 108 //! # impl Display for DataStoreError { 109 //! # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 110 //! # unimplemented!() 111 //! # } 112 //! # } 113 //! # 114 //! # impl std::error::Error for DataStoreError {} 115 //! # 116 //! # const REDACTED_CONTENT: () = (); 117 //! # 118 //! # let error = anyhow!("..."); 119 //! # let root_cause = &error; 120 //! # 121 //! # let ret = 122 //! // If the error was caused by redaction, then return a 123 //! // tombstone instead of the content. 124 //! match root_cause.downcast_ref::<DataStoreError>() { 125 //! Some(DataStoreError::Censored(_)) => Ok(Poll::Ready(REDACTED_CONTENT)), 126 //! None => Err(error), 127 //! } 128 //! # ; 129 //! ``` 130 //! 131 //! - If using the nightly channel, or stable with `features = ["backtrace"]`, a 132 //! backtrace is captured and printed with the error if the underlying error 133 //! type does not already provide its own. In order to see backtraces, they 134 //! must be enabled through the environment variables described in 135 //! [`std::backtrace`]: 136 //! 137 //! - If you want panics and errors to both have backtraces, set 138 //! `RUST_BACKTRACE=1`; 139 //! - If you want only errors to have backtraces, set `RUST_LIB_BACKTRACE=1`; 140 //! - If you want only panics to have backtraces, set `RUST_BACKTRACE=1` and 141 //! `RUST_LIB_BACKTRACE=0`. 142 //! 143 //! The tracking issue for this feature is [rust-lang/rust#53487]. 144 //! 145 //! [`std::backtrace`]: https://doc.rust-lang.org/std/backtrace/index.html#environment-variables 146 //! [rust-lang/rust#53487]: https://github.com/rust-lang/rust/issues/53487 147 //! 148 //! - Anyhow works with any error type that has an impl of `std::error::Error`, 149 //! including ones defined in your crate. We do not bundle a `derive(Error)` 150 //! macro but you can write the impls yourself or use a standalone macro like 151 //! [thiserror]. 152 //! 153 //! [thiserror]: https://github.com/dtolnay/thiserror 154 //! 155 //! ``` 156 //! use thiserror::Error; 157 //! 158 //! #[derive(Error, Debug)] 159 //! pub enum FormatError { 160 //! #[error("Invalid header (expected {expected:?}, got {found:?})")] 161 //! InvalidHeader { 162 //! expected: String, 163 //! found: String, 164 //! }, 165 //! #[error("Missing attribute: {0}")] 166 //! MissingAttribute(String), 167 //! } 168 //! ``` 169 //! 170 //! - One-off error messages can be constructed using the `anyhow!` macro, which 171 //! supports string interpolation and produces an `anyhow::Error`. 172 //! 173 //! ``` 174 //! # use anyhow::{anyhow, Result}; 175 //! # 176 //! # fn demo() -> Result<()> { 177 //! # let missing = "..."; 178 //! return Err(anyhow!("Missing attribute: {}", missing)); 179 //! # Ok(()) 180 //! # } 181 //! ``` 182 //! 183 //! A `bail!` macro is provided as a shorthand for the same early return. 184 //! 185 //! ``` 186 //! # use anyhow::{bail, Result}; 187 //! # 188 //! # fn demo() -> Result<()> { 189 //! # let missing = "..."; 190 //! bail!("Missing attribute: {}", missing); 191 //! # Ok(()) 192 //! # } 193 //! ``` 194 //! 195 //! <br> 196 //! 197 //! # No-std support 198 //! 199 //! In no_std mode, the same API is almost all available and works the same way. 200 //! To depend on Anyhow in no_std mode, disable our default enabled "std" 201 //! feature in Cargo.toml. A global allocator is required. 202 //! 203 //! ```toml 204 //! [dependencies] 205 //! anyhow = { version = "1.0", default-features = false } 206 //! ``` 207 //! 208 //! Since the `?`-based error conversions would normally rely on the 209 //! `std::error::Error` trait which is only available through std, no_std mode 210 //! will require an explicit `.map_err(Error::msg)` when working with a 211 //! non-Anyhow error type inside a function that returns Anyhow's error type. 212 213 #![doc(html_root_url = "https://docs.rs/anyhow/1.0.44")] 214 #![cfg_attr(backtrace, feature(backtrace))] 215 #![cfg_attr(doc_cfg, feature(doc_cfg))] 216 #![cfg_attr(not(feature = "std"), no_std)] 217 #![deny(dead_code, unused_imports, unused_mut)] 218 #![allow( 219 clippy::doc_markdown, 220 clippy::enum_glob_use, 221 clippy::missing_errors_doc, 222 clippy::missing_panics_doc, 223 clippy::module_name_repetitions, 224 clippy::must_use_candidate, 225 clippy::needless_doctest_main, 226 clippy::new_ret_no_self, 227 clippy::redundant_else, 228 clippy::unused_self, 229 clippy::used_underscore_binding, 230 clippy::wildcard_imports, 231 clippy::wrong_self_convention 232 )] 233 234 mod alloc { 235 #[cfg(not(feature = "std"))] 236 extern crate alloc; 237 238 #[cfg(not(feature = "std"))] 239 pub use alloc::boxed::Box; 240 241 #[cfg(feature = "std")] 242 pub use std::boxed::Box; 243 } 244 245 #[macro_use] 246 mod backtrace; 247 mod chain; 248 mod context; 249 mod error; 250 mod fmt; 251 mod kind; 252 mod macros; 253 mod ptr; 254 mod wrapper; 255 256 use crate::error::ErrorImpl; 257 use crate::ptr::Own; 258 use core::fmt::Display; 259 260 #[cfg(not(feature = "std"))] 261 use core::fmt::Debug; 262 263 #[cfg(feature = "std")] 264 use std::error::Error as StdError; 265 266 #[cfg(not(feature = "std"))] 267 trait StdError: Debug + Display { source(&self) -> Option<&(dyn StdError + 'static)>268 fn source(&self) -> Option<&(dyn StdError + 'static)> { 269 None 270 } 271 } 272 273 pub use anyhow as format_err; 274 275 /// The `Error` type, a wrapper around a dynamic error type. 276 /// 277 /// `Error` works a lot like `Box<dyn std::error::Error>`, but with these 278 /// differences: 279 /// 280 /// - `Error` requires that the error is `Send`, `Sync`, and `'static`. 281 /// - `Error` guarantees that a backtrace is available, even if the underlying 282 /// error type does not provide one. 283 /// - `Error` is represented as a narrow pointer — exactly one word in 284 /// size instead of two. 285 /// 286 /// <br> 287 /// 288 /// # Display representations 289 /// 290 /// When you print an error object using "{}" or to_string(), only the outermost 291 /// underlying error or context is printed, not any of the lower level causes. 292 /// This is exactly as if you had called the Display impl of the error from 293 /// which you constructed your anyhow::Error. 294 /// 295 /// ```console 296 /// Failed to read instrs from ./path/to/instrs.json 297 /// ``` 298 /// 299 /// To print causes as well using anyhow's default formatting of causes, use the 300 /// alternate selector "{:#}". 301 /// 302 /// ```console 303 /// Failed to read instrs from ./path/to/instrs.json: No such file or directory (os error 2) 304 /// ``` 305 /// 306 /// The Debug format "{:?}" includes your backtrace if one was captured. Note 307 /// that this is the representation you get by default if you return an error 308 /// from `fn main` instead of printing it explicitly yourself. 309 /// 310 /// ```console 311 /// Error: Failed to read instrs from ./path/to/instrs.json 312 /// 313 /// Caused by: 314 /// No such file or directory (os error 2) 315 /// ``` 316 /// 317 /// and if there is a backtrace available: 318 /// 319 /// ```console 320 /// Error: Failed to read instrs from ./path/to/instrs.json 321 /// 322 /// Caused by: 323 /// No such file or directory (os error 2) 324 /// 325 /// Stack backtrace: 326 /// 0: <E as anyhow::context::ext::StdError>::ext_context 327 /// at /git/anyhow/src/backtrace.rs:26 328 /// 1: core::result::Result<T,E>::map_err 329 /// at /git/rustc/src/libcore/result.rs:596 330 /// 2: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::with_context 331 /// at /git/anyhow/src/context.rs:58 332 /// 3: testing::main 333 /// at src/main.rs:5 334 /// 4: std::rt::lang_start 335 /// at /git/rustc/src/libstd/rt.rs:61 336 /// 5: main 337 /// 6: __libc_start_main 338 /// 7: _start 339 /// ``` 340 /// 341 /// To see a conventional struct-style Debug representation, use "{:#?}". 342 /// 343 /// ```console 344 /// Error { 345 /// context: "Failed to read instrs from ./path/to/instrs.json", 346 /// source: Os { 347 /// code: 2, 348 /// kind: NotFound, 349 /// message: "No such file or directory", 350 /// }, 351 /// } 352 /// ``` 353 /// 354 /// If none of the built-in representations are appropriate and you would prefer 355 /// to render the error and its cause chain yourself, it can be done something 356 /// like this: 357 /// 358 /// ``` 359 /// use anyhow::{Context, Result}; 360 /// 361 /// fn main() { 362 /// if let Err(err) = try_main() { 363 /// eprintln!("ERROR: {}", err); 364 /// err.chain().skip(1).for_each(|cause| eprintln!("because: {}", cause)); 365 /// std::process::exit(1); 366 /// } 367 /// } 368 /// 369 /// fn try_main() -> Result<()> { 370 /// # const IGNORE: &str = stringify! { 371 /// ... 372 /// # }; 373 /// # Ok(()) 374 /// } 375 /// ``` 376 #[repr(transparent)] 377 pub struct Error { 378 inner: Own<ErrorImpl>, 379 } 380 381 /// Iterator of a chain of source errors. 382 /// 383 /// This type is the iterator returned by [`Error::chain`]. 384 /// 385 /// # Example 386 /// 387 /// ``` 388 /// use anyhow::Error; 389 /// use std::io; 390 /// 391 /// pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> { 392 /// for cause in error.chain() { 393 /// if let Some(io_error) = cause.downcast_ref::<io::Error>() { 394 /// return Some(io_error.kind()); 395 /// } 396 /// } 397 /// None 398 /// } 399 /// ``` 400 #[cfg(feature = "std")] 401 #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] 402 #[derive(Clone)] 403 pub struct Chain<'a> { 404 state: crate::chain::ChainState<'a>, 405 } 406 407 /// `Result<T, Error>` 408 /// 409 /// This is a reasonable return type to use throughout your application but also 410 /// for `fn main`; if you do, failures will be printed along with any 411 /// [context][Context] and a backtrace if one was captured. 412 /// 413 /// `anyhow::Result` may be used with one *or* two type parameters. 414 /// 415 /// ```rust 416 /// use anyhow::Result; 417 /// 418 /// # const IGNORE: &str = stringify! { 419 /// fn demo1() -> Result<T> {...} 420 /// // ^ equivalent to std::result::Result<T, anyhow::Error> 421 /// 422 /// fn demo2() -> Result<T, OtherError> {...} 423 /// // ^ equivalent to std::result::Result<T, OtherError> 424 /// # }; 425 /// ``` 426 /// 427 /// # Example 428 /// 429 /// ``` 430 /// # pub trait Deserialize {} 431 /// # 432 /// # mod serde_json { 433 /// # use super::Deserialize; 434 /// # use std::io; 435 /// # 436 /// # pub fn from_str<T: Deserialize>(json: &str) -> io::Result<T> { 437 /// # unimplemented!() 438 /// # } 439 /// # } 440 /// # 441 /// # #[derive(Debug)] 442 /// # struct ClusterMap; 443 /// # 444 /// # impl Deserialize for ClusterMap {} 445 /// # 446 /// use anyhow::Result; 447 /// 448 /// fn main() -> Result<()> { 449 /// # return Ok(()); 450 /// let config = std::fs::read_to_string("cluster.json")?; 451 /// let map: ClusterMap = serde_json::from_str(&config)?; 452 /// println!("cluster info: {:#?}", map); 453 /// Ok(()) 454 /// } 455 /// ``` 456 pub type Result<T, E = Error> = core::result::Result<T, E>; 457 458 /// Provides the `context` method for `Result`. 459 /// 460 /// This trait is sealed and cannot be implemented for types outside of 461 /// `anyhow`. 462 /// 463 /// <br> 464 /// 465 /// # Example 466 /// 467 /// ``` 468 /// use anyhow::{Context, Result}; 469 /// use std::fs; 470 /// use std::path::PathBuf; 471 /// 472 /// pub struct ImportantThing { 473 /// path: PathBuf, 474 /// } 475 /// 476 /// impl ImportantThing { 477 /// # const IGNORE: &'static str = stringify! { 478 /// pub fn detach(&mut self) -> Result<()> {...} 479 /// # }; 480 /// # fn detach(&mut self) -> Result<()> { 481 /// # unimplemented!() 482 /// # } 483 /// } 484 /// 485 /// pub fn do_it(mut it: ImportantThing) -> Result<Vec<u8>> { 486 /// it.detach().context("Failed to detach the important thing")?; 487 /// 488 /// let path = &it.path; 489 /// let content = fs::read(path) 490 /// .with_context(|| format!("Failed to read instrs from {}", path.display()))?; 491 /// 492 /// Ok(content) 493 /// } 494 /// ``` 495 /// 496 /// When printed, the outermost context would be printed first and the lower 497 /// level underlying causes would be enumerated below. 498 /// 499 /// ```console 500 /// Error: Failed to read instrs from ./path/to/instrs.json 501 /// 502 /// Caused by: 503 /// No such file or directory (os error 2) 504 /// ``` 505 /// 506 /// <br> 507 /// 508 /// # Effect on downcasting 509 /// 510 /// After attaching context of type `C` onto an error of type `E`, the resulting 511 /// `anyhow::Error` may be downcast to `C` **or** to `E`. 512 /// 513 /// That is, in codebases that rely on downcasting, Anyhow's context supports 514 /// both of the following use cases: 515 /// 516 /// - **Attaching context whose type is insignificant onto errors whose type 517 /// is used in downcasts.** 518 /// 519 /// In other error libraries whose context is not designed this way, it can 520 /// be risky to introduce context to existing code because new context might 521 /// break existing working downcasts. In Anyhow, any downcast that worked 522 /// before adding context will continue to work after you add a context, so 523 /// you should freely add human-readable context to errors wherever it would 524 /// be helpful. 525 /// 526 /// ``` 527 /// # use anyhow::bail; 528 /// # use thiserror::Error; 529 /// # 530 /// # #[derive(Error, Debug)] 531 /// # #[error("???")] 532 /// # struct SuspiciousError; 533 /// # 534 /// # fn helper() -> Result<()> { 535 /// # bail!(SuspiciousError); 536 /// # } 537 /// # 538 /// use anyhow::{Context, Result}; 539 /// 540 /// fn do_it() -> Result<()> { 541 /// helper().context("Failed to complete the work")?; 542 /// # const IGNORE: &str = stringify! { 543 /// ... 544 /// # }; 545 /// # unreachable!() 546 /// } 547 /// 548 /// fn main() { 549 /// let err = do_it().unwrap_err(); 550 /// if let Some(e) = err.downcast_ref::<SuspiciousError>() { 551 /// // If helper() returned SuspiciousError, this downcast will 552 /// // correctly succeed even with the context in between. 553 /// # return; 554 /// } 555 /// # panic!("expected downcast to succeed"); 556 /// } 557 /// ``` 558 /// 559 /// - **Attaching context whose type is used in downcasts onto errors whose 560 /// type is insignificant.** 561 /// 562 /// Some codebases prefer to use machine-readable context to categorize 563 /// lower level errors in a way that will be actionable to higher levels of 564 /// the application. 565 /// 566 /// ``` 567 /// # use anyhow::bail; 568 /// # use thiserror::Error; 569 /// # 570 /// # #[derive(Error, Debug)] 571 /// # #[error("???")] 572 /// # struct HelperFailed; 573 /// # 574 /// # fn helper() -> Result<()> { 575 /// # bail!("no such file or directory"); 576 /// # } 577 /// # 578 /// use anyhow::{Context, Result}; 579 /// 580 /// fn do_it() -> Result<()> { 581 /// helper().context(HelperFailed)?; 582 /// # const IGNORE: &str = stringify! { 583 /// ... 584 /// # }; 585 /// # unreachable!() 586 /// } 587 /// 588 /// fn main() { 589 /// let err = do_it().unwrap_err(); 590 /// if let Some(e) = err.downcast_ref::<HelperFailed>() { 591 /// // If helper failed, this downcast will succeed because 592 /// // HelperFailed is the context that has been attached to 593 /// // that error. 594 /// # return; 595 /// } 596 /// # panic!("expected downcast to succeed"); 597 /// } 598 /// ``` 599 pub trait Context<T, E>: context::private::Sealed { 600 /// Wrap the error value with additional context. context<C>(self, context: C) -> Result<T, Error> where C: Display + Send + Sync + 'static601 fn context<C>(self, context: C) -> Result<T, Error> 602 where 603 C: Display + Send + Sync + 'static; 604 605 /// Wrap the error value with additional context that is evaluated lazily 606 /// only once an error does occur. with_context<C, F>(self, f: F) -> Result<T, Error> where C: Display + Send + Sync + 'static, F: FnOnce() -> C607 fn with_context<C, F>(self, f: F) -> Result<T, Error> 608 where 609 C: Display + Send + Sync + 'static, 610 F: FnOnce() -> C; 611 } 612 613 // Not public API. Referenced by macro-generated code. 614 #[doc(hidden)] 615 pub mod private { 616 use crate::Error; 617 use core::fmt::{Debug, Display}; 618 619 pub use core::result::Result::Err; 620 621 #[doc(hidden)] 622 pub mod kind { 623 pub use crate::kind::{AdhocKind, TraitKind}; 624 625 #[cfg(feature = "std")] 626 pub use crate::kind::BoxedKind; 627 } 628 629 #[cold] new_adhoc<M>(message: M) -> Error where M: Display + Debug + Send + Sync + 'static,630 pub fn new_adhoc<M>(message: M) -> Error 631 where 632 M: Display + Debug + Send + Sync + 'static, 633 { 634 Error::from_adhoc(message, backtrace!()) 635 } 636 637 #[cfg(anyhow_no_macro_reexport)] 638 pub use crate::{__anyhow_concat as concat, __anyhow_stringify as stringify}; 639 #[cfg(not(anyhow_no_macro_reexport))] 640 pub use core::{concat, stringify}; 641 642 #[cfg(anyhow_no_macro_reexport)] 643 #[doc(hidden)] 644 #[macro_export] 645 macro_rules! __anyhow_concat { 646 ($($tt:tt)*) => { 647 concat!($($tt)*) 648 }; 649 } 650 651 #[cfg(anyhow_no_macro_reexport)] 652 #[doc(hidden)] 653 #[macro_export] 654 macro_rules! __anyhow_stringify { 655 ($($tt:tt)*) => { 656 stringify!($($tt)*) 657 }; 658 } 659 } 660