Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// Do not suggest the other syntax if we are in trait impl:
// the desugaring would contain an associated type constraint.
if !is_impl {
err.span_suggestion(
err.span_suggestion_verbose(
span,
"use parenthetical notation instead",
fn_trait_to_string(self.tcx(), trait_segment, true),
Expand Down Expand Up @@ -2036,7 +2036,7 @@ impl<'a, 'tcx> rustc_errors::Diagnostic<'a, ()> for AmbiguityBetweenVariantAndAs
could_refer_to(DefKind::Variant, variant_def_id, "");
could_refer_to(mode.def_kind_for_diagnostics(), item_def_id, " also");

lint.span_suggestion(
lint.span_suggestion_verbose(
span,
"use fully-qualified syntax",
format!("<{} as {}>::{}", self_ty, tcx.item_name(bound_def_id), segment_ident),
Expand Down
6 changes: 5 additions & 1 deletion tests/ui/cast/dyn-any-to-fn-with-missing-generics.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/dyn-any-to-fn-with-missing-generics.rs:9:39
|
LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3));
| ^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | println!("{:?}",(vfnfer[0] as dyn Fn() -> ())(3));
| ++++++++

error[E0107]: missing generics for trait `Fn`
--> $DIR/dyn-any-to-fn-with-missing-generics.rs:9:39
Expand Down
14 changes: 12 additions & 2 deletions tests/ui/impl-trait/opaque-used-in-extraneous-argument.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,32 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/opaque-used-in-extraneous-argument.rs:5:19
|
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
| ^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(P) -> T`
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - fn frob() -> impl Fn<P, Output = T> + '_ {}
LL + fn frob() -> impl Fn(P) -> T + '_ {}
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/opaque-used-in-extraneous-argument.rs:5:19
|
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
| ^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(P) -> T`
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use parenthetical notation instead
|
LL - fn frob() -> impl Fn<P, Output = T> + '_ {}
LL + fn frob() -> impl Fn(P) -> T + '_ {}
|

error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/opaque-used-in-extraneous-argument.rs:17:20
Expand Down
7 changes: 6 additions & 1 deletion tests/ui/lint/future-incompatible-lint-group.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ error: ambiguous associated item
--> $DIR/future-incompatible-lint-group.rs:19:17
|
LL | fn foo() -> Self::V { 0 }
| ^^^^^^^ help: use fully-qualified syntax: `<E as Tr1>::V`
| ^^^^^^^
|
note: `V` could refer to the variant defined here
--> $DIR/future-incompatible-lint-group.rs:8:10
Expand All @@ -32,6 +32,11 @@ note: the lint level is defined here
LL | #![deny(future_incompatible)]
| ^^^^^^^^^^^^^^^^^^^
= note: `#[deny(ambiguous_associated_items)]` implied by `#[deny(future_incompatible)]`
help: use fully-qualified syntax
|
LL - fn foo() -> Self::V { 0 }
LL + fn foo() -> <E as Tr1>::V { 0 }
|

error: aborting due to 1 previous error; 1 warning emitted

21 changes: 18 additions & 3 deletions tests/ui/suggestions/fn-trait-notation.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,46 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/fn-trait-notation.rs:4:8
|
LL | F: Fn<i32, Output = i32>,
| ^^^^^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(i32) -> i32`
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - F: Fn<i32, Output = i32>,
LL + F: Fn(i32) -> i32,
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/fn-trait-notation.rs:6:8
|
LL | G: Fn<(i32, i32, ), Output = (i32, i32)>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(i32, i32) -> (i32, i32)`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - G: Fn<(i32, i32, ), Output = (i32, i32)>,
LL + G: Fn(i32, i32) -> (i32, i32),
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/fn-trait-notation.rs:7:8
|
LL | H: Fn<(i32,), Output = i32>,
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(i32) -> i32`
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - H: Fn<(i32,), Output = i32>,
LL + H: Fn(i32) -> i32,
|

error[E0059]: type parameter to bare `Fn` trait must be a tuple
--> $DIR/fn-trait-notation.rs:4:8
Expand Down
28 changes: 24 additions & 4 deletions tests/ui/traits/next-solver/assertion-left-right-goal.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,64 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/assertion-left-right-goal.rs:6:28
|
LL | async fn new() -> impl Fn<()> {
| ^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - async fn new() -> impl Fn<()> {
LL + async fn new() -> impl Fn() -> () {
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/assertion-left-right-goal.rs:6:28
|
LL | async fn new() -> impl Fn<()> {
| ^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use parenthetical notation instead
|
LL - async fn new() -> impl Fn<()> {
LL + async fn new() -> impl Fn() -> () {
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/assertion-left-right-goal.rs:6:28
|
LL | async fn new() -> impl Fn<()> {
| ^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use parenthetical notation instead
|
LL - async fn new() -> impl Fn<()> {
LL + async fn new() -> impl Fn() -> () {
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/assertion-left-right-goal.rs:6:28
|
LL | async fn new() -> impl Fn<()> {
| ^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
help: use parenthetical notation instead
|
LL - async fn new() -> impl Fn<()> {
LL + async fn new() -> impl Fn() -> () {
|

error[E0308]: mismatched types
--> $DIR/assertion-left-right-goal.rs:6:35
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: ambiguous associated item
--> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15
|
LL | fn f() -> Self::V { 0 }
| ^^^^^^^ help: use fully-qualified syntax: `<E as Tr>::V`
| ^^^^^^^
|
note: `V` could refer to the variant defined here
--> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:22:5
Expand All @@ -17,6 +17,11 @@ LL | type V;
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
= note: `#[deny(ambiguous_associated_items)]` (part of `#[deny(future_incompatible)]`) on by default
help: use fully-qualified syntax
|
LL - fn f() -> Self::V { 0 }
LL + fn f() -> <E as Tr>::V { 0 }
|

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:9:18
|
LL | pub fn shared<T: Fn>() {}
| ^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | pub fn shared<T: Fn() -> ()>() {}
| ++++++++

error[E0107]: missing generics for trait `Fn`
--> $DIR/missing-fn-trait-args-issue-136407.rs:9:18
Expand All @@ -18,11 +22,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:13:19
|
LL | pub fn mutable<T: FnMut>() {}
| ^^^^^ help: use parenthetical notation instead: `FnMut() -> ()`
| ^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | pub fn mutable<T: FnMut() -> ()>() {}
| ++++++++

error[E0107]: missing generics for trait `FnMut`
--> $DIR/missing-fn-trait-args-issue-136407.rs:13:19
Expand All @@ -34,11 +42,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:17:16
|
LL | pub fn once<T: FnOnce>() {}
| ^^^^^^ help: use parenthetical notation instead: `FnOnce() -> ()`
| ^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | pub fn once<T: FnOnce() -> ()>() {}
| ++++++++

error[E0107]: missing generics for trait `FnOnce`
--> $DIR/missing-fn-trait-args-issue-136407.rs:17:16
Expand All @@ -50,11 +62,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:21:24
|
LL | pub fn async_shared<T: AsyncFn>() {}
| ^^^^^^^ help: use parenthetical notation instead: `AsyncFn() -> ()`
| ^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | pub fn async_shared<T: AsyncFn() -> ()>() {}
| ++++++++

error[E0107]: missing generics for trait `AsyncFn`
--> $DIR/missing-fn-trait-args-issue-136407.rs:21:24
Expand All @@ -66,11 +82,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:25:25
|
LL | pub fn async_mutable<T: AsyncFnMut>() {}
| ^^^^^^^^^^ help: use parenthetical notation instead: `AsyncFnMut() -> ()`
| ^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | pub fn async_mutable<T: AsyncFnMut() -> ()>() {}
| ++++++++

error[E0107]: missing generics for trait `AsyncFnMut`
--> $DIR/missing-fn-trait-args-issue-136407.rs:25:25
Expand All @@ -82,11 +102,15 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:29:22
|
LL | pub fn async_once<T: AsyncFnOnce>() {}
| ^^^^^^^^^^^ help: use parenthetical notation instead: `AsyncFnOnce() -> ()`
| ^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL | pub fn async_once<T: AsyncFnOnce() -> ()>() {}
| ++++++++

error[E0107]: missing generics for trait `AsyncFnOnce`
--> $DIR/missing-fn-trait-args-issue-136407.rs:29:22
Expand All @@ -98,11 +122,16 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/missing-fn-trait-args-issue-136407.rs:33:23
|
LL | pub fn with_output<T: Fn<Output = ()>>() {}
| ^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - pub fn with_output<T: Fn<Output = ()>>() {}
LL + pub fn with_output<T: Fn() -> ()>() {}
|

error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
--> $DIR/missing-fn-trait-args-issue-136407.rs:33:23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@ error[E0658]: the precise format of `Fn`-family traits' type parameters is subje
--> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:3:17
|
LL | fn bar1(x: &dyn Fn<(), Output=()>) {
| ^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - fn bar1(x: &dyn Fn<(), Output=()>) {
LL + fn bar1(x: &dyn Fn() -> ()) {
|

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
--> $DIR/unboxed-closure-sugar-not-used-on-fn.rs:7:28
|
LL | fn bar2<T>(x: &T) where T: Fn<()> {
| ^^^^^^ help: use parenthetical notation instead: `Fn() -> ()`
| ^^^^^^
|
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
help: use parenthetical notation instead
|
LL - fn bar2<T>(x: &T) where T: Fn<()> {
LL + fn bar2<T>(x: &T) where T: Fn() -> () {
|

error: aborting due to 2 previous errors

Expand Down
Loading