rustc::diagnostics::DIAGNOSTICSUnstable [-] [+] [src]

pub static DIAGNOSTICS: [(&'static str, &'static str); 14usize] = [("E0001",
  "\nThis error suggests that the expression arm corresponding to the noted pattern\nwill never be reached as for all possible values of the expression being\nmatched, one of the preceding patterns will match.\n\nThis means that perhaps some of the preceding patterns are too general, this one\nis too specific or the ordering is incorrect.\n"),
 ("E0002",
  "\nThis error indicates that an empty match expression is illegal because the type\nit is matching on is non-empty (there exist values of this type). In safe code\nit is impossible to create an instance of an empty type, so empty match\nexpressions are almost never desired.  This error is typically fixed by adding\none or more cases to the match expression.\n\nAn example of an empty type is `enum Empty { }`.\n"),
 ("E0003",
  "\nNot-a-Number (NaN) values cannot be compared for equality and hence can never\nmatch the input to a match expression. To match against NaN values, you should\ninstead use the `is_nan` method in a guard, as in: x if x.is_nan() => ...\n"),
 ("E0004",
  "\nThis error indicates that the compiler cannot guarantee a matching pattern for\none or more possible inputs to a match expression. Guaranteed matches are\nrequired in order to assign values to match expressions, or alternatively,\ndetermine the flow of execution.\n\nIf you encounter this error you must alter your patterns so that every possible\nvalue of the input type is matched. For types with a small number of variants\n(like enums) you should probably cover all cases explicitly. Alternatively, the\nunderscore `_` wildcard pattern can be added after all other patterns to match\n\"anything else\".\n"),
 ("E0005",
  "\nPatterns used to bind names must be irrefutable, that is, they must guarantee that a\nname will be extracted in all cases. If you encounter this error you probably need\nto use a `match` or `if let` to deal with the possibility of failure.\n"),
 ("E0006",
  "\nPatterns used to bind names must be irrefutable, that is, they must guarantee that a\nname will be extracted in all cases. If you encounter this error you probably need\nto use a `match` or `if let` to deal with the possibility of failure.\n"),
 ("E0007",
  "\nThis error indicates that the bindings in a match arm would require a value to\nbe moved into more than one location, thus violating unique ownership. Code like\nthe following is invalid as it requires the entire Option to be moved\ninto a variable called `op_string` while simultaneously requiring the inner\nString to be moved into a variable called `s`.\n\nlet x = Some(\"s\".to_string());\nmatch x {\n    op_string @ Some(s) => ...\n    None => ...\n}\n\nSee also Error 303.\n"),
 ("E0008",
  "\nNames bound in match arms retain their type in pattern guards. As such, if a\nname is bound by move in a pattern, it should also be moved to wherever it is\nreferenced in the pattern guard code. Doing so however would prevent the name\nfrom being available in the body of the match arm. Consider the following:\n\nmatch Some(\"hi\".to_string()) {\n    Some(s) if s.len() == 0 => // use s.\n    ...\n}\n\nThe variable `s` has type String, and its use in the guard is as a variable of\ntype String. The guard code effectively executes in a separate scope to the body\nof the arm, so the value would be moved into this anonymous scope and therefore\nbecome unavailable in the body of the arm. Although this example seems\ninnocuous, the problem is most clear when considering functions that take their\nargument by value.\n\nmatch Some(\"hi\".to_string()) {\n    Some(s) if { drop(s); false } => (),\n    Some(s) => // use s.\n    ...\n}\n\nThe value would be dropped in the guard then become unavailable not only in the\nbody of that arm but also in all subsequent arms! The solution is to bind by\nreference when using guards or refactor the entire expression, perhaps by\nputting the condition inside the body of the arm.\n"),
 ("E0162",
  "\nAn if-let pattern attempts to match the pattern, and enters the body if the\nmatch was succesful. If the match is irrefutable (when it cannot fail to match),\nuse a regular `let`-binding instead. For instance:\n\nstruct Irrefutable(i32);\nlet irr = Irrefutable(0);\n\n// This fails to compile because the match is irrefutable.\nif let Irrefutable(x) = irr {\n    // This body will always be executed.\n    foo(x);\n}\n\n// Try this instead:\nlet Irrefutable(x) = irr;\nfoo(x);\n"),
 ("E0165",
  "\nA while-let pattern attempts to match the pattern, and enters the body if the\nmatch was succesful. If the match is irrefutable (when it cannot fail to match),\nuse a regular `let`-binding inside a `loop` instead. For instance:\n\nstruct Irrefutable(i32);\nlet irr = Irrefutable(0);\n\n// This fails to compile because the match is irrefutable.\nwhile let Irrefutable(x) = irr {\n    ...\n}\n\n// Try this instead:\nloop {\n    let Irrefutable(x) = irr;\n    ...\n}\n"),
 ("E0297",
  "\nPatterns used to bind names must be irrefutable. That is, they must guarantee\nthat a name will be extracted in all cases. Instead of pattern matching the\nloop variable, consider using a `match` or `if let` inside the loop body. For\ninstance:\n\n// This fails because `None` is not covered.\nfor Some(x) in xs {\n    ...\n}\n\n// Match inside the loop instead:\nfor item in xs {\n    match item {\n        Some(x) => ...\n        None => ...\n    }\n}\n\n// Or use `if let`:\nfor item in xs {\n    if let Some(x) = item {\n        ...\n    }\n}\n"),
 ("E0301",
  "\nMutable borrows are not allowed in pattern guards, because matching cannot have\nside effects. Side effects could alter the matched object or the environment\non which the match depends in such a way, that the match would not be\nexhaustive. For instance, the following would not match any arm if mutable\nborrows were allowed:\n\nmatch Some(()) {\n    None => { },\n    option if option.take().is_none() => { /* impossible, option is `Some` */ },\n    Some(_) => { } // When the previous match failed, the option became `None`.\n}\n"),
 ("E0302",
  "\nAssignments are not allowed in pattern guards, because matching cannot have\nside effects. Side effects could alter the matched object or the environment\non which the match depends in such a way, that the match would not be\nexhaustive. For instance, the following would not match any arm if assignments\nwere allowed:\n\nmatch Some(()) {\n    None => { },\n    option if { option = None; false } { },\n    Some(_) => { } // When the previous match failed, the option became `None`.\n}\n"),
 ("E0303",
  "\nIn certain cases it is possible for sub-bindings to violate memory safety.\nUpdates to the borrow checker in a future version of Rust may remove this\nrestriction, but for now patterns must be rewritten without sub-bindings.\n\n// Code like this...\nmatch Some(5) {\n    ref op_num @ Some(num) => ...\n    None => ...\n}\n\n// ... should be updated to code like this.\nmatch Some(5) {\n    Some(num) => {\n        let op_num = &Some(num);\n        ...\n    }\n    None => ...\n}\n\nSee also https://github.com/rust-lang/rust/issues/14587\n")]