From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../rustc_error_codes/src/error_codes/E0531.md | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0531.md (limited to 'compiler/rustc_error_codes/src/error_codes/E0531.md') diff --git a/compiler/rustc_error_codes/src/error_codes/E0531.md b/compiler/rustc_error_codes/src/error_codes/E0531.md new file mode 100644 index 000000000..2814046fb --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0531.md @@ -0,0 +1,42 @@ +An unknown tuple struct/variant has been used. + +Erroneous code example: + +```compile_fail,E0531 +let Type(x) = Type(12); // error! +match Bar(12) { + Bar(x) => {} // error! + _ => {} +} +``` + +In most cases, it's either a forgotten import or a typo. However, let's look at +how you can have such a type: + +```edition2018 +struct Type(u32); // this is a tuple struct + +enum Foo { + Bar(u32), // this is a tuple variant +} + +use Foo::*; // To use Foo's variant directly, we need to import them in + // the scope. +``` + +Either way, it should work fine with our previous code: + +```edition2018 +struct Type(u32); + +enum Foo { + Bar(u32), +} +use Foo::*; + +let Type(x) = Type(12); // ok! +match Type(12) { + Type(x) => {} // ok! + _ => {} +} +``` -- cgit v1.2.3