Skip to content

Commit f5ed25c

Browse files
committed
---
yaml --- r: 156343 b: refs/heads/snap-stage3 c: fe8e591 h: refs/heads/master i: 156341: 79848a4 156339: f64bb63 156335: df814e0 v: v3
1 parent 8451439 commit f5ed25c

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: c29a7520e7fb4a5b4d4eccfc594e05793ef6688d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: eb598e5344bde56b0ba12681e7d46c25b2dd1c88
4+
refs/heads/snap-stage3: fe8e591147857a0f5ad10570e7cc3f304e9b2cd2
55
refs/heads/try: 6601b0501e31d08d3892a2d5a7d8a57ab120bf75
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Copyright 2014 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+
// Test method calls with self as an argument
12+
13+
static mut COUNT: u64 = 1;
14+
15+
struct Foo;
16+
17+
trait Bar {
18+
fn foo1(&self);
19+
fn foo2(self);
20+
fn foo3(self: Box<Self>);
21+
22+
fn bar1(&self) {
23+
unsafe { COUNT *= 7; }
24+
}
25+
fn bar2(self) {
26+
unsafe { COUNT *= 11; }
27+
}
28+
fn bar3(self: Box<Self>) {
29+
unsafe { COUNT *= 13; }
30+
}
31+
}
32+
33+
impl Bar for Foo {
34+
fn foo1(&self) {
35+
unsafe { COUNT *= 2; }
36+
}
37+
38+
fn foo2(self) {
39+
unsafe { COUNT *= 3; }
40+
}
41+
42+
fn foo3(self: Box<Foo>) {
43+
unsafe { COUNT *= 5; }
44+
}
45+
}
46+
47+
impl Foo {
48+
fn baz(self) {
49+
unsafe { COUNT *= 17; }
50+
// Test internal call.
51+
Bar::foo1(&self);
52+
Bar::foo2(self);
53+
Bar::foo3(box self);
54+
55+
Bar::bar1(&self);
56+
Bar::bar2(self);
57+
Bar::bar3(box self);
58+
}
59+
}
60+
61+
fn main() {
62+
let x = Foo;
63+
// Test external call.
64+
Bar::foo1(&x);
65+
Bar::foo2(x);
66+
Bar::foo3(box x);
67+
68+
Bar::bar1(&x);
69+
Bar::bar2(x);
70+
Bar::bar3(box x);
71+
72+
x.baz();
73+
74+
unsafe { assert!(COUNT == 2u64*2*3*3*5*5*7*7*11*11*13*13*17); }
75+
}

0 commit comments

Comments
 (0)