Skip to content

Commit 34bc0f5

Browse files
committed
---
yaml --- r: 137709 b: refs/heads/auto c: 2bb0796 h: refs/heads/master i: 137707: 8eecefc v: v3
1 parent 31fa73a commit 34bc0f5

File tree

5 files changed

+96
-42
lines changed

5 files changed

+96
-42
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 6340c1a3739de1519f7416ac52263b4234965739
16+
refs/heads/auto: 2bb0796ae27b3b1c0563f1779680e63b2ca322c3
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/typeck/coherence/overlap.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@ struct OverlapChecker<'cx, 'tcx:'cx> {
3535
impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
3636
fn check_for_overlapping_impls(&self) {
3737
debug!("check_for_overlapping_impls");
38-
let trait_impls = self.tcx.trait_impls.borrow();
39-
for trait_def_id in trait_impls.keys() {
38+
39+
// Collect this into a vector to avoid holding the
40+
// refcell-lock during the
41+
// check_for_overlapping_impls_of_trait() check, since that
42+
// check can populate this table further with impls from other
43+
// crates.
44+
let trait_def_ids: Vec<ast::DefId> =
45+
self.tcx.trait_impls.borrow().keys().map(|&d| d).collect();
46+
47+
for trait_def_id in trait_def_ids.iter() {
4048
self.check_for_overlapping_impls_of_trait(*trait_def_id);
4149
}
4250
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy.
12+
13+
pub trait Go {
14+
fn go(&self, arg: int);
15+
}
16+
17+
pub fn go<G:Go>(this: &G, arg: int) {
18+
this.go(arg)
19+
}
20+
21+
pub trait GoMut {
22+
fn go_mut(&mut self, arg: int);
23+
}
24+
25+
pub fn go_mut<G:GoMut>(this: &mut G, arg: int) {
26+
this.go_mut(arg)
27+
}
28+
29+
pub trait GoOnce {
30+
fn go_once(self, arg: int);
31+
}
32+
33+
pub fn go_once<G:GoOnce>(this: G, arg: int) {
34+
this.go_once(arg)
35+
}
36+
37+
impl<G> GoMut for G
38+
where G : Go
39+
{
40+
fn go_mut(&mut self, arg: int) {
41+
go(&*self, arg)
42+
}
43+
}
44+
45+
impl<G> GoOnce for G
46+
where G : GoMut
47+
{
48+
fn go_once(mut self, arg: int) {
49+
go_mut(&mut self, arg)
50+
}
51+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
// aux-build:go_trait.rs
12+
13+
extern crate go_trait;
14+
15+
use go_trait::{Go,GoMut};
16+
use std::fmt::Show;
17+
use std::default::Default;
18+
19+
struct MyThingy;
20+
21+
impl Go for MyThingy {
22+
fn go(&self, arg: int) { }
23+
}
24+
25+
impl GoMut for MyThingy { //~ ERROR conflicting implementations
26+
fn go_mut(&mut self, arg: int) { }
27+
}
28+
29+
fn main() { }

branches/auto/src/test/run-pass/traits-conditional-model-fn.rs

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,14 @@
1212
// most one of `Go`, `GoMut`, or `GoOnce`, and then the others follow
1313
// automatically.
1414

15-
use std::rc::Rc;
16-
use std::cell::Cell;
17-
18-
trait Go {
19-
fn go(&self, arg: int);
20-
}
21-
22-
fn go<G:Go>(this: &G, arg: int) {
23-
this.go(arg)
24-
}
15+
// aux-build:go_trait.rs
2516

26-
trait GoMut {
27-
fn go_mut(&mut self, arg: int);
28-
}
17+
extern crate go_trait;
2918

30-
fn go_mut<G:GoMut>(this: &mut G, arg: int) {
31-
this.go_mut(arg)
32-
}
33-
34-
trait GoOnce {
35-
fn go_once(self, arg: int);
36-
}
19+
use go_trait::{Go, GoMut, GoOnce, go, go_mut, go_once};
3720

38-
fn go_once<G:GoOnce>(this: G, arg: int) {
39-
this.go_once(arg)
40-
}
41-
42-
impl<G> GoMut for G
43-
where G : Go
44-
{
45-
fn go_mut(&mut self, arg: int) {
46-
go(&*self, arg)
47-
}
48-
}
49-
50-
impl<G> GoOnce for G
51-
where G : GoMut
52-
{
53-
fn go_once(mut self, arg: int) {
54-
go_mut(&mut self, arg)
55-
}
56-
}
21+
use std::rc::Rc;
22+
use std::cell::Cell;
5723

5824
///////////////////////////////////////////////////////////////////////////
5925

0 commit comments

Comments
 (0)