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::>(); //~ ERROR does not fulfill `Send` + assert_send::>(); //~ 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 or the MIT license +// , 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 = box 3 as Box; + //~^ 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) { a(x); } -fn d(x: Box) { +fn d(x: Box) { 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 Invokable for Invoker { } } -fn f(a: A, b: u16) -> Box+> { +fn f(a: A, b: u16) -> Box> { box Invoker { a: a, b: b, - } as (Box>+) + } as (Box>) } 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::(); foo:: ()>(); - foo::(); foo::(); foo::(); foo::(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 A for T {} -fn owned1(a: T) { box a as Box; } /* note `:` */ fn owned2(a: Box) { a as Box; } fn owned3(a: Box) { box a as Box; } 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() { + bar::(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) { -} - fn b(_x: Box) { } fn c(x: Box) { - a(x); + e(x); } fn d(x: Box) { - b(x); + e(x); } -fn e(x: Box) { // sugar for Box - a(x); +fn e(x: Box) { + e(x); } pub fn main() { }