]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-91489.rs
point at private fields in struct literal
[rust.git] / src / test / ui / issues / issue-91489.rs
1 // check-pass
2
3 // regression test for #91489
4
5 use std::borrow::Borrow;
6 use std::borrow::Cow;
7
8 pub struct VariantType {}
9 pub struct VariantTy {}
10
11 impl Borrow<VariantTy> for VariantType {
12     fn borrow(&self) -> &VariantTy {
13         unimplemented!()
14     }
15 }
16
17 impl ToOwned for VariantTy {
18     type Owned = VariantType;
19     fn to_owned(&self) -> VariantType {
20         unimplemented!()
21     }
22 }
23
24 impl VariantTy {
25     pub fn as_str(&self) -> () {}
26 }
27
28 // the presence of this was causing all attempts to call `as_str` on
29 // `Cow<'_, VariantTy>, including in itself, to not find the method
30 static _TYP: () = {
31     let _ = || {
32         // should be found
33         Cow::Borrowed(&VariantTy {}).as_str();
34     };
35 };
36
37 fn main() {
38     // should be found
39     Cow::Borrowed(&VariantTy {}).as_str()
40 }