]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-52262.rs
point at private fields in struct literal
[rust.git] / src / test / ui / issues / issue-52262.rs
1 // compile-flags:-Ztreat-err-as-bug=5
2 #[derive(Debug)]
3 enum MyError {
4     NotFound { key: Vec<u8> },
5     Err41,
6 }
7
8 impl std::error::Error for MyError {}
9
10 impl std::fmt::Display for MyError {
11     fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
12         match self {
13             MyError::NotFound { key } => write!(
14                 f,
15                 "unknown error with code {}.",
16                 String::from_utf8(*key).unwrap()
17                 //~^ ERROR cannot move out of `*key` which is behind a shared reference
18             ),
19             MyError::Err41 => write!(f, "Sit by a lake"),
20         }
21     }
22 }
23 fn main() {
24     println!("Hello, world!");
25 }