diff options
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/kindck-send.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/trailing-plus-in-bounds.rs | 18 | ||||
| -rw-r--r-- | src/test/compile-fail/trait-bounds-cant-coerce.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/close-over-big-then-small-data.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/closure-syntax.rs | 1 | ||||
| -rw-r--r-- | src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs | 1 | ||||
| -rw-r--r-- | src/test/run-pass/proc-bounds.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/trait-bounds-basic.rs | 11 |
9 files changed, 33 insertions, 14 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ae2ec216bee..158a8c5a116 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1646,6 +1646,12 @@ impl<'a> Parser<'a> { 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 diff --git a/src/test/compile-fail/kindck-send.rs b/src/test/compile-fail/kindck-send.rs index 0414e64f1b7..313b6eeb347 100644 --- a/src/test/compile-fail/kindck-send.rs +++ b/src/test/compile-fail/kindck-send.rs @@ -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>(); diff --git a/src/test/compile-fail/trailing-plus-in-bounds.rs b/src/test/compile-fail/trailing-plus-in-bounds.rs new file mode 100644 index 00000000000..e8f9ed4d2cf --- /dev/null +++ b/src/test/compile-fail/trailing-plus-in-bounds.rs @@ -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 +} + diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 3737025da6c..0b9f09d9482 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -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 } diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 3d642be082c..b5c42c453a7 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -33,11 +33,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -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() { diff --git a/src/test/run-pass/closure-syntax.rs b/src/test/run-pass/closure-syntax.rs index 2bb0e6fa19c..df7d59e2560 100644 --- a/src/test/run-pass/closure-syntax.rs +++ b/src/test/run-pass/closure-syntax.rs @@ -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>(); diff --git a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs index 47a09d55438..a08bdb09d3d 100644 --- a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs @@ -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>; } diff --git a/src/test/run-pass/proc-bounds.rs b/src/test/run-pass/proc-bounds.rs index c103e087363..b6076cc26fc 100644 --- a/src/test/run-pass/proc-bounds.rs +++ b/src/test/run-pass/proc-bounds.rs @@ -28,7 +28,7 @@ pub fn main() { let a = 3; - bar::<proc():>(proc() { + bar::<proc()>(proc() { let b = &a; println!("{}", *b); }); diff --git a/src/test/run-pass/trait-bounds-basic.rs b/src/test/run-pass/trait-bounds-basic.rs index d1bb0db511b..013a8dcf60e 100644 --- a/src/test/run-pass/trait-bounds-basic.rs +++ b/src/test/run-pass/trait-bounds-basic.rs @@ -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() { } |
