diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-01-27 22:37:17 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-01-27 22:38:28 +0300 |
| commit | f57ea7cb3daf186bcd181f9add9e56cc45ff8380 (patch) | |
| tree | 2bfbc11bacea93adb416094b11a8e79743f9533d /src/test | |
| parent | d79f7cde061f18d354d914393640f9c1aacf45a8 (diff) | |
| download | rust-f57ea7cb3daf186bcd181f9add9e56cc45ff8380.tar.gz rust-f57ea7cb3daf186bcd181f9add9e56cc45ff8380.zip | |
Make `+` in `impl/dyn Trait` non-associative
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/impl-trait/impl-trait-plus-priority.rs (renamed from src/test/parse-fail/impl-trait-plus-priority.rs) | 26 | ||||
| -rw-r--r-- | src/test/ui/impl-trait/impl-trait-plus-priority.stderr | 68 |
2 files changed, 87 insertions, 7 deletions
diff --git a/src/test/parse-fail/impl-trait-plus-priority.rs b/src/test/ui/impl-trait/impl-trait-plus-priority.rs index 6d12a68cf3d..f451123ca27 100644 --- a/src/test/parse-fail/impl-trait-plus-priority.rs +++ b/src/test/ui/impl-trait/impl-trait-plus-priority.rs @@ -10,11 +10,15 @@ // compile-flags: -Z parse-only -Z continue-parse-after-error +fn f() -> impl A + {} // OK fn f() -> impl A + B {} // OK fn f() -> dyn A + B {} // OK fn f() -> A + B {} // OK impl S { + fn f(self) -> impl A + { // OK + let _ = |a, b| -> impl A + {}; // OK + } fn f(self) -> impl A + B { // OK let _ = |a, b| -> impl A + B {}; // OK } @@ -26,21 +30,29 @@ impl S { } } +type A = fn() -> impl A +; +//~^ ERROR ambiguous `+` in a type type A = fn() -> impl A + B; -//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> impl A` +//~^ ERROR ambiguous `+` in a type type A = fn() -> dyn A + B; -//~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> dyn A` +//~^ ERROR ambiguous `+` in a type type A = fn() -> A + B; //~^ ERROR expected a path on the left-hand side of `+`, not `fn() -> A` -type A = Fn() -> impl A + B; // OK, interpreted as `(Fn() -> impl A) + B` -type A = Fn() -> dyn A + B; // OK, interpreted as `(Fn() -> dyn A) + B` -type A = Fn() -> A + B; // OK, interpreted as `(Fn() -> A) + B` +type A = Fn() -> impl A +; +//~^ ERROR ambiguous `+` in a type +type A = Fn() -> impl A + B; +//~^ ERROR ambiguous `+` in a type +type A = Fn() -> dyn A + B; +//~^ ERROR ambiguous `+` in a type +type A = Fn() -> A + B; // OK, interpreted as `(Fn() -> A) + B` for compatibility +type A = &impl A +; +//~^ ERROR ambiguous `+` in a type type A = &impl A + B; -//~^ ERROR expected a path on the left-hand side of `+`, not `&impl A` +//~^ ERROR ambiguous `+` in a type type A = &dyn A + B; -//~^ ERROR expected a path on the left-hand side of `+`, not `&dyn A` +//~^ ERROR ambiguous `+` in a type type A = &A + B; //~^ ERROR expected a path on the left-hand side of `+`, not `&A` diff --git a/src/test/ui/impl-trait/impl-trait-plus-priority.stderr b/src/test/ui/impl-trait/impl-trait-plus-priority.stderr new file mode 100644 index 00000000000..885c3941971 --- /dev/null +++ b/src/test/ui/impl-trait/impl-trait-plus-priority.stderr @@ -0,0 +1,68 @@ +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:33:18 + | +33 | type A = fn() -> impl A +; + | ^^^^^^^^ help: use parentheses to disambiguate: `(impl A)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:35:18 + | +35 | type A = fn() -> impl A + B; + | ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl A + B)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:37:18 + | +37 | type A = fn() -> dyn A + B; + | ^^^^^^^^^ help: use parentheses to disambiguate: `(dyn A + B)` + +error[E0178]: expected a path on the left-hand side of `+`, not `fn() -> A` + --> $DIR/impl-trait-plus-priority.rs:39:10 + | +39 | type A = fn() -> A + B; + | ^^^^^^^^^^^^^ perhaps you forgot parentheses? + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:42:18 + | +42 | type A = Fn() -> impl A +; + | ^^^^^^^^ help: use parentheses to disambiguate: `(impl A)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:44:18 + | +44 | type A = Fn() -> impl A + B; + | ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl A + B)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:46:18 + | +46 | type A = Fn() -> dyn A + B; + | ^^^^^^^^^ help: use parentheses to disambiguate: `(dyn A + B)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:50:11 + | +50 | type A = &impl A +; + | ^^^^^^^^ help: use parentheses to disambiguate: `(impl A)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:52:11 + | +52 | type A = &impl A + B; + | ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl A + B)` + +error: ambiguous `+` in a type + --> $DIR/impl-trait-plus-priority.rs:54:11 + | +54 | type A = &dyn A + B; + | ^^^^^^^^^ help: use parentheses to disambiguate: `(dyn A + B)` + +error[E0178]: expected a path on the left-hand side of `+`, not `&A` + --> $DIR/impl-trait-plus-priority.rs:56:10 + | +56 | type A = &A + B; + | ^^^^^^ help: try adding parentheses: `&(A + B)` + +error: aborting due to 11 previous errors + |
