Skip to content

Commit f556c8c

Browse files
committed
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
2 parents 0ae4b97 + ae06747 commit f556c8c

9 files changed

+33
-14
lines changed

src/libsyntax/parse/parser.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,12 @@ impl<'a> Parser<'a> {
16581658
let bounds = {
16591659
if self.eat(&token::BINOP(token::PLUS)) {
16601660
let (_, bounds) = self.parse_ty_param_bounds(false);
1661+
if bounds.len() == 0 {
1662+
let last_span = self.last_span;
1663+
self.span_err(last_span,
1664+
"at least one type parameter bound \
1665+
must be specified after the `+`");
1666+
}
16611667
Some(bounds)
16621668
} else {
16631669
None

src/test/compile-fail/kindck-send.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn test<'a,T,U:Send>(_: &'a int) {
4040
assert_send::<&'static Dummy>(); //~ ERROR does not fulfill `Send`
4141
assert_send::<&'a Dummy>(); //~ ERROR does not fulfill `Send`
4242
assert_send::<&'a Dummy+Send>(); //~ ERROR does not fulfill `Send`
43-
assert_send::<Box<Dummy+>>(); //~ ERROR does not fulfill `Send`
43+
assert_send::<Box<Dummy>>(); //~ ERROR does not fulfill `Send`
4444

4545
// ...unless they are properly bounded
4646
assert_send::<&'static Dummy+Send>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2012 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+
use std::fmt::Show;
12+
13+
fn main() {
14+
let x: Box<Show+> = box 3 as Box<Show+>;
15+
//~^ ERROR at least one type parameter bound must be specified
16+
//~^^ ERROR at least one type parameter bound must be specified
17+
}
18+

src/test/compile-fail/trait-bounds-cant-coerce.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn c(x: Box<Foo+Share+Send>) {
1919
a(x);
2020
}
2121

22-
fn d(x: Box<Foo+>) {
22+
fn d(x: Box<Foo>) {
2323
a(x); //~ ERROR found no bounds
2424
}
2525

src/test/run-pass/close-over-big-then-small-data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
3333
}
3434
}
3535

36-
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>+> {
36+
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>> {
3737
box Invoker {
3838
a: a,
3939
b: b,
40-
} as (Box<Invokable<A>>+)
40+
} as (Box<Invokable<A>>)
4141
}
4242

4343
pub fn main() {

src/test/run-pass/closure-syntax.rs

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ fn bar<'b>() {
5959
foo::< <'a>|int, f32, &'a int|:'b + Share -> &'a int>();
6060
foo::<proc()>();
6161
foo::<proc() -> ()>();
62-
foo::<proc():>();
6362
foo::<proc():'static>();
6463
foo::<proc():Share>();
6564
foo::<proc<'a>(int, f32, &'a int):'static + Share -> &'a int>();

src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ pub fn main() {}
2020
trait A {}
2121
impl<T: 'static> A for T {}
2222

23-
fn owned1<T: 'static>(a: T) { box a as Box<A+>; } /* note `:` */
2423
fn owned2<T: 'static>(a: Box<T>) { a as Box<A>; }
2524
fn owned3<T: 'static>(a: Box<T>) { box a as Box<A>; }

src/test/run-pass/proc-bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn main() {
2828

2929

3030
let a = 3;
31-
bar::<proc():>(proc() {
31+
bar::<proc()>(proc() {
3232
let b = &a;
3333
println!("{}", *b);
3434
});

src/test/run-pass/trait-bounds-basic.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@
1212
trait Foo {
1313
}
1414

15-
fn a(_x: Box<Foo+>) {
16-
}
17-
1815
fn b(_x: Box<Foo+Send>) {
1916
}
2017

2118
fn c(x: Box<Foo+Share+Send>) {
22-
a(x);
19+
e(x);
2320
}
2421

2522
fn d(x: Box<Foo+Send>) {
26-
b(x);
23+
e(x);
2724
}
2825

29-
fn e(x: Box<Foo>) { // sugar for Box<Foo+Owned>
30-
a(x);
26+
fn e(x: Box<Foo>) {
27+
e(x);
3128
}
3229

3330
pub fn main() { }

0 commit comments

Comments
 (0)