1 // This code exercises the surface area that we expect of the Error generic
2 // member access API. If the current toolchain is able to compile it, then
3 // anyhow is able to provide backtrace support.
4 
5 #![feature(error_generic_member_access)]
6 
7 use std::backtrace::Backtrace;
8 use std::error::{self, Error, Request};
9 use std::fmt::{self, Debug, Display};
10 
11 struct MyError(Thing);
12 struct Thing;
13 
14 impl Debug for MyError {
fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result15     fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
16         unimplemented!()
17     }
18 }
19 
20 impl Display for MyError {
fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result21     fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
22         unimplemented!()
23     }
24 }
25 
26 impl Error for MyError {
provide<'a>(&'a self, request: &mut Request<'a>)27     fn provide<'a>(&'a self, request: &mut Request<'a>) {
28         request.provide_ref(&self.0);
29     }
30 }
31 
32 const _: fn(&dyn Error) -> Option<&Backtrace> = |err| error::request_ref::<Backtrace>(err);
33 
34 // Include in sccache cache key.
35 const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP");
36