Skip to content

Commit d79f7cd

Browse files
committed
Add tests
1 parent 95d27c3 commit d79f7cd

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

src/test/parse-fail/closure-return-syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313

1414
fn main() {
1515
let x = || -> i32 22;
16-
//~^ ERROR expected one of `!`, `(`, `::`, `<`, or `{`, found `22`
16+
//~^ ERROR expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22`
1717
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
fn f() -> impl A + B {} // OK
14+
fn f() -> dyn A + B {} // OK
15+
fn f() -> A + B {} // OK
16+
17+
impl S {
18+
fn f(self) -> impl A + B { // OK
19+
let _ = |a, b| -> impl A + B {}; // OK
20+
}
21+
fn f(self) -> dyn A + B { // OK
22+
let _ = |a, b| -> dyn A + B {}; // OK
23+
}
24+
fn f(self) -> A + B { // OK
25+
let _ = |a, b| -> A + B {}; // OK
26+
}
27+
}
28+
29+
type A = fn() -> impl A + B;
30+
//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> impl A`
31+
type A = fn() -> dyn A + B;
32+
//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> dyn A`
33+
type A = fn() -> A + B;
34+
//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> A`
35+
36+
type A = Fn() -> impl A + B; // OK, interpreted as `(Fn() -> impl A) + B`
37+
type A = Fn() -> dyn A + B; // OK, interpreted as `(Fn() -> dyn A) + B`
38+
type A = Fn() -> A + B; // OK, interpreted as `(Fn() -> A) + B`
39+
40+
type A = &impl A + B;
41+
//~^ ERROR expected a path on the left-hand side of `+`, not `&impl A`
42+
type A = &dyn A + B;
43+
//~^ ERROR expected a path on the left-hand side of `+`, not `&dyn A`
44+
type A = &A + B;
45+
//~^ ERROR expected a path on the left-hand side of `+`, not `&A`
46+
47+
fn main() {}

src/test/parse-fail/issue-24780.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
// compile-flags: -Z parse-only
1616

1717
fn foo() -> Vec<usize>> {
18-
//~^ ERROR expected one of `!`, `::`, `where`, or `{`, found `>`
18+
//~^ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>`
1919
Vec::new()
2020
}

0 commit comments

Comments
 (0)