rustc: Fix coherence errors in the build
This commit is contained in:
parent
db020ab63c
commit
b71a8827e3
@ -5,7 +5,7 @@
|
||||
import option::{some, none};
|
||||
import option = option::option;
|
||||
import path = path::path;
|
||||
import tuple::extensions;
|
||||
import tuple::{extensions, tuple_ops, extended_tuple_ops};
|
||||
import str::{extensions, str_slice, unique_str};
|
||||
import vec::extensions;
|
||||
import vec::{const_vector, copyable_vector, immutable_vector};
|
||||
@ -40,6 +40,7 @@ export str_slice, unique_str;
|
||||
export const_vector, copyable_vector, immutable_vector;
|
||||
export immutable_copyable_vector, iter_trait_extensions, vec_concat;
|
||||
export base_iter, copyable_iter, extended_iter;
|
||||
export tuple_ops, extended_tuple_ops;
|
||||
export ptr;
|
||||
|
||||
// Export the log levels as global constants. Higher levels mean
|
||||
|
@ -1,7 +1,12 @@
|
||||
//! Operations on tuples
|
||||
|
||||
trait tuple_ops<T,U> {
|
||||
pure fn first() -> T;
|
||||
pure fn second() -> U;
|
||||
pure fn swap() -> (U, T);
|
||||
}
|
||||
|
||||
impl extensions <T:copy, U:copy> for (T, U) {
|
||||
impl extensions <T:copy, U:copy> of tuple_ops<T,U> for (T, U) {
|
||||
|
||||
/// Return the first element of self
|
||||
pure fn first() -> T {
|
||||
@ -23,7 +28,14 @@ impl extensions <T:copy, U:copy> for (T, U) {
|
||||
|
||||
}
|
||||
|
||||
impl extensions<A: copy, B: copy> for (&[A], &[B]) {
|
||||
trait extended_tuple_ops<A,B> {
|
||||
fn zip() -> ~[(A, B)];
|
||||
fn map<C>(f: fn(A, B) -> C) -> ~[C];
|
||||
}
|
||||
|
||||
impl extensions<A: copy, B: copy> of extended_tuple_ops<A,B>
|
||||
for (&[A], &[B]) {
|
||||
|
||||
fn zip() -> ~[(A, B)] {
|
||||
let (a, b) = self;
|
||||
vec::zip(a, b)
|
||||
@ -35,7 +47,9 @@ impl extensions<A: copy, B: copy> for (&[A], &[B]) {
|
||||
}
|
||||
}
|
||||
|
||||
impl extensions<A: copy, B: copy> for (~[A], ~[B]) {
|
||||
impl extensions<A: copy, B: copy> of extended_tuple_ops<A,B>
|
||||
for (~[A], ~[B]) {
|
||||
|
||||
fn zip() -> ~[(A, B)] {
|
||||
let (a, b) = self;
|
||||
vec::zip(a, b)
|
||||
|
@ -202,7 +202,7 @@ impl ast_builder of ext_ctxt_ast_builder for ext_ctxt {
|
||||
span: empty_span()}
|
||||
}
|
||||
|
||||
fn ty_nil() -> @ast::ty {
|
||||
fn ty_nil_ast_builder() -> @ast::ty {
|
||||
@{id: self.next_id(),
|
||||
node: ast::ty_nil,
|
||||
span: empty_span()}
|
||||
|
@ -22,7 +22,21 @@ import ast_builder::ast_builder;
|
||||
import ast_builder::methods;
|
||||
import ast_builder::path;
|
||||
|
||||
impl compile for message {
|
||||
trait gen_send {
|
||||
fn gen_send(cx: ext_ctxt) -> @ast::item;
|
||||
}
|
||||
|
||||
trait to_type_decls {
|
||||
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item];
|
||||
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item];
|
||||
}
|
||||
|
||||
trait gen_init {
|
||||
fn gen_init(cx: ext_ctxt) -> @ast::item;
|
||||
fn compile(cx: ext_ctxt) -> @ast::item;
|
||||
}
|
||||
|
||||
impl compile of gen_send for message {
|
||||
fn gen_send(cx: ext_ctxt) -> @ast::item {
|
||||
#debug("pipec: gen_send");
|
||||
alt self {
|
||||
@ -80,7 +94,7 @@ impl compile for message {
|
||||
|
||||
let args_ast = vec::append(
|
||||
~[cx.arg_mode(@~"pipe",
|
||||
cx.ty_path(path(this.data_name())
|
||||
cx.ty_path_ast_builder(path(this.data_name())
|
||||
.add_tys(cx.ty_vars(this.ty_params))),
|
||||
ast::by_copy)],
|
||||
args_ast);
|
||||
@ -104,7 +118,7 @@ impl compile for message {
|
||||
|
||||
cx.item_fn_poly(self.name(),
|
||||
args_ast,
|
||||
cx.ty_nil(),
|
||||
cx.ty_nil_ast_builder(),
|
||||
self.get_params(),
|
||||
cx.expr_block(body))
|
||||
}
|
||||
@ -112,12 +126,12 @@ impl compile for message {
|
||||
}
|
||||
|
||||
fn to_ty(cx: ext_ctxt) -> @ast::ty {
|
||||
cx.ty_path_ast_builder(path(self.name)
|
||||
.add_tys(cx.ty_vars(self.ty_params)))
|
||||
cx.ty_path_ast_builder(path(self.name())
|
||||
.add_tys(cx.ty_vars(self.get_params())))
|
||||
}
|
||||
}
|
||||
|
||||
impl compile for state {
|
||||
impl compile of to_type_decls for state {
|
||||
fn to_type_decls(cx: ext_ctxt) -> ~[@ast::item] {
|
||||
#debug("pipec: to_type_decls");
|
||||
// This compiles into two different type declarations. Say the
|
||||
@ -144,7 +158,7 @@ impl compile for state {
|
||||
};
|
||||
|
||||
vec::append_one(tys,
|
||||
cx.ty_path((dir + next_name)
|
||||
cx.ty_path_ast_builder((dir + next_name)
|
||||
.add_tys(next_tys)))
|
||||
}
|
||||
none { tys }
|
||||
@ -184,7 +198,7 @@ impl compile for state {
|
||||
}
|
||||
}
|
||||
|
||||
impl compile for protocol {
|
||||
impl compile of gen_init for protocol {
|
||||
fn gen_init(cx: ext_ctxt) -> @ast::item {
|
||||
let start_state = self.states[0];
|
||||
|
||||
@ -303,19 +317,3 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt {
|
||||
}
|
||||
}
|
||||
|
||||
trait two_vector_utils<A, B> {
|
||||
fn zip() -> ~[(A, B)];
|
||||
fn map<C>(f: fn(A, B) -> C) -> ~[C];
|
||||
}
|
||||
|
||||
impl methods<A: copy, B: copy> of two_vector_utils<A, B> for (~[A], ~[B]) {
|
||||
fn zip() -> ~[(A, B)] {
|
||||
let (a, b) = self;
|
||||
vec::zip(a, b)
|
||||
}
|
||||
|
||||
fn map<C>(f: fn(A, B) -> C) -> ~[C] {
|
||||
let (a, b) = self;
|
||||
vec::map2(a, b, f)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import dvec::{dvec, extensions};
|
||||
|
||||
import ast::{ident};
|
||||
|
||||
import ast_builder::{path, methods, ast_builder};
|
||||
import ast_builder::{path, methods, ast_builder, append_types};
|
||||
|
||||
enum direction {
|
||||
send, recv
|
||||
@ -78,7 +78,8 @@ impl methods for state {
|
||||
}
|
||||
|
||||
fn to_ty(cx: ext_ctxt) -> @ast::ty {
|
||||
cx.ty_path(path(self.name).add_tys(cx.ty_vars(self.ty_params)))
|
||||
cx.ty_path_ast_builder
|
||||
(path(self.name).add_tys(cx.ty_vars(self.ty_params)))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user