summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/field-access-considering-privacy.rs
blob: 3de06b21420b4771d5303554fa8b99ef9392f15b (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
35
use a::TyCtxt;

mod a {
    use std::ops::Deref;
    pub struct TyCtxt<'tcx> {
        gcx: &'tcx GlobalCtxt<'tcx>,
    }

    impl<'tcx> Deref for TyCtxt<'tcx> {
        type Target = &'tcx GlobalCtxt<'tcx>;

        fn deref(&self) -> &Self::Target {
            &self.gcx
        }
    }

    pub struct GlobalCtxt<'tcx> {
        pub sess: &'tcx Session,
        _t: &'tcx (),
    }

    pub struct Session {
        pub opts: (),
    }
}

mod b {
    fn foo<'tcx>(tcx: crate::TyCtxt<'tcx>) {
        tcx.opts;
        //~^ ERROR no field `opts` on type `TyCtxt<'tcx>`
        //~| HELP one of the expressions' fields has a field of the same name
    }
}

fn main() {}