auto merge of #5069 : pcwalton/rust/plussing-2, r=pcwalton

This commit is contained in:
bors 2013-02-21 08:35:12 -08:00
commit c0218fb106
10 changed files with 52 additions and 53 deletions

View File

@ -2072,12 +2072,12 @@ on values of type `T` inside the function. It will also cause a
compile-time error when anyone tries to call `print_all` on an array
whose element type does not have a `Printable` implementation.
Type parameters can have multiple bounds by separating them with spaces,
Type parameters can have multiple bounds by separating them with `+`,
as in this version of `print_all` that copies elements.
~~~
# trait Printable { fn print(&self); }
fn print_all<T: Printable Copy>(printable_things: ~[T]) {
fn print_all<T: Printable + Copy>(printable_things: ~[T]) {
let mut i = 0;
while i < printable_things.len() {
let copy_of_thing = printable_things[i];

View File

@ -1203,8 +1203,8 @@ pub trait Select2<T:Owned,U:Owned> {
impl<T: Owned,
U: Owned,
Left: Selectable GenericPort<T>,
Right: Selectable GenericPort<U>>
Left: Selectable + GenericPort<T>,
Right: Selectable + GenericPort<U>>
Select2<T,U> for (Left, Right) {
fn select() -> Either<T, U> {
match self {

View File

@ -72,8 +72,8 @@ pub impl LatticeValue for ty::t {
}
pub impl CombineFields {
fn var_sub_var<T:Copy InferStr LatticeValue,
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
fn var_sub_var<T:Copy + InferStr + LatticeValue,
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
&self,
+a_id: V,
+b_id: V) -> ures
@ -125,8 +125,8 @@ pub impl CombineFields {
}
/// make variable a subtype of T
fn var_sub_t<T:Copy InferStr LatticeValue,
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
fn var_sub_t<T:Copy + InferStr + LatticeValue,
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
&self,
+a_id: V,
+b: T) -> ures
@ -149,8 +149,8 @@ pub impl CombineFields {
a_id, a_bounds, b_bounds, node_a.rank)
}
fn t_sub_var<T:Copy InferStr LatticeValue,
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
fn t_sub_var<T:Copy + InferStr + LatticeValue,
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
&self,
+a: T,
+b_id: V) -> ures
@ -201,8 +201,8 @@ pub impl CombineFields {
}
}
fn set_var_to_merged_bounds<T:Copy InferStr LatticeValue,
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
fn set_var_to_merged_bounds<T:Copy + InferStr + LatticeValue,
V:Copy+Eq+ToStr+Vid+UnifyVid<Bounds<T>>>(
&self,
+v_id: V,
a: &Bounds<T>,
@ -395,9 +395,9 @@ pub enum LatticeVarResult<V,T> {
* the variables and return the unified variable, in which case the
* result is a variable. This is indicated with a `VarResult`
* return. */
pub fn lattice_vars<L:LatticeDir Combine,
T:Copy InferStr LatticeValue,
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
pub fn lattice_vars<L:LatticeDir + Combine,
T:Copy + InferStr + LatticeValue,
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
self: &L, // defines whether we want LUB or GLB
+a_vid: V, // first variable
+b_vid: V, // second variable
@ -441,9 +441,9 @@ pub fn lattice_vars<L:LatticeDir Combine,
}
}
pub fn lattice_var_and_t<L:LatticeDir Combine,
T:Copy InferStr LatticeValue,
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
pub fn lattice_var_and_t<L:LatticeDir + Combine,
T:Copy + InferStr + LatticeValue,
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
self: &L,
+a_id: V,
b: &T,

View File

@ -163,8 +163,8 @@ pub fn mk_err<T:SimplyUnifiable>(+a_is_expected: bool,
}
pub impl InferCtxt {
fn simple_vars<T:Copy Eq InferStr SimplyUnifiable,
V:Copy Eq Vid ToStr UnifyVid<Option<T>>>(
fn simple_vars<T:Copy + Eq + InferStr + SimplyUnifiable,
V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
&mut self,
+a_is_expected: bool,
+a_id: V,
@ -201,8 +201,8 @@ pub impl InferCtxt {
return uok();
}
fn simple_var_t<T:Copy Eq InferStr SimplyUnifiable,
V:Copy Eq Vid ToStr UnifyVid<Option<T>>>(
fn simple_var_t<T:Copy + Eq + InferStr + SimplyUnifiable,
V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
&mut self,
+a_is_expected: bool,
+a_id: V,

View File

@ -151,7 +151,7 @@ pub mod serial {
}
/// Create a pair of `FlatChan` and `FlatPort`, backed by pipes
pub fn pipe_stream<T: Encodable<DefaultEncoder>
pub fn pipe_stream<T: Encodable<DefaultEncoder> +
Decodable<DefaultDecoder>>(
) -> (PipePort<T>, PipeChan<T>) {
let (port, chan) = pipes::stream();
@ -443,8 +443,8 @@ pub mod flatteners {
SerializingFlattener
*/
pub fn deserialize_buffer<D: Decoder FromReader,
T: Decodable<D>>(buf: &[u8]) -> T {
pub fn deserialize_buffer<D: Decoder + FromReader,
T: Decodable<D>>(buf: &[u8]) -> T {
let buf = vec::from_slice(buf);
let buf_reader = @BufReader::new(buf);
let reader = buf_reader as @Reader;
@ -452,8 +452,8 @@ pub mod flatteners {
Decodable::decode(&deser)
}
pub fn serialize_value<D: Encoder FromWriter,
T: Encodable<D>>(val: &T) -> ~[u8] {
pub fn serialize_value<D: Encoder + FromWriter,
T: Encodable<D>>(val: &T) -> ~[u8] {
let bytes_writer = @BytesWriter();
let writer = bytes_writer as @Writer;
let ser = FromWriter::from_writer(writer);

View File

@ -260,9 +260,7 @@ impl Context {
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
}
fn prep<T:Owned
Encodable<json::Encoder>
Decodable<json::Decoder>>(
fn prep<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
@self,
fn_name:&str,
blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> {
@ -278,9 +276,8 @@ trait TPrep {
fn declare_input(&self, kind:&str, name:&str, val:&str);
fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool;
fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool;
fn exec<T:Owned
Encodable<json::Encoder>
Decodable<json::Decoder>>(&self, blk: ~fn(&Exec) -> T) -> Work<T>;
fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
&self, blk: ~fn(&Exec) -> T) -> Work<T>;
}
impl TPrep for @Mut<Prep> {
@ -318,11 +315,8 @@ impl TPrep for @Mut<Prep> {
return true;
}
fn exec<T:Owned
Encodable<json::Encoder>
Decodable<json::Decoder>>(&self,
blk: ~fn(&Exec) -> T) -> Work<T> {
fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
&self, blk: ~fn(&Exec) -> T) -> Work<T> {
let mut bo = Some(blk);
do self.borrow_imm |p| {
@ -360,20 +354,15 @@ impl TPrep for @Mut<Prep> {
}
}
impl<T:Owned
Encodable<json::Encoder>
Decodable<json::Decoder>>
Work<T> {
impl<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>> Work<T> {
static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
Work { prep: p, res: Some(e) }
}
}
// FIXME (#3724): movable self. This should be in impl Work.
fn unwrap<T:Owned
Encodable<json::Encoder>
Decodable<json::Decoder>>(w: Work<T>) -> T {
fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
w: Work<T>) -> T {
let mut ww = w;
let mut s = None;
@ -383,7 +372,6 @@ fn unwrap<T:Owned
None => fail!(),
Some(Left(v)) => v,
Some(Right(port)) => {
let (exe, v) = match recv(port) {
oneshot::send(data) => data
};

View File

@ -46,7 +46,8 @@ pub enum ObsoleteSyntax {
ObsoleteBinaryMove,
ObsoleteUnsafeBlock,
ObsoleteUnenforcedBound,
ObsoleteImplSyntax
ObsoleteImplSyntax,
ObsoleteTraitBoundSeparator,
}
pub impl to_bytes::IterBytes for ObsoleteSyntax {
@ -120,7 +121,11 @@ pub impl Parser {
ObsoleteImplSyntax => (
"colon-separated impl syntax",
"write `impl Trait for Type`"
)
),
ObsoleteTraitBoundSeparator => (
"space-separated trait bounds",
"write `+` between trait bounds"
),
};
self.report(sp, kind, kind_str, desc);

View File

@ -75,6 +75,7 @@ use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove};
use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith};
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::obsolete::{ObsoleteTraitBoundSeparator};
use parse::prec::{as_prec, token_to_binop};
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@ -2676,7 +2677,12 @@ pub impl Parser {
}
if self.eat(token::BINOP(token::PLUS)) {
// Should be `break;` but that isn't backwards compatible.
loop;
}
if is_ident_or_path(self.token) {
self.obsolete(copy self.span,
ObsoleteTraitBoundSeparator);
}
}
}

View File

@ -38,8 +38,8 @@ fn test_prettyprint<A:Encodable<prettyprint::Serializer>>(
}
fn test_ebml<A:
Eq
Encodable<EBWriter::Encoder>
Eq +
Encodable<EBWriter::Encoder> +
Decodable<EBReader::Decoder>
>(a1: &A) {
let bytes = do io::with_bytes_writer |wr| {

View File

@ -59,7 +59,7 @@ fn square_from_char(c: char) -> square {
}
}
fn read_board_grid<rdr: &static io::Reader>(+in: rdr) -> ~[~[square]] {
fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] {
let in = (in) as io::Reader;
let mut grid = ~[];
for in.each_line |line| {