Content-Length: 24892 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../../std/../error_codes/./E0530.html

E0530 - Error codes index

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error code E0530

A binding shadowed something it shouldn’t.

A match arm or a variable has a name that is already used by something else, e.g.

  • struct name
  • enum variant
  • static
  • associated constant

This error may also happen when an enum variant with fields is used in a pattern, but without its fields.

#![allow(unused)]
fn main() {
enum Enum {
    WithField(i32)
}

use Enum::*;
match WithField(1) {
    WithField => {} // error: missing (_)
}
}

Match bindings cannot shadow statics:

#![allow(unused)]
fn main() {
static TEST: i32 = 0;

let r = 123;
match r {
    TEST => {} // error: name of a static
}
}

Fixed examples:

#![allow(unused)]
fn main() {
static TEST: i32 = 0;

let r = 123;
match r {
    some_value => {} // ok!
}
}

or

#![allow(unused)]
fn main() {
const TEST: i32 = 0; // const, not static

let r = 123;
match r {
    TEST => {} // const is ok!
    other_values => {}
}
}








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/string/../error/../string/../../std/../error_codes/./E0530.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy