| 1 | #![allow( |
| 2 | // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422 |
| 3 | clippy::nonstandard_macro_braces, |
| 4 | )] |
| 5 | |
| 6 | mod droprust-analyzer cargo anyhow 1.0.103 drop/; |
| 7 | |
| 8 | use craterust-analyzer cargo anyhow 1.0.103 crate/::droprust-analyzer cargo anyhow 1.0.103 drop/::{DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#, Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#}; |
| 9 | use anyhowrust-analyzer cargo anyhow 1.0.103 crate/::{Contextrust-analyzer cargo anyhow 1.0.103 Context#, Errorrust-analyzer cargo anyhow 1.0.103 Error#, Resultrust-analyzer cargo anyhow 1.0.103 Result#}; |
| 10 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#}; |
| 11 | use thiserrorrust-analyzer cargo thiserror 2.0.18 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.18 Error:; |
| 12 | |
| 13 | // https://github.com/dtolnay/anyhow/issues/18 |
| 14 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 15 | fn test_inferencerust-analyzer cargo anyhow 1.0.103 test_inference().() -> Resultrust-analyzer cargo anyhow 1.0.103 Result#<()> { |
| 16 | let x = "1"; |
| 17 | let y: u32 = x.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().contextrust-analyzer cargo anyhow 1.0.103 context/impl#[`Result<T, E>`][`Context<T, E>`]context().("...")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 18 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(y, 1); |
| 19 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 20 | } |
| 21 | |
| 22 | macro_rules! context_typerust-analyzer cargo anyhow 1.0.103 context_type! { |
| 23 | ($name:ident) => { |
| 24 | #[derive(Debug)] |
| 25 | struct $name { |
| 26 | message: &'static str, |
| 27 | #[allow(dead_code)] |
| 28 | drop: DetectDrop, |
| 29 | } |
| 30 | |
| 31 | impl Display for $name { |
| 32 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 33 | f.write_str(self.message) |
| 34 | } |
| 35 | } |
| 36 | }; |
| 37 | } |
| 38 | |
| 39 | context_typerust-analyzer cargo anyhow 1.0.103 context_type!!(HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel#); |
| 40 | context_typerust-analyzer cargo anyhow 1.0.103 context_type!!(MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel#); |
| 41 | |
| 42 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Errorrust-analyzer cargo thiserror-impl 2.0.18 Error:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 43 | #[error("{message}")] |
| 44 | struct LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel# { |
| 45 | messagerust-analyzer cargo anyhow 1.0.103 LowLevel#message.: &'static str, |
| 46 | droprust-analyzer cargo anyhow 1.0.103 LowLevel#drop.: DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#, |
| 47 | } |
| 48 | |
| 49 | struct Droppedrust-analyzer cargo anyhow 1.0.103 Dropped# { |
| 50 | lowrust-analyzer cargo anyhow 1.0.103 Dropped#low.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#, |
| 51 | midrust-analyzer cargo anyhow 1.0.103 Dropped#mid.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#, |
| 52 | highrust-analyzer cargo anyhow 1.0.103 Dropped#high.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#, |
| 53 | } |
| 54 | |
| 55 | impl Droppedrust-analyzer cargo anyhow 1.0.103 Dropped# { |
| 56 | fn nonerust-analyzer cargo anyhow 1.0.103 impl#[Dropped]none().(&self) -> bool { |
| 57 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.lowrust-analyzer cargo anyhow 1.0.103 Dropped#low..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.midrust-analyzer cargo anyhow 1.0.103 Dropped#mid..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.highrust-analyzer cargo anyhow 1.0.103 Dropped#high..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() |
| 58 | } |
| 59 | |
| 60 | fn allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().(&self) -> bool { |
| 61 | self.lowrust-analyzer cargo anyhow 1.0.103 Dropped#low..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && self.midrust-analyzer cargo anyhow 1.0.103 Dropped#mid..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && self.highrust-analyzer cargo anyhow 1.0.103 Dropped#high..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | fn make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().() -> (Errorrust-analyzer cargo anyhow 1.0.103 Error#, Droppedrust-analyzer cargo anyhow 1.0.103 Dropped#) { |
| 66 | let dropped = Droppedrust-analyzer cargo anyhow 1.0.103 Dropped# { |
| 67 | lowrust-analyzer cargo anyhow 1.0.103 Dropped#low.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#::newrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]new().(), |
| 68 | midrust-analyzer cargo anyhow 1.0.103 Dropped#mid.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#::newrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]new().(), |
| 69 | highrust-analyzer cargo anyhow 1.0.103 Dropped#high.: Flagrust-analyzer cargo anyhow 1.0.103 drop/Flag#::newrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]new().(), |
| 70 | }; |
| 71 | |
| 72 | let low = LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel# { |
| 73 | messagerust-analyzer cargo anyhow 1.0.103 LowLevel#message.: "no such file or directory", |
| 74 | droprust-analyzer cargo anyhow 1.0.103 LowLevel#drop.: DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#::newrust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop]new().(&dropped.lowrust-analyzer cargo anyhow 1.0.103 Dropped#low.), |
| 75 | }; |
| 76 | |
| 77 | // impl Context for Result<T, E> |
| 78 | let mid = Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#::<(), LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel#>(low) |
| 79 | .contextrust-analyzer cargo anyhow 1.0.103 context/impl#[`Result<T, E>`][`Context<T, E>`]context().(MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel# { |
| 80 | messagerust-analyzer cargo anyhow 1.0.103 MidLevel#message.: "failed to load config", |
| 81 | droprust-analyzer cargo anyhow 1.0.103 MidLevel#drop.: DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#::newrust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop]new().(&dropped.midrust-analyzer cargo anyhow 1.0.103 Dropped#mid.), |
| 82 | }) |
| 83 | .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 84 | |
| 85 | // impl Context for Result<T, Error> |
| 86 | let high = Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#::<(), Errorrust-analyzer cargo anyhow 1.0.103 Error#>(mid) |
| 87 | .contextrust-analyzer cargo anyhow 1.0.103 context/impl#[`Result<T, E>`][`Context<T, E>`]context().(HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel# { |
| 88 | messagerust-analyzer cargo anyhow 1.0.103 HighLevel#message.: "failed to start server", |
| 89 | droprust-analyzer cargo anyhow 1.0.103 HighLevel#drop.: DetectDroprust-analyzer cargo anyhow 1.0.103 drop/DetectDrop#::newrust-analyzer cargo anyhow 1.0.103 drop/impl#[DetectDrop]new().(&dropped.highrust-analyzer cargo anyhow 1.0.103 Dropped#high.), |
| 90 | }) |
| 91 | .unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 92 | |
| 93 | (high, dropped) |
| 94 | } |
| 95 | |
| 96 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 97 | fn test_downcast_refrust-analyzer cargo anyhow 1.0.103 test_downcast_ref().() { |
| 98 | let (err, dropped) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 99 | |
| 100 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().err.isrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]is().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>()); |
| 101 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 102 | |
| 103 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.isrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]is().::<HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel#>()); |
| 104 | let high = err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 105 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(high.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "failed to start server"); |
| 106 | |
| 107 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.isrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]is().::<MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel#>()); |
| 108 | let mid = err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 109 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(mid.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "failed to load config"); |
| 110 | |
| 111 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.isrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]is().::<LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel#>()); |
| 112 | let low = err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 113 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "no such file or directory"); |
| 114 | |
| 115 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.nonerust-analyzer cargo anyhow 1.0.103 impl#[Dropped]none().()); |
| 116 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(err); |
| 117 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().()); |
| 118 | } |
| 119 | |
| 120 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 121 | fn test_downcast_highrust-analyzer cargo anyhow 1.0.103 test_downcast_high().() { |
| 122 | let (err, dropped) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 123 | |
| 124 | let err = err.downcastrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast().::<HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 125 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dropped.highrust-analyzer cargo anyhow 1.0.103 Dropped#high..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().()); |
| 126 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.lowrust-analyzer cargo anyhow 1.0.103 Dropped#low..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && dropped.midrust-analyzer cargo anyhow 1.0.103 Dropped#mid..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().()); |
| 127 | |
| 128 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(err); |
| 129 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().()); |
| 130 | } |
| 131 | |
| 132 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 133 | fn test_downcast_midrust-analyzer cargo anyhow 1.0.103 test_downcast_mid().() { |
| 134 | let (err, dropped) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 135 | |
| 136 | let err = err.downcastrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast().::<MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 137 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dropped.midrust-analyzer cargo anyhow 1.0.103 Dropped#mid..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().()); |
| 138 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.lowrust-analyzer cargo anyhow 1.0.103 Dropped#low..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && dropped.highrust-analyzer cargo anyhow 1.0.103 Dropped#high..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().()); |
| 139 | |
| 140 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(err); |
| 141 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().()); |
| 142 | } |
| 143 | |
| 144 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 145 | fn test_downcast_lowrust-analyzer cargo anyhow 1.0.103 test_downcast_low().() { |
| 146 | let (err, dropped) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 147 | |
| 148 | let err = err.downcastrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast().::<LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 149 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dropped.lowrust-analyzer cargo anyhow 1.0.103 Dropped#low..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().()); |
| 150 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.midrust-analyzer cargo anyhow 1.0.103 Dropped#mid..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().() && dropped.highrust-analyzer cargo anyhow 1.0.103 Dropped#high..getrust-analyzer cargo anyhow 1.0.103 drop/impl#[Flag]get().()); |
| 151 | |
| 152 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(err); |
| 153 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().()); |
| 154 | } |
| 155 | |
| 156 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 157 | fn test_unsuccessful_downcastrust-analyzer cargo anyhow 1.0.103 test_unsuccessful_downcast().() { |
| 158 | let (err, dropped) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 159 | |
| 160 | let err = err.downcastrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>().unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().(); |
| 161 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.nonerust-analyzer cargo anyhow 1.0.103 impl#[Dropped]none().()); |
| 162 | |
| 163 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(err); |
| 164 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().()); |
| 165 | } |
| 166 | |
| 167 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 168 | fn test_downcast_mutrust-analyzer cargo anyhow 1.0.103 test_downcast_mut().() { |
| 169 | let (mut err, dropped) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 170 | |
| 171 | err.downcast_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_mut().::<HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().messagerust-analyzer cargo anyhow 1.0.103 HighLevel#message. = "high context"; |
| 172 | err.downcast_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_mut().::<MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().messagerust-analyzer cargo anyhow 1.0.103 MidLevel#message. = "mid context"; |
| 173 | err.downcast_mutrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_mut().::<LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().messagerust-analyzer cargo anyhow 1.0.103 LowLevel#message. = "low error"; |
| 174 | |
| 175 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 176 | err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<HighLevelrust-analyzer cargo anyhow 1.0.103 HighLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().messagerust-analyzer cargo anyhow 1.0.103 HighLevel#message., |
| 177 | "high context", |
| 178 | ); |
| 179 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 180 | err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<MidLevelrust-analyzer cargo anyhow 1.0.103 MidLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().messagerust-analyzer cargo anyhow 1.0.103 MidLevel#message., |
| 181 | "mid context", |
| 182 | ); |
| 183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(err.downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<LowLevelrust-analyzer cargo anyhow 1.0.103 LowLevel#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().messagerust-analyzer cargo anyhow 1.0.103 LowLevel#message., "low error"); |
| 184 | |
| 185 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.nonerust-analyzer cargo anyhow 1.0.103 impl#[Dropped]none().()); |
| 186 | droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(err); |
| 187 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(dropped.allrust-analyzer cargo anyhow 1.0.103 impl#[Dropped]all().()); |
| 188 | } |
| 189 | |
| 190 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 191 | fn test_root_causerust-analyzer cargo anyhow 1.0.103 test_root_cause().() { |
| 192 | let (err, _) = make_chainrust-analyzer cargo anyhow 1.0.103 make_chain().(); |
| 193 | |
| 194 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(err.root_causerust-analyzer cargo anyhow 1.0.103 error/impl#[Error]root_cause().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "no such file or directory"); |
| 195 | } |