diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs index df8bd3fa75e14..cd1689f21cc6e 100644 --- a/src/librustc_resolve/late/diagnostics.rs +++ b/src/librustc_resolve/late/diagnostics.rs @@ -445,6 +445,12 @@ impl<'a> LateResolutionVisitor<'a, '_> { (Res::Def(DefKind::Ctor(_, CtorKind::Fictive), _), _) if ns == ValueNS => { bad_struct_syntax_suggestion(); } + (Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), _) if ns == ValueNS => { + err.span_label( + span, + format!("did you mean `{} ( /* fields */ )`?", path_str), + ); + } (Res::SelfTy(..), _) if ns == ValueNS => { err.span_label(span, fallback_label); err.note("can't use `Self` as a constructor, you must use the implemented struct"); diff --git a/src/test/ui/empty/empty-struct-tuple-pat.stderr b/src/test/ui/empty/empty-struct-tuple-pat.stderr index 777b9d4a4acd0..6c15e7bf282ce 100644 --- a/src/test/ui/empty/empty-struct-tuple-pat.stderr +++ b/src/test/ui/empty/empty-struct-tuple-pat.stderr @@ -20,15 +20,16 @@ error[E0532]: expected unit struct/variant or constant, found tuple variant `E:: --> $DIR/empty-struct-tuple-pat.rs:29:9 | LL | E::Empty4 => () - | ^^^^^^^^^ not a unit struct/variant or constant + | ^^^^^^^^^ did you mean `E::Empty4 ( /* fields */ )`? error[E0532]: expected unit struct/variant or constant, found tuple variant `XE::XEmpty5` --> $DIR/empty-struct-tuple-pat.rs:33:9 | LL | XE::XEmpty5 => (), | ^^^^------- - | | - | help: a unit variant with a similar name exists: `XEmpty4` + | | | + | | help: a unit variant with a similar name exists: `XEmpty4` + | did you mean `XE::XEmpty5 ( /* fields */ )`? error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-32004.stderr b/src/test/ui/issues/issue-32004.stderr index f8c418b25a0e4..b56fa949acb7e 100644 --- a/src/test/ui/issues/issue-32004.stderr +++ b/src/test/ui/issues/issue-32004.stderr @@ -3,8 +3,9 @@ error[E0532]: expected unit struct/variant or constant, found tuple variant `Foo | LL | Foo::Bar => {} | ^^^^^--- - | | - | help: a unit variant with a similar name exists: `Baz` + | | | + | | help: a unit variant with a similar name exists: `Baz` + | did you mean `Foo::Bar ( /* fields */ )`? error[E0532]: expected tuple struct/variant, found unit struct `S` --> $DIR/issue-32004.rs:16:9 diff --git a/src/test/ui/issues/issue-63983.rs b/src/test/ui/issues/issue-63983.rs new file mode 100644 index 0000000000000..c1c79091fc802 --- /dev/null +++ b/src/test/ui/issues/issue-63983.rs @@ -0,0 +1,15 @@ +enum MyEnum { + Tuple(i32), + Struct{ s: i32 }, +} + +fn foo(en: MyEnum) { + match en { + MyEnum::Tuple => "", + //~^ ERROR expected unit struct/variant or constant, found tuple variant `MyEnum::Tuple` + MyEnum::Struct => "", + //~^ ERROR expected unit struct/variant or constant, found struct variant `MyEnum::Struct` + }; +} + +fn main() {} diff --git a/src/test/ui/issues/issue-63983.stderr b/src/test/ui/issues/issue-63983.stderr new file mode 100644 index 0000000000000..67acd1d57c27a --- /dev/null +++ b/src/test/ui/issues/issue-63983.stderr @@ -0,0 +1,15 @@ +error[E0532]: expected unit struct/variant or constant, found tuple variant `MyEnum::Tuple` + --> $DIR/issue-63983.rs:8:9 + | +LL | MyEnum::Tuple => "", + | ^^^^^^^^^^^^^ did you mean `MyEnum::Tuple ( /* fields */ )`? + +error[E0532]: expected unit struct/variant or constant, found struct variant `MyEnum::Struct` + --> $DIR/issue-63983.rs:10:9 + | +LL | MyEnum::Struct => "", + | ^^^^^^^^^^^^^^ did you mean `MyEnum::Struct { /* fields */ }`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0532`.