]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/method-access-to-range-literal-typo.fixed
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / method-access-to-range-literal-typo.fixed
1 // run-rustfix
2
3 #![allow(unused)]
4
5 fn as_ref() -> Option<Vec<u8>> {
6     None
7 }
8 struct Type {
9     option: Option<Vec<u8>>
10 }
11 trait Trait {
12     fn foo(&self) -> &Vec<u8>;
13 }
14 impl Trait for Option<Vec<u8>> {
15     fn foo(&self) -> &Vec<u8> {
16         self.as_ref().unwrap()
17     }
18 }
19
20 impl 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
32 fn main() {
33     let _ = Type { option: None }.method();
34 }