Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 23a9469

Browse files
committedJan 27, 2017
Auto merge of #39158 - petrochenkov:bounds, r=nikomatsakis
Bounds parsing refactoring 2 See #37511 for previous discussion. cc @matklad Relaxed parsing rules: - zero bounds after `:` are allowed in all contexts. - zero predicates are allowed after `where`. - trailing separator `,` is allowed after predicates in `where` clauses not followed by `{`. Other parsing rules: - trailing separator `+` is still allowed in all bound lists. Code is also cleaned up and tests added. I haven't touched parsing of trait object types yet, I'll do it later.
2 parents 8430042 + bd4d5ec commit 23a9469

32 files changed

+565
-469
lines changed
 

‎src/librustc_passes/ast_validation.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
146146
TyKind::TraitObject(ref bounds) => {
147147
self.no_questions_in_bounds(bounds, "trait object types", false);
148148
}
149+
TyKind::ImplTrait(ref bounds) => {
150+
if !bounds.iter()
151+
.any(|b| if let TraitTyParamBound(..) = *b { true } else { false }) {
152+
self.err_handler().span_err(ty.span, "at least one trait must be specified");
153+
}
154+
}
149155
_ => {}
150156
}
151157

@@ -284,6 +290,26 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
284290

285291
visit::walk_vis(self, vis)
286292
}
293+
294+
fn visit_generics(&mut self, g: &'a Generics) {
295+
let mut seen_default = None;
296+
for ty_param in &g.ty_params {
297+
if ty_param.default.is_some() {
298+
seen_default = Some(ty_param.span);
299+
} else if let Some(span) = seen_default {
300+
self.err_handler()
301+
.span_err(span, "type parameters with a default must be trailing");
302+
break
303+
}
304+
}
305+
for predicate in &g.where_clause.predicates {
306+
if let WherePredicate::EqPredicate(ref predicate) = *predicate {
307+
self.err_handler().span_err(predicate.span, "equality constraints are not yet \
308+
supported in where clauses (#20041)");
309+
}
310+
}
311+
visit::walk_generics(self, g)
312+
}
287313
}
288314

289315
pub fn check_crate(session: &Session, krate: &Crate) {

‎src/librustc_typeck/collect.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,11 +1833,8 @@ fn ty_generic_predicates<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
18331833
}
18341834
}
18351835

1836-
&hir::WherePredicate::EqPredicate(ref eq_pred) => {
1836+
&hir::WherePredicate::EqPredicate(..) => {
18371837
// FIXME(#20041)
1838-
span_bug!(eq_pred.span,
1839-
"Equality constraints are not yet \
1840-
implemented (#20041)")
18411838
}
18421839
}
18431840
}

‎src/librustdoc/clean/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,11 @@ impl Clean<WherePredicate> for hir::WherePredicate {
842842
}
843843
}
844844

845-
hir::WherePredicate::EqPredicate(_) => {
846-
unimplemented!() // FIXME(#20041)
845+
hir::WherePredicate::EqPredicate(ref wrp) => {
846+
WherePredicate::EqPredicate {
847+
lhs: wrp.lhs_ty.clean(cx),
848+
rhs: wrp.rhs_ty.clean(cx)
849+
}
847850
}
848851
}
849852
}

‎src/libsyntax/parse/parser.rs

Lines changed: 277 additions & 433 deletions
Large diffs are not rendered by default.

‎src/libsyntax/parse/token.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,29 @@ impl Token {
187187
}
188188
}
189189

