2023-01-08 16:31:47 -06:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![allow(unused)]
|
|
|
|
|
2022-12-15 18:24:42 -06:00
|
|
|
fn as_ref() -> Option<Vec<u8>> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
struct Type {
|
|
|
|
option: Option<Vec<u8>>
|
|
|
|
}
|
2022-12-27 11:25:00 -06:00
|
|
|
trait Trait {
|
2023-01-08 16:31:47 -06:00
|
|
|
fn foo(&self) -> &Vec<u8>;
|
2022-12-27 11:25:00 -06:00
|
|
|
}
|
|
|
|
impl Trait for Option<Vec<u8>> {
|
2023-01-08 16:31:47 -06:00
|
|
|
fn foo(&self) -> &Vec<u8> {
|
|
|
|
self.as_ref().unwrap()
|
2022-12-27 11:25:00 -06:00
|
|
|
}
|
|
|
|
}
|
2022-12-15 18:24:42 -06:00
|
|
|
|
|
|
|
impl Type {
|
2023-01-08 16:31:47 -06:00
|
|
|
fn method(&self) -> Option<&Vec<u8>> {
|
2022-12-15 18:24:42 -06:00
|
|
|
self.option..as_ref().map(|x| x)
|
|
|
|
//~^ ERROR E0308
|
|
|
|
}
|
2023-01-08 16:31:47 -06:00
|
|
|
fn method2(&self) -> Option<&u8> {
|
2022-12-27 11:25:00 -06:00
|
|
|
self.option..foo().get(0)
|
2022-12-15 18:24:42 -06:00
|
|
|
//~^ ERROR E0425
|
|
|
|
//~| ERROR E0308
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = Type { option: None }.method();
|
|
|
|
}
|