diff options
Diffstat (limited to 'tests/ui/suggestions/field-access-considering-privacy.rs')
-rw-r--r-- | tests/ui/suggestions/field-access-considering-privacy.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/suggestions/field-access-considering-privacy.rs b/tests/ui/suggestions/field-access-considering-privacy.rs new file mode 100644 index 000000000..3de06b214 --- /dev/null +++ b/tests/ui/suggestions/field-access-considering-privacy.rs @@ -0,0 +1,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() {} |