190+
/// Returns `true` if the token can appear at the start of a type.
191+
pub fn can_begin_type(&self) -> bool {
192+
match *self {
193+
OpenDelim(Paren) => true, // tuple
194+
OpenDelim(Bracket) => true, // array
195+
Ident(..) => true, // type name or keyword
196+
Underscore => true, // placeholder
197+
Not => true, // never
198+
BinOp(Star) => true, // raw pointer
199+
BinOp(And) => true, // reference
200+
AndAnd => true, // double reference
201+
Lt | BinOp(Shl) => true, // associated path
202+
ModSep => true, // global path
203+
Interpolated(ref nt) => match **nt {
204+
NtTy(..) => true,
205+
NtIdent(..) => true,
206+
NtPath(..) => true,
207+
_ => false,
208+
},
209+
_ => false,
210+
}
211+
}
212+
190213
/// Returns `true` if the token is any literal
191214
pub fn is_lit(&self) -> bool {
192215
match *self {

‎src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
struct RefAny<'a, T>(&'a T);
1919

20-
impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {
21-
//~^ ERROR expected identifier, found `>`
22-
}
20+
impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
21+
//~^ ERROR trailing attribute after type parameters
2322

24-
fn main() {
25-
26-
}
23+
fn main() {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2014 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+
struct Heap;
12+
13+
struct Vec<A = Heap, T>;
14+
//~^ ERROR type parameters with a default must be trailing
15+
16+
struct Foo<A, B = Vec<C>, C>;
17+
//~^ ERROR type parameters with a default must be trailing
18+
//~| ERROR type parameters with a default cannot use forward declared identifiers
19+
20+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 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+
#![feature(conservative_impl_trait)]
12+
13+
fn f() -> impl 'static {} //~ ERROR at least one trait must be specified
14+
15+
fn main() {}

‎src/test/compile-fail/issue-20616-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
type Type_1_<'a, T> = &'a T;
1717

1818

19-
type Type_1<'a T> = &'a T; //~ error: expected `,` or `>` after lifetime name, found `T`
19+
type Type_1<'a T> = &'a T; //~ error: expected one of `,`, `:`, or `>`, found `T`
2020

2121

2222
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`

‎src/test/compile-fail/issue-20616-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Type_1_<'a, T> = &'a T;
1919
//type Type_1<'a T> = &'a T; // error: expected `,` or `>` after lifetime name, found `T`
2020

2121

22-
type Type_2 = Type_1_<'static ()>; //~ error: expected `,` or `>` after lifetime name, found `(`
22+
type Type_2 = Type_1_<'static ()>; //~ error: expected one of `,` or `>`, found `(`
2323

2424

2525
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`

‎src/test/compile-fail/issue-20616-3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Type_1_<'a, T> = &'a T;
2222
//type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
2323

2424

25-
type Type_3<T> = Box<T,,>; //~ error: expected type, found `,`
25+
type Type_3<T> = Box<T,,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,`
2626

2727

2828
//type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`

‎src/test/compile-fail/issue-20616-4.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ type Type_1_<'a, T> = &'a T;
2525
//type Type_3<T> = Box<T,,>; // error: expected type, found `,`
2626

2727

28-
type Type_4<T> = Type_1_<'static,, T>; //~ error: expected type, found `,`
28+
type Type_4<T> = Type_1_<'static,, T>;
29+
//~^ error: expected one of `>`, identifier, lifetime, or type, found `,`
2930

3031

3132
type Type_5_<'a> = Type_1_<'a, ()>;

‎src/test/compile-fail/issue-20616-5.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ type Type_1_<'a, T> = &'a T;
3131
type Type_5_<'a> = Type_1_<'a, ()>;
3232

3333

34-
type Type_5<'a> = Type_1_<'a, (),,>; //~ error: expected type, found `,`
34+
type Type_5<'a> = Type_1_<'a, (),,>;
35+
//~^ error: expected one of `>`, identifier, lifetime, or type, found `,`
3536

3637

3738
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`

‎src/test/compile-fail/issue-20616-6.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ type Type_5_<'a> = Type_1_<'a, ()>;
3434
//type Type_5<'a> = Type_1_<'a, (),,>; // error: expected type, found `,`
3535

3636

37-
type Type_6 = Type_5_<'a,,>; //~ error: expected type, found `,`
37+
type Type_6 = Type_5_<'a,,>;
38+
//~^ error: expected one of `>`, identifier, lifetime, or type, found `,`
3839

3940

4041
//type Type_7 = Box<(),,>; // error: expected type, found `,`

‎src/test/compile-fail/issue-20616-7.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Type_5_<'a> = Type_1_<'a, ()>;
3737
//type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
3838

3939

40-
type Type_7 = Box<(),,>; //~ error: expected type, found `,`
40+
type Type_7 = Box<(),,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,`
4141

4242

4343
//type Type_8<'a,,> = &'a (); // error: expected ident, found `,`

‎src/test/compile-fail/issue-20616-8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type Type_5_<'a> = Type_1_<'a, ()>;
4040
//type Type_7 = Box<(),,>; // error: expected type, found `,`
4141

4242

43-
type Type_8<'a,,> = &'a (); //~ error: expected identifier, found `,`
43+
type Type_8<'a,,> = &'a (); //~ error: expected one of `>`, identifier, or lifetime, found `,`
4444

4545

4646
//type Type_9<T,,> = Box<T>; // error: expected identifier, found `,`

‎src/test/compile-fail/issue-20616-9.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ type Type_5_<'a> = Type_1_<'a, ()>;
4343
//type Type_8<'a,,> = &'a (); // error: expected identifier, found `,`
4444

4545

46-
type Type_9<T,,> = Box<T>; //~ error: expected identifier, found `,`
46+
type Type_9<T,,> = Box<T>; //~ error: expected one of `>`, identifier, or lifetime, found `,`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2017 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+
fn f() where u8 = u16 {}
12+
//~^ ERROR equality constraints are not yet supported in where clauses
13+
fn g() where for<'a> &(u8,) == u16, {}
14+
//~^ ERROR equality constraints are not yet supported in where clauses
15+
16+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 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+
trait Trait1 {}
12+
trait Trait2 {}
13+
14+
fn f() where
15+
for<'a> Trait1<'a>: Trait1<'a>, // OK
16+
(for<'a> Trait1<'a>): Trait1<'a>,
17+
//~^ ERROR use of undeclared lifetime name `'a`
18+
for<'a> for<'b> Trait2<'a, 'b>: Trait2<'a, 'b>,
19+
//~^ ERROR use of undeclared lifetime name `'b`
20+
//~| ERROR nested quantification of lifetimes
21+
{}
22+
23+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only
12+
13+
type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b`
14+
15+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only
12+
13+
type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+`
14+
15+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only
12+
13+
type A where 'a; //~ ERROR expected `:`, found `;`
14+
15+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only
12+
13+
type A where 'a: 'b + 'c = u8; // OK
14+
type A where 'a: 'b, = u8; // OK
15+
type A where 'a: = u8; // OK
16+
type A where 'a:, = u8; // OK
17+
type A where 'a: 'b + 'c = u8; // OK
18+
type A where = u8; // OK
19+
type A where 'a: 'b + = u8; // OK
20+
type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,`
21+
22+
fn main() {}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only -Z continue-parse-after-error
12+
13+
type A = for<'a: 'b + 'c> fn(); // OK
14+
type A = for<'a: 'b,> fn(); // OK
15+
type A = for<'a:> fn(); // OK
16+
type A = for<'a:,> fn(); // OK
17+
type A = for<'a> fn(); // OK
18+
type A = for<> fn(); // OK
19+
type A = for<'a: 'b +> fn(); // OK
20+
21+
type A = for<'a, T> fn(); //~ ERROR only lifetime parameters can be used in this context
22+
type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,`
23+
24+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only
12+
13+
type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK
14+
type A where T: Trait, = u8; // OK
15+
type A where T: = u8; // OK
16+
type A where T:, = u8; // OK
17+
type A where T: Trait + Trait = u8; // OK
18+
type A where = u8; // OK
19+
type A where T: Trait + = u8; // OK
20+
type A where T, = u8;
21+
//~^ ERROR expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,`
22+
23+
fn main() {}

‎src/test/parse-fail/bounds-type.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 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+
// compile-flags: -Z parse-only -Z continue-parse-after-error
12+
13+
struct S<
14+
T: 'a + Tr, // OK
15+
T: Tr + 'a, // OK
16+
T: 'a, // OK
17+
T:, // OK
18+
T: ?for<'a: 'b + 'c> Trait, // OK
19+
T: Tr +, // OK
20+
T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
21+
>;
22+
23+
fn main() {}

‎src/test/parse-fail/issue-14303-path.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@
1212

1313
fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {}
1414
//~^ ERROR lifetime parameters must be declared prior to type parameters
15-
//~^^ ERROR expected pattern, found `'c`

‎src/test/parse-fail/generic-non-trailing-defaults.rs renamed to ‎src/test/parse-fail/issue-17904-2.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
// compile-flags: -Z parse-only -Z continue-parse-after-error
1212

13-
struct Heap;
14-
15-
struct Vec<A = Heap, T>; //~ ERROR type parameters with a default must be trailing
16-
17-
struct Foo<A, B = Vec<C>, C>; //~ ERROR type parameters with a default must be trailing
13+
struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where`
1814

1915
fn main() {}

‎src/test/parse-fail/issue-17904.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
struct Baz<U> where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax.
1414
struct Baz<U> where U: Eq(U) -> R; // Notice this parses as well.
1515
struct Baz<U>(U) where U: Eq; // This rightfully signals no error as well.
16-
struct Foo<T> where T: Copy, (T); //~ ERROR unexpected token in `where` clause
17-
struct Bar<T> { x: T } where T: Copy //~ ERROR expected item, found `where`
16+
struct Foo<T> where T: Copy, (T); //~ ERROR expected one of `+`, `:`, `==`, or `=`, found `;`
1817

1918
fn main() {}

‎src/test/parse-fail/issue-32214.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
// compile-flags: -Z parse-only -Z continue-parse-after-error
1212

13-
pub fn test<W, I: Iterator<Item=(), W> >() {
14-
//~^ ERROR expected `=`, found `>`
15-
}
13+
pub fn test<W, I: Iterator<Item=(), W> >() {}
14+
//~^ ERROR type parameters must be declared prior to associated type bindings
1615

1716
fn main() { }

‎src/test/parse-fail/lifetime-semicolon.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@ struct Foo<'a, 'b> {
1515
}
1616

1717
fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {}
18-
//~^ ERROR expected `,` or `>` after lifetime name, found `;`
19-
//~^^ NOTE did you mean a single argument type &'a Type, or did you mean the comma-separated
18+
//~^ ERROR expected one of `,` or `>`, found `;`

‎src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
// compile-flags: -Z parse-only -Z continue-parse-after-error
1212

13+
// Empty predicate list is OK
1314
fn equal1<T>(_: &T, _: &T) -> bool where {
14-
//~^ ERROR a `where` clause must have at least one predicate in it
1515
true
1616
}
1717

18+
// Empty bound list is OK
1819
fn equal2<T>(_: &T, _: &T) -> bool where T: {
19-
//~^ ERROR each predicate in a `where` clause must have at least one bound
2020
true
2121
}
2222

0 commit comments

Comments
 (0)
Please sign in to comment.