From 692bc344d55cf9d86c60b06c92a70684d013c89f Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sat, 6 Jul 2024 03:07:46 +0000 Subject: Make parse error suggestions verbose and fix spans Go over all structured parser suggestions and make them verbose style. When suggesting to add or remove delimiters, turn them into multiple suggestion parts. --- .../ui/impl-trait/extra-impl-in-trait-impl.stderr | 14 ++++- .../impl-trait/impl-fn-parsing-ambiguities.stderr | 14 ++++- .../ui/impl-trait/impl-trait-plus-priority.stderr | 70 ++++++++++++++++++---- 3 files changed, 84 insertions(+), 14 deletions(-) (limited to 'tests/ui/impl-trait') diff --git a/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr index 91c7da5a04f..e4d14c4807c 100644 --- a/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr +++ b/tests/ui/impl-trait/extra-impl-in-trait-impl.stderr @@ -2,25 +2,35 @@ error: unexpected `impl` keyword --> $DIR/extra-impl-in-trait-impl.rs:8:18 | LL | impl impl Default for S { - | ^^^^^ help: remove the extra `impl` + | ^^^^^ | note: this is parsed as an `impl Trait` type, but a trait is expected at this position --> $DIR/extra-impl-in-trait-impl.rs:8:18 | LL | impl impl Default for S { | ^^^^^^^^^^^^ +help: remove the extra `impl` + | +LL - impl impl Default for S { +LL + impl Default for S { + | error: unexpected `impl` keyword --> $DIR/extra-impl-in-trait-impl.rs:14:6 | LL | impl impl Default for S2 { - | ^^^^^ help: remove the extra `impl` + | ^^^^^ | note: this is parsed as an `impl Trait` type, but a trait is expected at this position --> $DIR/extra-impl-in-trait-impl.rs:14:6 | LL | impl impl Default for S2 { | ^^^^^^^^^^^^ +help: remove the extra `impl` + | +LL - impl impl Default for S2 { +LL + impl Default for S2 { + | error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr index e0955faac7c..94b6ffdd912 100644 --- a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr +++ b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -2,13 +2,23 @@ error: ambiguous `+` in a type --> $DIR/impl-fn-parsing-ambiguities.rs:4:27 | LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { - | ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)` + | ^^^^^^^^^^^^^^^ + | +help: try adding parentheses + | +LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { + | + + error: ambiguous `+` in a type --> $DIR/impl-fn-parsing-ambiguities.rs:10:24 | LL | fn b() -> impl Fn() -> impl Debug + Send { - | ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)` + | ^^^^^^^^^^^^^^^^^ + | +help: try adding parentheses + | +LL | fn b() -> impl Fn() -> (impl Debug + Send) { + | + + error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` --> $DIR/impl-fn-parsing-ambiguities.rs:4:40 diff --git a/tests/ui/impl-trait/impl-trait-plus-priority.stderr b/tests/ui/impl-trait/impl-trait-plus-priority.stderr index 205d9b0b75e..03e7910095a 100644 --- a/tests/ui/impl-trait/impl-trait-plus-priority.stderr +++ b/tests/ui/impl-trait/impl-trait-plus-priority.stderr @@ -2,19 +2,34 @@ error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:23:18 | LL | type A = fn() -> impl A +; - | ^^^^^^^^ help: use parentheses to disambiguate: `(impl A)` + | ^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = fn() -> (impl A +); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:25:18 | LL | type A = fn() -> impl A + B; - | ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl A + B)` + | ^^^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = fn() -> (impl A + B); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:27:18 | LL | type A = fn() -> dyn A + B; - | ^^^^^^^^^ help: use parentheses to disambiguate: `(dyn A + B)` + | ^^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = fn() -> (dyn A + B); + | + + error[E0178]: expected a path on the left-hand side of `+`, not `fn() -> A` --> $DIR/impl-trait-plus-priority.rs:29:10 @@ -26,43 +41,78 @@ error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:32:18 | LL | type A = Fn() -> impl A +; - | ^^^^^^^^ help: use parentheses to disambiguate: `(impl A)` + | ^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = Fn() -> (impl A +); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:34:18 | LL | type A = Fn() -> impl A + B; - | ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl A + B)` + | ^^^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = Fn() -> (impl A + B); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:36:18 | LL | type A = Fn() -> dyn A + B; - | ^^^^^^^^^ help: use parentheses to disambiguate: `(dyn A + B)` + | ^^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = Fn() -> (dyn A + B); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:40:11 | LL | type A = &impl A +; - | ^^^^^^^^ help: use parentheses to disambiguate: `(impl A)` + | ^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = &(impl A +); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:42:11 | LL | type A = &impl A + B; - | ^^^^^^^^^^ help: use parentheses to disambiguate: `(impl A + B)` + | ^^^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = &(impl A + B); + | + + error: ambiguous `+` in a type --> $DIR/impl-trait-plus-priority.rs:44:11 | LL | type A = &dyn A + B; - | ^^^^^^^^^ help: use parentheses to disambiguate: `(dyn A + B)` + | ^^^^^^^^^ + | +help: try adding parentheses + | +LL | type A = &(dyn A + B); + | + + error[E0178]: expected a path on the left-hand side of `+`, not `&A` --> $DIR/impl-trait-plus-priority.rs:46:10 | LL | type A = &A + B; - | ^^^^^^ help: try adding parentheses: `&(A + B)` + | ^^^^^^ + | +help: try adding parentheses + | +LL | type A = &(A + B); + | + + error: aborting due to 11 previous errors -- cgit 1.4.1-3-g733a5