fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2 3#![allow(unused)] 4 5fn as_ref() -> Option<Vec<u8>> { 6 None 7} 8struct Type { 9 option: Option<Vec<u8>> 10} 11trait Trait { 12 fn foo(&self) -> &Vec<u8>; 13} 14impl Trait for Option<Vec<u8>> { 15 fn foo(&self) -> &Vec<u8> { 16 self.as_ref().unwrap() 17 } 18} 19 20impl Type { 21 fn method(&self) -> Option<&Vec<u8>> { 22 self.option.as_ref().map(|x| x) 23 //~^ ERROR E0308 24 } 25 fn method2(&self) -> Option<&u8> { 26 self.option.foo().get(0) 27 //~^ ERROR E0425 28 //~| ERROR E0308 29 } 30} 31 32fn main() { 33 let _ = Type { option: None }.method(); 34}