]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/autoderef-privacy.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Check we do not select a private method or field when computing autoderefs
16 pub struct Bar2 { i: i32 }
21 fn f(&self) -> bool { true }
26 pub struct Bar { i: ::Bar2 }
28 pub struct Baz(::Baz2
);
31 fn f(&self) -> bool { false }
34 impl ::std
::ops
::Deref
for Bar
{
36 fn deref(&self) -> &::Bar2 { &self.i }
39 impl ::std
::ops
::Deref
for Baz
{
41 fn deref(&self) -> &::Baz2 { &self.0 }
44 pub fn f(bar
: &Bar
, baz
: &Baz
) {
45 // Since the private fields and methods are visible here, there should be no autoderefs.
46 let _
: &::Bar2
= &bar
.i
;
47 let _
: &::Baz2
= &baz
.0;
53 let bar
= foo
::Bar
::default();
54 let baz
= foo
::Baz
::default();