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