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