auto merge of #15062 : pcwalton/rust/trailing-plus, r=brson

This will break code that looks like `Box<Trait+>`. Change that code to
`Box<Trait>` instead.

Closes #14925.

[breaking-change]

r? @brson
This commit is contained in:
bors 2014-06-21 15:36:39 +00:00
commit f556c8cbd8
9 changed files with 33 additions and 14 deletions

View File

@ -1658,6 +1658,12 @@ pub fn parse_path(&mut self, mode: PathParsingMode) -> PathAndBounds {
let bounds = {
if self.eat(&token::BINOP(token::PLUS)) {
let (_, bounds) = self.parse_ty_param_bounds(false);
if bounds.len() == 0 {
let last_span = self.last_span;
self.span_err(last_span,
"at least one type parameter bound \
must be specified after the `+`");
}
Some(bounds)
} else {
None

View File

@ -40,7 +40,7 @@ fn test<'a,T,U:Send>(_: &'a int) {
assert_send::<&'static Dummy>(); //~ ERROR does not fulfill `Send`
assert_send::<&'a Dummy>(); //~ ERROR does not fulfill `Send`
assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill `Send`
assert_send::<Box<Dummy+>>(); //~ ERROR does not fulfill `Send`
assert_send::<Box<Dummy>>(); //~ ERROR does not fulfill `Send`
// ...unless they are properly bounded
assert_send::<&'static Dummy+Send>();

View File

@ -0,0 +1,18 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::fmt::Show;
fn main() {
let x: Box<Show+> = box 3 as Box<Show+>;
//~^ ERROR at least one type parameter bound must be specified
//~^^ ERROR at least one type parameter bound must be specified
}

View File

@ -19,7 +19,7 @@ fn c(x: Box<Foo+Share+Send>) {
a(x);
}
fn d(x: Box<Foo+>) {
fn d(x: Box<Foo>) {
a(x); //~ ERROR found no bounds
}

View File

@ -33,11 +33,11 @@ fn f(&self) -> (A, u16) {
}
}
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+> {
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>> {
box Invoker {
a: a,
b: b,
} as (Box<Invokable<A>>+)
} as (Box<Invokable<A>>)
}
pub fn main() {

View File

@ -59,7 +59,6 @@ fn bar<'b>() {
foo::< <'a>|int, f32, &'a int|:'b + Share -> &'a int>();
foo::<proc()>();
foo::<proc() -> ()>();
foo::<proc():>();
foo::<proc():'static>();
foo::<proc():Share>();
foo::<proc<'a>(int, f32, &'a int):'static + Share -> &'a int>();

View File

@ -20,6 +20,5 @@ pub fn main() {}
trait A {}
impl<T: 'static> A for T {}
fn owned1<T: 'static>(a: T) { box a as Box<A+>; } /* note `:` */
fn owned2<T: 'static>(a: Box<T>) { a as Box<A>; }
fn owned3<T: 'static>(a: Box<T>) { box a as Box<A>; }

View File

@ -28,7 +28,7 @@ pub fn main() {
let a = 3;
bar::<proc():>(proc() {
bar::<proc()>(proc() {
let b = &a;
println!("{}", *b);
});

View File

@ -12,22 +12,19 @@
trait Foo {
}
fn a(_x: Box<Foo+>) {
}
fn b(_x: Box<Foo+Send>) {
}
fn c(x: Box<Foo+Share+Send>) {
a(x);
e(x);
}
fn d(x: Box<Foo+Send>) {
b(x);
e(x);
}
fn e(x: Box<Foo>) { // sugar for Box<Foo+Owned>
a(x);
fn e(x: Box<Foo>) {
e(x);
}
pub fn main() { }