]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/issue-35169-2.rs
rustc_typeck: do not overlap a borrow of TypeckTables with method lookup.
[rust.git] / src / test / rustdoc / issue-35169-2.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.
4 //
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.
10
11 use std::ops::Deref;
12 use std::ops::DerefMut;
13
14 pub struct Foo;
15 pub struct Bar;
16
17 impl Foo {
18     pub fn by_ref(&self) {}
19     pub fn by_explicit_ref(self: &Foo) {}
20     pub fn by_mut_ref(&mut self) {}
21     pub fn by_explicit_mut_ref(self: &mut Foo) {}
22     pub fn static_foo() {}
23 }
24
25 impl Deref for Bar {
26     type Target = Foo;
27     fn deref(&self) -> &Foo { loop {} }
28 }
29
30 impl DerefMut for Bar {
31     fn deref_mut(&mut self) -> &mut Foo { loop {} }
32 }
33
34 // @has issue_35169_2/Bar.t.html
35 // @has issue_35169_2/struct.Bar.html
36 // @has - '//*[@id="by_ref.v"]' 'fn by_ref(&self)'
37 // @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)'
38 // @has - '//*[@id="by_explicit_ref.v"]' 'fn by_explicit_ref(self: &Foo)'
39 // @has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)'
40 // @has - '//*[@id="by_mut_ref.v"]' 'fn by_mut_ref(&mut self)'
41 // @has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)'
42 // @has - '//*[@id="by_explicit_mut_ref.v"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
43 // @has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
44 // @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
45 // @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'