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/E0025.md | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0025.md (limited to 'compiler/rustc_error_codes/src/error_codes/E0025.md') diff --git a/compiler/rustc_error_codes/src/error_codes/E0025.md b/compiler/rustc_error_codes/src/error_codes/E0025.md new file mode 100644 index 000000000..a85dc8c19 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0025.md @@ -0,0 +1,34 @@ +Each field of a struct can only be bound once in a pattern. + +Erroneous code example: + +```compile_fail,E0025 +struct Foo { + a: u8, + b: u8, +} + +fn main(){ + let x = Foo { a:1, b:2 }; + + let Foo { a: x, a: y } = x; + // error: field `a` bound multiple times in the pattern +} +``` + +Each occurrence of a field name binds the value of that field, so to fix this +error you will have to remove or alter the duplicate uses of the field name. +Perhaps you misspelled another field name? Example: + +``` +struct Foo { + a: u8, + b: u8, +} + +fn main(){ + let x = Foo { a:1, b:2 }; + + let Foo { a: x, b: y } = x; // ok! +} +``` -- cgit v1.2.3