Skip to content

Commit b71a882

Browse files
committed
rustc: Fix coherence errors in the build
1 parent db020ab commit b71a882

File tree

5 files changed

+45
-31
lines changed

5 files changed

+45
-31
lines changed

src/libcore/core.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import option::{some, none};
66
import option = option::option;
77
import path = path::path;
8-
import tuple::extensions;
8+
import tuple::{extensions, tuple_ops, extended_tuple_ops};
99
import str::{extensions, str_slice, unique_str};
1010
import vec::extensions;
1111
import vec::{const_vector, copyable_vector, immutable_vector};
@@ -40,6 +40,7 @@ export str_slice, unique_str;
4040
export const_vector, copyable_vector, immutable_vector;
4141
export immutable_copyable_vector, iter_trait_extensions, vec_concat;
4242
export base_iter, copyable_iter, extended_iter;
43+
export tuple_ops, extended_tuple_ops;
4344
export ptr;
4445

4546
// Export the log levels as global constants. Higher levels mean

src/libcore/tuple.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
//! Operations on tuples
22
3+
trait tuple_ops<T,U> {
4+
pure fn first() -> T;
5+
pure fn second() -> U;
6+
pure fn swap() -> (U, T);
7+
}
38

4-
impl extensions <T:copy, U:copy> for (T, U) {
9+
impl extensions <T:copy, U:copy> of tuple_ops<T,U> for (T, U) {
510

611
/// Return the first element of self
712
pure fn first() -> T {
@@ -23,7 +28,14 @@ impl extensions <T:copy, U:copy> for (T, U) {
2328

2429
}
2530

26-
impl extensions<A: copy, B: copy> for (&[A], &[B]) {
31+
trait extended_tuple_ops<A,B> {
32+
fn zip() -> ~[(A, B)];
33+
fn map<C>(f: fn(A, B) -> C) -> ~[C];
34+
}
35+
36+
impl extensions<A: copy, B: copy> of extended_tuple_ops<A,B>
37+
for (&[A], &[B]) {
38+
2739
fn zip() -> ~[(A, B)] {
2840
let (a, b) = self;
2941
vec::zip(a, b)
@@ -35,7 +47,9 @@ impl extensions<A: copy, B: copy> for (&[A], &[B]) {
3547
}
3648
}
3749

38-
impl extensions<A: copy, B: copy> for (~[A], ~[B]) {
50+
impl extensions<A: copy, B: copy> of extended_tuple_ops<A,B>
51+
for (~[A], ~[B]) {
52+
3953
fn zip() -> ~[(A, B)] {
4054
let (a, b) = self;
4155
vec::zip(a, b)

src/libsyntax/ext/pipes/ast_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl ast_builder of ext_ctxt_ast_builder for ext_ctxt {
202202
span: empty_span()}
203203
}
204204

205-
fn ty_nil() -> @ast::ty {
205+
fn ty_nil_ast_builder() -> @ast::ty {
206206
@{id: self.next_id(),
207207
node: ast::ty_nil,
208208
span: empty_span()}

src/libsyntax/ext/pipes/pipec.rs

+22-24
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ import ast_builder::ast_builder;
2222
import ast_builder::methods;
2323
import ast_builder::path;
2424

25-
impl compile for message {
25+
trait gen_send {
26+
fn gen_send(cx: ext_ctxt) -> @ast::item;
27+
}
28+
29+
trait to_type_decls {
30+
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item];
31+
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item];
32+
}
33+
34+
trait gen_init {
35+
fn gen_init(cx: ext_ctxt) -> @ast::item;
36+
fn compile(cx: ext_ctxt) -> @ast::item;
37+
}
38+
39+
impl compile of gen_send for message {
2640
fn gen_send(cx: ext_ctxt) -> @ast::item {
2741
#debug("pipec: gen_send");
2842
alt self {
@@ -80,7 +94,7 @@ impl compile for message {
8094

8195
let args_ast = vec::append(
8296
~[cx.arg_mode(@~"pipe",
83-
cx.ty_path(path(this.data_name())
97+
cx.ty_path_ast_builder(path(this.data_name())
8498
.add_tys(cx.ty_vars(this.ty_params))),
8599
ast::by_copy)],
86100
args_ast);
@@ -104,20 +118,20 @@ impl compile for message {
104118

105119
cx.item_fn_poly(self.name(),
106120
args_ast,
107-
cx.ty_nil(),
121+
cx.ty_nil_ast_builder(),
108122
self.get_params(),
109123
cx.expr_block(body))
110124
}
111125
}
112126
}
113127

114128
fn to_ty(cx: ext_ctxt) -> @ast::ty {
115-
cx.ty_path_ast_builder(path(self.name)
116-
.add_tys(cx.ty_vars(self.ty_params)))
129+
cx.ty_path_ast_builder(path(self.name())
130+
.add_tys(cx.ty_vars(self.get_params())))
117131
}
118132
}
119133

120-
impl compile for state {
134+
impl compile of to_type_decls for state {
121135
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] {
122136
#debug("pipec: to_type_decls");
123137
// This compiles into two different type declarations. Say the
@@ -144,7 +158,7 @@ impl compile for state {
144158
};
145159

146160
vec::append_one(tys,
147-
cx.ty_path((dir + next_name)
161+
cx.ty_path_ast_builder((dir + next_name)
148162
.add_tys(next_tys)))
149163
}
150164
none { tys }
@@ -184,7 +198,7 @@ impl compile for state {
184198
}
185199
}
186200

187-
impl compile for protocol {
201+
impl compile of gen_init for protocol {
188202
fn gen_init(cx: ext_ctxt) -> @ast::item {
189203
let start_state = self.states[0];
190204

@@ -303,19 +317,3 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt {
303317
}
304318
}
305319

306-
trait two_vector_utils<A, B> {
307-
fn zip() -> ~[(A, B)];
308-
fn map<C>(f: fn(A, B) -> C) -> ~[C];
309-
}
310-
311-
impl methods<A: copy, B: copy> of two_vector_utils<A, B> for (~[A], ~[B]) {
312-
fn zip() -> ~[(A, B)] {
313-
let (a, b) = self;
314-
vec::zip(a, b)
315-
}
316-
317-
fn map<C>(f: fn(A, B) -> C) -> ~[C] {
318-
let (a, b) = self;
319-
vec::map2(a, b, f)
320-
}
321-
}

src/libsyntax/ext/pipes/proto.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import dvec::{dvec, extensions};
33

44
import ast::{ident};
55

6-
import ast_builder::{path, methods, ast_builder};
6+
import ast_builder::{path, methods, ast_builder, append_types};
77

88
enum direction {
99
send, recv
@@ -78,7 +78,8 @@ impl methods for state {
7878
}
7979

8080
fn to_ty(cx: ext_ctxt) -> @ast::ty {
81-
cx.ty_path(path(self.name).add_tys(cx.ty_vars(self.ty_params)))
81+
cx.ty_path_ast_builder
82+
(path(self.name).add_tys(cx.ty_vars(self.ty_params)))
8283
}
8384
}
8485

0 commit comments

Comments
 (0)