1//! This module defines the following.
2//! - The `ErrCode` type.
3//! - A constant for every error code, with a name like `E0123`.
4//! - A static table `DIAGNOSTICS` pairing every error code constant with its
5//! long description text.
67use std::fmt;
89impl ::std::fmt::Debug for ErrCode {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
fmt.write_fmt(format_args!("ErrCode({0})", self.as_u32()))
}
}rustc_index::newtype_index! {
10#[max = 9999] // Because all error codes have four digits.
11#[orderable]
12 #[encodable]
13 #[debug_format = "ErrCode({})"]
14pub struct ErrCode {}
15}1617impl fmt::Displayfor ErrCode {
18fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19f.write_fmt(format_args!("E{0:04}", self.as_u32()))write!(f, "E{:04}", self.as_u32())20 }
21}
2223impl ::rustc_error_messages::IntoDiagArg for ErrCode {
fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>)
-> ::rustc_error_messages::DiagArgValue {
self.to_string().into_diag_arg(path)
}
}rustc_error_messages::into_diag_arg_using_display!(ErrCode);
2425macro_rules!define_error_code_constants_and_diagnostics_table {
26 ($($num:literal,)*) => (
27 $(
28pub const ${concat(E, $num)}: $crate::ErrCode = $crate::ErrCode::from_u32($num);
29 )*
30pub static DIAGNOSTICS: &[($crate::ErrCode, &str)] = &[
31 $( (
32 ${concat(E, $num)},
33include_str!(
34concat!("../../rustc_error_codes/src/error_codes/E", stringify!($num), ".md")
35 )
36 ), )*
37 ];
38 )
39}
4041pub const E0806: crate::ErrCode = crate::ErrCode::from_u32(0806);
pub static DIAGNOSTICS: &[(crate::ErrCode, &str)] =
&[(E0001,
"#### Note: this error code is no longer emitted by the compiler.\n\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\none is too specific or the ordering is incorrect.\n\nFor example, the following `match` block has too many arms:\n\n```\nmatch Some(0) {\n Some(bar) => {/* ... */}\n x => {/* ... */} // This handles the `None` case\n _ => {/* ... */} // All possible cases have already been handled\n}\n```\n\n`match` blocks have their patterns matched in order, so, for example, putting\na wildcard arm above a more specific arm will make the latter arm irrelevant.\n\nEnsure the ordering of the match arm is correct and remove any superfluous\narms.\n"),
(E0002,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error indicates that an empty match expression is invalid 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 { }`. So, the following will work:\n\n```\nenum Empty {}\n\nfn foo(x: Empty) {\n match x {\n // empty\n }\n}\n```\n\nHowever, this won\'t:\n\n```compile_fail\nfn foo(x: Option<String>) {\n match x {\n // empty\n }\n}\n```\n"),
(E0004,
"This 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\nErroneous code example:\n\n```compile_fail,E0004\nenum Terminator {\n HastaLaVistaBaby,\n TalkToMyHand,\n}\n\nlet x = Terminator::HastaLaVistaBaby;\n\nmatch x { // error: non-exhaustive patterns: `HastaLaVistaBaby` not covered\n Terminator::TalkToMyHand => {}\n}\n```\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\". Example:\n\n```\nenum Terminator {\n HastaLaVistaBaby,\n TalkToMyHand,\n}\n\nlet x = Terminator::HastaLaVistaBaby;\n\nmatch x {\n Terminator::TalkToMyHand => {}\n Terminator::HastaLaVistaBaby => {}\n}\n\n// or:\n\nmatch x {\n Terminator::TalkToMyHand => {}\n _ => {}\n}\n```\n"),
(E0005,
"Patterns used to bind names must be irrefutable, that is, they must guarantee\nthat a name will be extracted in all cases.\n\nErroneous code example:\n\n```compile_fail,E0005\nlet x = Some(1);\nlet Some(y) = x;\n// error: refutable pattern in local binding: `None` not covered\n```\n\nIf you encounter this error you probably need to use a `match` or `if let` to\ndeal with the possibility of failure. Example:\n\n```\nlet x = Some(1);\n\nmatch x {\n Some(y) => {\n // do something\n },\n None => {}\n}\n\n// or:\n\nif let Some(y) = x {\n // do something\n}\n```\n"),
(E0007,
"#### Note: this error code is no longer emitted by the compiler.\n\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\nlike the following is invalid as it requires the entire `Option<String>` to be\nmoved into a variable called `op_string` while simultaneously requiring the\ninner `String` to be moved into a variable called `s`.\n\nErroneous code example:\n\n```compile_fail,E0382\n#![feature(bindings_after_at)]\n\nlet x = Some(\"s\".to_string());\n\nmatch x {\n op_string @ Some(s) => {}, // error: use of moved value\n None => {},\n}\n```\n\nSee also the error E0303.\n"),
(E0009,
"#### Note: this error code is no longer emitted by the compiler.\n\nIn a pattern, all values that don\'t implement the `Copy` trait have to be bound\nthe same way. The goal here is to avoid binding simultaneously by-move and\nby-ref.\n\nThis limitation may be removed in a future version of Rust.\n\nErroneous code example:\n\n```\n#![feature(move_ref_pattern)]\n\nstruct X { x: (), }\n\nlet x = Some((X { x: () }, X { x: () }));\nmatch x {\n Some((y, ref z)) => {}, // error: cannot bind by-move and by-ref in the\n // same pattern\n None => panic!()\n}\n```\n\nYou have two solutions:\n\nSolution #1: Bind the pattern\'s values the same way.\n\n```\nstruct X { x: (), }\n\nlet x = Some((X { x: () }, X { x: () }));\nmatch x {\n Some((ref y, ref z)) => {},\n // or Some((y, z)) => {}\n None => panic!()\n}\n```\n\nSolution #2: Implement the `Copy` trait for the `X` structure.\n\nHowever, please keep in mind that the first solution should be preferred.\n\n```\n#[derive(Clone, Copy)]\nstruct X { x: (), }\n\nlet x = Some((X { x: () }, X { x: () }));\nmatch x {\n Some((y, ref z)) => {},\n None => panic!()\n}\n```\n"),
(E0010,
"The value of statics and constants must be known at compile time, and they live\nfor the entire lifetime of a program. Creating a boxed value allocates memory on\nthe heap at runtime, and therefore cannot be done at compile time.\n\nErroneous code example:\n\n```compile_fail,E0010\nconst CON : Vec<i32> = vec![1, 2, 3];\n```\n"),
(E0013,
"#### Note: this error code is no longer emitted by the compiler\n\nStatic and const variables can refer to other const variables. But a const\nvariable cannot refer to a static variable.\n\nErroneous code example:\n\n```\nstatic X: i32 = 42;\nconst Y: i32 = X;\n```\n\nIn this example, `Y` cannot refer to `X`. To fix this, the value can be\nextracted as a const and then used:\n\n```\nconst A: i32 = 42;\nstatic X: i32 = A;\nconst Y: i32 = A;\n```\n"),
(E0014,
"#### Note: this error code is no longer emitted by the compiler.\n\nConstants can only be initialized by a constant value or, in a future\nversion of Rust, a call to a const function. This error indicates the use\nof a path (like a::b, or x) denoting something other than one of these\nallowed items.\n\nErroneous code example:\n\n```\nconst FOO: i32 = { let x = 0; x }; // \'x\' isn\'t a constant nor a function!\n```\n\nTo avoid it, you have to replace the non-constant value:\n\n```\nconst FOO: i32 = { const X : i32 = 0; X };\n// or even:\nconst FOO2: i32 = { 0 }; // but brackets are useless here\n```\n"),
(E0015,
"A non-`const` function was called in a `const` context.\n\nErroneous code example:\n\n```compile_fail,E0015\nfn create_some() -> Option<u8> {\n Some(1)\n}\n\n// error: cannot call non-const function `create_some` in constants\nconst FOO: Option<u8> = create_some();\n```\n\nAll functions used in a `const` context (constant or static expression) must\nbe marked `const`.\n\nTo fix this error, you can declare `create_some` as a constant function:\n\n```\n// declared as a `const` function:\nconst fn create_some() -> Option<u8> {\n Some(1)\n}\n\nconst FOO: Option<u8> = create_some(); // no error!\n```\n"),
(E0023,
"A pattern attempted to extract an incorrect number of fields from a variant.\n\nErroneous code example:\n\n```compile_fail,E0023\nenum Fruit {\n Apple(String, String),\n Pear(u32),\n}\n\nlet x = Fruit::Apple(String::new(), String::new());\n\nmatch x {\n Fruit::Apple(a) => {}, // error!\n _ => {}\n}\n```\n\nA pattern used to match against an enum variant must provide a sub-pattern for\neach field of the enum variant.\n\nHere the `Apple` variant has two fields, and should be matched against like so:\n\n```\nenum Fruit {\n Apple(String, String),\n Pear(u32),\n}\n\nlet x = Fruit::Apple(String::new(), String::new());\n\n// Correct.\nmatch x {\n Fruit::Apple(a, b) => {},\n _ => {}\n}\n```\n\nMatching with the wrong number of fields has no sensible interpretation:\n\n```compile_fail,E0023\nenum Fruit {\n Apple(String, String),\n Pear(u32),\n}\n\nlet x = Fruit::Apple(String::new(), String::new());\n\n// Incorrect.\nmatch x {\n Fruit::Apple(a) => {},\n Fruit::Apple(a, b, c) => {},\n}\n```\n\nCheck how many fields the enum was declared with and ensure that your pattern\nuses the same number.\n"),
(E0025,
"Each field of a struct can only be bound once in a pattern.\n\nErroneous code example:\n\n```compile_fail,E0025\nstruct Foo {\n a: u8,\n b: u8,\n}\n\nfn main(){\n let x = Foo { a:1, b:2 };\n\n let Foo { a: x, a: y } = x;\n // error: field `a` bound multiple times in the pattern\n}\n```\n\nEach occurrence of a field name binds the value of that field, so to fix this\nerror you will have to remove or alter the duplicate uses of the field name.\nPerhaps you misspelled another field name? Example:\n\n```\nstruct Foo {\n a: u8,\n b: u8,\n}\n\nfn main(){\n let x = Foo { a:1, b:2 };\n\n let Foo { a: x, b: y } = x; // ok!\n}\n```\n"),
(E0026,
"A struct pattern attempted to extract a nonexistent field from a struct.\n\nErroneous code example:\n\n```compile_fail,E0026\nstruct Thing {\n x: u32,\n y: u32,\n}\n\nlet thing = Thing { x: 0, y: 0 };\n\nmatch thing {\n Thing { x, z } => {} // error: `Thing::z` field doesn\'t exist\n}\n```\n\nIf you are using shorthand field patterns but want to refer to the struct field\nby a different name, you should rename it explicitly. Struct fields are\nidentified by the name used before the colon `:` so struct patterns should\nresemble the declaration of the struct type being matched.\n\n```\nstruct Thing {\n x: u32,\n y: u32,\n}\n\nlet thing = Thing { x: 0, y: 0 };\n\nmatch thing {\n Thing { x, y: z } => {} // we renamed `y` to `z`\n}\n```\n"),
(E0027,
"A pattern for a struct fails to specify a sub-pattern for every one of the\nstruct\'s fields.\n\nErroneous code example:\n\n```compile_fail,E0027\nstruct Dog {\n name: String,\n age: u32,\n}\n\nlet d = Dog { name: \"Rusty\".to_string(), age: 8 };\n\n// This is incorrect.\nmatch d {\n Dog { age: x } => {}\n}\n```\n\nTo fix this error, ensure that each field from the struct\'s definition is\nmentioned in the pattern, or use `..` to ignore unwanted fields. Example:\n\n```\nstruct Dog {\n name: String,\n age: u32,\n}\n\nlet d = Dog { name: \"Rusty\".to_string(), age: 8 };\n\nmatch d {\n Dog { name: ref n, age: x } => {}\n}\n\n// This is also correct (ignore unused fields).\nmatch d {\n Dog { age: x, .. } => {}\n}\n```\n"),
(E0029,
"Something other than numbers and characters has been used for a range.\n\nErroneous code example:\n\n```compile_fail,E0029\nlet string = \"salutations !\";\n\n// The ordering relation for strings cannot be evaluated at compile time,\n// so this doesn\'t work:\nmatch string {\n \"hello\" ..= \"world\" => {}\n _ => {}\n}\n\n// This is a more general version, using a guard:\nmatch string {\n s if s >= \"hello\" && s <= \"world\" => {}\n _ => {}\n}\n```\n\nIn a match expression, only numbers and characters can be matched against a\nrange. This is because the compiler checks that the range is non-empty at\ncompile-time, and is unable to evaluate arbitrary comparison functions. If you\nwant to capture values of an orderable type between two end-points, you can use\na guard.\n"),
(E0030,
"When matching against a range, the compiler verifies that the range is\nnon-empty. Range patterns include both end-points, so this is equivalent to\nrequiring the start of the range to be less than or equal to the end of the\nrange.\n\nErroneous code example:\n\n```compile_fail,E0030\nmatch 5u32 {\n // This range is ok, albeit pointless.\n 1 ..= 1 => {}\n // This range is empty, and the compiler can tell.\n 1000 ..= 5 => {}\n}\n```\n"),
(E0033,
"A trait type has been dereferenced.\n\nErroneous code example:\n\n```compile_fail,E0033\n# trait SomeTrait { fn method_one(&self){} fn method_two(&self){} }\n# impl<T> SomeTrait for T {}\nlet trait_obj: &SomeTrait = &\"some_value\";\n\n// This tries to implicitly dereference to create an unsized local variable.\nlet &invalid = trait_obj;\n\n// You can call methods without binding to the value being pointed at.\ntrait_obj.method_one();\ntrait_obj.method_two();\n```\n\nA pointer to a trait type cannot be implicitly dereferenced by a pattern. Every\ntrait defines a type, but because the size of trait implementers isn\'t fixed,\nthis type has no compile-time size. Therefore, all accesses to trait types must\nbe through pointers. If you encounter this error you should try to avoid\ndereferencing the pointer.\n\nYou can read more about trait objects in the [Trait Objects] section of the\nReference.\n\n[Trait Objects]: https://doc.rust-lang.org/reference/types.html#trait-objects\n"),
(E0034,
"The compiler doesn\'t know what method to call because more than one method\nhas the same prototype.\n\nErroneous code example:\n\n```compile_fail,E0034\nstruct Test;\n\ntrait Trait1 {\n fn foo();\n}\n\ntrait Trait2 {\n fn foo();\n}\n\nimpl Trait1 for Test { fn foo() {} }\nimpl Trait2 for Test { fn foo() {} }\n\nfn main() {\n Test::foo() // error, which foo() to call?\n}\n```\n\nTo avoid this error, you have to keep only one of them and remove the others.\nSo let\'s take our example and fix it:\n\n```\nstruct Test;\n\ntrait Trait1 {\n fn foo();\n}\n\nimpl Trait1 for Test { fn foo() {} }\n\nfn main() {\n Test::foo() // and now that\'s good!\n}\n```\n\nHowever, a better solution would be using fully explicit naming of type and\ntrait:\n\n```\nstruct Test;\n\ntrait Trait1 {\n fn foo();\n}\n\ntrait Trait2 {\n fn foo();\n}\n\nimpl Trait1 for Test { fn foo() {} }\nimpl Trait2 for Test { fn foo() {} }\n\nfn main() {\n <Test as Trait1>::foo()\n}\n```\n\nOne last example:\n\n```\ntrait F {\n fn m(&self);\n}\n\ntrait G {\n fn m(&self);\n}\n\nstruct X;\n\nimpl F for X { fn m(&self) { println!(\"I am F\"); } }\nimpl G for X { fn m(&self) { println!(\"I am G\"); } }\n\nfn main() {\n let f = X;\n\n F::m(&f); // it displays \"I am F\"\n G::m(&f); // it displays \"I am G\"\n}\n```\n"),
(E0038,
"For any given trait `Trait` there may be a related _type_ called the _trait\nobject type_ which is typically written as `dyn Trait`. In earlier editions of\nRust, trait object types were written as plain `Trait` (just the name of the\ntrait, written in type positions) but this was a bit too confusing, so we now\nwrite `dyn Trait`.\n\nSome traits are not allowed to be used as trait object types. The traits that\nare allowed to be used as trait object types are called \"dyn-compatible\"[^1]\ntraits. Attempting to use a trait object type for a trait that is not\ndyn-compatible will trigger error E0038.\n\nTwo general aspects of trait object types give rise to the restrictions:\n\n 1. Trait object types are dynamically sized types (DSTs), and trait objects of\n these types can only be accessed through pointers, such as `&dyn Trait` or\n `Box<dyn Trait>`. The size of such a pointer is known, but the size of the\n `dyn Trait` object pointed-to by the pointer is _opaque_ to code working\n with it, and different trait objects with the same trait object type may\n have different sizes.\n\n 2. The pointer used to access a trait object is paired with an extra pointer\n to a \"virtual method table\" or \"vtable\", which is used to implement dynamic\n dispatch to the object\'s implementations of the trait\'s methods. There is a\n single such vtable for each trait implementation, but different trait\n objects with the same trait object type may point to vtables from different\n implementations.\n\nThe specific conditions that violate dyn-compatibility follow, most of which\nrelate to missing size information and vtable polymorphism arising from these\naspects.\n\n[^1]: Formerly known as \"object-safe\".\n\n### The trait requires `Self: Sized`\n\nTraits that are declared as `Trait: Sized` or which otherwise inherit a\nconstraint of `Self:Sized` are not dyn-compatible.\n\nThe reasoning behind this is somewhat subtle. It derives from the fact that Rust\nrequires (and defines) that every trait object type `dyn Trait` automatically\nimplements `Trait`. Rust does this to simplify error reporting and ease\ninteroperation between static and dynamic polymorphism. For example, this code\nworks:\n\n```\ntrait Trait {\n}\n\nfn static_foo<T:Trait + ?Sized>(b: &T) {\n}\n\nfn dynamic_bar(a: &dyn Trait) {\n static_foo(a)\n}\n```\n\nThis code works because `dyn Trait`, if it exists, always implements `Trait`.\n\nHowever as we know, any `dyn Trait` is also unsized, and so it can never\nimplement a sized trait like `Trait:Sized`. So, rather than allow an exception\nto the rule that `dyn Trait` always implements `Trait`, Rust chooses to prohibit\nsuch a `dyn Trait` from existing at all.\n\nOnly unsized traits are considered dyn-compatible.\n\nGenerally, `Self: Sized` is used to indicate that the trait should not be used\nas a trait object. If the trait comes from your own crate, consider removing\nthis restriction.\n\n### Method references the `Self` type in its parameters or return type\n\nThis happens when a trait has a method like the following:\n\n```\ntrait Trait {\n fn foo(&self) -> Self;\n}\n\nimpl Trait for String {\n fn foo(&self) -> Self {\n \"hi\".to_owned()\n }\n}\n\nimpl Trait for u8 {\n fn foo(&self) -> Self {\n 1\n }\n}\n```\n\n(Note that `&self` and `&mut self` are okay, it\'s additional `Self` types which\ncause this problem.)\n\nIn such a case, the compiler cannot predict the return type of `foo()` in a\nsituation like the following:\n\n```compile_fail,E0038\ntrait Trait {\n fn foo(&self) -> Self;\n}\n\nfn call_foo(x: Box<dyn Trait>) {\n let y = x.foo(); // What type is y?\n // ...\n}\n```\n\nIf only some methods aren\'t dyn-compatible, you can add a `where Self: Sized`\nbound on them to mark them as explicitly unavailable to trait objects. The\nfunctionality will still be available to all other implementers, including\n`Box<dyn Trait>` which is itself sized (assuming you `impl Trait for Box<dyn\nTrait>`).\n\n```\ntrait Trait {\n fn foo(&self) -> Self where Self: Sized;\n // more functions\n}\n```\n\nNow, `foo()` can no longer be called on a trait object, but you will now be\nallowed to make a trait object, and that will be able to call any dyn-compatible\nmethods. With such a bound, one can still call `foo()` on types implementing\nthat trait that aren\'t behind trait objects.\n\n### Method has generic type parameters\n\nAs mentioned before, trait objects contain pointers to method tables. So, if we\nhave:\n\n```\ntrait Trait {\n fn foo(&self);\n}\n\nimpl Trait for String {\n fn foo(&self) {\n // implementation 1\n }\n}\n\nimpl Trait for u8 {\n fn foo(&self) {\n // implementation 2\n }\n}\n// ...\n```\n\nAt compile time each implementation of `Trait` will produce a table containing\nthe various methods (and other items) related to the implementation, which will\nbe used as the virtual method table for a `dyn Trait` object derived from that\nimplementation.\n\nThis works fine, but when the method gains generic parameters, we can have a\nproblem.\n\nUsually, generic parameters get _monomorphized_. For example, if I have\n\n```\nfn foo<T>(x: T) {\n // ...\n}\n```\n\nThe machine code for `foo::<u8>()`, `foo::<bool>()`, `foo::<String>()`, or any\nother instantiation is different. Hence the compiler generates the\nimplementation on-demand. If you call `foo()` with a `bool` parameter, the\ncompiler will only generate code for `foo::<bool>()`. When we have additional\ntype parameters, the number of monomorphized implementations the compiler\ngenerates does not grow drastically, since the compiler will only generate an\nimplementation if the function is called with fully concrete arguments\n(i.e., arguments which do not contain any generic parameters).\n\nHowever, with trait objects we have to make a table containing _every_ object\nthat implements the trait. Now, if it has type parameters, we need to add\nimplementations for every type that implements the trait, and there could\ntheoretically be an infinite number of types.\n\nFor example, with:\n\n```\ntrait Trait {\n fn foo<T>(&self, on: T);\n // more methods\n}\n\nimpl Trait for String {\n fn foo<T>(&self, on: T) {\n // implementation 1\n }\n}\n\nimpl Trait for u8 {\n fn foo<T>(&self, on: T) {\n // implementation 2\n }\n}\n\n// 8 more implementations\n```\n\nNow, if we have the following code:\n\n```compile_fail,E0038\n# trait Trait { fn foo<T>(&self, on: T); }\n# impl Trait for String { fn foo<T>(&self, on: T) {} }\n# impl Trait for u8 { fn foo<T>(&self, on: T) {} }\n# impl Trait for bool { fn foo<T>(&self, on: T) {} }\n# // etc.\nfn call_foo(thing: Box<dyn Trait>) {\n thing.foo(true); // this could be any one of the 8 types above\n thing.foo(1);\n thing.foo(\"hello\");\n}\n```\n\nWe don\'t just need to create a table of all implementations of all methods of\n`Trait`, we need to create such a table, for each different type fed to\n`foo()`. In this case this turns out to be (10 types implementing `Trait`)\\*(3\ntypes being fed to `foo()`) = 30 implementations!\n\nWith real world traits these numbers can grow drastically.\n\nTo fix this, it is suggested to use a `where Self: Sized` bound similar to the\nfix for the sub-error above if you do not intend to call the method with type\nparameters:\n\n```\ntrait Trait {\n fn foo<T>(&self, on: T) where Self: Sized;\n // more methods\n}\n```\n\nIf this is not an option, consider replacing the type parameter with another\ntrait object (e.g., if `T: OtherTrait`, use `on: Box<dyn OtherTrait>`). If the\nnumber of types you intend to feed to this method is limited, consider manually\nlisting out the methods of different types.\n\n### Method has no receiver\n\nMethods that do not take a `self` parameter can\'t be called since there won\'t be\na way to get a pointer to the method table for them.\n\n```\ntrait Foo {\n fn foo() -> u8;\n}\n```\n\nThis could be called as `<Foo as Foo>::foo()`, which would not be able to pick\nan implementation.\n\nAdding a `Self: Sized` bound to these methods will generally make this compile.\n\n```\ntrait Foo {\n fn foo() -> u8 where Self: Sized;\n}\n```\n\n### Trait contains associated constants\n\nJust like static functions, associated constants aren\'t stored on the method\ntable. If the trait or any subtrait contain an associated constant, they are not\ndyn compatible.\n\n```compile_fail,E0038\ntrait Foo {\n const X: i32;\n}\n\nimpl dyn Foo {}\n```\n\nA simple workaround is to use a helper method instead:\n\n```\ntrait Foo {\n fn x(&self) -> i32;\n}\n```\n\n### Trait uses `Self` as a type parameter in the supertrait listing\n\nThis is similar to the second sub-error, but subtler. It happens in situations\nlike the following:\n\n```compile_fail,E0038\ntrait Super<A: ?Sized> {}\n\ntrait Trait: Super<Self> {\n}\n\nstruct Foo;\n\nimpl Super<Foo> for Foo{}\n\nimpl Trait for Foo {}\n\nfn main() {\n let x: Box<dyn Trait>;\n}\n```\n\nHere, the supertrait might have methods as follows:\n\n```\ntrait Super<A: ?Sized> {\n fn get_a(&self) -> &A; // note that this is dyn-compatible!\n}\n```\n\nIf the trait `Trait` was deriving from something like `Super<String>` or\n`Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type\n`get_a()` will definitely return an object of that type.\n\nHowever, if it derives from `Super<Self>`, even though `Super` is\ndyn-compatible, the method `get_a()` would return an object of unknown type when\ncalled on the function. `Self` type parameters let us make dyn-compatible traits\nno longer compatible, so they are forbidden when specifying supertraits.\n\nThere\'s no easy fix for this. Generally, code will need to be refactored so that\nyou no longer need to derive from `Super<Self>`.\n"),
(E0040,
"It is not allowed to manually call destructors in Rust.\n\nErroneous code example:\n\n```compile_fail,E0040\nstruct Foo {\n x: i32,\n}\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"kaboom\");\n }\n}\n\nfn main() {\n let mut x = Foo { x: -7 };\n x.drop(); // error: explicit use of destructor method\n}\n```\n\nIt is unnecessary to do this since `drop` is called automatically whenever a\nvalue goes out of scope. However, if you really need to drop a value by hand,\nyou can use the `std::mem::drop` function:\n\n```\nstruct Foo {\n x: i32,\n}\nimpl Drop for Foo {\n fn drop(&mut self) {\n println!(\"kaboom\");\n }\n}\nfn main() {\n let mut x = Foo { x: -7 };\n drop(x); // ok!\n}\n```\n"),
(E0044,
"You cannot use type or const parameters on foreign items.\n\nExample of erroneous code:\n\n```compile_fail,E0044\nextern \"C\" { fn some_func<T>(x: T); }\n```\n\nTo fix this, replace the generic parameter with the specializations that you\nneed:\n\n```\nextern \"C\" { fn some_func_i32(x: i32); }\nextern \"C\" { fn some_func_i64(x: i64); }\n```\n"),
(E0045,
"Variadic parameters have been used on a non-C ABI function.\n\nErroneous code example:\n\n```compile_fail,E0045\nextern \"Rust\" {\n fn foo(x: u8, ...); // error!\n}\n```\n\nRust only supports variadic parameters for interoperability with C code in its\nFFI. As such, variadic parameters can only be used with functions which are\nusing the C ABI. To fix such code, put them in an extern \"C\" block:\n\n```\nextern \"C\" {\n fn foo (x: u8, ...);\n}\n```\n"),
(E0046,
"Items are missing in a trait implementation.\n\nErroneous code example:\n\n```compile_fail,E0046\ntrait Foo {\n fn foo();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {}\n// error: not all trait items implemented, missing: `foo`\n```\n\nWhen trying to make some type implement a trait `Foo`, you must, at minimum,\nprovide implementations for all of `Foo`\'s required methods (meaning the\nmethods that do not have default implementations), as well as any required\ntrait items like associated types or constants. Example:\n\n```\ntrait Foo {\n fn foo();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn foo() {} // ok!\n}\n```\n"),
(E0049,
"An attempted implementation of a trait method has the wrong number of type or\nconst parameters.\n\nErroneous code example:\n\n```compile_fail,E0049\ntrait Foo {\n fn foo<T: Default>(x: T) -> Self;\n}\n\nstruct Bar;\n\n// error: method `foo` has 0 type parameters but its trait declaration has 1\n// type parameter\nimpl Foo for Bar {\n fn foo(x: bool) -> Self { Bar }\n}\n```\n\nFor example, the `Foo` trait has a method `foo` with a type parameter `T`,\nbut the implementation of `foo` for the type `Bar` is missing this parameter.\nTo fix this error, they must have the same type parameters:\n\n```\ntrait Foo {\n fn foo<T: Default>(x: T) -> Self;\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn foo<T: Default>(x: T) -> Self { // ok!\n Bar\n }\n}\n```\n"),
(E0050,
"An attempted implementation of a trait method has the wrong number of function\nparameters.\n\nErroneous code example:\n\n```compile_fail,E0050\ntrait Foo {\n fn foo(&self, x: u8) -> bool;\n}\n\nstruct Bar;\n\n// error: method `foo` has 1 parameter but the declaration in trait `Foo::foo`\n// has 2\nimpl Foo for Bar {\n fn foo(&self) -> bool { true }\n}\n```\n\nFor example, the `Foo` trait has a method `foo` with two function parameters\n(`&self` and `u8`), but the implementation of `foo` for the type `Bar` omits\nthe `u8` parameter. To fix this error, they must have the same parameters:\n\n```\ntrait Foo {\n fn foo(&self, x: u8) -> bool;\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn foo(&self, x: u8) -> bool { // ok!\n true\n }\n}\n```\n"),
(E0053,
"The parameters of any trait method must match between a trait implementation\nand the trait definition.\n\nErroneous code example:\n\n```compile_fail,E0053\ntrait Foo {\n fn foo(x: u16);\n fn bar(&self);\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n // error, expected u16, found i16\n fn foo(x: i16) { }\n\n // error, types differ in mutability\n fn bar(&mut self) { }\n}\n```\n"),
(E0054,
"It is not allowed to cast to a bool.\n\nErroneous code example:\n\n```compile_fail,E0054\nlet x = 5;\n\n// Not allowed, won\'t compile\nlet x_is_nonzero = x as bool;\n```\n\nIf you are trying to cast a numeric type to a bool, you can compare it with\nzero instead:\n\n```\nlet x = 5;\n\n// Ok\nlet x_is_nonzero = x != 0;\n```\n"),
(E0055,
"During a method call, a value is automatically dereferenced as many times as\nneeded to make the value\'s type match the method\'s receiver. The catch is that\nthe compiler will only attempt to dereference a number of times up to the\nrecursion limit (which can be set via the `recursion_limit` attribute).\n\nFor a somewhat artificial example:\n\n```compile_fail,E0055\n#![recursion_limit=\"4\"]\n\nstruct Foo;\n\nimpl Foo {\n fn foo(&self) {}\n}\n\nfn main() {\n let foo = Foo;\n let ref_foo = &&&&&Foo;\n\n // error, reached the recursion limit while auto-dereferencing `&&&&&Foo`\n ref_foo.foo();\n}\n```\n\nOne fix may be to increase the recursion limit. Note that it is possible to\ncreate an infinite recursion of dereferencing, in which case the only fix is to\nsomehow break the recursion.\n"),
(E0057,
"An invalid number of arguments was given when calling a closure.\n\nErroneous code example:\n\n```compile_fail,E0057\nlet f = |x| x * 3;\nlet a = f(); // invalid, too few parameters\nlet b = f(4); // this works!\nlet c = f(2, 3); // invalid, too many parameters\n```\n\nWhen invoking closures or other implementations of the function traits `Fn`,\n`FnMut` or `FnOnce` using call notation, the number of parameters passed to the\nfunction must match its definition.\n\nA generic function must be treated similarly:\n\n```\nfn foo<F: Fn()>(f: F) {\n f(); // this is valid, but f(3) would not work\n}\n```\n"),
(E0059,
"The built-in function traits are generic over a tuple of the function arguments.\nIf one uses angle-bracket notation (`Fn<(T,), Output=U>`) instead of parentheses\n(`Fn(T) -> U`) to denote the function trait, the type parameter should be a\ntuple. Otherwise function call notation cannot be used and the trait will not be\nimplemented by closures.\n\nThe most likely source of this error is using angle-bracket notation without\nwrapping the function argument type into a tuple, for example:\n\n```compile_fail,E0059\n#![feature(unboxed_closures)]\n\nfn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }\n```\n\nIt can be fixed by adjusting the trait bound like this:\n\n```\n#![feature(unboxed_closures)]\n\nfn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }\n```\n\nNote that `(T,)` always denotes the type of a 1-tuple containing an element of\ntype `T`. The comma is necessary for syntactic disambiguation.\n"),
(E0060,
"External C functions are allowed to be variadic. However, a variadic function\ntakes a minimum number of arguments. For example, consider C\'s variadic `printf`\nfunction:\n\n```compile_fail,E0060\nuse std::os::raw::{c_char, c_int};\n\nextern \"C\" {\n fn printf(_: *const c_char, ...) -> c_int;\n}\n\nunsafe { printf(); } // error!\n```\n\nUsing this declaration, it must be called with at least one argument, so\nsimply calling `printf()` is invalid. But the following uses are allowed:\n\n```rust,edition2021\n# use std::os::raw::{c_char, c_int};\n# #[cfg_attr(all(windows, target_env = \"msvc\"),\n# link(name = \"legacy_stdio_definitions\",\n# kind = \"static\", modifiers = \"-bundle\"))]\n# extern \"C\" { fn printf(_: *const c_char, ...) -> c_int; }\n# fn main() {\nunsafe {\n printf(c\"test\\n\".as_ptr());\n\n printf(c\"number = %d\\n\".as_ptr(), 3);\n\n printf(c\"%d, %d\\n\".as_ptr(), 10, 5);\n}\n# }\n```\n"),
(E0061,
"An invalid number of arguments was passed when calling a function.\n\nErroneous code example:\n\n```compile_fail,E0061\nfn f(u: i32) {}\n\nf(); // error!\n```\n\nThe number of arguments passed to a function must match the number of arguments\nspecified in the function signature.\n\nFor example, a function like:\n\n```\nfn f(a: u16, b: &str) {}\n```\n\nMust always be called with exactly two arguments, e.g., `f(2, \"test\")`.\n\nNote that Rust does not have a notion of optional function arguments or\nvariadic functions (except for its C-FFI).\n"),
(E0062,
"A struct\'s or struct-like enum variant\'s field was specified more than once.\n\nErroneous code example:\n\n```compile_fail,E0062\nstruct Foo {\n x: i32,\n}\n\nfn main() {\n let x = Foo {\n x: 0,\n x: 0, // error: field `x` specified more than once\n };\n}\n```\n\nThis error indicates that during an attempt to build a struct or struct-like\nenum variant, one of the fields was specified more than once. Each field should\nbe specified exactly one time. Example:\n\n```\nstruct Foo {\n x: i32,\n}\n\nfn main() {\n let x = Foo { x: 0 }; // ok!\n}\n```\n"),
(E0063,
"A struct\'s or struct-like enum variant\'s field was not provided.\n\nErroneous code example:\n\n```compile_fail,E0063\nstruct Foo {\n x: i32,\n y: i32,\n}\n\nfn main() {\n let x = Foo { x: 0 }; // error: missing field: `y`\n}\n```\n\nEach field should be specified exactly once. Example:\n\n```\nstruct Foo {\n x: i32,\n y: i32,\n}\n\nfn main() {\n let x = Foo { x: 0, y: 0 }; // ok!\n}\n```\n"),
(E0067,
"An invalid left-hand side expression was used on an assignment operation.\n\nErroneous code example:\n\n```compile_fail,E0067\n12 += 1; // error!\n```\n\nYou need to have a place expression to be able to assign it something. For\nexample:\n\n```\nlet mut x: i8 = 12;\nx += 1; // ok!\n```\n"),
(E0069,
"The compiler found a function whose body contains a `return;` statement but\nwhose return type is not `()`.\n\nErroneous code example:\n\n```compile_fail,E0069\n// error\nfn foo() -> u8 {\n return;\n}\n```\n\nSince `return;` is just like `return ();`, there is a mismatch between the\nfunction\'s return type and the value being returned.\n"),
(E0070,
"An assignment operator was used on a non-place expression.\n\nErroneous code examples:\n\n```compile_fail,E0070\nstruct SomeStruct {\n x: i32,\n y: i32,\n}\n\nconst SOME_CONST: i32 = 12;\n\nfn some_other_func() {}\n\nfn some_function() {\n SOME_CONST = 14; // error: a constant value cannot be changed!\n 1 = 3; // error: 1 isn\'t a valid place!\n some_other_func() = 4; // error: we cannot assign value to a function!\n SomeStruct::x = 12; // error: SomeStruct a structure name but it is used\n // like a variable!\n}\n```\n\nThe left-hand side of an assignment operator must be a place expression. A\nplace expression represents a memory location and can be a variable (with\noptional namespacing), a dereference, an indexing expression or a field\nreference.\n\nMore details can be found in the [Expressions] section of the Reference.\n\n[Expressions]: https://doc.rust-lang.org/reference/expressions.html#places-rvalues-and-temporaries\n\nAnd now let\'s give working examples:\n\n```\nstruct SomeStruct {\n x: i32,\n y: i32,\n}\nlet mut s = SomeStruct { x: 0, y: 0 };\n\ns.x = 3; // that\'s good !\n\n// ...\n\nfn some_func(x: &mut i32) {\n *x = 12; // that\'s good !\n}\n```\n"),
(E0071,
"A structure-literal syntax was used to create an item that is not a structure\nor enum variant.\n\nExample of erroneous code:\n\n```compile_fail,E0071\ntype U32 = u32;\nlet t = U32 { value: 4 }; // error: expected struct, variant or union type,\n // found builtin type `u32`\n```\n\nTo fix this, ensure that the name was correctly spelled, and that the correct\nform of initializer was used.\n\nFor example, the code above can be fixed to:\n\n```\ntype U32 = u32;\nlet t: U32 = 4;\n```\n\nor:\n\n```\nstruct U32 { value: u32 }\nlet t = U32 { value: 4 };\n```\n"),
(E0072,
"A recursive type has infinite size because it doesn\'t have an indirection.\n\nErroneous code example:\n\n```compile_fail,E0072\nstruct ListNode {\n head: u8,\n tail: Option<ListNode>, // error: no indirection here so impossible to\n // compute the type\'s size\n}\n```\n\nWhen defining a recursive struct or enum, any use of the type being defined\nfrom inside the definition must occur behind a pointer (like `Box`, `&` or\n`Rc`). This is because structs and enums must have a well-defined size, and\nwithout the pointer, the size of the type would need to be unbounded.\n\nIn the example, the type cannot have a well-defined size, because it needs to be\narbitrarily large (since we would be able to nest `ListNode`s to any depth).\nSpecifically,\n\n```plain\nsize of `ListNode` = 1 byte for `head`\n + 1 byte for the discriminant of the `Option`\n + size of `ListNode`\n```\n\nOne way to fix this is by wrapping `ListNode` in a `Box`, like so:\n\n```\nstruct ListNode {\n head: u8,\n tail: Option<Box<ListNode>>,\n}\n```\n\nThis works because `Box` is a pointer, so its size is well-known.\n"),
(E0073,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou cannot define a struct (or enum) `Foo` that requires an instance of `Foo`\nin order to make a new `Foo` value. This is because there would be no way a\nfirst instance of `Foo` could be made to initialize another instance!\n\nHere\'s an example of a struct that has this problem:\n\n```\nstruct Foo { x: Box<Foo> } // error\n```\n\nOne fix is to use `Option`, like so:\n\n```\nstruct Foo { x: Option<Box<Foo>> }\n```\n\nNow it\'s possible to create at least one instance of `Foo`: `Foo { x: None }`.\n"),
(E0074,
"#### Note: this error code is no longer emitted by the compiler.\n\nWhen using the `#[simd]` attribute on a tuple struct, the components of the\ntuple struct must all be of a concrete, nongeneric type so the compiler can\nreason about how to use SIMD with them. This error will occur if the types\nare generic.\n\nThis will cause an error:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad<T>([T; 4]);\n```\n\nThis will not:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good([u32; 4]);\n```\n"),
(E0075,
"A `#[simd]` attribute was applied to an empty or multi-field struct.\n\nErroneous code examples:\n\n```compile_fail,E0075\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad; // error!\n```\n\n```compile_fail,E0075\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad([u32; 1], [u32; 1]); // error!\n```\n\nThe `#[simd]` attribute can only be applied to a single-field struct, because\nthe one field must be the array of values in the vector.\n\nFixed example:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good([u32; 2]); // ok!\n```\n"),
(E0076,
"The type of the field in a tuple struct isn\'t an array when using the `#[simd]`\nattribute.\n\nErroneous code example:\n\n```compile_fail,E0076\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad(u16); // error!\n```\n\nWhen using the `#[simd]` attribute to automatically use SIMD operations in tuple\nstructs, if you want a single-lane vector then the field must be a 1-element\narray, or the compiler will trigger this error.\n\nFixed example:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good([u16; 1]); // ok!\n```\n"),
(E0077,
"A tuple struct\'s element isn\'t a machine type when using the `#[simd]`\nattribute.\n\nErroneous code example:\n\n```compile_fail,E0077\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad([String; 2]); // error!\n```\n\nWhen using the `#[simd]` attribute on a tuple struct, the elements in the tuple\nmust be machine types so SIMD operations can be applied to them.\n\nFixed example:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good([u32; 4]); // ok!\n```\n"),
(E0080,
"A constant value failed to get evaluated.\n\nErroneous code example:\n\n```compile_fail,E0080\nenum Enum {\n X = (1 << 500),\n Y = (1 / 0),\n}\n```\n\nThis error indicates that the compiler was unable to sensibly evaluate a\nconstant expression that had to be evaluated. Attempting to divide by 0\nor causing an integer overflow are two ways to induce this error.\n\nEnsure that the expressions given can be evaluated as the desired integer type.\n\nSee the [Discriminants] section of the Reference for more information about\nsetting custom integer types on enums using the\n[`repr` attribute][repr-attribute].\n\n[discriminants]: https://doc.rust-lang.org/reference/items/enumerations.html#discriminants\n[repr-attribute]: https://doc.rust-lang.org/reference/type-layout.html#representations\n"),
(E0081,
"A discriminant value is present more than once.\n\nErroneous code example:\n\n```compile_fail,E0081\nenum Enum {\n P = 3,\n X = 3, // error!\n Y = 5,\n}\n```\n\nEnum discriminants are used to differentiate enum variants stored in memory.\nThis error indicates that the same value was used for two or more variants,\nmaking it impossible to distinguish them.\n\n```\nenum Enum {\n P,\n X = 3, // ok!\n Y = 5,\n}\n```\n\nNote that variants without a manually specified discriminant are numbered from\ntop to bottom starting from 0, so clashes can occur with seemingly unrelated\nvariants.\n\n```compile_fail,E0081\nenum Bad {\n X,\n Y = 0, // error!\n}\n```\n\nHere `X` will have already been specified the discriminant 0 by the time `Y` is\nencountered, so a conflict occurs.\n"),
(E0084,
"An unsupported representation was attempted on a zero-variant enum.\n\nErroneous code example:\n\n```compile_fail,E0084\n#[repr(i32)]\nenum NightsWatch {} // error: unsupported representation for zero-variant enum\n```\n\nIt is impossible to define an integer type to be used to represent zero-variant\nenum values because there are no zero-variant enum values. There is no way to\nconstruct an instance of the following type using only safe code. So you have\ntwo solutions. Either you add variants in your enum:\n\n```\n#[repr(i32)]\nenum NightsWatch {\n JonSnow,\n Commander,\n}\n```\n\nor you remove the integer representation of your enum:\n\n```\nenum NightsWatch {}\n```\n"),
(E0087,
"#### Note: this error code is no longer emitted by the compiler.\n\nToo many type arguments were supplied for a function. For example:\n\n```compile_fail,E0107\nfn foo<T>() {}\n\nfn main() {\n foo::<f64, bool>(); // error: wrong number of type arguments:\n // expected 1, found 2\n}\n```\n\nThe number of supplied arguments must exactly match the number of defined type\nparameters.\n"),
(E0088,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou gave too many lifetime arguments. Erroneous code example:\n\n```compile_fail,E0107\nfn f() {}\n\nfn main() {\n f::<\'static>() // error: wrong number of lifetime arguments:\n // expected 0, found 1\n}\n```\n\nPlease check you give the right number of lifetime arguments. Example:\n\n```\nfn f() {}\n\nfn main() {\n f() // ok!\n}\n```\n\nIt\'s also important to note that the Rust compiler can generally\ndetermine the lifetime by itself. Example:\n\n```\nstruct Foo {\n value: String\n}\n\nimpl Foo {\n // it can be written like this\n fn get_value<\'a>(&\'a self) -> &\'a str { &self.value }\n // but the compiler works fine with this too:\n fn without_lifetime(&self) -> &str { &self.value }\n}\n\nfn main() {\n let f = Foo { value: \"hello\".to_owned() };\n\n println!(\"{}\", f.get_value());\n println!(\"{}\", f.without_lifetime());\n}\n```\n"),
(E0089,
"#### Note: this error code is no longer emitted by the compiler.\n\nToo few type arguments were supplied for a function. For example:\n\n```compile_fail,E0107\nfn foo<T, U>() {}\n\nfn main() {\n foo::<f64>(); // error: wrong number of type arguments: expected 2, found 1\n}\n```\n\nNote that if a function takes multiple type arguments but you want the compiler\nto infer some of them, you can use type placeholders:\n\n```compile_fail,E0107\nfn foo<T, U>(x: T) {}\n\nfn main() {\n let x: bool = true;\n foo::<f64>(x); // error: wrong number of type arguments:\n // expected 2, found 1\n foo::<_, f64>(x); // same as `foo::<bool, f64>(x)`\n}\n```\n"),
(E0090,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou gave too few lifetime arguments. Example:\n\n```compile_fail,E0107\nfn foo<\'a: \'b, \'b: \'a>() {}\n\nfn main() {\n foo::<\'static>(); // error: wrong number of lifetime arguments:\n // expected 2, found 1\n}\n```\n\nPlease check you give the right number of lifetime arguments. Example:\n\n```\nfn foo<\'a: \'b, \'b: \'a>() {}\n\nfn main() {\n foo::<\'static, \'static>();\n}\n```\n"),
(E0091,
"An unnecessary type parameter was given in a type alias.\n\nErroneous code example:\n\n```compile_fail,E0091\ntype Foo<T> = u32; // error: type parameter `T` is never used\n// or:\ntype Foo<A, B> = Box<A>; // error: type parameter `B` is never used\n```\n\nPlease check you didn\'t write too many parameters. Example:\n\n```\ntype Foo = u32; // ok!\ntype Foo2<A> = Box<A>; // ok!\n```\n"),
(E0092,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn undefined atomic operation function was declared.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\nunsafe fn atomic_foo(); // error: unrecognized atomic operation\n // function\n```\n\nPlease check you didn\'t make a mistake in the function\'s name. All intrinsic\nfunctions are defined in `library/core/src/intrinsics` in the Rust source code.\n"),
(E0093,
"An unknown intrinsic function was declared.\n\nErroneous code example:\n\n```compile_fail,E0093\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\nunsafe fn foo(); // error: unrecognized intrinsic function: `foo`\n\nfn main() {\n unsafe {\n foo();\n }\n}\n```\n\nPlease check you didn\'t make a mistake in the function\'s name. All intrinsic\nfunctions are defined in `library/core/src/intrinsics` in the Rust source code.\n"),
(E0094,
"An invalid number of generic parameters was passed to an intrinsic function.\n\nErroneous code example:\n\n```compile_fail,E0094\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\nfn size_of<T, U>() -> usize; // error: intrinsic has wrong number\n // of type parameters\n```\n\nPlease check that you provided the right number of type parameters\nand verify with the function declaration in the Rust source code.\nExample:\n\n```\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\nfn size_of<T>() -> usize; // ok!\n```\n"),
(E0106,
"This error indicates that a lifetime is missing from a type. If it is an error\ninside a function signature, the problem may be with failing to adhere to the\nlifetime elision rules (see below).\n\nErroneous code examples:\n\n```compile_fail,E0106\nstruct Foo1 { x: &bool }\n // ^ expected lifetime parameter\nstruct Foo2<\'a> { x: &\'a bool } // correct\n\nstruct Bar1 { x: Foo2 }\n // ^^^^ expected lifetime parameter\nstruct Bar2<\'a> { x: Foo2<\'a> } // correct\n\nenum Baz1 { A(u8), B(&bool), }\n // ^ expected lifetime parameter\nenum Baz2<\'a> { A(u8), B(&\'a bool), } // correct\n\ntype MyStr1 = &str;\n // ^ expected lifetime parameter\ntype MyStr2<\'a> = &\'a str; // correct\n```\n\nLifetime elision is a special, limited kind of inference for lifetimes in\nfunction signatures which allows you to leave out lifetimes in certain cases.\nFor more background on lifetime elision see [the book][book-le].\n\nThe lifetime elision rules require that any function signature with an elided\noutput lifetime must either have:\n\n - exactly one input lifetime\n - or, multiple input lifetimes, but the function must also be a method with a\n `&self` or `&mut self` receiver\n\nIn the first case, the output lifetime is inferred to be the same as the unique\ninput lifetime. In the second case, the lifetime is instead inferred to be the\nsame as the lifetime on `&self` or `&mut self`.\n\nHere are some examples of elision errors:\n\n```compile_fail,E0106\n// error, no input lifetimes\nfn foo() -> &str { }\n\n// error, `x` and `y` have distinct lifetimes inferred\nfn bar(x: &str, y: &str) -> &str { }\n\n// error, `y`\'s lifetime is inferred to be distinct from `x`\'s\nfn baz<\'a>(x: &\'a str, y: &str) -> &str { }\n```\n\n[book-le]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#lifetime-elision\n"),
(E0107,
"An incorrect number of generic arguments was provided.\n\nErroneous code example:\n\n```compile_fail,E0107\nstruct Foo<T> { x: T }\n\nstruct Bar { x: Foo } // error: wrong number of type arguments:\n // expected 1, found 0\nstruct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:\n // expected 1, found 2\n\nfn foo<T, U>(x: T, y: U) {}\nfn f() {}\n\nfn main() {\n let x: bool = true;\n foo::<bool>(x); // error: wrong number of type arguments:\n // expected 2, found 1\n foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:\n // expected 2, found 3\n f::<\'static>(); // error: wrong number of lifetime arguments\n // expected 0, found 1\n}\n```\n\nWhen using/declaring an item with generic arguments, you must provide the exact\nsame number:\n\n```\nstruct Foo<T> { x: T }\n\nstruct Bar<T> { x: Foo<T> } // ok!\nstruct Baz<S, T> { x: Foo<S>, y: Foo<T> } // ok!\n\nfn foo<T, U>(x: T, y: U) {}\nfn f() {}\n\nfn main() {\n let x: bool = true;\n foo::<bool, u32>(x, 12); // ok!\n f(); // ok!\n}\n```\n"),
(E0109,
"You tried to provide a generic argument to a type which doesn\'t need it.\n\nErroneous code example:\n\n```compile_fail,E0109\ntype X = u32<i32>; // error: type arguments are not allowed for this type\ntype Y = bool<\'static>; // error: lifetime parameters are not allowed on\n // this type\n```\n\nCheck that you used the correct argument and that the definition is correct.\n\nExample:\n\n```\ntype X = u32; // ok!\ntype Y = bool; // ok!\n```\n\nNote that generic arguments for enum variant constructors go after the variant,\nnot after the enum. For example, you would write `Option::None::<u32>`,\nrather than `Option::<u32>::None`.\n"),
(E0110,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou tried to provide a lifetime to a type which doesn\'t need it.\nSee `E0109` for more details.\n"),
(E0116,
"An inherent implementation was defined for a type outside the current crate.\n\nErroneous code example:\n\n```compile_fail,E0116\nimpl Vec<u8> { } // error\n```\n\nYou can only define an inherent implementation for a type in the same crate\nwhere the type was defined. For example, an `impl` block as above is not allowed\nsince `Vec` is defined in the standard library.\n\nTo fix this problem, you can either:\n\n - define a trait that has the desired associated functions/types/constants and\n implement the trait for the type in question\n - define a new type wrapping the type and define an implementation on the new\n type\n\nNote that using the `type` keyword does not work here because `type` only\nintroduces a type alias:\n\n```compile_fail,E0116\ntype Bytes = Vec<u8>;\n\nimpl Bytes { } // error, same as above\n```\n"),
(E0117,
"Only traits defined in the current crate can be implemented for arbitrary types.\n\nErroneous code example:\n\n```compile_fail,E0117\nimpl Drop for u32 {}\n```\n\nThis error indicates a violation of one of Rust\'s orphan rules for trait\nimplementations. The rule prohibits any implementation of a foreign trait (a\ntrait defined in another crate) where\n\n - the type that is implementing the trait is foreign\n - all of the parameters being passed to the trait (if there are any) are also\n foreign.\n\nTo avoid this kind of error, ensure that at least one local type is referenced\nby the `impl`:\n\n```\npub struct Foo; // you define your type in your crate\n\nimpl Drop for Foo { // and you can implement the trait on it!\n // code of trait implementation here\n# fn drop(&mut self) { }\n}\n\nimpl From<Foo> for i32 { // or you use a type from your crate as\n // a type parameter\n fn from(i: Foo) -> i32 {\n 0\n }\n}\n```\n\nAlternatively, define a trait locally and implement that instead:\n\n```\ntrait Bar {\n fn get(&self) -> usize;\n}\n\nimpl Bar for u32 {\n fn get(&self) -> usize { 0 }\n}\n```\n\nFor information on the design of the orphan rules, see [RFC 1023].\n\n[RFC 1023]: https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md\n"),
(E0118,
"An inherent implementation was defined for something which isn\'t a struct,\nenum, union, or trait object.\n\nErroneous code example:\n\n```compile_fail,E0118\nimpl<T> T { // error: no nominal type found for inherent implementation\n fn get_state(&self) -> String {\n // ...\n }\n}\n```\n\nTo fix this error, please implement a trait on the type or wrap it in a struct.\nExample:\n\n```\n// we create a trait here\ntrait LiveLongAndProsper {\n fn get_state(&self) -> String;\n}\n\n// and now you can implement it on T\nimpl<T> LiveLongAndProsper for T {\n fn get_state(&self) -> String {\n \"He\'s dead, Jim!\".to_owned()\n }\n}\n```\n\nAlternatively, you can create a newtype. A newtype is a wrapping tuple-struct.\nFor example, `NewType` is a newtype over `Foo` in `struct NewType(Foo)`.\nExample:\n\n```\nstruct TypeWrapper<T>(T);\n\nimpl<T> TypeWrapper<T> {\n fn get_state(&self) -> String {\n \"Fascinating!\".to_owned()\n }\n}\n```\n"),
(E0119,
"There are conflicting trait implementations for the same type.\n\nErroneous code example:\n\n```compile_fail,E0119\ntrait MyTrait {\n fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n fn get(&self) -> usize { 0 }\n}\n\nstruct Foo {\n value: usize\n}\n\nimpl MyTrait for Foo { // error: conflicting implementations of trait\n // `MyTrait` for type `Foo`\n fn get(&self) -> usize { self.value }\n}\n```\n\nWhen looking for the implementation for the trait, the compiler finds\nboth the `impl<T> MyTrait for T` where T is all types and the `impl\nMyTrait for Foo`. Since a trait cannot be implemented multiple times,\nthis is an error. So, when you write:\n\n```\ntrait MyTrait {\n fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n fn get(&self) -> usize { 0 }\n}\n```\n\nThis makes the trait implemented on all types in the scope. So if you\ntry to implement it on another one after that, the implementations will\nconflict. Example:\n\n```\ntrait MyTrait {\n fn get(&self) -> usize;\n}\n\nimpl<T> MyTrait for T {\n fn get(&self) -> usize { 0 }\n}\n\nstruct Foo;\n\nfn main() {\n let f = Foo;\n\n f.get(); // the trait is implemented so we can use it\n}\n```\n"),
(E0120,
"`Drop` was implemented on a trait object or reference, which is not allowed;\nonly structs, enums, and unions can implement Drop.\n\nErroneous code examples:\n\n```compile_fail,E0120\ntrait MyTrait {}\n\nimpl Drop for MyTrait {\n fn drop(&mut self) {}\n}\n```\n\n```compile_fail,E0120\nstruct Concrete {}\n\nimpl Drop for &\'_ mut Concrete {\n fn drop(&mut self) {}\n}\n```\n\nA workaround for traits is to create a wrapper struct with a generic type,\nadd a trait bound to the type, and implement `Drop` on the wrapper:\n\n```\ntrait MyTrait {}\nstruct MyWrapper<T: MyTrait> { foo: T }\n\nimpl <T: MyTrait> Drop for MyWrapper<T> {\n fn drop(&mut self) {}\n}\n\n```\n\nAlternatively, the `Drop` wrapper can contain the trait object:\n\n```\ntrait MyTrait {}\n\n// or Box<dyn MyTrait>, if you wanted an owned trait object\nstruct MyWrapper<\'a> { foo: &\'a dyn MyTrait }\n\nimpl <\'a> Drop for MyWrapper<\'a> {\n fn drop(&mut self) {}\n}\n```\n"),
(E0121,
"The type placeholder `_` was used within a type on an item\'s signature.\n\nErroneous code example:\n\n```compile_fail,E0121\nfn foo() -> _ { 5 } // error\n\nstatic BAR: _ = \"test\"; // error\n```\n\nIn those cases, you need to provide the type explicitly:\n\n```\nfn foo() -> i32 { 5 } // ok!\n\nstatic BAR: &str = \"test\"; // ok!\n```\n\nThe type placeholder `_` can be used outside item\'s signature as follows:\n\n```\nlet x = \"a4a\".split(\'4\')\n .collect::<Vec<_>>(); // No need to precise the Vec\'s generic type.\n```\n"),
(E0124,
"A struct was declared with two fields having the same name.\n\nErroneous code example:\n\n```compile_fail,E0124\nstruct Foo {\n field1: i32,\n field1: i32, // error: field is already declared\n}\n```\n\nPlease verify that the field names have been correctly spelled. Example:\n\n```\nstruct Foo {\n field1: i32,\n field2: i32, // ok!\n}\n```\n"),
(E0128,
"A type parameter with default value is using forward declared identifier.\n\nErroneous code example:\n\n```compile_fail,E0128\nstruct Foo<T = U, U = ()> {\n field1: T,\n field2: U,\n}\n// error: generic parameters with a default cannot use forward declared\n// identifiers\n```\n\nType parameter defaults can only use parameters that occur before them. Since\ntype parameters are evaluated in-order, this issue could be fixed by doing:\n\n```\nstruct Foo<U = (), T = U> {\n field1: T,\n field2: U,\n}\n```\n\nPlease also verify that this wasn\'t because of a name-clash and rename the type\nparameter if so.\n"),
(E0130,
"A pattern was declared as an argument in a foreign function declaration.\n\nErroneous code example:\n\n```compile_fail,E0130\nextern \"C\" {\n fn foo((a, b): (u32, u32)); // error: patterns aren\'t allowed in foreign\n // function declarations\n}\n```\n\nTo fix this error, replace the pattern argument with a regular one. Example:\n\n```\nstruct SomeStruct {\n a: u32,\n b: u32,\n}\n\nextern \"C\" {\n fn foo(s: SomeStruct); // ok!\n}\n```\n\nOr:\n\n```\nextern \"C\" {\n fn foo(a: (u32, u32)); // ok!\n}\n```\n"),
(E0131,
"The `main` function was defined with generic parameters.\n\nErroneous code example:\n\n```compile_fail,E0131\nfn main<T>() { // error: main function is not allowed to have generic parameters\n}\n```\n\nIt is not possible to define the `main` function with generic parameters.\nIt must not take any arguments.\n"),
(E0132,
"#### Note: this error code is no longer emitted by the compiler.\n\nA function with the `start` attribute was declared with type parameters.\n"),
(E0133,
"Unsafe code was used outside of an unsafe block.\n\nErroneous code example:\n\n```compile_fail,E0133\nunsafe fn f() { return; } // This is the unsafe code\n\nfn main() {\n f(); // error: call to unsafe function requires unsafe function or block\n}\n```\n\nUsing unsafe functionality is potentially dangerous and disallowed by safety\nchecks. Examples:\n\n* Dereferencing raw pointers\n* Calling functions via FFI\n* Calling functions marked unsafe\n\nThese safety checks can be relaxed for a section of the code by wrapping the\nunsafe instructions with an `unsafe` block. For instance:\n\n```\nunsafe fn f() { return; }\n\nfn main() {\n unsafe { f(); } // ok!\n}\n```\n\nSee the [unsafe section][unsafe-section] of the Book for more details.\n\n#### Unsafe code in functions\n\nUnsafe code is currently accepted in unsafe functions, but that is being phased\nout in favor of requiring unsafe blocks here too.\n\n```\nunsafe fn f() { return; }\n\nunsafe fn g() {\n f(); // Is accepted, but no longer recommended\n unsafe { f(); } // Recommended way to write this\n}\n```\n\nLinting against this is controlled via the `unsafe_op_in_unsafe_fn` lint, which\nis `warn` by default in the 2024 edition and `allow` by default in earlier\neditions.\n\n[unsafe-section]: https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html\n"),
(E0136,
"#### Note: this error code is no longer emitted by the compiler.\n\nMore than one `main` function was found.\n\nErroneous code example:\n\n```compile_fail\nfn main() {\n // ...\n}\n\n// ...\n\nfn main() { // error!\n // ...\n}\n```\n\nA binary can only have one entry point, and by default that entry point is the\n`main()` function. If there are multiple instances of this function, please\nrename one of them.\n"),
(E0137,
"#### Note: this error code is no longer emitted by the compiler.\n\nMore than one function was declared with the `#[main]` attribute.\n\nErroneous code example:\n\n```compile_fail\n#![feature(main)]\n\n#[main]\nfn foo() {}\n\n#[main]\nfn f() {} // error: multiple functions with a `#[main]` attribute\n```\n\nThis error indicates that the compiler found multiple functions with the\n`#[main]` attribute. This is an error because there must be a unique entry\npoint into a Rust program. Example:\n\n```compile_fail\n#![feature(main)]\n\n#[main]\nfn f() {} // ok!\n```\n"),
(E0138,
"#### Note: this error code is no longer emitted by the compiler.\n\nMore than one function was declared with the `#[start]` attribute.\n"),
(E0139,
"#### Note: this error code is no longer emitted by the compiler.\n\nThere are various restrictions on transmuting between types in Rust; for example\ntypes being transmuted must have the same size. To apply all these restrictions,\nthe compiler must know the exact types that may be transmuted. When type\nparameters are involved, this cannot always be done.\n\nSo, for example, the following is not allowed:\n\n```\nuse std::mem::transmute;\n\nstruct Foo<T>(Vec<T>);\n\nfn foo<T>(x: Vec<T>) {\n // we are transmuting between Vec<T> and Foo<F> here\n let y: Foo<T> = unsafe { transmute(x) };\n // do something with y\n}\n```\n\nIn this specific case there\'s a good chance that the transmute is harmless (but\nthis is not guaranteed by Rust). However, when alignment and enum optimizations\ncome into the picture, it\'s quite likely that the sizes may or may not match\nwith different type parameter instantiations. It\'s not possible to check this\nfor _all_ possible types, so `transmute()` simply only accepts types without any\nuninstantiated type parameters.\n\nIf you need this, there\'s a good chance you\'re doing something wrong. Keep in\nmind that Rust doesn\'t guarantee much about the layout of different structs\n(even two structs with identical declarations may have different layouts). If\nthere is a solution that avoids the transmute entirely, try it instead.\n\nIf it\'s possible, hand-monomorphize the code by writing the function for each\npossible type instantiation. It\'s possible to use traits to do this cleanly,\nfor example:\n\n```\nuse std::mem::transmute;\n\nstruct Foo<T>(Vec<T>);\n\ntrait MyTransmutableType: Sized {\n fn transmute(_: Vec<Self>) -> Foo<Self>;\n}\n\nimpl MyTransmutableType for u8 {\n fn transmute(x: Vec<u8>) -> Foo<u8> {\n unsafe { transmute(x) }\n }\n}\n\nimpl MyTransmutableType for String {\n fn transmute(x: Vec<String>) -> Foo<String> {\n unsafe { transmute(x) }\n }\n}\n\n// ... more impls for the types you intend to transmute\n\nfn foo<T: MyTransmutableType>(x: Vec<T>) {\n let y: Foo<T> = <T as MyTransmutableType>::transmute(x);\n // do something with y\n}\n```\n\nEach impl will be checked for a size match in the transmute as usual, and since\nthere are no unbound type parameters involved, this should compile unless there\nis a size mismatch in one of the impls.\n\nIt is also possible to manually transmute:\n\n```\n# use std::ptr;\n# let v = Some(\"value\");\n# type SomeType = &\'static [u8];\nunsafe {\n ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType`\n}\n# ;\n```\n\nNote that this does not move `v` (unlike `transmute`), and may need a\ncall to `mem::forget(v)` in case you want to avoid destructors being called.\n"),
(E0152,
"A lang item was redefined.\n\nErroneous code example:\n\n```compile_fail,E0152\n#![feature(lang_items)]\n\n#[lang = \"owned_box\"]\nstruct Foo<T>(T); // error: duplicate lang item found: `owned_box`\n```\n\nLang items are already implemented in the standard library. Unless you are\nwriting a free-standing application (e.g., a kernel), you do not need to provide\nthem yourself.\n\nYou can build a free-standing crate by adding `#![no_std]` to the crate\nattributes:\n\n```ignore (only-for-syntax-highlight)\n#![no_std]\n```\n\nSee also [this section of the Rustonomicon][beneath std].\n\n[beneath std]: https://doc.rust-lang.org/nomicon/beneath-std.html\n"),
(E0154,
"#### Note: this error code is no longer emitted by the compiler.\n\nImports (`use` statements) are not allowed after non-item statements, such as\nvariable declarations and expression statements.\n\nHere is an example that demonstrates the error:\n\n```\nfn f() {\n // Variable declaration before import\n let x = 0;\n use std::io::Read;\n // ...\n}\n```\n\nThe solution is to declare the imports at the top of the block, function, or\nfile.\n\nHere is the previous example again, with the correct order:\n\n```\nfn f() {\n use std::io::Read;\n let x = 0;\n // ...\n}\n```\n\nSee the [Declaration Statements][declaration-statements] section of the\nreference for more information about what constitutes an item declaration\nand what does not.\n\n[declaration-statements]: https://doc.rust-lang.org/reference/statements.html#declaration-statements\n"),
(E0158,
"A generic parameter or `static` has been referenced in a pattern.\n\nErroneous code example:\n\n```compile_fail,E0158\nenum Foo {\n One,\n Two\n}\n\ntrait Bar {\n const X: Foo;\n}\n\nfn test<A: Bar>(arg: Foo) {\n match arg {\n A::X => println!(\"A::X\"), // error: E0158: constant pattern depends\n // on a generic parameter\n Foo::Two => println!(\"Two\")\n }\n}\n```\n\nGeneric parameters cannot be referenced in patterns because it is impossible\nfor the compiler to prove exhaustiveness (that some pattern will always match).\nTake the above example, because Rust does type checking in the *generic*\nmethod, not the *monomorphized* specific instance. So because `Bar` could have\ntheoretically arbitrary implementations, there\'s no way to always be sure that\n`A::X` is `Foo::One`. So this code must be rejected. Even if code can be\nproven exhaustive by a programmer, the compiler cannot currently prove this.\n\nThe same holds true of `static`s.\n\nIf you want to match against a `const` that depends on a generic parameter or a\n`static`, consider using a guard instead:\n\n```\ntrait Trait {\n const X: char;\n}\n\nstatic FOO: char = \'j\';\n\nfn test<A: Trait, const Y: char>(arg: char) {\n match arg {\n c if c == A::X => println!(\"A::X\"),\n c if c == Y => println!(\"Y\"),\n c if c == FOO => println!(\"FOO\"),\n _ => ()\n }\n}\n```\n"),
(E0161,
"A value was moved whose size was not known at compile time.\n\nErroneous code example:\n\n```compile_fail,E0161\ntrait Bar {\n fn f(self);\n}\n\nimpl Bar for i32 {\n fn f(self) {}\n}\n\nfn main() {\n let b: Box<dyn Bar> = Box::new(0i32);\n b.f();\n // error: cannot move a value of type dyn Bar: the size of dyn Bar cannot\n // be statically determined\n}\n```\n\nIn Rust, you can only move a value when its size is known at compile time.\n\nTo work around this restriction, consider \"hiding\" the value behind a reference:\neither `&x` or `&mut x`. Since a reference has a fixed size, this lets you move\nit around as usual. Example:\n\n```\ntrait Bar {\n fn f(&self);\n}\n\nimpl Bar for i32 {\n fn f(&self) {}\n}\n\nfn main() {\n let b: Box<dyn Bar> = Box::new(0i32);\n b.f();\n // ok!\n}\n```\n"),
(E0162,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn `if let` pattern attempts to match the pattern, and enters the body if the\nmatch was successful. If the match is irrefutable (when it cannot fail to\nmatch), use a regular `let`-binding instead. For instance:\n\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 // ...\n}\n```\n\nTry this instead:\n\n```\nstruct Irrefutable(i32);\nlet irr = Irrefutable(0);\n\nlet Irrefutable(x) = irr;\nprintln!(\"{}\", x);\n```\n"),
(E0164,
"Something which is neither a tuple struct nor a tuple variant was used as a\npattern.\n\nErroneous code example:\n\n```compile_fail,E0164\nenum A {\n B,\n C,\n}\n\nimpl A {\n fn new() {}\n}\n\nfn bar(foo: A) {\n match foo {\n A::new() => (), // error!\n _ => {}\n }\n}\n```\n\nThis error means that an attempt was made to match something which is neither a\ntuple struct nor a tuple variant. Only these two elements are allowed as a\npattern:\n\n```\nenum A {\n B,\n C,\n}\n\nimpl A {\n fn new() {}\n}\n\nfn bar(foo: A) {\n match foo {\n A::B => (), // ok!\n _ => {}\n }\n}\n```\n"),
(E0165,
"#### Note: this error code is no longer emitted by the compiler.\n\nA `while let` pattern attempts to match the pattern, and enters the body if the\nmatch was successful. If the match is irrefutable (when it cannot fail to\nmatch), use a regular `let`-binding inside a `loop` instead. For instance:\n\n```no_run\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\nTry this instead:\n\n```no_run\nstruct Irrefutable(i32);\nlet irr = Irrefutable(0);\n\nloop {\n let Irrefutable(x) = irr;\n // ...\n}\n```\n"),
(E0170,
"A pattern binding is using the same name as one of the variants of a type.\n\nErroneous code example:\n\n```compile_fail,E0170\n# #![deny(warnings)]\nenum Method {\n GET,\n POST,\n}\n\nfn is_empty(s: Method) -> bool {\n match s {\n GET => true,\n _ => false\n }\n}\n\nfn main() {}\n```\n\nEnum variants are qualified by default. For example, given this type:\n\n```\nenum Method {\n GET,\n POST,\n}\n```\n\nYou would match it using:\n\n```\nenum Method {\n GET,\n POST,\n}\n\nlet m = Method::GET;\n\nmatch m {\n Method::GET => {},\n Method::POST => {},\n}\n```\n\nIf you don\'t qualify the names, the code will bind new variables named \"GET\" and\n\"POST\" instead. This behavior is likely not what you want, so `rustc` warns when\nthat happens.\n\nQualified names are good practice, and most code works well with them. But if\nyou prefer them unqualified, you can import the variants into scope:\n\n```\nuse Method::*;\nenum Method { GET, POST }\n# fn main() {}\n```\n\nIf you want others to be able to import variants from your module directly, use\n`pub use`:\n\n```\npub use Method::*;\npub enum Method { GET, POST }\n# fn main() {}\n```\n"),
(E0178,
"The `+` type operator was used in an ambiguous context.\n\nErroneous code example:\n\n```compile_fail,E0178\ntrait Foo {}\n\nstruct Bar<\'a> {\n x: &\'a Foo + \'a, // error!\n y: &\'a mut Foo + \'a, // error!\n z: fn() -> Foo + \'a, // error!\n}\n```\n\nIn types, the `+` type operator has low precedence, so it is often necessary\nto use parentheses:\n\n```\ntrait Foo {}\n\nstruct Bar<\'a> {\n x: &\'a (Foo + \'a), // ok!\n y: &\'a mut (Foo + \'a), // ok!\n z: fn() -> (Foo + \'a), // ok!\n}\n```\n\nMore details can be found in [RFC 438].\n\n[RFC 438]: https://github.com/rust-lang/rfcs/pull/438\n"),
(E0183,
"Manual implementation of a `Fn*` trait.\n\nErroneous code example:\n\n```compile_fail,E0183\nstruct MyClosure {\n foo: i32\n}\n\nimpl FnOnce<()> for MyClosure { // error\n type Output = ();\n extern \"rust-call\" fn call_once(self, args: ()) -> Self::Output {\n println!(\"{}\", self.foo);\n }\n}\n```\n\nManually implementing `Fn`, `FnMut` or `FnOnce` is unstable\nand requires `#![feature(fn_traits, unboxed_closures)]`.\n\n```\n#![feature(fn_traits, unboxed_closures)]\n\nstruct MyClosure {\n foo: i32\n}\n\nimpl FnOnce<()> for MyClosure { // ok!\n type Output = ();\n extern \"rust-call\" fn call_once(self, args: ()) -> Self::Output {\n println!(\"{}\", self.foo);\n }\n}\n```\n\nThe arguments must be a tuple representing the argument list.\nFor more info, see the [tracking issue][iss29625]:\n\n[iss29625]: https://github.com/rust-lang/rust/issues/29625\n"),
(E0184,
"The `Copy` trait was implemented on a type with a `Drop` implementation.\n\nErroneous code example:\n\n```compile_fail,E0184\n#[derive(Copy)]\nstruct Foo; // error!\n\nimpl Drop for Foo {\n fn drop(&mut self) {\n }\n}\n```\n\nExplicitly implementing both `Drop` and `Copy` trait on a type is currently\ndisallowed. This feature can make some sense in theory, but the current\nimplementation is incorrect and can lead to memory unsafety (see\n[issue #20126][iss20126]), so it has been disabled for now.\n\n[iss20126]: https://github.com/rust-lang/rust/issues/20126\n"),
(E0185,
"An associated function for a trait was defined to be static, but an\nimplementation of the trait declared the same function to be a method (i.e., to\ntake a `self` parameter).\n\nErroneous code example:\n\n```compile_fail,E0185\ntrait Foo {\n fn foo();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n // error, method `foo` has a `&self` declaration in the impl, but not in\n // the trait\n fn foo(&self) {}\n}\n```\n\nWhen a type implements a trait\'s associated function, it has to use the same\nsignature. So in this case, since `Foo::foo` does not take any argument and\ndoes not return anything, its implementation on `Bar` should be the same:\n\n```\ntrait Foo {\n fn foo();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn foo() {} // ok!\n}\n```\n"),
(E0186,
"An associated function for a trait was defined to be a method (i.e., to take a\n`self` parameter), but an implementation of the trait declared the same function\nto be static.\n\nErroneous code example:\n\n```compile_fail,E0186\ntrait Foo {\n fn foo(&self);\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n // error, method `foo` has a `&self` declaration in the trait, but not in\n // the impl\n fn foo() {}\n}\n```\n\nWhen a type implements a trait\'s associated function, it has to use the same\nsignature. So in this case, since `Foo::foo` takes `self` as argument and\ndoes not return anything, its implementation on `Bar` should be the same:\n\n```\ntrait Foo {\n fn foo(&self);\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn foo(&self) {} // ok!\n}\n```\n"),
(E0191,
"An associated type wasn\'t specified for a trait object.\n\nErroneous code example:\n\n```compile_fail,E0191\ntrait Trait {\n type Bar;\n}\n\ntype Foo = dyn Trait; // error: the value of the associated type `Bar` (from\n // the trait `Trait`) must be specified\n```\n\nTrait objects need to have all associated types specified. Please verify that\nall associated types of the trait were specified and the correct trait was used.\nExample:\n\n```\ntrait Trait {\n type Bar;\n}\n\ntype Foo = dyn Trait<Bar=i32>; // ok!\n```\n"),
(E0192,
"#### Note: this error code is no longer emitted by the compiler.\n\nA negative impl was added on a trait implementation.\n\nErroneous code example:\n\n```compile_fail\ntrait Trait {\n type Bar;\n}\n\nstruct Foo;\n\nimpl !Trait for Foo { } //~ ERROR\n\nfn main() {}\n```\n\nNegative impls are only allowed for auto traits. For more\ninformation see the [opt-in builtin traits RFC][RFC 19].\n\n[RFC 19]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md\n"),
(E0193,
"#### Note: this error code is no longer emitted by the compiler.\n\n`where` clauses must use generic type parameters: it does not make sense to use\nthem otherwise. An example causing this error:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n#[derive(Copy,Clone)]\nstruct Wrapper<T> {\n Wrapped: T\n}\n\nimpl Foo for Wrapper<u32> where Wrapper<u32>: Clone {\n fn bar(&self) { }\n}\n```\n\nThis use of a `where` clause is strange - a more common usage would look\nsomething like the following:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n#[derive(Copy,Clone)]\nstruct Wrapper<T> {\n Wrapped: T\n}\nimpl <T> Foo for Wrapper<T> where Wrapper<T>: Clone {\n fn bar(&self) { }\n}\n```\n\nHere, we\'re saying that the implementation exists on Wrapper only when the\nwrapped type `T` implements `Clone`. The `where` clause is important because\nsome types will not implement `Clone`, and thus will not get this method.\n\nIn our erroneous example, however, we\'re referencing a single concrete type.\nSince we know for certain that `Wrapper<u32>` implements `Clone`, there\'s no\nreason to also specify it in a `where` clause.\n"),
(E0195,
"The lifetime parameters of the method do not match the trait declaration.\n\nErroneous code example:\n\n```compile_fail,E0195\ntrait Trait {\n fn bar<\'a,\'b:\'a>(x: &\'a str, y: &\'b str);\n}\n\nstruct Foo;\n\nimpl Trait for Foo {\n fn bar<\'a,\'b>(x: &\'a str, y: &\'b str) {\n // error: lifetime parameters or bounds on method `bar`\n // do not match the trait declaration\n }\n}\n```\n\nThe lifetime constraint `\'b` for `bar()` implementation does not match the\ntrait declaration. Ensure lifetime declarations match exactly in both trait\ndeclaration and implementation. Example:\n\n```\ntrait Trait {\n fn t<\'a,\'b:\'a>(x: &\'a str, y: &\'b str);\n}\n\nstruct Foo;\n\nimpl Trait for Foo {\n fn t<\'a,\'b:\'a>(x: &\'a str, y: &\'b str) { // ok!\n }\n}\n```\n"),
(E0197,
"An inherent implementation was marked unsafe.\n\nErroneous code example:\n\n```compile_fail,E0197\nstruct Foo;\n\nunsafe impl Foo { } // error!\n```\n\nInherent implementations (one that do not implement a trait but provide\nmethods associated with a type) are always safe because they are not\nimplementing an unsafe trait. Removing the `unsafe` keyword from the inherent\nimplementation will resolve this error.\n\n```\nstruct Foo;\n\nimpl Foo { } // ok!\n```\n"),
(E0198,
"A negative implementation was marked as unsafe.\n\nErroneous code example:\n\n```compile_fail,E0198\nstruct Foo;\n\nunsafe impl !Clone for Foo { } // error!\n```\n\nA negative implementation is one that excludes a type from implementing a\nparticular trait. Not being able to use a trait is always a safe operation,\nso negative implementations are always safe and never need to be marked as\nunsafe.\n\nThis will compile:\n\n```ignore (ignore auto_trait future compatibility warning)\n#![feature(auto_traits)]\n\nstruct Foo;\n\nauto trait Enterprise {}\n\nimpl !Enterprise for Foo { }\n```\n\nPlease note that negative impls are only allowed for auto traits.\n"),
(E0199,
"A trait implementation was marked as unsafe while the trait is safe.\n\nErroneous code example:\n\n```compile_fail,E0199\nstruct Foo;\n\ntrait Bar { }\n\nunsafe impl Bar for Foo { } // error!\n```\n\nSafe traits should not have unsafe implementations, therefore marking an\nimplementation for a safe trait unsafe will cause a compiler error. Removing\nthe unsafe marker on the trait noted in the error will resolve this problem:\n\n```\nstruct Foo;\n\ntrait Bar { }\n\nimpl Bar for Foo { } // ok!\n```\n"),
(E0200,
"An unsafe trait was implemented without an unsafe implementation.\n\nErroneous code example:\n\n```compile_fail,E0200\nstruct Foo;\n\nunsafe trait Bar { }\n\nimpl Bar for Foo { } // error!\n```\n\nUnsafe traits must have unsafe implementations. This error occurs when an\nimplementation for an unsafe trait isn\'t marked as unsafe. This may be resolved\nby marking the unsafe implementation as unsafe.\n\n```\nstruct Foo;\n\nunsafe trait Bar { }\n\nunsafe impl Bar for Foo { } // ok!\n```\n"),
(E0201,
"Two associated items (like methods, associated types, associated functions,\netc.) were defined with the same identifier.\n\nErroneous code example:\n\n```compile_fail,E0201\nstruct Foo(u8);\n\nimpl Foo {\n fn bar(&self) -> bool { self.0 > 5 }\n fn bar() {} // error: duplicate associated function\n}\n\ntrait Baz {\n type Quux;\n fn baz(&self) -> bool;\n}\n\nimpl Baz for Foo {\n type Quux = u32;\n\n fn baz(&self) -> bool { true }\n\n // error: duplicate method\n fn baz(&self) -> bool { self.0 > 5 }\n\n // error: duplicate associated type\n type Quux = u32;\n}\n```\n\nNote, however, that items with the same name are allowed for inherent `impl`\nblocks that don\'t overlap:\n\n```\nstruct Foo<T>(T);\n\nimpl Foo<u8> {\n fn bar(&self) -> bool { self.0 > 5 }\n}\n\nimpl Foo<bool> {\n fn bar(&self) -> bool { self.0 }\n}\n```\n"),
(E0203,
"Having duplicate relaxed default bounds is unsupported.\n\nErroneous code example:\n\n```compile_fail,E0203\nstruct Bad<T: ?Sized + ?Sized>{\n inner: T,\n}\n```\n\nHere the type parameter `T` cannot have duplicate relaxed bounds for default\ntrait `Sized`. This can be fixed by only using one relaxed bound:\n\n```\nstruct Good<T: ?Sized>{\n inner: T\n}\n```\n"),
(E0204,
"The `Copy` trait was implemented on a type which contains a field that doesn\'t\nimplement the `Copy` trait.\n\nErroneous code example:\n\n```compile_fail,E0204\nstruct Foo {\n foo: Vec<u32>,\n}\n\nimpl Copy for Foo { } // error!\n```\n\nThe `Copy` trait is implemented by default only on primitive types. If your\ntype only contains primitive types, you\'ll be able to implement `Copy` on it.\nOtherwise, it won\'t be possible.\n\nHere\'s another example that will fail:\n\n```compile_fail,E0204\n#[derive(Copy)] // error!\nstruct Foo<\'a> {\n ty: &\'a mut bool,\n}\n```\n\nThis fails because `&mut T` is not `Copy`, even when `T` is `Copy` (this\ndiffers from the behavior for `&T`, which is always `Copy`).\n"),
(E0205,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn attempt to implement the `Copy` trait for an enum failed because one of the\nvariants does not implement `Copy`. To fix this, you must implement `Copy` for\nthe mentioned variant. Note that this may not be possible, as in the example of\n\n```compile_fail,E0204\nenum Foo {\n Bar(Vec<u32>),\n Baz,\n}\n\nimpl Copy for Foo { }\n```\n\nThis fails because `Vec<T>` does not implement `Copy` for any `T`.\n\nHere\'s another example that will fail:\n\n```compile_fail,E0204\n#[derive(Copy)]\nenum Foo<\'a> {\n Bar(&\'a mut bool),\n Baz,\n}\n```\n\nThis fails because `&mut T` is not `Copy`, even when `T` is `Copy` (this\ndiffers from the behavior for `&T`, which is always `Copy`).\n"),
(E0206,
"The `Copy` trait was implemented on a type which is neither a struct, an\nenum, nor a union.\n\nErroneous code example:\n\n```compile_fail,E0206\n#[derive(Copy, Clone)]\nstruct Bar;\n\nimpl Copy for &\'static mut Bar { } // error!\n```\n\nYou can only implement `Copy` for a struct, an enum, or a union.\nThe previous example will fail because `&\'static mut Bar`\nis not a struct, an enum, or a union.\n"),
(E0207,
"A type, const or lifetime parameter that is specified for `impl` is not\nconstrained.\n\nErroneous code example:\n\n```compile_fail,E0207\nstruct Foo;\n\nimpl<T: Default> Foo {\n // error: the type parameter `T` is not constrained by the impl trait, self\n // type, or predicates [E0207]\n fn get(&self) -> T {\n <T as Default>::default()\n }\n}\n```\n\nAny type or const parameter of an `impl` must meet at least one of the\nfollowing criteria:\n\n - it appears in the _implementing type_ of the impl, e.g. `impl<T> Foo<T>`\n - for a trait impl, it appears in the _implemented trait_, e.g.\n `impl<T> SomeTrait<T> for Foo`\n - it is bound as an associated type, e.g. `impl<T, U> SomeTrait for T\n where T: AnotherTrait<AssocType=U>`\n\nAny unconstrained lifetime parameter of an `impl` is not supported if the\nlifetime parameter is used by an associated type.\n\n### Error example 1\n\nSuppose we have a struct `Foo` and we would like to define some methods for it.\nThe previous code example has a definition which leads to a compiler error:\n\nThe problem is that the parameter `T` does not appear in the implementing type\n(`Foo`) of the impl. In this case, we can fix the error by moving the type\nparameter from the `impl` to the method `get`:\n\n```\nstruct Foo;\n\n// Move the type parameter from the impl to the method\nimpl Foo {\n fn get<T: Default>(&self) -> T {\n <T as Default>::default()\n }\n}\n```\n\n### Error example 2\n\nAs another example, suppose we have a `Maker` trait and want to establish a\ntype `FooMaker` that makes `Foo`s:\n\n```compile_fail,E0207\ntrait Maker {\n type Item;\n fn make(&mut self) -> Self::Item;\n}\n\nstruct Foo<T> {\n foo: T\n}\n\nstruct FooMaker;\n\nimpl<T: Default> Maker for FooMaker {\n// error: the type parameter `T` is not constrained by the impl trait, self\n// type, or predicates [E0207]\n type Item = Foo<T>;\n\n fn make(&mut self) -> Foo<T> {\n Foo { foo: <T as Default>::default() }\n }\n}\n```\n\nThis fails to compile because `T` does not appear in the trait or in the\nimplementing type.\n\nOne way to work around this is to introduce a phantom type parameter into\n`FooMaker`, like so:\n\n```\nuse std::marker::PhantomData;\n\ntrait Maker {\n type Item;\n fn make(&mut self) -> Self::Item;\n}\n\nstruct Foo<T> {\n foo: T\n}\n\n// Add a type parameter to `FooMaker`\nstruct FooMaker<T> {\n phantom: PhantomData<T>,\n}\n\nimpl<T: Default> Maker for FooMaker<T> {\n type Item = Foo<T>;\n\n fn make(&mut self) -> Foo<T> {\n Foo {\n foo: <T as Default>::default(),\n }\n }\n}\n```\n\nAnother way is to do away with the associated type in `Maker` and use an input\ntype parameter instead:\n\n```\n// Use a type parameter instead of an associated type here\ntrait Maker<Item> {\n fn make(&mut self) -> Item;\n}\n\nstruct Foo<T> {\n foo: T\n}\n\nstruct FooMaker;\n\nimpl<T: Default> Maker<Foo<T>> for FooMaker {\n fn make(&mut self) -> Foo<T> {\n Foo { foo: <T as Default>::default() }\n }\n}\n```\n\n### Error example 3\n\nSuppose we have a struct `Foo` and we would like to define some methods for it.\nThe following code example has a definition which leads to a compiler error:\n\n```compile_fail,E0207\nstruct Foo;\n\nimpl<const T: i32> Foo {\n // error: the const parameter `T` is not constrained by the impl trait, self\n // type, or predicates [E0207]\n fn get(&self) -> i32 {\n i32::default()\n }\n}\n```\n\nThe problem is that the const parameter `T` does not appear in the implementing\ntype (`Foo`) of the impl. In this case, we can fix the error by moving the type\nparameter from the `impl` to the method `get`:\n\n\n```\nstruct Foo;\n\n// Move the const parameter from the impl to the method\nimpl Foo {\n fn get<const T: i32>(&self) -> i32 {\n i32::default()\n }\n}\n```\n\n### Error example 4\n\nSuppose we have a struct `Foo` and a struct `Bar` that uses lifetime `\'a`. We\nwould like to implement trait `Contains` for `Foo`. The trait `Contains` have\nthe associated type `B`. The following code example has a definition which\nleads to a compiler error:\n\n```compile_fail,E0207\nstruct Foo;\nstruct Bar<\'a>;\n\ntrait Contains {\n type B;\n\n fn get(&self) -> i32;\n}\n\nimpl<\'a> Contains for Foo {\n type B = Bar<\'a>;\n\n // error: the lifetime parameter `\'a` is not constrained by the impl trait,\n // self type, or predicates [E0207]\n fn get(&self) -> i32 {\n i32::default()\n }\n}\n```\n\nPlease note that unconstrained lifetime parameters are not supported if they are\nbeing used by an associated type.\n\nIn cases where the associated type\'s lifetime is meant to be tied to the\nself type, and none of the methods on the trait need ownership or different\nmutability, then an option is to implement the trait on a borrowed type:\n\n```rust\nstruct Foo(i32);\n\ntrait Contents {\n type Item;\n\n fn get(&self) -> Self::Item;\n}\n\n// Note the lifetime `\'a` is used both for the self type...\nimpl<\'a> Contents for &\'a Foo {\n // ...and the associated type.\n type Item = &\'a i32;\n\n fn get(&self) -> Self::Item {\n &self.0\n }\n}\n```\n\n### Additional information\n\nFor more information, please see [RFC 447].\n\n[RFC 447]: https://github.com/rust-lang/rfcs/blob/master/text/0447-no-unused-impl-parameters.md\n"),
(E0208,
"#### This error code is internal to the compiler and will not be emitted with normal Rust code.\n#### Note: this error code is no longer emitted by the compiler.\n\nThis error code shows the variance of a type\'s generic parameters.\n\nErroneous code example:\n\n```compile_fail\n// NOTE: this feature is perma-unstable and should *only* be used for\n// testing purposes.\n#![allow(internal_features)]\n#![feature(rustc_attrs)]\n\n#[rustc_variance]\nstruct Foo<\'a, T> { // error: deliberate error to display type\'s variance\n t: &\'a mut T,\n}\n```\n\nwhich produces the following error:\n\n```text\nerror: [-, o]\n --> <anon>:4:1\n |\n4 | struct Foo<\'a, T> {\n | ^^^^^^^^^^^^^^^^^\n```\n\n*Note that while `#[rustc_variance]` still exists and is used within the*\n*compiler, it no longer is marked as `E0208` and instead has no error code.*\n\nThis error is deliberately triggered with the `#[rustc_variance]` attribute\n(`#![feature(rustc_attrs)]` must be enabled) and helps to show you the variance\nof the type\'s generic parameters. You can read more about variance and\nsubtyping in [this section of the Rustonomicon]. For a more in depth look at\nvariance (including a more complete list of common variances) see\n[this section of the Reference]. For information on how variance is implemented\nin the compiler, see [this section of `rustc-dev-guide`].\n\nThis error can be easily fixed by removing the `#[rustc_variance]` attribute,\nthe compiler\'s suggestion to comment it out can be applied automatically with\n`rustfix`.\n\n[this section of the Rustonomicon]: https://doc.rust-lang.org/nomicon/subtyping.html\n[this section of the Reference]: https://doc.rust-lang.org/reference/subtyping.html#variance\n[this section of `rustc-dev-guide`]: https://rustc-dev-guide.rust-lang.org/variance.html\n"),
(E0210,
"This error indicates a violation of one of Rust\'s orphan rules for trait\nimplementations. The rule concerns the use of type parameters in an\nimplementation of a foreign trait (a trait defined in another crate), and\nstates that type parameters must be \"covered\" by a local type.\n\nWhen implementing a foreign trait for a foreign type,\nthe trait must have one or more type parameters.\nA type local to your crate must appear before any use of any type parameters.\n\nTo understand what this means, it is perhaps easier to consider a few examples.\n\nIf `ForeignTrait` is a trait defined in some external crate `foo`, then the\nfollowing trait `impl` is an error:\n\n```compile_fail,E0210\n# #[cfg(for_demonstration_only)]\nextern crate foo;\n# #[cfg(for_demonstration_only)]\nuse foo::ForeignTrait;\n# use std::panic::UnwindSafe as ForeignTrait;\n\nimpl<T> ForeignTrait for T { } // error\n# fn main() {}\n```\n\nTo work around this, it can be covered with a local type, `MyType`:\n\n```\n# use std::panic::UnwindSafe as ForeignTrait;\nstruct MyType<T>(T);\nimpl<T> ForeignTrait for MyType<T> { } // Ok\n```\n\nPlease note that a type alias is not sufficient.\n\nFor another example of an error, suppose there\'s another trait defined in `foo`\nnamed `ForeignTrait2` that takes two type parameters. Then this `impl` results\nin the same rule violation:\n\n```ignore (cannot-doctest-multicrate-project)\nstruct MyType2;\nimpl<T> ForeignTrait2<T, MyType<T>> for MyType2 { } // error\n```\n\nThe reason for this is that there are two appearances of type parameter `T` in\nthe `impl` header, both as parameters for `ForeignTrait2`. The first appearance\nis uncovered, and so runs afoul of the orphan rule.\n\nConsider one more example:\n\n```ignore (cannot-doctest-multicrate-project)\nimpl<T> ForeignTrait2<MyType<T>, T> for MyType2 { } // Ok\n```\n\nThis only differs from the previous `impl` in that the parameters `T` and\n`MyType<T>` for `ForeignTrait2` have been swapped. This example does *not*\nviolate the orphan rule; it is permitted.\n\nTo see why that last example was allowed, you need to understand the general\nrule. Unfortunately this rule is a bit tricky to state. Consider an `impl`:\n\n```ignore (only-for-syntax-highlight)\nimpl<P1, ..., Pm> ForeignTrait<T1, ..., Tn> for T0 { ... }\n```\n\nwhere `P1, ..., Pm` are the type parameters of the `impl` and `T0, ..., Tn`\nare types. One of the types `T0, ..., Tn` must be a local type (this is another\norphan rule, see the explanation for E0117).\n\nBoth of the following must be true:\n1. At least one of the types `T0..=Tn` must be a local type.\nLet `Ti` be the first such type.\n2. No uncovered type parameters `P1..=Pm` may appear in `T0..Ti`\n(excluding `Ti`).\n\nFor information on the design of the orphan rules,\nsee [RFC 2451] and [RFC 1023].\n\n[RFC 2451]: https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html\n[RFC 1023]: https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md\n"),
(E0211,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou used a function or type which doesn\'t fit the requirements for where it was\nused. Erroneous code examples:\n\n```compile_fail\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\nunsafe fn unreachable(); // error: intrinsic has wrong type\n\n// or:\n\nfn main() -> i32 { 0 }\n// error: main function expects type: `fn() {main}`: expected (), found i32\n\n// or:\n\nlet x = 1u8;\nmatch x {\n 0u8..=3i8 => (),\n // error: mismatched types in range: expected u8, found i8\n _ => ()\n}\n\n// or:\n\nuse std::rc::Rc;\nstruct Foo;\n\nimpl Foo {\n fn x(self: Rc<Foo>) {}\n // error: mismatched self type: expected `Foo`: expected struct\n // `Foo`, found struct `alloc::rc::Rc`\n}\n```\n\nFor the first code example, please check the function definition. Example:\n\n```\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\nunsafe fn unreachable() -> !; // ok!\n```\n\nThe second case example is a bit particular: the main function must always\nhave this definition:\n\n```compile_fail\nfn main();\n```\n\nThey never take parameters and never return types.\n\nFor the third example, when you match, all patterns must have the same type\nas the type you\'re matching on. Example:\n\n```\nlet x = 1u8;\n\nmatch x {\n 0u8..=3u8 => (), // ok!\n _ => ()\n}\n```\n\nAnd finally, for the last example, only `Box<Self>`, `&Self`, `Self`,\nor `&mut Self` work as explicit self parameters. Example:\n\n```\nstruct Foo;\n\nimpl Foo {\n fn x(self: Box<Foo>) {} // ok!\n}\n```\n"),
(E0212,
"Cannot use the associated type of\na trait with uninferred generic parameters.\n\nErroneous code example:\n\n```compile_fail,E0212\npub trait Foo<T> {\n type A;\n\n fn get(&self, t: T) -> Self::A;\n}\n\nfn foo2<I : for<\'x> Foo<&\'x isize>>(\n field: I::A) {} // error!\n```\n\nIn this example, we have to instantiate `\'x`, and\nwe don\'t know what lifetime to instantiate it with.\nTo fix this, spell out the precise lifetimes involved.\nExample:\n\n```\npub trait Foo<T> {\n type A;\n\n fn get(&self, t: T) -> Self::A;\n}\n\nfn foo3<I : for<\'x> Foo<&\'x isize>>(\n x: <I as Foo<&isize>>::A) {} // ok!\n\n\nfn foo4<\'a, I : for<\'x> Foo<&\'x isize>>(\n x: <I as Foo<&\'a isize>>::A) {} // ok!\n```\n"),
(E0214,
"A generic type was described using parentheses rather than angle brackets.\n\nErroneous code example:\n\n```compile_fail,E0214\nlet v: Vec(&str) = vec![\"foo\"];\n```\n\nThis is not currently supported: `v` should be defined as `Vec<&str>`.\nParentheses are currently only used with generic types when defining parameters\nfor `Fn`-family traits.\n\nThe previous code example fixed:\n\n```\nlet v: Vec<&str> = vec![\"foo\"];\n```\n"),
(E0220,
"The associated type used was not defined in the trait.\n\nErroneous code example:\n\n```compile_fail,E0220\ntrait T1 {\n type Bar;\n}\n\ntype Foo = T1<F=i32>; // error: associated type `F` not found for `T1`\n\n// or:\n\ntrait T2 {\n type Bar;\n\n // error: Baz is used but not declared\n fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool;\n}\n```\n\nMake sure that you have defined the associated type in the trait body.\nAlso, verify that you used the right trait or you didn\'t misspell the\nassociated type name. Example:\n\n```\ntrait T1 {\n type Bar;\n}\n\ntype Foo = T1<Bar=i32>; // ok!\n\n// or:\n\ntrait T2 {\n type Bar;\n type Baz; // we declare `Baz` in our trait.\n\n // and now we can use it here:\n fn return_bool(&self, _: &Self::Bar, _: &Self::Baz) -> bool;\n}\n```\n"),
(E0221,
"An attempt was made to retrieve an associated type, but the type was ambiguous.\n\nErroneous code example:\n\n```compile_fail,E0221\ntrait T1 {}\ntrait T2 {}\n\ntrait Foo {\n type A: T1;\n}\n\ntrait Bar : Foo {\n type A: T2;\n fn do_something() {\n let _: Self::A;\n }\n}\n```\n\nIn this example, `Foo` defines an associated type `A`. `Bar` inherits that type\nfrom `Foo`, and defines another associated type of the same name. As a result,\nwhen we attempt to use `Self::A`, it\'s ambiguous whether we mean the `A` defined\nby `Foo` or the one defined by `Bar`.\n\nThere are two options to work around this issue. The first is simply to rename\none of the types. Alternatively, one can specify the intended type using the\nfollowing syntax:\n\n```\ntrait T1 {}\ntrait T2 {}\n\ntrait Foo {\n type A: T1;\n}\n\ntrait Bar : Foo {\n type A: T2;\n fn do_something() {\n let _: <Self as Bar>::A;\n }\n}\n```\n"),
(E0222,
"An attempt was made to constrain an associated type.\n\nErroneous code example:\n\n```compile_fail,E0222\npub trait Vehicle {\n type Color;\n}\n\npub trait Box {\n type Color;\n}\n\npub trait BoxCar : Box + Vehicle {}\n\nfn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) {} // Invalid constraint\n```\n\nIn this example, `BoxCar` has two supertraits: `Vehicle` and `Box`. Both of\nthese traits define an associated type `Color`. `BoxCar` inherits two types\nwith that name from both supertraits. Because of this, we need to use the\nfully qualified path syntax to refer to the appropriate `Color` associated\ntype, either `<BoxCar as Vehicle>::Color` or `<BoxCar as Box>::Color`, but this\nsyntax is not allowed to be used in a function signature.\n\nIn order to encode this kind of constraint, a `where` clause and a new type\nparameter are needed:\n\n```\npub trait Vehicle {\n type Color;\n}\n\npub trait Box {\n type Color;\n}\n\npub trait BoxCar : Box + Vehicle {}\n\n// Introduce a new `CAR` type parameter\nfn foo<CAR, COLOR>(\n c: CAR,\n) where\n // Bind the type parameter `CAR` to the trait `BoxCar`\n CAR: BoxCar,\n // Further restrict `<BoxCar as Vehicle>::Color` to be the same as the\n // type parameter `COLOR`\n CAR: Vehicle<Color = COLOR>,\n // We can also simultaneously restrict the other trait\'s associated type\n CAR: Box<Color = COLOR>\n{}\n```\n"),
(E0223,
"An attempt was made to retrieve an associated type, but the type was ambiguous.\n\nErroneous code example:\n\n```compile_fail,E0223\ntrait Trait { type X; }\n\nfn main() {\n let foo: Trait::X;\n}\n```\n\nThe problem here is that we\'re attempting to take the associated type of `X`\nfrom `Trait`. Unfortunately, the type of `X` is not defined, because it\'s only\nmade concrete in implementations of the trait. A working version of this code\nmight look like:\n\n```\ntrait Trait { type X; }\n\nstruct Struct;\nimpl Trait for Struct {\n type X = u32;\n}\n\nfn main() {\n let foo: <Struct as Trait>::X;\n}\n```\n\nThis syntax specifies that we want the associated type `X` from `Struct`\'s\nimplementation of `Trait`.\n\nDue to internal limitations of the current compiler implementation we cannot\nsimply use `Struct::X`.\n"),
(E0224,
"A trait object was declared with no traits.\n\nErroneous code example:\n\n```compile_fail,E0224\ntype Foo = dyn \'static +;\n```\n\nRust does not currently support this.\n\nTo solve, ensure that the trait object has at least one trait:\n\n```\ntype Foo = dyn \'static + Copy;\n```\n"),
(E0225,
"Multiple types were used as bounds for a closure or trait object.\n\nErroneous code example:\n\n```compile_fail,E0225\nfn main() {\n let _: Box<dyn std::io::Read + std::io::Write>;\n}\n```\n\nRust does not currently support this.\n\nAuto traits such as Send and Sync are an exception to this rule:\nIt\'s possible to have bounds of one non-builtin trait, plus any number of\nauto traits. For example, the following compiles correctly:\n\n```\nfn main() {\n let _: Box<dyn std::io::Read + Send + Sync>;\n}\n```\n"),
(E0226,
"More than one explicit lifetime bound was used on a trait object.\n\nExample of erroneous code:\n\n```compile_fail,E0226\ntrait Foo {}\n\ntype T<\'a, \'b> = dyn Foo + \'a + \'b; // error: Trait object `arg` has two\n // lifetime bound, \'a and \'b.\n```\n\nHere `T` is a trait object with two explicit lifetime bounds, \'a and \'b.\n\nOnly a single explicit lifetime bound is permitted on trait objects.\nTo fix this error, consider removing one of the lifetime bounds:\n\n```\ntrait Foo {}\n\ntype T<\'a> = dyn Foo + \'a;\n```\n"),
(E0227,
"This error indicates that the compiler is unable to determine whether there is\nexactly one unique region in the set of derived region bounds.\n\nExample of erroneous code:\n\n```compile_fail,E0227\ntrait Foo<\'foo>: \'foo {}\ntrait Bar<\'bar>: \'bar {}\n\ntrait FooBar<\'foo, \'bar>: Foo<\'foo> + Bar<\'bar> {}\n\nstruct Baz<\'foo, \'bar> {\n baz: dyn FooBar<\'foo, \'bar>,\n}\n```\n\nHere, `baz` can have either `\'foo` or `\'bar` lifetimes.\n\nTo resolve this error, provide an explicit lifetime:\n\n```rust\ntrait Foo<\'foo>: \'foo {}\ntrait Bar<\'bar>: \'bar {}\n\ntrait FooBar<\'foo, \'bar>: Foo<\'foo> + Bar<\'bar> {}\n\nstruct Baz<\'foo, \'bar, \'baz>\nwhere\n \'baz: \'foo + \'bar,\n{\n obj: dyn FooBar<\'foo, \'bar> + \'baz,\n}\n```\n"),
(E0228,
"The lifetime bound for this object type cannot be deduced from context and must\nbe specified.\n\nErroneous code example:\n\n```compile_fail,E0228\ntrait Trait { }\n\nstruct TwoBounds<\'a, \'b, T: Sized + \'a + \'b> {\n x: &\'a i32,\n y: &\'b i32,\n z: T,\n}\n\ntype Foo<\'a, \'b> = TwoBounds<\'a, \'b, dyn Trait>;\n```\n\nWhen a trait object is used as a type argument of a generic type, Rust will try\nto infer its lifetime if unspecified. However, this isn\'t possible when the\ncontaining type has more than one lifetime bound.\n\nThe above example can be resolved by either reducing the number of lifetime\nbounds to one or by making the trait object lifetime explicit, like so:\n\n```\ntrait Trait { }\n\nstruct TwoBounds<\'a, \'b, T: Sized + \'a + \'b> {\n x: &\'a i32,\n y: &\'b i32,\n z: T,\n}\n\ntype Foo<\'a, \'b> = TwoBounds<\'a, \'b, dyn Trait + \'b>;\n```\n\nFor more information, see [RFC 599] and its amendment [RFC 1156].\n\n[RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md\n[RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md\n"),
(E0229,
"An associated item constraint was written in an unexpected context.\n\nErroneous code example:\n\n```compile_fail,E0229\npub trait Foo {\n type A;\n fn boo(&self) -> <Self as Foo>::A;\n}\n\nstruct Bar;\n\nimpl Foo for isize {\n type A = usize;\n fn boo(&self) -> usize { 42 }\n}\n\nfn baz<I>(x: &<I as Foo<A = Bar>>::A) {}\n// error: associated item constraint are not allowed here\n```\n\nTo solve this error, please move the associated item constraints to the type\nparameter declaration:\n\n```\n# struct Bar;\n# trait Foo { type A; }\nfn baz<I: Foo<A=Bar>>(x: &<I as Foo>::A) {} // ok!\n```\n\nOr into the where-clause:\n\n```\n# struct Bar;\n# trait Foo { type A; }\nfn baz<I>(x: &<I as Foo>::A) where I: Foo<A=Bar> {}\n```\n"),
(E0230,
"The `#[rustc_on_unimplemented]` attribute lets you specify a custom error\nmessage for when a particular trait isn\'t implemented on a type placed in a\nposition that needs that trait. For example, when the following code is\ncompiled:\n\n```compile_fail,E0230\n#![feature(rustc_attrs)]\n#![allow(internal_features)]\n\n#[rustc_on_unimplemented = \"error on `{Self}` with params `<{A},{B}>`\"] // error\ntrait BadAnnotation<A> {}\n```\n\nThere will be an error about `bool` not implementing `Index<u8>`, followed by a\nnote saying \"the type `bool` cannot be indexed by `u8`\".\n\nAs you can see, you can specify type parameters in curly braces for\ninstantiation with the actual types (using the regular format string syntax) in\na given situation. Furthermore, `{Self}` will be instantiated to the type (in\nthis case, `bool`) that we tried to use.\n\nThis error appears when the curly braces contain an identifier which doesn\'t\nmatch with any of the type parameters or the string `Self`. This might happen\nif you misspelled a type parameter, or if you intended to use literal curly\nbraces. If it is the latter, escape the curly braces with a second curly brace\nof the same type; e.g., a literal `{` is `{{`.\n"),
(E0231,
"The `#[rustc_on_unimplemented]` attribute lets you specify a custom error\nmessage for when a particular trait isn\'t implemented on a type placed in a\nposition that needs that trait. For example, when the following code is\ncompiled:\n\n```compile_fail,E0231\n#![feature(rustc_attrs)]\n#![allow(internal_features)]\n\n#[rustc_on_unimplemented = \"error on `{Self}` with params `<{A},{}>`\"] // error!\ntrait BadAnnotation<A> {}\n```\n\nthere will be an error about `bool` not implementing `Index<u8>`, followed by a\nnote saying \"the type `bool` cannot be indexed by `u8`\".\n\nAs you can see, you can specify type parameters in curly braces for\ninstantiation with the actual types (using the regular format string syntax) in\na given situation. Furthermore, `{Self}` will be instantiated to the type (in\nthis case, `bool`) that we tried to use.\n\nThis error appears when the curly braces do not contain an identifier. Please\nadd one of the same name as a type parameter. If you intended to use literal\nbraces, use `{{` and `}}` to escape them.\n"),
(E0232,
"The `#[rustc_on_unimplemented]` attribute lets you specify a custom error\nmessage for when a particular trait isn\'t implemented on a type placed in a\nposition that needs that trait. For example, when the following code is\ncompiled:\n\n```compile_fail,E0232\n#![feature(rustc_attrs)]\n#![allow(internal_features)]\n\n#[rustc_on_unimplemented(lorem=\"\")] // error!\ntrait BadAnnotation {}\n```\n\nthere will be an error about `bool` not implementing `Index<u8>`, followed by a\nnote saying \"the type `bool` cannot be indexed by `u8`\".\n\nFor this to work, some note must be specified. An empty attribute will not do\nanything, please remove the attribute or add some helpful note for users of the\ntrait.\n"),
(E0243,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error indicates that not enough type parameters were found in a type or\ntrait.\n\nFor example, the `Foo` struct below is defined to be generic in `T`, but the\ntype parameter is missing in the definition of `Bar`:\n\n```compile_fail,E0107\nstruct Foo<T> { x: T }\n\nstruct Bar { x: Foo }\n```\n"),
(E0244,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error indicates that too many type parameters were found in a type or\ntrait.\n\nFor example, the `Foo` struct below has no type parameters, but is supplied\nwith two in the definition of `Bar`:\n\n```compile_fail,E0107\nstruct Foo { x: bool }\n\nstruct Bar<S, T> { x: Foo<S, T> }\n```\n"),
(E0251,
"#### Note: this error code is no longer emitted by the compiler.\n\nTwo items of the same name cannot be imported without rebinding one of the\nitems under a new local name.\n\nAn example of this error:\n\n```\nuse foo::baz;\nuse bar::*; // error, do `use foo::baz as quux` instead on the previous line\n\nfn main() {}\n\nmod foo {\n pub struct baz;\n}\n\nmod bar {\n pub mod baz {}\n}\n```\n"),
(E0252,
"Two items of the same name cannot be imported without rebinding one of the\nitems under a new local name.\n\nErroneous code example:\n\n```compile_fail,E0252\nuse foo::baz;\nuse bar::baz; // error, do `use bar::baz as quux` instead\n\nfn main() {}\n\nmod foo {\n pub struct baz;\n}\n\nmod bar {\n pub mod baz {}\n}\n```\n\nYou can use aliases in order to fix this error. Example:\n\n```\nuse foo::baz as foo_baz;\nuse bar::baz; // ok!\n\nfn main() {}\n\nmod foo {\n pub struct baz;\n}\n\nmod bar {\n pub mod baz {}\n}\n```\n\nOr you can reference the item with its parent:\n\n```\nuse bar::baz;\n\nfn main() {\n let x = foo::baz; // ok!\n}\n\nmod foo {\n pub struct baz;\n}\n\nmod bar {\n pub mod baz {}\n}\n```\n"),
(E0253,
"#### Note: this error code is no longer emitted by the compiler.\n\nAttempt was made to import an unimportable type. This can happen when trying\nto import a type from a trait.\n\nErroneous code example:\n\n```\n#![feature(import_trait_associated_functions)]\n\nmod foo {\n pub trait MyTrait {\n type SomeType;\n }\n}\n\nuse foo::MyTrait::SomeType;\n// error: `SomeType` is not directly importable\n\nfn main() {}\n```\n\nIt\'s invalid to directly import types belonging to a trait.\n"),
(E0254,
"Attempt was made to import an item whereas an extern crate with this name has\nalready been imported.\n\nErroneous code example:\n\n```compile_fail,E0254\nextern crate core;\n\nmod foo {\n pub trait core {\n fn do_something();\n }\n}\n\nuse foo::core; // error: an extern crate named `core` has already\n // been imported in this module\n\nfn main() {}\n```\n\nTo fix this issue, you have to rename at least one of the two imports.\nExample:\n\n```\nextern crate core as libcore; // ok!\n\nmod foo {\n pub trait core {\n fn do_something();\n }\n}\n\nuse foo::core;\n\nfn main() {}\n```\n"),
(E0255,
"You can\'t import a value whose name is the same as another value defined in the\nmodule.\n\nErroneous code example:\n\n```compile_fail,E0255\nuse bar::foo; // error: an item named `foo` is already in scope\n\nfn foo() {}\n\nmod bar {\n pub fn foo() {}\n}\n\nfn main() {}\n```\n\nYou can use aliases in order to fix this error. Example:\n\n```\nuse bar::foo as bar_foo; // ok!\n\nfn foo() {}\n\nmod bar {\n pub fn foo() {}\n}\n\nfn main() {}\n```\n\nOr you can reference the item with its parent:\n\n```\nfn foo() {}\n\nmod bar {\n pub fn foo() {}\n}\n\nfn main() {\n bar::foo(); // we get the item by referring to its parent\n}\n```\n"),
(E0256,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou can\'t import a type or module when the name of the item being imported is\nthe same as another type or submodule defined in the module.\n\nAn example of this error:\n\n```compile_fail\nuse foo::Bar; // error\n\ntype Bar = u32;\n\nmod foo {\n pub mod Bar { }\n}\n\nfn main() {}\n```\n"),
(E0259,
"The name chosen for an external crate conflicts with another external crate\nthat has been imported into the current module.\n\nErroneous code example:\n\n```compile_fail,E0259\nextern crate core;\nextern crate std as core;\n\nfn main() {}\n```\n\nThe solution is to choose a different name that doesn\'t conflict with any\nexternal crate imported into the current module.\n\nCorrect example:\n\n```\nextern crate core;\nextern crate std as other_name;\n\nfn main() {}\n```\n"),
(E0260,
"The name for an item declaration conflicts with an external crate\'s name.\n\nErroneous code example:\n\n```compile_fail,E0260\nextern crate core;\n\nstruct core;\n\nfn main() {}\n```\n\nThere are two possible solutions:\n\nSolution #1: Rename the item.\n\n```\nextern crate core;\n\nstruct xyz;\n```\n\nSolution #2: Import the crate with a different name.\n\n```\nextern crate core as xyz;\n\nstruct abc;\n```\n\nSee the [Declaration Statements][declaration-statements] section of the\nreference for more information about what constitutes an item declaration\nand what does not.\n\n[declaration-statements]: https://doc.rust-lang.org/reference/statements.html#declaration-statements\n"),
(E0261,
"An undeclared lifetime was used.\n\nErroneous code example:\n\n```compile_fail,E0261\n// error, use of undeclared lifetime name `\'a`\nfn foo(x: &\'a str) { }\n\nstruct Foo {\n // error, use of undeclared lifetime name `\'a`\n x: &\'a str,\n}\n```\n\nThese can be fixed by declaring lifetime parameters:\n\n```\nstruct Foo<\'a> {\n x: &\'a str,\n}\n\nfn foo<\'a>(x: &\'a str) {}\n```\n\nImpl blocks declare lifetime parameters separately. You need to add lifetime\nparameters to an impl block if you\'re implementing a type that has a lifetime\nparameter of its own.\nFor example:\n\n```compile_fail,E0261\nstruct Foo<\'a> {\n x: &\'a str,\n}\n\n// error, use of undeclared lifetime name `\'a`\nimpl Foo<\'a> {\n fn foo<\'a>(x: &\'a str) {}\n}\n```\n\nThis is fixed by declaring the impl block like this:\n\n```\nstruct Foo<\'a> {\n x: &\'a str,\n}\n\n// correct\nimpl<\'a> Foo<\'a> {\n fn foo(x: &\'a str) {}\n}\n```\n"),
(E0262,
"An invalid name was used for a lifetime parameter.\n\nErroneous code example:\n\n```compile_fail,E0262\n// error, invalid lifetime parameter name `\'static`\nfn foo<\'static>(x: &\'static str) { }\n```\n\nDeclaring certain lifetime names in parameters is disallowed. For example,\nbecause the `\'static` lifetime is a special built-in lifetime name denoting\nthe lifetime of the entire program, this is an error:\n"),
(E0263,
"#### Note: this error code is no longer emitted by the compiler.\n\nA lifetime was declared more than once in the same scope.\n\nErroneous code example:\n\n```compile_fail,E0403\nfn foo<\'a, \'b, \'a>(x: &\'a str, y: &\'b str, z: &\'a str) { // error!\n}\n```\n\nTwo lifetimes cannot have the same name. To fix this example, change\nthe second `\'a` lifetime into something else (`\'c` for example):\n\n```\nfn foo<\'a, \'b, \'c>(x: &\'a str, y: &\'b str, z: &\'c str) { // ok!\n}\n```\n"),
(E0264,
"An unknown external lang item was used.\n\nErroneous code example:\n\n```compile_fail,E0264\n#![feature(lang_items)]\n#![allow(internal_features)]\n\nextern \"C\" {\n #[lang = \"cake\"] // error: unknown external lang item: `cake`\n fn cake();\n}\n```\n\nA list of available external lang items is available in\n`compiler/rustc_hir/src/weak_lang_items.rs`. Example:\n\n```\n#![feature(lang_items)]\n#![allow(internal_features)]\n\nextern \"C\" {\n #[lang = \"panic_impl\"] // ok!\n fn cake();\n}\n```\n"),
(E0267,
"A loop keyword (`break` or `continue`) was used inside a closure but outside of\nany loop.\n\nErroneous code example:\n\n```compile_fail,E0267\nlet w = || { break; }; // error: `break` inside of a closure\n```\n\n`break` and `continue` keywords can be used as normal inside closures as long as\nthey are also contained within a loop. To halt the execution of a closure you\nshould instead use a return statement. Example:\n\n```\nlet w = || {\n for _ in 0..10 {\n break;\n }\n};\n\nw();\n```\n"),
(E0268,
"A loop keyword (`break` or `continue`) was used outside of a loop.\n\nErroneous code example:\n\n```compile_fail,E0268\nfn some_func() {\n break; // error: `break` outside of a loop\n}\n```\n\nWithout a loop to break out of or continue in, no sensible action can be taken.\nPlease verify that you are using `break` and `continue` only in loops. Example:\n\n```\nfn some_func() {\n for _ in 0..10 {\n break; // ok!\n }\n}\n```\n"),
(E0271,
"A type mismatched an associated type of a trait.\n\nErroneous code example:\n\n```compile_fail,E0271\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType=u32> {\n// ~~~~~~~~ ~~~~~~~~~~~~~~~~~~\n// | |\n// This says `foo` can |\n// only be used with |\n// some type that |\n// implements `Trait`. |\n// |\n// This says not only must\n// `T` be an impl of `Trait`\n// but also that the impl\n// must assign the type `u32`\n// to the associated type.\n println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &\'static str; }\n//~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n// | |\n// `i8` does have |\n// implementation |\n// of `Trait`... |\n// ... but it is an implementation\n// that assigns `&\'static str` to\n// the associated type.\n\nfoo(3_i8);\n// Here, we invoke `foo` with an `i8`, which does not satisfy\n// the constraint `<i8 as Trait>::AssociatedType=u32`, and\n// therefore the type-checker complains with this error code.\n```\n\nThe issue can be resolved by changing the associated type:\n1) in the `foo` implementation:\n```\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType = &\'static str> {\n println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = &\'static str; }\n\nfoo(3_i8);\n```\n\n2) in the `Trait` implementation for `i8`:\n```\ntrait Trait { type AssociatedType; }\n\nfn foo<T>(t: T) where T: Trait<AssociatedType = u32> {\n println!(\"in foo\");\n}\n\nimpl Trait for i8 { type AssociatedType = u32; }\n\nfoo(3_i8);\n```\n"),
(E0275,
"An evaluation of a trait requirement overflowed.\n\nErroneous code example:\n\n```compile_fail,E0275\ntrait Foo {}\n\nstruct Bar<T>(T);\n\nimpl<T> Foo for T where Bar<T>: Foo {}\n```\n\nThis error occurs when there was a recursive trait requirement that overflowed\nbefore it could be evaluated. This often means that there is an unbounded\nrecursion in resolving some type bounds.\n\nTo determine if a `T` is `Foo`, we need to check if `Bar<T>` is `Foo`. However,\nto do this check, we need to determine that `Bar<Bar<T>>` is `Foo`. To\ndetermine this, we check if `Bar<Bar<Bar<T>>>` is `Foo`, and so on. This is\nclearly a recursive requirement that can\'t be resolved directly.\n\nConsider changing your trait bounds so that they\'re less self-referential.\n"),
(E0276,
"A trait implementation has stricter requirements than the trait definition.\n\nErroneous code example:\n\n```compile_fail,E0276\ntrait Foo {\n fn foo<T>(x: T);\n}\n\nimpl Foo for bool {\n fn foo<T>(x: T) where T: Copy {}\n}\n```\n\nHere, all types implementing `Foo` must have a method `foo<T>(x: T)` which can\ntake any type `T`. However, in the `impl` for `bool`, we have added an extra\nbound that `T` is `Copy`, which isn\'t compatible with the original trait.\n\nConsider removing the bound from the method or adding the bound to the original\nmethod definition in the trait.\n"),
(E0277,
"You tried to use a type which doesn\'t implement some trait in a place which\nexpected that trait.\n\nErroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n foo.bar();\n}\n\nfn main() {\n // we now call the method with the i32 type, which doesn\'t implement\n // the Foo trait\n some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you\'re using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n fn bar(&self);\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n fn bar(&self) {}\n}\n\nfn some_func<T: Foo>(foo: T) {\n foo.bar(); // we can now use this method since i32 implements the\n // Foo trait\n}\n\nfn main() {\n some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n // implemented for the type `T`\n}\n\nfn main() {\n // We now call the method with the i32 type,\n // which *does* implement the Debug trait.\n some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function. Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function. It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we\'re\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n println!(\"{:?}\", foo);\n}\n\nfn main() {\n // Calling the method is still fine, as i32 implements Debug.\n some_func(5i32);\n\n // This would fail to compile now:\n // struct WithoutDebug;\n // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"),
(E0281,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou tried to supply a type which doesn\'t implement some trait in a location\nwhich expected that trait. This error typically occurs when working with\n`Fn`-based types. Erroneous code example:\n\n```compile_fail\nfn foo<F: Fn(usize)>(x: F) { }\n\nfn main() {\n // type mismatch: ... implements the trait `core::ops::Fn<(String,)>`,\n // but the trait `core::ops::Fn<(usize,)>` is required\n // [E0281]\n foo(|y: String| { });\n}\n```\n\nThe issue in this case is that `foo` is defined as accepting a `Fn` with one\nargument of type `String`, but the closure we attempted to pass to it requires\none arguments of type `usize`.\n"),
(E0282,
"The compiler could not infer a type and asked for a type annotation.\n\nErroneous code example:\n\n```compile_fail,E0282\nlet x = Vec::new();\n```\n\nThis error indicates that type inference did not result in one unique possible\ntype, and extra information is required. In most cases this can be provided\nby adding a type annotation. Sometimes you need to specify a generic type\nparameter manually.\n\nIn the example above, type `Vec` has a type parameter `T`. When calling\n`Vec::new`, barring any other later usage of the variable `x` that allows the\ncompiler to infer what type `T` is, the compiler needs to be told what it is.\n\nThe type can be specified on the variable:\n\n```\nlet x: Vec<i32> = Vec::new();\n```\n\nThe type can also be specified in the path of the expression:\n\n```\nlet x = Vec::<i32>::new();\n```\n\nIn cases with more complex types, it is not necessary to annotate the full\ntype. Once the ambiguity is resolved, the compiler can infer the rest:\n\n```\nlet x: Vec<_> = \"hello\".chars().rev().collect();\n```\n\nAnother way to provide the compiler with enough information, is to specify the\ngeneric type parameter:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<char>>();\n```\n\nAgain, you need not specify the full type if the compiler can infer it:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<_>>();\n```\n\nApart from a method or function with a generic type parameter, this error can\noccur when a type parameter of a struct or trait cannot be inferred. In that\ncase it is not always possible to use a type annotation, because all candidates\nhave the same return type. For instance:\n\n```compile_fail,E0282\nstruct Foo<T> {\n num: T,\n}\n\nimpl<T> Foo<T> {\n fn bar() -> i32 {\n 0\n }\n\n fn baz() {\n let number = Foo::bar();\n }\n}\n```\n\nThis will fail because the compiler does not know which instance of `Foo` to\ncall `bar` on. Change `Foo::bar()` to `Foo::<T>::bar()` to resolve the error.\n"),
(E0283,
"The compiler could not infer a type and asked for a type annotation.\n\nErroneous code example:\n\n```compile_fail,E0283\nlet x = \"hello\".chars().rev().collect();\n```\n\nThis error indicates that type inference did not result in one unique possible\ntype, and extra information is required. In most cases this can be provided\nby adding a type annotation. Sometimes you need to specify a generic type\nparameter manually.\n\nA common example is the `collect` method on `Iterator`. It has a generic type\nparameter with a `FromIterator` bound, which for a `char` iterator is\nimplemented by `Vec` and `String` among others. Consider the following snippet\nthat reverses the characters of a string:\n\nIn the first code example, the compiler cannot infer what the type of `x` should\nbe: `Vec<char>` and `String` are both suitable candidates. To specify which type\nto use, you can use a type annotation on `x`:\n\n```\nlet x: Vec<char> = \"hello\".chars().rev().collect();\n```\n\nIt is not necessary to annotate the full type. Once the ambiguity is resolved,\nthe compiler can infer the rest:\n\n```\nlet x: Vec<_> = \"hello\".chars().rev().collect();\n```\n\nAnother way to provide the compiler with enough information, is to specify the\ngeneric type parameter:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<char>>();\n```\n\nAgain, you need not specify the full type if the compiler can infer it:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<_>>();\n```\n\nWe can see a self-contained example below:\n\n```compile_fail,E0283\nstruct Foo;\n\nimpl Into<u32> for Foo {\n fn into(self) -> u32 { 1 }\n}\n\nlet foo = Foo;\nlet bar: u32 = foo.into() * 1u32;\n```\n\nThis error can be solved by adding type annotations that provide the missing\ninformation to the compiler. In this case, the solution is to specify the\ntrait\'s type parameter:\n\n```\nstruct Foo;\n\nimpl Into<u32> for Foo {\n fn into(self) -> u32 { 1 }\n}\n\nlet foo = Foo;\nlet bar: u32 = Into::<u32>::into(foo) * 1u32;\n```\n"),
(E0284,
"This error occurs when the compiler is unable to unambiguously infer the\nreturn type of a function or method which is generic on return type, such\nas the `collect` method for `Iterator`s.\n\nFor example:\n\n```compile_fail,E0284\nfn main() {\n let n: u32 = 1;\n let mut d: u64 = 2;\n d = d + n.into();\n}\n```\n\nHere we have an addition of `d` and `n.into()`. Hence, `n.into()` can return\nany type `T` where `u64: Add<T>`. On the other hand, the `into` method can\nreturn any type where `u32: Into<T>`.\n\nThe author of this code probably wants `into()` to return a `u64`, but the\ncompiler can\'t be sure that there isn\'t another type `T` where both\n`u32: Into<T>` and `u64: Add<T>`.\n\nTo resolve this error, use a concrete type for the intermediate expression:\n\n```\nfn main() {\n let n: u32 = 1;\n let mut d: u64 = 2;\n let m: u64 = n.into();\n d = d + m;\n}\n```\n"),
(E0297,
"#### Note: this error code is no longer emitted by the compiler.\n\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```compile_fail,E0005\nlet xs : Vec<Option<i32>> = vec![Some(1), None];\n\n// This fails because `None` is not covered.\nfor Some(x) in xs {\n // ...\n}\n```\n\nMatch inside the loop instead:\n\n```\nlet xs : Vec<Option<i32>> = vec![Some(1), None];\n\nfor item in xs {\n match item {\n Some(x) => {},\n None => {},\n }\n}\n```\n\nOr use `if let`:\n\n```\nlet xs : Vec<Option<i32>> = vec![Some(1), None];\n\nfor item in xs {\n if let Some(x) = item {\n // ...\n }\n}\n```\n"),
(E0301,
"#### Note: this error code is no longer emitted by the compiler.\n\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\n```compile_fail,E0596\nmatch Some(()) {\n None => { },\n option if option.take().is_none() => {\n /* impossible, option is `Some` */\n },\n Some(_) => { } // When the previous match failed, the option became `None`.\n}\n```\n"),
(E0302,
"#### Note: this error code is no longer emitted by the compiler.\n\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\n```compile_fail,E0594\nmatch Some(()) {\n None => { },\n option if { option = None; false } => { },\n Some(_) => { } // When the previous match failed, the option became `None`.\n}\n```\n"),
(E0303,
"#### Note: this error code is no longer emitted by the compiler.\n\nSub-bindings, e.g. `ref x @ Some(ref y)` are now allowed under\n`#![feature(bindings_after_at)]` and checked to make sure that\nmemory safety is upheld.\n\n--------------\n\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\nBefore:\n\n```compile_fail\nmatch Some(\"hi\".to_string()) {\n ref op_string_ref @ Some(s) => {},\n None => {},\n}\n```\n\nAfter:\n\n```\nmatch Some(\"hi\".to_string()) {\n Some(ref s) => {\n let op_string_ref = &Some(s);\n // ...\n },\n None => {},\n}\n```\n\nThe `op_string_ref` binding has type `&Option<&String>` in both cases.\n\nSee also [Issue 14587][issue-14587].\n\n[issue-14587]: https://github.com/rust-lang/rust/issues/14587\n"),
(E0307,
"The `self` parameter in a method has an invalid \"receiver type\".\n\nErroneous code example:\n\n```compile_fail,E0307\nstruct Foo;\nstruct Bar;\n\ntrait Trait {\n fn foo(&self);\n}\n\nimpl Trait for Foo {\n fn foo(self: &Bar) {}\n}\n```\n\nMethods take a special first parameter, of which there are three variants:\n`self`, `&self`, and `&mut self`. These are syntactic sugar for\n`self: Self`, `self: &Self`, and `self: &mut Self` respectively.\n\n```\n# struct Foo;\ntrait Trait {\n fn foo(&self);\n// ^^^^^ `self` here is a reference to the receiver object\n}\n\nimpl Trait for Foo {\n fn foo(&self) {}\n// ^^^^^ the receiver type is `&Foo`\n}\n```\n\nThe type `Self` acts as an alias to the type of the current trait\nimplementer, or \"receiver type\". Besides the already mentioned `Self`,\n`&Self` and `&mut Self` valid receiver types, the following are also valid:\n`self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, and `self: Pin<P>`\n(where P is one of the previous types except `Self`). Note that `Self` can\nalso be the underlying implementing type, like `Foo` in the following\nexample:\n\n```\n# struct Foo;\n# trait Trait {\n# fn foo(&self);\n# }\nimpl Trait for Foo {\n fn foo(self: &Foo) {}\n}\n```\n\nThis error will be emitted by the compiler when using an invalid receiver type,\nlike in the following example:\n\n```compile_fail,E0307\n# struct Foo;\n# struct Bar;\n# trait Trait {\n# fn foo(&self);\n# }\nimpl Trait for Foo {\n fn foo(self: &Bar) {}\n}\n```\n\nThe nightly feature [Arbitrary self types][AST] extends the accepted\nset of receiver types to also include any type that implements the\n`Receiver` trait and can follow its chain of `Target` types to `Self`.\nThere\'s a blanket implementation of `Receiver` for `T: Deref`, so any\ntype which dereferences to `Self` can be used.\n\n```\n#![feature(arbitrary_self_types)]\n\nstruct Foo;\nstruct Bar;\n\n// Because you can dereference `Bar` into `Foo`...\nimpl std::ops::Deref for Bar {\n type Target = Foo;\n\n fn deref(&self) -> &Foo {\n &Foo\n }\n}\n\nimpl Foo {\n fn foo(self: Bar) {}\n// ^^^^^^^^^ ...it can be used as the receiver type\n}\n```\n\n[AST]: https://doc.rust-lang.org/unstable-book/language-features/arbitrary-self-types.html\n"),
(E0308,
"Expected type did not match the received type.\n\nErroneous code examples:\n\n```compile_fail,E0308\nfn plus_one(x: i32) -> i32 {\n x + 1\n}\n\nplus_one(\"Not a number\");\n// ^^^^^^^^^^^^^^ expected `i32`, found `&str`\n\nif \"Not a bool\" {\n// ^^^^^^^^^^^^ expected `bool`, found `&str`\n}\n\nlet x: f32 = \"Not a float\";\n// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`\n// |\n// expected due to this\n```\n\nThis error occurs when an expression was used in a place where the compiler\nexpected an expression of a different type. It can occur in several cases, the\nmost common being when calling a function and passing an argument which has a\ndifferent type than the matching type in the function declaration.\n"),
(E0309,
"A parameter type is missing an explicit lifetime bound and may not live long\nenough.\n\nErroneous code example:\n\n```compile_fail,E0309\n// This won\'t compile because the applicable impl of\n// `SomeTrait` (below) requires that `T: \'a`, but the struct does\n// not have a matching where-clause.\nstruct Foo<\'a, T> {\n foo: <T as SomeTrait<\'a>>::Output,\n}\n\ntrait SomeTrait<\'a> {\n type Output;\n}\n\nimpl<\'a, T> SomeTrait<\'a> for T\nwhere\n T: \'a,\n{\n type Output = u32;\n}\n```\n\nThe type definition contains some field whose type requires an outlives\nannotation. Outlives annotations (e.g., `T: \'a`) are used to guarantee that all\nthe data in `T` is valid for at least the lifetime `\'a`. This scenario most\ncommonly arises when the type contains an associated type reference like\n`<T as SomeTrait<\'a>>::Output`, as shown in the previous code.\n\nThere, the where clause `T: \'a` that appears on the impl is not known to be\nsatisfied on the struct. To make this example compile, you have to add a\nwhere-clause like `T: \'a` to the struct definition:\n\n```\nstruct Foo<\'a, T>\nwhere\n T: \'a,\n{\n foo: <T as SomeTrait<\'a>>::Output\n}\n\ntrait SomeTrait<\'a> {\n type Output;\n}\n\nimpl<\'a, T> SomeTrait<\'a> for T\nwhere\n T: \'a,\n{\n type Output = u32;\n}\n```\n"),
(E0310,
"A parameter type is missing a lifetime constraint or has a lifetime that\ndoes not live long enough.\n\nErroneous code example:\n\n```compile_fail,E0310\n// This won\'t compile because T is not constrained to the static lifetime\n// the reference needs\nstruct Foo<T> {\n foo: &\'static T\n}\n```\n\nType parameters in type definitions have lifetimes associated with them that\nrepresent how long the data stored within them is guaranteed to live. This\nlifetime must be as long as the data needs to be alive, and missing the\nconstraint that denotes this will cause this error.\n\nThis will compile, because it has the constraint on the type parameter:\n\n```\nstruct Foo<T: \'static> {\n foo: &\'static T\n}\n```\n"),
(E0311,
"This error occurs when there is an unsatisfied outlives bound involving an\nelided region and a generic type parameter or associated type.\n\nErroneous code example:\n\n```compile_fail,E0311\nfn no_restriction<T>(x: &()) -> &() {\n with_restriction::<T>(x)\n}\n\nfn with_restriction<\'a, T: \'a>(x: &\'a ()) -> &\'a () {\n x\n}\n```\n\nWhy doesn\'t this code compile? It helps to look at the lifetime bounds that are\nautomatically added by the compiler. For more details see the documentation for\n[lifetime elision]( https://doc.rust-lang.org/reference/lifetime-elision.html).\n\nThe compiler elides the lifetime of `x` and the return type to some arbitrary\nlifetime `\'anon` in `no_restriction()`. The only information available to the\ncompiler is that `\'anon` is valid for the duration of the function. When\ncalling `with_restriction()`, the compiler requires the completely unrelated\ntype parameter `T` to outlive `\'anon` because of the `T: \'a` bound in\n`with_restriction()`. This causes an error because `T` is not required to\noutlive `\'anon` in `no_restriction()`.\n\nIf `no_restriction()` were to use `&T` instead of `&()` as an argument, the\ncompiler would have added an implied bound, causing this to compile.\n\nThis error can be resolved by explicitly naming the elided lifetime for `x` and\nthen explicitly requiring that the generic parameter `T` outlives that lifetime:\n\n```\nfn no_restriction<\'a, T: \'a>(x: &\'a ()) -> &\'a () {\n with_restriction::<T>(x)\n}\n\nfn with_restriction<\'a, T: \'a>(x: &\'a ()) -> &\'a () {\n x\n}\n```\n"),
(E0312,
"#### Note: this error code is no longer emitted by the compiler.\n\nReference\'s lifetime of borrowed content doesn\'t match the expected lifetime.\n\nErroneous code example:\n\n```compile_fail\npub fn opt_str<\'a>(maybestr: &\'a Option<String>) -> &\'static str {\n if maybestr.is_none() {\n \"(none)\"\n } else {\n let s: &\'a str = maybestr.as_ref().unwrap();\n s // Invalid lifetime!\n }\n}\n```\n\nTo fix this error, either lessen the expected lifetime or find a way to not have\nto use this reference outside of its current scope (by running the code directly\nin the same block for example?):\n\n```\n// In this case, we can fix the issue by switching from \"static\" lifetime to \'a\npub fn opt_str<\'a>(maybestr: &\'a Option<String>) -> &\'a str {\n if maybestr.is_none() {\n \"(none)\"\n } else {\n let s: &\'a str = maybestr.as_ref().unwrap();\n s // Ok!\n }\n}\n```\n"),
(E0316,
"A `where` clause contains a nested quantification over lifetimes.\n\nErroneous code example:\n\n```compile_fail,E0316\ntrait Tr<\'a, \'b> {}\n\nfn foo<T>(t: T)\nwhere\n for<\'a> &\'a T: for<\'b> Tr<\'a, \'b>, // error: nested quantification\n{\n}\n```\n\nRust syntax allows lifetime quantifications in two places within\n`where` clauses: Quantifying over the trait bound only (as in\n`Ty: for<\'l> Trait<\'l>`) and quantifying over the whole clause\n(as in `for<\'l> &\'l Ty: Trait<\'l>`). Using both in the same clause\nleads to a nested lifetime quantification, which is not supported.\n\nThe following example compiles, because the clause with the nested\nquantification has been rewritten to use only one `for<>`:\n\n```\ntrait Tr<\'a, \'b> {}\n\nfn foo<T>(t: T)\nwhere\n for<\'a, \'b> &\'a T: Tr<\'a, \'b>, // ok\n{\n}\n```\n"),
(E0317,
"An `if` expression is missing an `else` block.\n\nErroneous code example:\n\n```compile_fail,E0317\nlet x = 5;\nlet a = if x == 5 {\n 1\n};\n```\n\nThis error occurs when an `if` expression without an `else` block is used in a\ncontext where a type other than `()` is expected. In the previous code example,\nthe `let` expression was expecting a value but since there was no `else`, no\nvalue was returned.\n\nAn `if` expression without an `else` block has the type `()`, so this is a type\nerror. To resolve it, add an `else` block having the same type as the `if`\nblock.\n\nSo to fix the previous code example:\n\n```\nlet x = 5;\nlet a = if x == 5 {\n 1\n} else {\n 2\n};\n```\n"),
(E0320,
"Recursion limit reached while creating drop-check rules.\n\nExample of erroneous code:\n\n```compile_fail,E0320\nenum A<T> {\n B,\n C(T, Box<A<(T, T)>>)\n}\n\nfn foo<T>() {\n A::<T>::B; // error: overflow while adding drop-check rules for A<T>\n}\n```\n\nThe Rust compiler must be able to reason about how a type is [`Drop`]ped, and\nby extension the types of its fields, to be able to generate the glue to\nproperly drop a value. The code example above shows a type where this inference\nis impossible because it is recursive. Note that this is *not* the same as\n[E0072](E0072.html), where a type has an infinite size; the type here has a\nfinite size but any attempt to `Drop` it would recurse infinitely. For more\ninformation, read [the `Drop` docs](../std/ops/trait.Drop.html).\n\nIt is not possible to define a type with recursive drop-check rules. All such\nrecursion must be removed.\n\n[`Drop`]: ../std/ops/trait.Drop.html\n"),
(E0321,
"A cross-crate opt-out trait was implemented on something which wasn\'t a struct\nor enum type.\n\nErroneous code example:\n\n```compile_fail,E0321\n#![feature(auto_traits)]\n\nstruct Foo;\n\nimpl !Sync for Foo {}\n\nunsafe impl Send for &\'static Foo {}\n// error: cross-crate traits with a default impl, like `core::marker::Send`,\n// can only be implemented for a struct/enum type, not\n// `&\'static Foo`\n```\n\nOnly structs and enums are permitted to impl Send, Sync, and other opt-out\ntrait, and the struct or enum must be local to the current crate. So, for\nexample, `unsafe impl Send for Rc<Foo>` is not allowed.\n"),
(E0322,
"A built-in trait was implemented explicitly. All implementations of the trait\nare provided automatically by the compiler.\n\nErroneous code example:\n\n```compile_fail,E0322\nstruct Foo;\n\nimpl Sized for Foo {} // error!\n```\n\nThe `Sized` trait is a special trait built-in to the compiler for types with a\nconstant size known at compile-time. This trait is automatically implemented\nfor types as needed by the compiler, and it is currently disallowed to\nexplicitly implement it for a type.\n"),
(E0323,
"An associated const was implemented when another trait item was expected.\n\nErroneous code example:\n\n```compile_fail,E0323\ntrait Foo {\n type N;\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n const N : u32 = 0;\n // error: item `N` is an associated const, which doesn\'t match its\n // trait `<Bar as Foo>`\n}\n```\n\nPlease verify that the associated const wasn\'t misspelled and the correct trait\nwas implemented. Example:\n\n```\nstruct Bar;\n\ntrait Foo {\n type N;\n}\n\nimpl Foo for Bar {\n type N = u32; // ok!\n}\n```\n\nOr:\n\n```\nstruct Bar;\n\ntrait Foo {\n const N : u32;\n}\n\nimpl Foo for Bar {\n const N : u32 = 0; // ok!\n}\n```\n"),
(E0324,
"A method was implemented when another trait item was expected.\n\nErroneous code example:\n\n```compile_fail,E0324\nstruct Bar;\n\ntrait Foo {\n const N : u32;\n\n fn M();\n}\n\nimpl Foo for Bar {\n fn N() {}\n // error: item `N` is an associated method, which doesn\'t match its\n // trait `<Bar as Foo>`\n}\n```\n\nTo fix this error, please verify that the method name wasn\'t misspelled and\nverify that you are indeed implementing the correct trait items. Example:\n\n```\nstruct Bar;\n\ntrait Foo {\n const N : u32;\n\n fn M();\n}\n\nimpl Foo for Bar {\n const N : u32 = 0;\n\n fn M() {} // ok!\n}\n```\n"),
(E0325,
"An associated type was implemented when another trait item was expected.\n\nErroneous code example:\n\n```compile_fail,E0325\nstruct Bar;\n\ntrait Foo {\n const N : u32;\n}\n\nimpl Foo for Bar {\n type N = u32;\n // error: item `N` is an associated type, which doesn\'t match its\n // trait `<Bar as Foo>`\n}\n```\n\nPlease verify that the associated type name wasn\'t misspelled and your\nimplementation corresponds to the trait definition. Example:\n\n```\nstruct Bar;\n\ntrait Foo {\n type N;\n}\n\nimpl Foo for Bar {\n type N = u32; // ok!\n}\n```\n\nOr:\n\n```\nstruct Bar;\n\ntrait Foo {\n const N : u32;\n}\n\nimpl Foo for Bar {\n const N : u32 = 0; // ok!\n}\n```\n"),
(E0326,
"An implementation of a trait doesn\'t match the type constraint.\n\nErroneous code example:\n\n```compile_fail,E0326\ntrait Foo {\n const BAR: bool;\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n const BAR: u32 = 5; // error, expected bool, found u32\n}\n```\n\nThe types of any associated constants in a trait implementation must match the\ntypes in the trait definition.\n"),
(E0328,
"The Unsize trait should not be implemented directly. All implementations of\nUnsize are provided automatically by the compiler.\n\nErroneous code example:\n\n```compile_fail,E0328\n#![feature(unsize)]\n\nuse std::marker::Unsize;\n\npub struct MyType;\n\nimpl<T> Unsize<T> for MyType {}\n```\n\nIf you are defining your own smart pointer type and would like to enable\nconversion from a sized to an unsized type with the\n[DST coercion system][RFC 982], use [`CoerceUnsized`] instead.\n\n```\n#![feature(coerce_unsized)]\n\nuse std::ops::CoerceUnsized;\n\npub struct MyType<T: ?Sized> {\n field_with_unsized_type: T,\n}\n\nimpl<T, U> CoerceUnsized<MyType<U>> for MyType<T>\n where T: CoerceUnsized<U> {}\n```\n\n[RFC 982]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md\n[`CoerceUnsized`]: https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html\n"),
(E0329,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn attempt was made to access an associated constant through either a generic\ntype parameter or `Self`. This is not supported yet. An example causing this\nerror is shown below:\n\n```\ntrait Foo {\n const BAR: f64;\n}\n\nstruct MyStruct;\n\nimpl Foo for MyStruct {\n const BAR: f64 = 0f64;\n}\n\nfn get_bar_bad<F: Foo>(t: F) -> f64 {\n F::BAR\n}\n```\n\nCurrently, the value of `BAR` for a particular type can only be accessed\nthrough a concrete type, as shown below:\n\n```\ntrait Foo {\n const BAR: f64;\n}\n\nstruct MyStruct;\n\nimpl Foo for MyStruct {\n const BAR: f64 = 0f64;\n}\n\nfn get_bar_good() -> f64 {\n <MyStruct as Foo>::BAR\n}\n```\n"),
(E0364,
"Private items cannot be publicly re-exported. This error indicates that you\nattempted to `pub use` a type or value that was not itself public.\n\nErroneous code example:\n\n```compile_fail,E0364\nmod a {\n fn foo() {}\n\n mod a {\n pub use super::foo; // error!\n }\n}\n```\n\nThe solution to this problem is to ensure that the items that you are\nre-exporting are themselves marked with `pub`:\n\n```\nmod a {\n pub fn foo() {} // ok!\n\n mod a {\n pub use super::foo;\n }\n}\n```\n\nSee the [Use Declarations][use-declarations] section of the reference for\nmore information on this topic.\n\n[use-declarations]: https://doc.rust-lang.org/reference/items/use-declarations.html\n"),
(E0365,
"Private modules cannot be publicly re-exported. This error indicates that you\nattempted to `pub use` a module that was not itself public.\n\nErroneous code example:\n\n```compile_fail,E0365\nmod foo {\n pub const X: u32 = 1;\n}\n\npub use foo as foo2;\n\nfn main() {}\n```\n\nThe solution to this problem is to ensure that the module that you are\nre-exporting is itself marked with `pub`:\n\n```\npub mod foo {\n pub const X: u32 = 1;\n}\n\npub use foo as foo2;\n\nfn main() {}\n```\n\nSee the [Use Declarations][use-declarations] section of the reference for\nmore information on this topic.\n\n[use-declarations]: https://doc.rust-lang.org/reference/items/use-declarations.html\n"),
(E0366,
"An attempt was made to implement `Drop` on a concrete specialization of a\ngeneric type. An example is shown below:\n\n```compile_fail,E0366\nstruct Foo<T> {\n t: T\n}\n\nimpl Drop for Foo<u32> {\n fn drop(&mut self) {}\n}\n```\n\nThis code is not legal: it is not possible to specialize `Drop` to a subset of\nimplementations of a generic type. One workaround for this is to wrap the\ngeneric type, as shown below:\n\n```\nstruct Foo<T> {\n t: T\n}\n\nstruct Bar {\n t: Foo<u32>\n}\n\nimpl Drop for Bar {\n fn drop(&mut self) {}\n}\n```\n"),
(E0367,
"An attempt was made to implement `Drop` on a specialization of a generic type.\n\nErroneous code example:\n\n```compile_fail,E0367\ntrait Foo {}\n\nstruct MyStruct<T> {\n t: T\n}\n\nimpl<T: Foo> Drop for MyStruct<T> {\n fn drop(&mut self) {}\n}\n```\n\nThis code is not legal: it is not possible to specialize `Drop` to a subset of\nimplementations of a generic type. In order for this code to work, `MyStruct`\nmust also require that `T` implements `Foo`. Alternatively, another option is\nto wrap the generic type in another that specializes appropriately:\n\n```\ntrait Foo{}\n\nstruct MyStruct<T> {\n t: T\n}\n\nstruct MyStructWrapper<T: Foo> {\n t: MyStruct<T>\n}\n\nimpl <T: Foo> Drop for MyStructWrapper<T> {\n fn drop(&mut self) {}\n}\n```\n"),
(E0368,
"A binary assignment operator like `+=` or `^=` was applied to a type that\ndoesn\'t support it.\n\nErroneous code example:\n\n```compile_fail,E0368\nlet mut x = 12f32; // error: binary operation `<<` cannot be applied to\n // type `f32`\n\nx <<= 2;\n```\n\nTo fix this error, please check that this type implements this binary\noperation. Example:\n\n```\nlet mut x = 12u32; // the `u32` type does implement the `ShlAssign` trait\n\nx <<= 2; // ok!\n```\n\nIt is also possible to overload most operators for your own type by\nimplementing the `[OP]Assign` traits from `std::ops`.\n\nAnother problem you might be facing is this: suppose you\'ve overloaded the `+`\noperator for some type `Foo` by implementing the `std::ops::Add` trait for\n`Foo`, but you find that using `+=` does not work, as in this example:\n\n```compile_fail,E0368\nuse std::ops::Add;\n\nstruct Foo(u32);\n\nimpl Add for Foo {\n type Output = Foo;\n\n fn add(self, rhs: Foo) -> Foo {\n Foo(self.0 + rhs.0)\n }\n}\n\nfn main() {\n let mut x: Foo = Foo(5);\n x += Foo(7); // error, `+=` cannot be applied to the type `Foo`\n}\n```\n\nThis is because `AddAssign` is not automatically implemented, so you need to\nmanually implement it for your type.\n"),
(E0369,
"A binary operation was attempted on a type which doesn\'t support it.\n\nErroneous code example:\n\n```compile_fail,E0369\nlet x = 12f32; // error: binary operation `<<` cannot be applied to\n // type `f32`\n\nx << 2;\n```\n\nTo fix this error, please check that this type implements this binary\noperation. Example:\n\n```\nlet x = 12u32; // the `u32` type does implement it:\n // https://doc.rust-lang.org/stable/std/ops/trait.Shl.html\n\nx << 2; // ok!\n```\n\nIt is also possible to overload most operators for your own type by\nimplementing traits from `std::ops`.\n\nString concatenation appends the string on the right to the string on the\nleft and may require reallocation. This requires ownership of the string\non the left. If something should be added to a string literal, move the\nliteral to the heap by allocating it with `to_owned()` like in\n`\"Your text\".to_owned()`.\n"),
(E0370,
"The maximum value of an enum was reached, so it cannot be automatically\nset in the next enum value.\n\nErroneous code example:\n\n```compile_fail,E0370\n#[repr(i64)]\nenum Foo {\n X = 0x7fffffffffffffff,\n Y, // error: enum discriminant overflowed on value after\n // 9223372036854775807: i64; set explicitly via\n // Y = -9223372036854775808 if that is desired outcome\n}\n```\n\nTo fix this, please set manually the next enum value or put the enum variant\nwith the maximum value at the end of the enum. Examples:\n\n```\n#[repr(i64)]\nenum Foo {\n X = 0x7fffffffffffffff,\n Y = 0, // ok!\n}\n```\n\nOr:\n\n```\n#[repr(i64)]\nenum Foo {\n Y = 0, // ok!\n X = 0x7fffffffffffffff,\n}\n```\n"),
(E0371,
"A trait was implemented on another which already automatically implemented it.\n\nErroneous code examples:\n\n```compile_fail,E0371\ntrait Foo { fn foo(&self) { } }\ntrait Bar: Foo { }\ntrait Baz: Bar { }\n\nimpl Bar for Baz { } // error, `Baz` implements `Bar` by definition\nimpl Foo for Baz { } // error, `Baz` implements `Bar` which implements `Foo`\nimpl Baz for Baz { } // error, `Baz` (trivially) implements `Baz`\nimpl Baz for Bar { } // Note: This is OK\n```\n\nWhen `Trait2` is a subtrait of `Trait1` (for example, when `Trait2` has a\ndefinition like `trait Trait2: Trait1 { ... }`), it is not allowed to implement\n`Trait1` for `Trait2`. This is because `Trait2` already implements `Trait1` by\ndefinition, so it is not useful to do this.\n"),
(E0373,
"A captured variable in a closure may not live long enough.\n\nErroneous code example:\n\n```compile_fail,E0373\nfn foo() -> Box<dyn Fn(u32) -> u32> {\n let x = 0u32;\n Box::new(|y| x + y)\n}\n```\n\nThis error occurs when an attempt is made to use data captured by a closure,\nwhen that data may no longer exist. It\'s most commonly seen when attempting to\nreturn a closure as shown in the previous code example.\n\nNotice that `x` is stack-allocated by `foo()`. By default, Rust captures\nclosed-over data by reference. This means that once `foo()` returns, `x` no\nlonger exists. An attempt to access `x` within the closure would thus be\nunsafe.\n\nAnother situation where this might be encountered is when spawning threads:\n\n```compile_fail,E0373\nfn foo() {\n let x = 0u32;\n let y = 1u32;\n\n let thr = std::thread::spawn(|| {\n x + y\n });\n}\n```\n\nSince our new thread runs in parallel, the stack frame containing `x` and `y`\nmay well have disappeared by the time we try to use them. Even if we call\n`thr.join()` within foo (which blocks until `thr` has completed, ensuring the\nstack frame won\'t disappear), we will not succeed: the compiler cannot prove\nthat this behavior is safe, and so won\'t let us do it.\n\nThe solution to this problem is usually to switch to using a `move` closure.\nThis approach moves (or copies, where possible) data into the closure, rather\nthan taking references to it. For example:\n\n```\nfn foo() -> Box<dyn Fn(u32) -> u32> {\n let x = 0u32;\n Box::new(move |y| x + y)\n}\n```\n\nNow that the closure has its own copy of the data, there\'s no need to worry\nabout safety.\n\nThis error may also be encountered while using `async` blocks:\n\n```compile_fail,E0373,edition2018\nuse std::future::Future;\n\nasync fn f() {\n let v = vec![1, 2, 3i32];\n spawn(async { //~ ERROR E0373\n println!(\"{:?}\", v)\n });\n}\n\nfn spawn<F: Future + Send + \'static>(future: F) {\n unimplemented!()\n}\n```\n\nSimilarly to closures, `async` blocks are not executed immediately and may\ncapture closed-over data by reference. For more information, see\n<https://rust-lang.github.io/async-book/03_async_await/01_chapter.html>.\n"),
(E0374,
"`CoerceUnsized` or `DispatchFromDyn` was implemented on a struct which does not\ncontain a field that is being unsized.\n\nExample of erroneous code:\n\n```compile_fail,E0374\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\nstruct Foo<T: ?Sized> {\n a: i32,\n}\n\n// error: Struct `Foo` has no unsized fields that need to be coerced.\nimpl<T, U> CoerceUnsized<Foo<U>> for Foo<T>\n where T: CoerceUnsized<U> {}\n```\n\n`CoerceUnsized` is used to coerce structs that have a field that can be unsized,\nlike a custom `MyBox<T>` being unsized to `MyBox<dyn Trait>`. `DispatchFromDyn`\nis used to dispatch from `MyBox<dyn Trait>` to `MyBox<Self>` in a dyn-compatible\ntrait.\n\nIf the struct doesn\'t have any fields of unsized types then there is no\nmeaningful way to implement `CoerceUnsized` or `DispatchFromDyn`, since\nthere is no coercion taking place.\n\nNote that `CoerceUnsized` and `DispatchFromDyn` is mainly used by smart pointers\nlike `Box`, `Rc` and `Arc` to be able to mark that they can coerce unsized types\nthat they are pointing at.\n"),
(E0375,
"`CoerceUnsized` or `DispatchFromDyn` was implemented on a struct which contains\nmore than one field that is being unsized.\n\nErroneous code example:\n\n```compile_fail,E0375\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\nstruct Foo<T: ?Sized, U: ?Sized> {\n a: i32,\n b: T,\n c: U,\n}\n\n// error: Struct `Foo` has more than one unsized field.\nimpl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {}\n```\n\n`CoerceUnsized` is used to coerce structs that have a field that can be unsized,\nlike a custom `MyBox<T>` being unsized to `MyBox<dyn Trait>`. `DispatchFromDyn`\nis used to dispatch from `MyBox<dyn Trait>` to `MyBox<Self>` in a dyn-compatible\ntrait.\n\nIf the struct has multiple fields that must be unsized, then the compiler has no\nway to generate a valid implementation of `CoerceUnsized` or `DispatchFromDyn`.\n\nNote that `CoerceUnsized` and `DispatchFromDyn` is mainly used by smart pointers\nlike `Box`, `Rc` and `Arc` to be able to mark that they can coerce unsized types\nthat they are pointing at.\n"),
(E0376,
"#### Note: this error code is no longer emitted by the compiler.\n\n`CoerceUnsized` or `DispatchFromDyn` was implemented between two types that\nare not structs.\n\nErroneous code example:\n\n```compile_fail,E0377\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\nstruct Foo<T: ?Sized> {\n a: T,\n}\n\n// error: The type `U` is not a struct\nimpl<T, U> CoerceUnsized<U> for Foo<T> {}\n```\n\n`CoerceUnsized` or `DispatchFromDyn` can only be implemented between structs.\n"),
(E0377,
"`CoerceUnsized` or `DispatchFromDyn` may only be implemented between structs\nof the same type.\n\nExample of erroneous code:\n\n```compile_fail,E0377\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\npub struct Foo<T: ?Sized> {\n field_with_unsized_type: T,\n}\n\npub struct Bar<T: ?Sized> {\n field_with_unsized_type: T,\n}\n\n// error: the trait `CoerceUnsized` may only be implemented for a coercion\n// between structures with the same definition\nimpl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {}\n```\n\n`CoerceUnsized` is used to coerce structs that have a field that can be unsized,\nlike a custom `MyBox<T>` being unsized to `MyBox<dyn Trait>`. `DispatchFromDyn`\nis used to dispatch from `MyBox<dyn Trait>` to `MyBox<Self>` in a dyn-compatible\ntrait.\n\nThe compiler cannot support coercions between structs of different types, so\na valid implementation of `CoerceUnsized` or `DispatchFromDyn` should be\nimplemented between the same struct with different generic parameters.\n\nNote that `CoerceUnsized` and `DispatchFromDyn` is mainly used by smart pointers\nlike `Box`, `Rc` and `Arc` to be able to mark that they can coerce unsized types\nthat they are pointing at.\n"),
(E0378,
"The `DispatchFromDyn` trait was implemented on something which is not a pointer\nor a newtype wrapper around a pointer.\n\nErroneous code example:\n\n```compile_fail,E0378\n#![feature(dispatch_from_dyn)]\nuse std::ops::DispatchFromDyn;\n\nstruct WrapperExtraField<T> {\n ptr: T,\n extra_stuff: i32,\n}\n\nimpl<T, U> DispatchFromDyn<WrapperExtraField<U>> for WrapperExtraField<T>\nwhere\n T: DispatchFromDyn<U>,\n{}\n```\n\nThe `DispatchFromDyn` trait currently can only be implemented for\nbuiltin pointer types and structs that are newtype wrappers around them\n\u{2014} that is, the struct must have only one field (except for `PhantomData`),\nand that field must itself implement `DispatchFromDyn`.\n\n```\n#![feature(dispatch_from_dyn, unsize)]\nuse std::{\n marker::Unsize,\n ops::DispatchFromDyn,\n};\n\nstruct Ptr<T: ?Sized>(*const T);\n\nimpl<T: ?Sized, U: ?Sized> DispatchFromDyn<Ptr<U>> for Ptr<T>\nwhere\n T: Unsize<U>,\n{}\n```\n\nAnother example:\n\n```\n#![feature(dispatch_from_dyn)]\nuse std::{\n ops::DispatchFromDyn,\n marker::PhantomData,\n};\n\nstruct Wrapper<T> {\n ptr: T,\n _phantom: PhantomData<()>,\n}\n\nimpl<T, U> DispatchFromDyn<Wrapper<U>> for Wrapper<T>\nwhere\n T: DispatchFromDyn<U>,\n{}\n```\n"),
(E0379,
"A trait method was declared const.\n\nErroneous code example:\n\n```compile_fail,E0379\ntrait Foo {\n const fn bar() -> u32; // error!\n}\n\nimpl Foo for () {\n const fn bar() -> u32 { 0 } // error!\n}\n```\n\nTrait methods cannot be declared `const` by design. For more information, see\n[RFC 911].\n\n[RFC 911]: https://github.com/rust-lang/rfcs/pull/911\n"),
(E0380,
"An auto trait was declared with a method or an associated item.\n\nErroneous code example:\n\n```compile_fail,E0380\nunsafe auto trait Trait {\n type Output; // error!\n}\n```\n\nAuto traits cannot have methods or associated items. For more information see\nthe [opt-in builtin traits RFC][RFC 19].\n\n[RFC 19]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md\n"),
(E0381,
"It is not allowed to use or capture an uninitialized variable.\n\nErroneous code example:\n\n```compile_fail,E0381\nfn main() {\n let x: i32;\n let y = x; // error, use of possibly-uninitialized variable\n}\n```\n\nTo fix this, ensure that any declared variables are initialized before being\nused. Example:\n\n```\nfn main() {\n let x: i32 = 0;\n let y = x; // ok!\n}\n```\n"),
(E0382,
"A variable was used after its contents have been moved elsewhere.\n\nErroneous code example:\n\n```compile_fail,E0382\nstruct MyStruct { s: u32 }\n\nfn main() {\n let mut x = MyStruct{ s: 5u32 };\n let y = x;\n x.s = 6;\n println!(\"{}\", x.s);\n}\n```\n\nSince `MyStruct` is a type that is not marked `Copy`, the data gets moved out\nof `x` when we set `y`. This is fundamental to Rust\'s ownership system: outside\nof workarounds like `Rc`, a value cannot be owned by more than one variable.\n\nSometimes we don\'t need to move the value. Using a reference, we can let another\nfunction borrow the value without changing its ownership. In the example below,\nwe don\'t actually have to move our string to `calculate_length`, we can give it\na reference to it with `&` instead.\n\n```\nfn main() {\n let s1 = String::from(\"hello\");\n\n let len = calculate_length(&s1);\n\n println!(\"The length of \'{}\' is {}.\", s1, len);\n}\n\nfn calculate_length(s: &String) -> usize {\n s.len()\n}\n```\n\nA mutable reference can be created with `&mut`.\n\nSometimes we don\'t want a reference, but a duplicate. All types marked `Clone`\ncan be duplicated by calling `.clone()`. Subsequent changes to a clone do not\naffect the original variable.\n\nMost types in the standard library are marked `Clone`. The example below\ndemonstrates using `clone()` on a string. `s1` is first set to \"many\", and then\ncopied to `s2`. Then the first character of `s1` is removed, without affecting\n`s2`. \"any many\" is printed to the console.\n\n```\nfn main() {\n let mut s1 = String::from(\"many\");\n let s2 = s1.clone();\n s1.remove(0);\n println!(\"{} {}\", s1, s2);\n}\n```\n\nIf we control the definition of a type, we can implement `Clone` on it ourselves\nwith `#[derive(Clone)]`.\n\nSome types have no ownership semantics at all and are trivial to duplicate. An\nexample is `i32` and the other number types. We don\'t have to call `.clone()` to\nclone them, because they are marked `Copy` in addition to `Clone`. Implicit\ncloning is more convenient in this case. We can mark our own types `Copy` if\nall their members also are marked `Copy`.\n\nIn the example below, we implement a `Point` type. Because it only stores two\nintegers, we opt-out of ownership semantics with `Copy`. Then we can\n`let p2 = p1` without `p1` being moved.\n\n```\n#[derive(Copy, Clone)]\nstruct Point { x: i32, y: i32 }\n\nfn main() {\n let mut p1 = Point{ x: -1, y: 2 };\n let p2 = p1;\n p1.x = 1;\n println!(\"p1: {}, {}\", p1.x, p1.y);\n println!(\"p2: {}, {}\", p2.x, p2.y);\n}\n```\n\nAlternatively, if we don\'t control the struct\'s definition, or mutable shared\nownership is truly required, we can use `Rc` and `RefCell`:\n\n```\nuse std::cell::RefCell;\nuse std::rc::Rc;\n\nstruct MyStruct { s: u32 }\n\nfn main() {\n let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));\n let y = x.clone();\n x.borrow_mut().s = 6;\n println!(\"{}\", x.borrow().s);\n}\n```\n\nWith this approach, x and y share ownership of the data via the `Rc` (reference\ncount type). `RefCell` essentially performs runtime borrow checking: ensuring\nthat at most one writer or multiple readers can access the data at any one time.\n\nIf you wish to learn more about ownership in Rust, start with the\n[Understanding Ownership][understanding-ownership] chapter in the Book.\n\n[understanding-ownership]: https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html\n"),
(E0383,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error occurs when an attempt is made to partially reinitialize a\nstructure that is currently uninitialized.\n\nFor example, this can happen when a drop has taken place:\n\n```compile_fail\nstruct Foo {\n a: u32,\n}\nimpl Drop for Foo {\n fn drop(&mut self) { /* ... */ }\n}\n\nlet mut x = Foo { a: 1 };\ndrop(x); // `x` is now uninitialized\nx.a = 2; // error, partial reinitialization of uninitialized structure `t`\n```\n\nThis error can be fixed by fully reinitializing the structure in question:\n\n```\nstruct Foo {\n a: u32,\n}\nimpl Drop for Foo {\n fn drop(&mut self) { /* ... */ }\n}\n\nlet mut x = Foo { a: 1 };\ndrop(x);\nx = Foo { a: 2 };\n```\n"),
(E0384,
"An immutable variable was reassigned.\n\nErroneous code example:\n\n```compile_fail,E0384\nfn main() {\n let x = 3;\n x = 5; // error, reassignment of immutable variable\n}\n```\n\nBy default, variables in Rust are immutable. To fix this error, add the keyword\n`mut` after the keyword `let` when declaring the variable. For example:\n\n```\nfn main() {\n let mut x = 3;\n x = 5;\n}\n```\n\nAlternatively, you might consider initializing a new variable: either with a new\nbound name or (by [shadowing]) with the bound name of your existing variable.\nFor example:\n\n[shadowing]: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing\n\n```\nfn main() {\n let x = 3;\n let x = 5;\n}\n```\n"),
(E0386,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error occurs when an attempt is made to mutate the target of a mutable\nreference stored inside an immutable container.\n\nFor example, this can happen when storing a `&mut` inside an immutable `Box`:\n\n```\nlet mut x: i64 = 1;\nlet y: Box<_> = Box::new(&mut x);\n**y = 2; // error, cannot assign to data in an immutable container\n```\n\nThis error can be fixed by making the container mutable:\n\n```\nlet mut x: i64 = 1;\nlet mut y: Box<_> = Box::new(&mut x);\n**y = 2;\n```\n\nIt can also be fixed by using a type with interior mutability, such as `Cell`\nor `RefCell`:\n\n```\nuse std::cell::Cell;\n\nlet x: i64 = 1;\nlet y: Box<Cell<_>> = Box::new(Cell::new(x));\ny.set(2);\n```\n"),
(E0387,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error occurs when an attempt is made to mutate or mutably reference data\nthat a closure has captured immutably.\n\nErroneous code example:\n\n```compile_fail\n// Accepts a function or a closure that captures its environment immutably.\n// Closures passed to foo will not be able to mutate their closed-over state.\nfn foo<F: Fn()>(f: F) { }\n\n// Attempts to mutate closed-over data. Error message reads:\n// `cannot assign to data in a captured outer variable...`\nfn mutable() {\n let mut x = 0u32;\n foo(|| x = 2);\n}\n\n// Attempts to take a mutable reference to closed-over data. Error message\n// reads: `cannot borrow data mutably in a captured outer variable...`\nfn mut_addr() {\n let mut x = 0u32;\n foo(|| { let y = &mut x; });\n}\n```\n\nThe problem here is that foo is defined as accepting a parameter of type `Fn`.\nClosures passed into foo will thus be inferred to be of type `Fn`, meaning that\nthey capture their context immutably.\n\nIf the definition of `foo` is under your control, the simplest solution is to\ncapture the data mutably. This can be done by defining `foo` to take FnMut\nrather than Fn:\n\n```\nfn foo<F: FnMut()>(f: F) { }\n```\n\nAlternatively, we can consider using the `Cell` and `RefCell` types to achieve\ninterior mutability through a shared reference. Our example\'s `mutable`\nfunction could be redefined as below:\n\n```\nuse std::cell::Cell;\n\nfn foo<F: Fn()>(f: F) { }\n\nfn mutable() {\n let x = Cell::new(0u32);\n foo(|| x.set(2));\n}\n```\n\nYou can read more in the API documentation for [Cell][std-cell].\n\n[std-cell]: https://doc.rust-lang.org/std/cell/\n"),
(E0388,
"#### Note: this error code is no longer emitted by the compiler.\n"),
(E0389,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn attempt was made to mutate data using a non-mutable reference. This\ncommonly occurs when attempting to assign to a non-mutable reference of a\nmutable reference (`&(&mut T)`).\n\nErroneous code example:\n\n```compile_fail\nstruct FancyNum {\n num: u8,\n}\n\nfn main() {\n let mut fancy = FancyNum{ num: 5 };\n let fancy_ref = &(&mut fancy);\n fancy_ref.num = 6; // error: cannot assign to data in a `&` reference\n println!(\"{}\", fancy_ref.num);\n}\n```\n\nHere, `&mut fancy` is mutable, but `&(&mut fancy)` is not. Creating an\nimmutable reference to a value borrows it immutably. There can be multiple\nreferences of type `&(&mut T)` that point to the same value, so they must be\nimmutable to prevent multiple mutable references to the same value.\n\nTo fix this, either remove the outer reference:\n\n```\nstruct FancyNum {\n num: u8,\n}\n\nfn main() {\n let mut fancy = FancyNum{ num: 5 };\n\n let fancy_ref = &mut fancy;\n // `fancy_ref` is now &mut FancyNum, rather than &(&mut FancyNum)\n\n fancy_ref.num = 6; // No error!\n\n println!(\"{}\", fancy_ref.num);\n}\n```\n\nOr make the outer reference mutable:\n\n```\nstruct FancyNum {\n num: u8\n}\n\nfn main() {\n let mut fancy = FancyNum{ num: 5 };\n\n let fancy_ref = &mut (&mut fancy);\n // `fancy_ref` is now &mut(&mut FancyNum), rather than &(&mut FancyNum)\n\n fancy_ref.num = 6; // No error!\n\n println!(\"{}\", fancy_ref.num);\n}\n```\n"),
(E0390,
"A method or constant was implemented on a primitive type.\n\nErroneous code example:\n\n```compile_fail,E0390\nstruct Foo {\n x: i32\n}\n\nimpl *mut Foo {}\n// error: cannot define inherent `impl` for primitive types\n```\n\nThis isn\'t allowed, but using a trait to implement a method or constant\nis a good solution.\nExample:\n\n```\nstruct Foo {\n x: i32\n}\n\ntrait Bar {\n fn bar();\n}\n\nimpl Bar for *mut Foo {\n fn bar() {} // ok!\n}\n```\n\nInstead of defining an inherent implementation on a reference, you could also\nmove the reference inside the implementation:\n\n```compile_fail,E0390\nstruct Foo;\n\nimpl &Foo { // error: no nominal type found for inherent implementation\n fn bar(self, other: Self) {}\n}\n```\n\nbecomes\n\n```\nstruct Foo;\n\nimpl Foo {\n fn bar(&self, other: &Self) {}\n}\n```\n"),
(E0391,
"A type dependency cycle has been encountered.\n\nErroneous code example:\n\n```compile_fail,E0391\ntrait FirstTrait : SecondTrait {\n\n}\n\ntrait SecondTrait : FirstTrait {\n\n}\n```\n\nThe previous example contains a circular dependency between two traits:\n`FirstTrait` depends on `SecondTrait` which itself depends on `FirstTrait`.\n\nSee https://rustc-dev-guide.rust-lang.org/overview.html#queries and\nhttps://rustc-dev-guide.rust-lang.org/query.html for more information.\n"),
(E0392,
"A type or lifetime parameter has been declared but is not actually used.\n\nErroneous code example:\n\n```compile_fail,E0392\nenum Foo<T> {\n Bar,\n}\n```\n\nIf the type parameter was included by mistake, this error can be fixed\nby simply removing the type parameter, as shown below:\n\n```\nenum Foo {\n Bar,\n}\n```\n\nAlternatively, if the type parameter was intentionally inserted, it must be\nused. A simple fix is shown below:\n\n```\nenum Foo<T> {\n Bar(T),\n}\n```\n\nThis error may also commonly be found when working with unsafe code. For\nexample, when using raw pointers one may wish to specify the lifetime for\nwhich the pointed-at data is valid. An initial attempt (below) causes this\nerror:\n\n```compile_fail,E0392\nstruct Foo<\'a, T> {\n x: *const T,\n}\n```\n\nWe want to express the constraint that Foo should not outlive `\'a`, because\nthe data pointed to by `T` is only valid for that lifetime. The problem is\nthat there are no actual uses of `\'a`. It\'s possible to work around this\nby adding a PhantomData type to the struct, using it to tell the compiler\nto act as if the struct contained a borrowed reference `&\'a T`:\n\n```\nuse std::marker::PhantomData;\n\nstruct Foo<\'a, T: \'a> {\n x: *const T,\n phantom: PhantomData<&\'a T>\n}\n```\n\n[PhantomData] can also be used to express information about unused type\nparameters.\n\n[PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html\n"),
(E0393,
"A type parameter which references `Self` in its default value was not specified.\n\nErroneous code example:\n\n```compile_fail,E0393\ntrait A<T = Self> {}\n\nfn together_we_will_rule_the_galaxy(son: &dyn A) {}\n// error: the type parameter `T` must be explicitly specified\n```\n\nA trait object is defined over a single, fully-defined trait. With a regular\ndefault parameter, this parameter can just be instantiated in. However, if the\ndefault parameter is `Self`, the trait changes for each concrete type; i.e.\n`i32` will be expected to implement `A<i32>`, `bool` will be expected to\nimplement `A<bool>`, etc... These types will not share an implementation of a\nfully-defined trait; instead they share implementations of a trait with\ndifferent parameters instantiated in for each implementation. This is\nirreconcilable with what we need to make a trait object work, and is thus\ndisallowed. Making the trait concrete by explicitly specifying the value of the\ndefaulted parameter will fix this issue. Fixed example:\n\n```\ntrait A<T = Self> {}\n\nfn together_we_will_rule_the_galaxy(son: &dyn A<i32>) {} // Ok!\n```\n"),
(E0398,
"#### Note: this error code is no longer emitted by the compiler.\n\nIn Rust 1.3, the default object lifetime bounds are expected to change, as\ndescribed in [RFC 1156]. You are getting a warning because the compiler\nthinks it is possible that this change will cause a compilation error in your\ncode. It is possible, though unlikely, that this is a false alarm.\n\nThe heart of the change is that where `&\'a Box<SomeTrait>` used to default to\n`&\'a Box<SomeTrait+\'a>`, it now defaults to `&\'a Box<SomeTrait+\'static>` (here,\n`SomeTrait` is the name of some trait type). Note that the only types which are\naffected are references to boxes, like `&Box<SomeTrait>` or\n`&[Box<SomeTrait>]`. More common types like `&SomeTrait` or `Box<SomeTrait>`\nare unaffected.\n\nTo silence this warning, edit your code to use an explicit bound. Most of the\ntime, this means that you will want to change the signature of a function that\nyou are calling. For example, if the error is reported on a call like `foo(x)`,\nand `foo` is defined as follows:\n\n```\n# trait SomeTrait {}\nfn foo(arg: &Box<SomeTrait>) { /* ... */ }\n```\n\nYou might change it to:\n\n```\n# trait SomeTrait {}\nfn foo<\'a>(arg: &\'a Box<SomeTrait+\'a>) { /* ... */ }\n```\n\nThis explicitly states that you expect the trait object `SomeTrait` to contain\nreferences (with a maximum lifetime of `\'a`).\n\n[RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md\n"),
(E0399,
"#### Note: this error code is no longer emitted by the compiler\n\nYou implemented a trait, overriding one or more of its associated types but did\nnot reimplement its default methods.\n\nExample of erroneous code:\n\n```\n#![feature(associated_type_defaults)]\n\npub trait Foo {\n type Assoc = u8;\n fn bar(&self) {}\n}\n\nimpl Foo for i32 {\n // error - the following trait items need to be reimplemented as\n // `Assoc` was overridden: `bar`\n type Assoc = i32;\n}\n```\n\nTo fix this, add an implementation for each default method from the trait:\n\n```\n#![feature(associated_type_defaults)]\n\npub trait Foo {\n type Assoc = u8;\n fn bar(&self) {}\n}\n\nimpl Foo for i32 {\n type Assoc = i32;\n fn bar(&self) {} // ok!\n}\n```\n"),
(E0401,
"Inner items do not inherit the generic parameters from the items\nthey are embedded in.\n\nErroneous code example:\n\n```compile_fail,E0401\nfn foo<T>(x: T) {\n fn bar(y: T) { // T is defined in the \"outer\" function\n // ..\n }\n bar(x);\n}\n```\n\nNor will this:\n\n```compile_fail,E0401\nfn foo<T>(x: T) {\n type MaybeT = Option<T>;\n // ...\n}\n```\n\nOr this:\n\n```compile_fail,E0401\nfn foo<T>(x: T) {\n struct Foo {\n x: T,\n }\n // ...\n}\n```\n\nItems nested inside other items are basically just like top-level items, except\nthat they can only be used from the item they are in.\n\nThere are a couple of solutions for this.\n\nIf the item is a function, you may use a closure:\n\n```\nfn foo<T>(x: T) {\n let bar = |y: T| { // explicit type annotation may not be necessary\n // ..\n };\n bar(x);\n}\n```\n\nFor a generic item, you can copy over the parameters:\n\n```\nfn foo<T>(x: T) {\n fn bar<T>(y: T) {\n // ..\n }\n bar(x);\n}\n```\n\n```\nfn foo<T>(x: T) {\n type MaybeT<T> = Option<T>;\n}\n```\n\nBe sure to copy over any bounds as well:\n\n```\nfn foo<T: Copy>(x: T) {\n fn bar<T: Copy>(y: T) {\n // ..\n }\n bar(x);\n}\n```\n\n```\nfn foo<T: Copy>(x: T) {\n struct Foo<T: Copy> {\n x: T,\n }\n}\n```\n\nThis may require additional type hints in the function body.\n\nIn case the item is a function inside an `impl`, defining a private helper\nfunction might be easier:\n\n```\n# struct Foo<T>(T);\nimpl<T> Foo<T> {\n pub fn foo(&self, x: T) {\n self.bar(x);\n }\n\n fn bar(&self, y: T) {\n // ..\n }\n}\n```\n\nFor default impls in traits, the private helper solution won\'t work, however\nclosures or copying the parameters should still work.\n"),
(E0403,
"Some type parameters have the same name.\n\nErroneous code example:\n\n```compile_fail,E0403\nfn f<T, T>(s: T, u: T) {} // error: the name `T` is already used for a generic\n // parameter in this item\'s generic parameters\n```\n\nPlease verify that none of the type parameters are misspelled, and rename any\nclashing parameters. Example:\n\n```\nfn f<T, Y>(s: T, u: Y) {} // ok!\n```\n\nType parameters in an associated item also cannot shadow parameters from the\ncontaining item:\n\n```compile_fail,E0403\ntrait Foo<T> {\n fn do_something(&self) -> T;\n fn do_something_else<T: Clone>(&self, bar: T);\n}\n```\n"),
(E0404,
"A type that is not a trait was used in a trait position, such as a bound\nor `impl`.\n\nErroneous code example:\n\n```compile_fail,E0404\nstruct Foo;\nstruct Bar;\n\nimpl Foo for Bar {} // error: `Foo` is not a trait\nfn baz<T: Foo>(t: T) {} // error: `Foo` is not a trait\n```\n\nAnother erroneous code example:\n\n```compile_fail,E0404\ntype Foo = Iterator<Item=String>;\n\nfn bar<T: Foo>(t: T) {} // error: `Foo` is a type alias\n```\n\nPlease verify that the trait\'s name was not misspelled or that the right\nidentifier was used. Example:\n\n```\ntrait Foo {\n // some functions\n}\nstruct Bar;\n\nimpl Foo for Bar { // ok!\n // functions implementation\n}\n\nfn baz<T: Foo>(t: T) {} // ok!\n```\n\nAlternatively, you could introduce a new trait with your desired restrictions\nas a super trait:\n\n```\n# trait Foo {}\n# struct Bar;\n# impl Foo for Bar {}\ntrait Qux: Foo {} // Anything that implements Qux also needs to implement Foo\nfn baz<T: Qux>(t: T) {} // also ok!\n```\n\nFinally, if you are on nightly and want to use a trait alias\ninstead of a type alias, you should use `#![feature(trait_alias)]`:\n\n```\n#![feature(trait_alias)]\ntrait Foo = Iterator<Item=String>;\n\nfn bar<T: Foo>(t: T) {} // ok!\n```\n"),
(E0405,
"The code refers to a trait that is not in scope.\n\nErroneous code example:\n\n```compile_fail,E0405\nstruct Foo;\n\nimpl SomeTrait for Foo {} // error: trait `SomeTrait` is not in scope\n```\n\nPlease verify that the name of the trait wasn\'t misspelled and ensure that it\nwas imported. Example:\n\n```\n# #[cfg(for_demonstration_only)]\n// solution 1:\nuse some_file::SomeTrait;\n\n// solution 2:\ntrait SomeTrait {\n // some functions\n}\n\nstruct Foo;\n\nimpl SomeTrait for Foo { // ok!\n // implements functions\n}\n```\n"),
(E0407,
"A definition of a method not in the implemented trait was given in a trait\nimplementation.\n\nErroneous code example:\n\n```compile_fail,E0407\ntrait Foo {\n fn a();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn a() {}\n fn b() {} // error: method `b` is not a member of trait `Foo`\n}\n```\n\nPlease verify you didn\'t misspell the method name and you used the correct\ntrait. First example:\n\n```\ntrait Foo {\n fn a();\n fn b();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn a() {}\n fn b() {} // ok!\n}\n```\n\nSecond example:\n\n```\ntrait Foo {\n fn a();\n}\n\nstruct Bar;\n\nimpl Foo for Bar {\n fn a() {}\n}\n\nimpl Bar {\n fn b() {}\n}\n```\n"),
(E0408,
"An \"or\" pattern was used where the variable bindings are not consistently bound\nacross patterns.\n\nErroneous code example:\n\n```compile_fail,E0408\nmatch x {\n Some(y) | None => { /* use y */ } // error: variable `y` from pattern #1 is\n // not bound in pattern #2\n _ => ()\n}\n```\n\nHere, `y` is bound to the contents of the `Some` and can be used within the\nblock corresponding to the match arm. However, in case `x` is `None`, we have\nnot specified what `y` is, and the block will use a nonexistent variable.\n\nTo fix this error, either split into multiple match arms:\n\n```\nlet x = Some(1);\nmatch x {\n Some(y) => { /* use y */ }\n None => { /* ... */ }\n}\n```\n\nor, bind the variable to a field of the same type in all sub-patterns of the\nor pattern:\n\n```\nlet x = (0, 2);\nmatch x {\n (0, y) | (y, 0) => { /* use y */}\n _ => {}\n}\n```\n\nIn this example, if `x` matches the pattern `(0, _)`, the second field is set\nto `y`. If it matches `(_, 0)`, the first field is set to `y`; so in all\ncases `y` is set to some value.\n"),
(E0409,
"An \"or\" pattern was used where the variable bindings are not consistently bound\nacross patterns.\n\nErroneous code example:\n\n```compile_fail,E0409\nlet x = (0, 2);\nmatch x {\n (0, ref y) | (y, 0) => { /* use y */} // error: variable `y` is bound with\n // different mode in pattern #2\n // than in pattern #1\n _ => ()\n}\n```\n\nHere, `y` is bound by-value in one case and by-reference in the other.\n\nTo fix this error, just use the same mode in both cases.\nGenerally using `ref` or `ref mut` where not already used will fix this:\n\n```\nlet x = (0, 2);\nmatch x {\n (0, ref y) | (ref y, 0) => { /* use y */}\n _ => ()\n}\n```\n\nAlternatively, split the pattern:\n\n```\nlet x = (0, 2);\nmatch x {\n (y, 0) => { /* use y */ }\n (0, ref y) => { /* use y */}\n _ => ()\n}\n```\n"),
(E0411,
"The `Self` keyword was used outside an impl, trait, or type definition.\n\nErroneous code example:\n\n```compile_fail,E0411\n<Self>::foo; // error: use of `Self` outside of an impl, trait, or type\n // definition\n```\n\nThe `Self` keyword represents the current type, which explains why it can only\nbe used inside an impl, trait, or type definition. It gives access to the\nassociated items of a type:\n\n```\ntrait Foo {\n type Bar;\n}\n\ntrait Baz : Foo {\n fn bar() -> Self::Bar; // like this\n}\n```\n\nHowever, be careful when two types have a common associated type:\n\n```compile_fail\ntrait Foo {\n type Bar;\n}\n\ntrait Foo2 {\n type Bar;\n}\n\ntrait Baz : Foo + Foo2 {\n fn bar() -> Self::Bar;\n // error: ambiguous associated type `Bar` in bounds of `Self`\n}\n```\n\nThis problem can be solved by specifying from which trait we want to use the\n`Bar` type:\n\n```\ntrait Foo {\n type Bar;\n}\n\ntrait Foo2 {\n type Bar;\n}\n\ntrait Baz : Foo + Foo2 {\n fn bar() -> <Self as Foo>::Bar; // ok!\n}\n```\n"),
(E0412,
"#### Note: this error code is no longer emitted by the compiler.\n\nErroneous code examples:\n\n```compile_fail,E0425\nimpl Something {} // error: type name `Something` is not in scope\n\n// or:\n\ntrait Foo {\n fn bar(N); // error: type name `N` is not in scope\n}\n\n// or:\n\nfn foo(x: T) {} // type name `T` is not in scope\n```\n\nTo fix this error, please verify you didn\'t misspell the type name, you did\ndeclare it or imported it into the scope. Examples:\n\n```\nstruct Something;\n\nimpl Something {} // ok!\n\n// or:\n\ntrait Foo {\n type N;\n\n fn bar(_: Self::N); // ok!\n}\n\n// or:\n\nfn foo<T>(x: T) {} // ok!\n```\n\nAnother case that causes this error is when a type is imported into a parent\nmodule. To fix this, you can follow the suggestion and use File directly or\n`use super::File;` which will import the types from the parent namespace. An\nexample that causes this error is below:\n\n```compile_fail,E0425\nuse std::fs::File;\n\nmod foo {\n fn some_function(f: File) {}\n}\n```\n\n```\nuse std::fs::File;\n\nmod foo {\n // either\n use super::File;\n // or\n // use std::fs::File;\n fn foo(f: File) {}\n}\n# fn main() {} // don\'t insert it for us; that\'ll break imports\n```\n"),
(E0415,
"More than one function parameter have the same name.\n\nErroneous code example:\n\n```compile_fail,E0415\nfn foo(f: i32, f: i32) {} // error: identifier `f` is bound more than\n // once in this parameter list\n```\n\nPlease verify you didn\'t misspell parameters\' name. Example:\n\n```\nfn foo(f: i32, g: i32) {} // ok!\n```\n"),
(E0416,
"An identifier is bound more than once in a pattern.\n\nErroneous code example:\n\n```compile_fail,E0416\nmatch (1, 2) {\n (x, x) => {} // error: identifier `x` is bound more than once in the\n // same pattern\n}\n```\n\nPlease verify you didn\'t misspell identifiers\' name. Example:\n\n```\nmatch (1, 2) {\n (x, y) => {} // ok!\n}\n```\n\nOr maybe did you mean to unify? Consider using a guard:\n\n```\n# let (A, B, C) = (1, 2, 3);\nmatch (A, B, C) {\n (x, x2, see) if x == x2 => { /* A and B are equal, do one thing */ }\n (y, z, see) => { /* A and B not equal; do another thing */ }\n}\n```\n"),
(E0422,
"An identifier that is neither defined nor a struct was used.\n\nErroneous code example:\n\n```compile_fail,E0422\nfn main () {\n let x = Foo { x: 1, y: 2 };\n}\n```\n\nIn this case, `Foo` is undefined, so it inherently isn\'t anything, and\ndefinitely not a struct.\n\n```compile_fail\nfn main () {\n let foo = 1;\n let x = foo { x: 1, y: 2 };\n}\n```\n\nIn this case, `foo` is defined, but is not a struct, so Rust can\'t use it as\none.\n"),
(E0423,
"An identifier was used like a function name or a value was expected and the\nidentifier exists but it belongs to a different namespace.\n\nErroneous code example:\n\n```compile_fail,E0423\nstruct Foo { a: bool };\n\nlet f = Foo();\n// error: expected function, tuple struct or tuple variant, found `Foo`\n// `Foo` is a struct name, but this expression uses it like a function name\n```\n\nPlease verify you didn\'t misspell the name of what you actually wanted to use\nhere. Example:\n\n```\nfn Foo() -> u32 { 0 }\n\nlet f = Foo(); // ok!\n```\n\nIt is common to forget the trailing `!` on macro invocations, which would also\nyield this error:\n\n```compile_fail,E0423\nprintln(\"\");\n// error: expected function, tuple struct or tuple variant,\n// found macro `println`\n// did you mean `println!(...)`? (notice the trailing `!`)\n```\n\nAnother case where this error is emitted is when a value is expected, but\nsomething else is found:\n\n```compile_fail,E0423\npub mod a {\n pub const I: i32 = 1;\n}\n\nfn h1() -> i32 {\n a.I\n //~^ ERROR expected value, found module `a`\n // did you mean `a::I`?\n}\n```\n"),
(E0424,
"The `self` keyword was used inside of an associated function without a \"`self`\nreceiver\" parameter.\n\nErroneous code example:\n\n```compile_fail,E0424\nstruct Foo;\n\nimpl Foo {\n // `bar` is a method, because it has a receiver parameter.\n fn bar(&self) {}\n\n // `foo` is not a method, because it has no receiver parameter.\n fn foo() {\n self.bar(); // error: `self` value is a keyword only available in\n // methods with a `self` parameter\n }\n}\n```\n\nThe `self` keyword can only be used inside methods, which are associated\nfunctions (functions defined inside of a `trait` or `impl` block) that have a\n`self` receiver as its first parameter, like `self`, `&self`, `&mut self` or\n`self: &mut Pin<Self>` (this last one is an example of an [\"arbitrary `self`\ntype\"](https://github.com/rust-lang/rust/issues/44874)).\n\nCheck if the associated function\'s parameter list should have contained a `self`\nreceiver for it to be a method, and add it if so. Example:\n\n```\nstruct Foo;\n\nimpl Foo {\n fn bar(&self) {}\n\n fn foo(self) { // `foo` is now a method.\n self.bar(); // ok!\n }\n}\n```\n"),
(E0425,
"An unresolved name was used.\n\nErroneous code examples:\n\n```compile_fail,E0425\nsomething_that_doesnt_exist::foo;\n// error: unresolved name `something_that_doesnt_exist::foo`\n\n// or:\n\ntrait Foo {\n fn bar() {\n Self; // error: unresolved name `Self`\n }\n}\n\n// or:\n\nlet x = unknown_variable; // error: unresolved name `unknown_variable`\n```\n\nPlease verify that the name wasn\'t misspelled and ensure that the\nidentifier being referred to is valid for the given situation. Example:\n\n```\nenum something_that_does_exist {\n Foo,\n}\n```\n\nOr:\n\n```\nmod something_that_does_exist {\n pub static foo : i32 = 0i32;\n}\n\nsomething_that_does_exist::foo; // ok!\n```\n\nOr:\n\n```\nlet unknown_variable = 12u32;\nlet x = unknown_variable; // ok!\n```\n\nIf the item is not defined in the current module, it must be imported using a\n`use` statement, like so:\n\n```\n# mod foo { pub fn bar() {} }\n# fn main() {\nuse foo::bar;\nbar();\n# }\n```\n\nIf the item you are importing is not defined in some super-module of the\ncurrent module, then it must also be declared as public (e.g., `pub fn`).\n"),
(E0426,
"An undeclared label was used.\n\nErroneous code example:\n\n```compile_fail,E0426\nloop {\n break \'a; // error: use of undeclared label `\'a`\n}\n```\n\nPlease verify you spelled or declared the label correctly. Example:\n\n```\n\'a: loop {\n break \'a; // ok!\n}\n```\n"),
(E0428,
"A type or module has been defined more than once.\n\nErroneous code example:\n\n```compile_fail,E0428\nstruct Bar;\nstruct Bar; // error: duplicate definition of value `Bar`\n```\n\nPlease verify you didn\'t misspell the type/module\'s name or remove/rename the\nduplicated one. Example:\n\n```\nstruct Bar;\nstruct Bar2; // ok!\n```\n"),
(E0429,
"The `self` keyword cannot appear alone as the last segment in a `use`\ndeclaration.\n\nErroneous code example:\n\n```compile_fail,E0429\nuse std::fmt::self; // error: `self` imports are only allowed within a { } list\n```\n\nTo use a namespace itself in addition to some of its members, `self` may appear\nas part of a brace-enclosed list of imports:\n\n```\nuse std::fmt::{self, Debug};\n```\n\nIf you only want to import the namespace, do so directly:\n\n```\nuse std::fmt;\n```\n"),
(E0430,
"The `self` import appears more than once in the list.\n\nErroneous code example:\n\n```compile_fail,E0430\nuse something::{self, self}; // error: `self` import can only appear once in\n // the list\n```\n\nPlease verify you didn\'t misspell the import name or remove the duplicated\n`self` import. Example:\n\n```\n# mod something {}\n# fn main() {\nuse something::{self}; // ok!\n# }\n```\n"),
(E0431,
"An invalid `self` import was made.\n\nErroneous code example:\n\n```compile_fail,E0431\nuse {self}; // error: `self` import can only appear in an import list with a\n // non-empty prefix\n```\n\nYou cannot import the current module into itself, please remove this import\nor verify you didn\'t misspell it.\n"),
(E0432,
"An import was unresolved.\n\nErroneous code example:\n\n```compile_fail,E0432\nuse something::Foo; // error: unresolved import `something::Foo`.\n```\n\nIn Rust 2015, paths in `use` statements are relative to the crate root. To\nimport items relative to the current and parent modules, use the `self::` and\n`super::` prefixes, respectively.\n\nIn Rust 2018 or later, paths in `use` statements are relative to the current\nmodule unless they begin with the name of a crate or a literal `crate::`, in\nwhich case they start from the crate root. As in Rust 2015 code, the `self::`\nand `super::` prefixes refer to the current and parent modules respectively.\n\nAlso verify that you didn\'t misspell the import name and that the import exists\nin the module from where you tried to import it. Example:\n\n```\nuse self::something::Foo; // Ok.\n\nmod something {\n pub struct Foo;\n}\n# fn main() {}\n```\n\nIf you tried to use a module from an external crate and are using Rust 2015,\nyou may have missed the `extern crate` declaration (which is usually placed in\nthe crate root):\n\n```edition2015\nextern crate core; // Required to use the `core` crate in Rust 2015.\n\nuse core::any;\n# fn main() {}\n```\n\nSince Rust 2018 the `extern crate` declaration is not required and\nyou can instead just `use` it:\n\n```edition2018\nuse core::any; // No extern crate required in Rust 2018.\n# fn main() {}\n```\n"),
(E0433,
"An undeclared crate, module, or type was used.\n\nErroneous code example:\n\n```compile_fail,E0433\nlet map = HashMap::new();\n// error: failed to resolve: use of undeclared type `HashMap`\n```\n\nPlease verify you didn\'t misspell the type/module\'s name or that you didn\'t\nforget to import it:\n\n```\nuse std::collections::HashMap; // HashMap has been imported.\nlet map: HashMap<u32, u32> = HashMap::new(); // So it can be used!\n```\n\nIf you\'ve expected to use a crate name:\n\n```compile_fail\nuse ferris_wheel::BigO;\n// error: failed to resolve: use of undeclared module or unlinked crate\n```\n\nMake sure the crate has been added as a dependency in `Cargo.toml`.\n\nTo use a module from your current crate, add the `crate::` prefix to the path.\n"),
(E0434,
"A variable used inside an inner function comes from a dynamic environment.\n\nErroneous code example:\n\n```compile_fail,E0434\nfn foo() {\n let y = 5;\n fn bar() -> u32 {\n y // error: can\'t capture dynamic environment in a fn item; use the\n // || { ... } closure form instead.\n }\n}\n```\n\nInner functions do not have access to their containing environment. To fix this\nerror, you can replace the function with a closure:\n\n```\nfn foo() {\n let y = 5;\n let bar = || {\n y\n };\n}\n```\n\nOr replace the captured variable with a constant or a static item:\n\n```\nfn foo() {\n static mut X: u32 = 4;\n const Y: u32 = 5;\n fn bar() -> u32 {\n unsafe {\n X = 3;\n }\n Y\n }\n}\n```\n"),
(E0435,
"A non-constant value was used in a constant expression.\n\nErroneous code example:\n\n```compile_fail,E0435\nlet foo = 42;\nlet a: [u8; foo]; // error: attempt to use a non-constant value in a constant\n```\n\n\'constant\' means \'a compile-time value\'.\n\nMore details can be found in the [Variables and Mutability] section of the book.\n\n[Variables and Mutability]: https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants\n\nTo fix this error, please replace the value with a constant. Example:\n\n```\nlet a: [u8; 42]; // ok!\n```\n\nOr:\n\n```\nconst FOO: usize = 42;\nlet a: [u8; FOO]; // ok!\n```\n"),
(E0436,
"The functional record update syntax was used on something other than a struct.\n\nErroneous code example:\n\n```compile_fail,E0436\nenum PublicationFrequency {\n Weekly,\n SemiMonthly { days: (u8, u8), annual_special: bool },\n}\n\nfn one_up_competitor(competitor_frequency: PublicationFrequency)\n -> PublicationFrequency {\n match competitor_frequency {\n PublicationFrequency::Weekly => PublicationFrequency::SemiMonthly {\n days: (1, 15), annual_special: false\n },\n c @ PublicationFrequency::SemiMonthly{ .. } =>\n PublicationFrequency::SemiMonthly {\n annual_special: true, ..c // error: functional record update\n // syntax requires a struct\n }\n }\n}\n```\n\nThe functional record update syntax is only allowed for structs (struct-like\nenum variants don\'t qualify, for example). To fix the previous code, rewrite the\nexpression without functional record update syntax:\n\n```\nenum PublicationFrequency {\n Weekly,\n SemiMonthly { days: (u8, u8), annual_special: bool },\n}\n\nfn one_up_competitor(competitor_frequency: PublicationFrequency)\n -> PublicationFrequency {\n match competitor_frequency {\n PublicationFrequency::Weekly => PublicationFrequency::SemiMonthly {\n days: (1, 15), annual_special: false\n },\n PublicationFrequency::SemiMonthly{ days, .. } =>\n PublicationFrequency::SemiMonthly {\n days, annual_special: true // ok!\n }\n }\n}\n```\n"),
(E0437,
"An associated type whose name does not match any of the associated types\nin the trait was used when implementing the trait.\n\nErroneous code example:\n\n```compile_fail,E0437\ntrait Foo {}\n\nimpl Foo for i32 {\n type Bar = bool;\n}\n```\n\nTrait implementations can only implement associated types that are members of\nthe trait in question.\n\nThe solution to this problem is to remove the extraneous associated type:\n\n```\ntrait Foo {}\n\nimpl Foo for i32 {}\n```\n"),
(E0438,
"An associated constant whose name does not match any of the associated constants\nin the trait was used when implementing the trait.\n\nErroneous code example:\n\n```compile_fail,E0438\ntrait Foo {}\n\nimpl Foo for i32 {\n const BAR: bool = true;\n}\n```\n\nTrait implementations can only implement associated constants that are\nmembers of the trait in question.\n\nThe solution to this problem is to remove the extraneous associated constant:\n\n```\ntrait Foo {}\n\nimpl Foo for i32 {}\n```\n"),
(E0439,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe length of the platform-intrinsic function `simd_shuffle` wasn\'t specified.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(platform_intrinsics)]\n\nextern \"platform-intrinsic\" {\n fn simd_shuffle<A,B>(a: A, b: A, c: [u32; 8]) -> B;\n // error: invalid `simd_shuffle`, needs length: `simd_shuffle`\n}\n```\n\nThe `simd_shuffle` function needs the length of the array passed as\nlast parameter in its name. Example:\n\n```ignore (no longer compiles)\n#![feature(platform_intrinsics)]\n\nextern \"platform-intrinsic\" {\n fn simd_shuffle8<A,B>(a: A, b: A, c: [u32; 8]) -> B;\n}\n```\n"),
(E0445,
"#### Note: this error code is no longer emitted by the compiler.\n\nA private trait was used on a public type parameter bound.\n\nPreviously erroneous code examples:\n\n```\ntrait Foo {\n fn dummy(&self) { }\n}\n\npub trait Bar : Foo {} // error: private trait in public interface\npub struct Bar2<T: Foo>(pub T); // same error\npub fn foo<T: Foo> (t: T) {} // same error\n\nfn main() {}\n```\n\nTo solve this error, please ensure that the trait is also public. The trait\ncan be made inaccessible if necessary by placing it into a private inner\nmodule, but it still has to be marked with `pub`. Example:\n\n```\npub trait Foo { // we set the Foo trait public\n fn dummy(&self) { }\n}\n\npub trait Bar : Foo {} // ok!\npub struct Bar2<T: Foo>(pub T); // ok!\npub fn foo<T: Foo> (t: T) {} // ok!\n\nfn main() {}\n```\n"),
(E0446,
"A private type or trait was used in a public associated type signature.\n\nErroneous code example:\n\n```compile_fail,E0446\nstruct Bar;\n\npub trait PubTr {\n type Alias;\n}\n\nimpl PubTr for u8 {\n type Alias = Bar; // error private type in public interface\n}\n\nfn main() {}\n```\n\nThere are two ways to solve this error. The first is to make the public type\nsignature only public to a module that also has access to the private type.\nThis is done by using pub(crate) or pub(in crate::my_mod::etc)\nExample:\n\n```\nstruct Bar;\n\npub(crate) trait PubTr { // only public to crate root\n type Alias;\n}\n\nimpl PubTr for u8 {\n type Alias = Bar;\n}\n\nfn main() {}\n```\n\nThe other way to solve this error is to make the private type public.\nExample:\n\n```\n\npub struct Bar; // we set the Bar trait public\n\npub trait PubTr {\n type Alias;\n}\n\nimpl PubTr for u8 {\n type Alias = Bar;\n}\n\nfn main() {}\n```\n"),
(E0447,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `pub` keyword was used inside a function.\n\nErroneous code example:\n\n```\nfn foo() {\n pub struct Bar; // error: visibility has no effect inside functions\n}\n```\n\nSince we cannot access items defined inside a function, the visibility of its\nitems does not impact outer code. So using the `pub` keyword in this context\nis invalid.\n"),
(E0448,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `pub` keyword was used inside a public enum.\n\nErroneous code example:\n\n```compile_fail\npub enum Foo {\n pub Bar, // error: unnecessary `pub` visibility\n}\n```\n\nSince the enum is already public, adding `pub` on one its elements is\nunnecessary. Example:\n\n```compile_fail\nenum Foo {\n pub Bar, // not ok!\n}\n```\n\nThis is the correct syntax:\n\n```\npub enum Foo {\n Bar, // ok!\n}\n```\n"),
(E0449,
"A visibility qualifier was used where one is not permitted. Visibility\nqualifiers are not permitted on enum variants, trait items, impl blocks, and\nextern blocks, as they already share the visibility of the parent item.\n\nErroneous code examples:\n\n```compile_fail,E0449\nstruct Bar;\n\ntrait Foo {\n fn foo();\n}\n\nenum Baz {\n pub Qux, // error: visibility qualifiers are not permitted here\n}\n\npub impl Bar {} // error: visibility qualifiers are not permitted here\n\npub impl Foo for Bar { // error: visibility qualifiers are not permitted here\n pub fn foo() {} // error: visibility qualifiers are not permitted here\n}\n```\n\nTo fix this error, simply remove the visibility qualifier. Example:\n\n```\nstruct Bar;\n\ntrait Foo {\n fn foo();\n}\n\nenum Baz {\n // Enum variants share the visibility of the enum they are in, so\n // `pub` is not allowed here\n Qux,\n}\n\n// Directly implemented methods share the visibility of the type itself,\n// so `pub` is not allowed here\nimpl Bar {}\n\n// Trait methods share the visibility of the trait, so `pub` is not\n// allowed in either case\nimpl Foo for Bar {\n fn foo() {}\n}\n```\n"),
(E0451,
"A struct constructor with private fields was invoked.\n\nErroneous code example:\n\n```compile_fail,E0451\nmod bar {\n pub struct Foo {\n pub a: isize,\n b: isize,\n }\n}\n\nlet f = bar::Foo{ a: 0, b: 0 }; // error: field `b` of struct `bar::Foo`\n // is private\n```\n\nTo fix this error, please ensure that all the fields of the struct are public,\nor implement a function for easy instantiation. Examples:\n\n```\nmod bar {\n pub struct Foo {\n pub a: isize,\n pub b: isize, // we set `b` field public\n }\n}\n\nlet f = bar::Foo{ a: 0, b: 0 }; // ok!\n```\n\nOr:\n\n```\nmod bar {\n pub struct Foo {\n pub a: isize,\n b: isize, // still private\n }\n\n impl Foo {\n pub fn new() -> Foo { // we create a method to instantiate `Foo`\n Foo { a: 0, b: 0 }\n }\n }\n}\n\nlet f = bar::Foo::new(); // ok!\n```\n"),
(E0452,
"An invalid lint attribute has been given.\n\nErroneous code example:\n\n```compile_fail,E0452\n#![allow(foo = \"\")] // error: malformed lint attribute\n```\n\nLint attributes only accept a list of identifiers (where each identifier is a\nlint name). Ensure the attribute is of this form:\n\n```\n#![allow(foo)] // ok!\n// or:\n#![allow(foo, foo2)] // ok!\n```\n"),
(E0453,
"A lint check attribute was overruled by a `forbid` directive set as an\nattribute on an enclosing scope, or on the command line with the `-F` option.\n\nExample of erroneous code:\n\n```compile_fail,E0453\n#![forbid(non_snake_case)]\n\n#[allow(non_snake_case)]\nfn main() {\n // error: allow(non_snake_case) incompatible with previous forbid\n let MyNumber = 2;\n}\n```\n\nThe `forbid` lint setting, like `deny`, turns the corresponding compiler\nwarning into a hard error. Unlike `deny`, `forbid` prevents itself from being\noverridden by inner attributes.\n\nIf you\'re sure you want to override the lint check, you can change `forbid` to\n`deny` (or use `-D` instead of `-F` if the `forbid` setting was given as a\ncommand-line option) to allow the inner lint check attribute:\n\n```\n#![deny(non_snake_case)]\n\n#[allow(non_snake_case)]\nfn main() {\n let MyNumber = 2; // ok!\n}\n```\n\nOtherwise, edit the code to pass the lint check, and remove the overruled\nattribute:\n\n```\n#![forbid(non_snake_case)]\n\nfn main() {\n let my_number = 2;\n}\n```\n"),
(E0454,
"A link name was given with an empty name.\n\nErroneous code example:\n\n```compile_fail,E0454\n#[link(name = \"\")] extern \"C\" {}\n// error: `#[link(name = \"\")]` given with empty name\n```\n\nThe rust compiler cannot link to an external library if you don\'t give it its\nname. Example:\n\n```no_run\n#[link(name = \"some_lib\")] extern \"C\" {} // ok!\n```\n"),
(E0455,
"Some linking kinds are target-specific and not supported on all platforms.\n\nLinking with `kind=framework` is only supported when targeting macOS,\nas frameworks are specific to that operating system.\n\nSimilarly, `kind=raw-dylib` is only supported when targeting Windows-like\nplatforms.\n\nErroneous code example:\n\n```ignore (should-compile_fail-but-cannot-doctest-conditionally-without-macos)\n#[link(name = \"FooCoreServices\", kind = \"framework\")] extern \"C\" {}\n// OS used to compile is Linux for example\n```\n\nTo solve this error you can use conditional compilation:\n\n```\n#[cfg_attr(target=\"macos\", link(name = \"FooCoreServices\", kind = \"framework\"))]\nextern \"C\" {}\n```\n\nLearn more in the [Conditional Compilation][conditional-compilation] section\nof the Reference.\n\n[conditional-compilation]: https://doc.rust-lang.org/reference/attributes.html#conditional-compilation\n"),
(E0457,
"#### Note: this error code is no longer emitted by the compiler\n\nPlugin `..` only found in rlib format, but must be available in dylib format.\n\nErroneous code example:\n\n`rlib-plugin.rs`\n```ignore (needs-linkage-with-other-tests)\n#![crate_type = \"rlib\"]\n#![feature(rustc_private)]\n\nextern crate rustc_middle;\nextern crate rustc_driver;\n\nuse rustc_driver::plugin::Registry;\n\n#[no_mangle]\nfn __rustc_plugin_registrar(_: &mut Registry) {}\n```\n\n`main.rs`\n```ignore (needs-linkage-with-other-tests)\n#![feature(plugin)]\n#![plugin(rlib_plugin)] // error: plugin `rlib_plugin` only found in rlib\n // format, but must be available in dylib\n\nfn main() {}\n```\n\nThe compiler exposes a plugin interface to allow altering the compile process\n(adding lints, etc). Plugins must be defined in their own crates (similar to\n[proc-macro](../reference/procedural-macros.html) isolation) and then compiled\nand linked to another crate. Plugin crates *must* be compiled to the\ndynamically-linked dylib format, and not the statically-linked rlib format.\nLearn more about different output types in\n[this section](../reference/linkage.html) of the Rust reference.\n\nThis error is easily fixed by recompiling the plugin crate in the dylib format.\n"),
(E0458,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn unknown \"kind\" was specified for a link attribute.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#[link(kind = \"wonderful_unicorn\")] extern \"C\" {}\n// error: unknown kind: `wonderful_unicorn`\n```\n\nPlease specify a valid \"kind\" value, from one of the following:\n\n* static\n* dylib\n* framework\n* raw-dylib\n"),
(E0459,
"A link was used without a name parameter.\n\nErroneous code example:\n\n```compile_fail,E0459\n#[link(kind = \"dylib\")] extern \"C\" {}\n// error: `#[link(...)]` specified without `name = \"foo\"`\n```\n\nPlease add the name parameter to allow the rust compiler to find the library\nyou want. Example:\n\n```no_run\n#[link(kind = \"dylib\", name = \"some_lib\")] extern \"C\" {} // ok!\n```\n"),
(E0460,
"Found possibly newer version of crate `..` which `..` depends on.\n\nConsider these erroneous files:\n\n`a1.rs`\n```ignore (needs-linkage-with-other-tests)\n#![crate_name = \"a\"]\n\npub fn foo<T>() {}\n```\n\n`a2.rs`\n```ignore (needs-linkage-with-other-tests)\n#![crate_name = \"a\"]\n\npub fn foo<T>() {\n println!(\"foo<T>()\");\n}\n```\n\n`b.rs`\n```ignore (needs-linkage-with-other-tests)\n#![crate_name = \"b\"]\n\nextern crate a; // linked with `a1.rs`\n\npub fn foo() {\n a::foo::<isize>();\n}\n```\n\n`main.rs`\n```ignore (needs-linkage-with-other-tests)\nextern crate a; // linked with `a2.rs`\nextern crate b; // error: found possibly newer version of crate `a` which `b`\n // depends on\n\nfn main() {}\n```\n\nThe dependency graph of this program can be represented as follows:\n```text\n crate `main`\n |\n +-------------+\n | |\n | v\ndepends: | crate `b`\n `a` v1 | |\n | | depends:\n | | `a` v2\n v |\n crate `a` <------+\n```\n\nCrate `main` depends on crate `a` (version 1) and crate `b` which in turn\ndepends on crate `a` (version 2); this discrepancy in versions cannot be\nreconciled. This difference in versions typically occurs when one crate is\ncompiled and linked, then updated and linked to another crate. The crate\n\"version\" is a SVH (Strict Version Hash) of the crate in an\nimplementation-specific way. Note that this error can *only* occur when\ndirectly compiling and linking with `rustc`; [Cargo] automatically resolves\ndependencies, without using the compiler\'s own dependency management that\ncauses this issue.\n\nThis error can be fixed by:\n * Using [Cargo], the Rust package manager, automatically fixing this issue.\n * Recompiling crate `a` so that both crate `b` and `main` have a uniform\n version to depend on.\n\n[Cargo]: ../cargo/index.html\n"),
(E0461,
"Couldn\'t find crate `..` with expected target triple `..`.\n\nExample of erroneous code:\n\n`a.rs`\n```ignore (cannot-link-with-other-tests)\n#![crate_type = \"lib\"]\n\nfn foo() {}\n```\n\n`main.rs`\n```ignore (cannot-link-with-other-tests)\nextern crate a;\n\nfn main() {\n a::foo();\n}\n```\n\n`a.rs` is then compiled with `--target powerpc-unknown-linux-gnu` and `b.rs`\nwith `--target x86_64-unknown-linux-gnu`. `a.rs` is compiled into a binary\nformat incompatible with `b.rs`; PowerPC and x86 are totally different\narchitectures. This issue also extends to any difference in target triples, as\n`std` is operating-system specific.\n\nThis error can be fixed by:\n * Using [Cargo](../cargo/index.html), the Rust package manager, automatically\n fixing this issue.\n * Recompiling either crate so that they target a consistent target triple.\n"),
(E0462,
"Found `staticlib` `..` instead of `rlib` or `dylib`.\n\nConsider the following two files:\n\n`a.rs`\n```ignore (cannot-link-with-other-tests)\n#![crate_type = \"staticlib\"]\n\nfn foo() {}\n```\n\n`main.rs`\n```ignore (cannot-link-with-other-tests)\nextern crate a;\n\nfn main() {\n a::foo();\n}\n```\n\nCrate `a` is compiled as a `staticlib`. A `staticlib` is a system-dependant\nlibrary only intended for linking with non-Rust applications (C programs). Note\nthat `staticlib`s include all upstream dependencies (`core`, `std`, other user\ndependencies, etc) which makes them significantly larger than `dylib`s:\nprefer `staticlib` for linking with C programs. Learn more about different\n`crate_type`s in [this section of the Reference](../reference/linkage.html).\n\nThis error can be fixed by:\n * Using [Cargo](../cargo/index.html), the Rust package manager, automatically\n fixing this issue.\n * Recompiling the crate as a `rlib` or `dylib`; formats suitable for Rust\n linking.\n"),
(E0463,
"A crate was declared but cannot be found.\n\nErroneous code example:\n\n```compile_fail,E0463\nextern crate foo; // error: can\'t find crate\n```\n\nYou need to link your code to the relevant crate in order to be able to use it\n(through Cargo or the `-L` option of rustc, for example).\n\n## Common causes\n\n- The crate is not present at all. If using Cargo, add it to `[dependencies]`\n in Cargo.toml.\n- The crate is present, but under a different name. If using Cargo, look for\n `package = ` under `[dependencies]` in Cargo.toml.\n\n## Common causes for missing `std` or `core`\n\n- You are cross-compiling for a target which doesn\'t have `std` prepackaged.\n Consider one of the following:\n + Adding a pre-compiled version of std with `rustup target add`\n + Building std from source with `cargo build -Z build-std`\n + Using `#![no_std]` at the crate root, so you won\'t need `std` in the first\n place.\n- You are developing the compiler itself and haven\'t built libstd from source.\n You can usually build it with `x.py build library/std`. More information\n about x.py is available in the [rustc-dev-guide].\n\n[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler\n"),
(E0464,
"The compiler found multiple library files with the requested crate name.\n\n```compile_fail\n// aux-build:crateresolve-1.rs\n// aux-build:crateresolve-2.rs\n// aux-build:crateresolve-3.rs\n\nextern crate crateresolve;\n//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found\n\nfn main() {}\n```\n\nThis error can occur in several different cases -- for example, when using\n`extern crate` or passing `--extern` options without crate paths. It can also be\ncaused by caching issues with the build directory, in which case `cargo clean`\nmay help.\n\nIn the above example, there are three different library files, all of which\ndefine the same crate name. Without providing a full path, there is no way for\nthe compiler to know which crate it should use.\n"),
(E0466,
"#### Note: this error code is no longer emitted by the compiler.\n\nMacro import declaration was malformed.\n\nErroneous code examples:\n\n```compile_fail\n#[macro_use(a_macro(another_macro))] // error: invalid import declaration\nextern crate core as some_crate;\n\n#[macro_use(i_want = \"some_macros\")] // error: invalid import declaration\nextern crate core as another_crate;\n```\n\nThis is a syntax error at the level of attribute declarations. The proper\nsyntax for macro imports is the following:\n\n```ignore (cannot-doctest-multicrate-project)\n// In some_crate:\n#[macro_export]\nmacro_rules! get_tacos {\n ...\n}\n\n#[macro_export]\nmacro_rules! get_pimientos {\n ...\n}\n\n// In your crate:\n#[macro_use(get_tacos, get_pimientos)] // It imports `get_tacos` and\nextern crate some_crate; // `get_pimientos` macros from some_crate\n```\n\nIf you would like to import all exported macros, write `macro_use` with no\narguments.\n"),
(E0468,
"A non-root module tried to import macros from another crate.\n\nExample of erroneous code:\n\n```compile_fail,E0468\nmod foo {\n #[macro_use(debug_assert)] // error: must be at crate root to import\n extern crate core; // macros from another crate\n fn run_macro() { debug_assert!(true); }\n}\n```\n\nOnly `extern crate` imports at the crate root level are allowed to import\nmacros.\n\nEither move the macro import to crate root or do without the foreign macros.\nThis will work:\n\n```\n#[macro_use(debug_assert)] // ok!\nextern crate core;\n\nmod foo {\n fn run_macro() { debug_assert!(true); }\n}\n# fn main() {}\n```\n"),
(E0469,
"A macro listed for import was not found.\n\nErroneous code example:\n\n```compile_fail,E0469\n#[macro_use(drink, be_merry)] // error: imported macro not found\nextern crate alloc;\n\nfn main() {\n // ...\n}\n```\n\nEither the listed macro is not contained in the imported crate, or it is not\nexported from the given crate.\n\nThis could be caused by a typo. Did you misspell the macro\'s name?\n\nDouble-check the names of the macros listed for import, and that the crate\nin question exports them.\n\nA working version would be:\n\n```ignore (cannot-doctest-multicrate-project)\n// In some_crate crate:\n#[macro_export]\nmacro_rules! eat {\n ...\n}\n\n#[macro_export]\nmacro_rules! drink {\n ...\n}\n\n// In your crate:\n#[macro_use(eat, drink)]\nextern crate some_crate; //ok!\n```\n"),
(E0472,
"Inline assembly (`asm!`) is not supported on this target.\n\nExample of erroneous code:\n\n```ignore (cannot-change-target)\n// compile-flags: --target sparc64-unknown-linux-gnu\n#![no_std]\n\nuse core::arch::asm;\n\nfn main() {\n unsafe {\n asm!(\"\"); // error: inline assembly is not supported on this target\n }\n}\n```\n\nThe Rust compiler does not support inline assembly, with the `asm!` macro\n(previously `llvm_asm!`), for all targets. All Tier 1 targets do support this\nmacro but support among Tier 2 and 3 targets is not guaranteed (even when they\nhave `std` support). Note that this error is related to\n`error[E0658]: inline assembly is not stable yet on this architecture`, but\ndistinct in that with `E0472` support is not planned or in progress.\n\nThere is no way to easily fix this issue, however:\n * Consider if you really need inline assembly, is there some other way to\n achieve your goal (intrinsics, etc)?\n * Consider writing your assembly externally, linking with it and calling it\n from Rust.\n * Consider contributing to <https://github.com/rust-lang/rust> and help\n integrate support for your target!\n"),
(E0476,
"The coerced type does not outlive the value being coerced to.\n\nExample of erroneous code:\n\n```compile_fail,E0476\n#![feature(coerce_unsized)]\n#![feature(unsize)]\n\nuse std::marker::Unsize;\nuse std::ops::CoerceUnsized;\n\n// error: lifetime of the source pointer does not outlive lifetime bound of the\n// object type\nimpl<\'a, \'b, T, S> CoerceUnsized<&\'a T> for &\'b S where S: Unsize<T> {}\n```\n\nDuring a coercion, the \"source pointer\" (the coerced type) did not outlive the\n\"object type\" (value being coerced to). In the above example, `\'b` is not a\nsubtype of `\'a`. This error can currently only be encountered with the unstable\n`CoerceUnsized` trait which allows custom coercions of unsized types behind a\nsmart pointer to be implemented.\n"),
(E0477,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe type does not fulfill the required lifetime.\n\nErroneous code example:\n\n```compile_fail\nuse std::sync::Mutex;\n\nstruct MyString<\'a> {\n data: &\'a str,\n}\n\nfn i_want_static_closure<F>(a: F)\n where F: Fn() + \'static {}\n\nfn print_string<\'a>(s: Mutex<MyString<\'a>>) {\n\n i_want_static_closure(move || { // error: this closure has lifetime \'a\n // rather than \'static\n println!(\"{}\", s.lock().unwrap().data);\n });\n}\n```\n\nIn this example, the closure does not satisfy the `\'static` lifetime constraint.\nTo fix this error, you need to double check the lifetime of the type. Here, we\ncan fix this problem by giving `s` a static lifetime:\n\n```\nuse std::sync::Mutex;\n\nstruct MyString<\'a> {\n data: &\'a str,\n}\n\nfn i_want_static_closure<F>(a: F)\n where F: Fn() + \'static {}\n\nfn print_string(s: Mutex<MyString<\'static>>) {\n\n i_want_static_closure(move || { // ok!\n println!(\"{}\", s.lock().unwrap().data);\n });\n}\n```\n"),
(E0478,
"A lifetime bound was not satisfied.\n\nErroneous code example:\n\n```compile_fail,E0478\n// Check that the explicit lifetime bound (`\'SnowWhite`, in this example) must\n// outlive all the superbounds from the trait (`\'kiss`, in this example).\n\ntrait Wedding<\'t>: \'t { }\n\nstruct Prince<\'kiss, \'SnowWhite> {\n child: Box<Wedding<\'kiss> + \'SnowWhite>,\n // error: lifetime bound not satisfied\n}\n```\n\nIn this example, the `\'SnowWhite` lifetime is supposed to outlive the `\'kiss`\nlifetime but the declaration of the `Prince` struct doesn\'t enforce it. To fix\nthis issue, you need to specify it:\n\n```\ntrait Wedding<\'t>: \'t { }\n\nstruct Prince<\'kiss, \'SnowWhite: \'kiss> { // You say here that \'SnowWhite\n // must live longer than \'kiss.\n child: Box<Wedding<\'kiss> + \'SnowWhite>, // And now it\'s all good!\n}\n```\n"),
(E0482,
"#### Note: this error code is no longer emitted by the compiler.\n\nA lifetime of a returned value does not outlive the function call.\n\nErroneous code example:\n\n```compile_fail,E0700\nfn prefix<\'a>(\n words: impl Iterator<Item = &\'a str>\n) -> impl Iterator<Item = String> { // error!\n words.map(|v| format!(\"foo-{}\", v))\n}\n```\n\nTo fix this error, make the lifetime of the returned value explicit:\n\n```\nfn prefix<\'a>(\n words: impl Iterator<Item = &\'a str> + \'a\n) -> impl Iterator<Item = String> + \'a { // ok!\n words.map(|v| format!(\"foo-{}\", v))\n}\n```\n\nThe [`impl Trait`] feature in this example uses an implicit `\'static` lifetime\nrestriction in the returned type. However the type implementing the `Iterator`\npassed to the function lives just as long as `\'a`, which is not long enough.\n\nThe solution involves adding lifetime bound to both function argument and\nthe return value to make sure that the values inside the iterator\nare not dropped when the function goes out of the scope.\n\nAn alternative solution would be to guarantee that the `Item` references\nin the iterator are alive for the whole lifetime of the program.\n\n```\nfn prefix(\n words: impl Iterator<Item = &\'static str>\n) -> impl Iterator<Item = String> { // ok!\n words.map(|v| format!(\"foo-{}\", v))\n}\n```\n\nA similar lifetime problem might arise when returning closures:\n\n```compile_fail,E0700\nfn foo(\n x: &mut Vec<i32>\n) -> impl FnMut(&mut Vec<i32>) -> &[i32] { // error!\n |y| {\n y.append(x);\n y\n }\n}\n```\n\nAnalogically, a solution here is to use explicit return lifetime\nand move the ownership of the variable to the closure.\n\n```\nfn foo<\'a>(\n x: &\'a mut Vec<i32>\n) -> impl FnMut(&mut Vec<i32>) -> &[i32] + \'a { // ok!\n move |y| {\n y.append(x);\n y\n }\n}\n```\n\nTo better understand the lifetime treatment in the [`impl Trait`],\nplease see the [RFC 1951].\n\n[`impl Trait`]: https://doc.rust-lang.org/reference/types/impl-trait.html\n[RFC 1951]: https://rust-lang.github.io/rfcs/1951-expand-impl-trait.html\n"),
(E0491,
"A reference has a longer lifetime than the data it references.\n\nErroneous code example:\n\n```compile_fail,E0491\nstruct Foo<\'a> {\n x: fn(&\'a i32),\n}\n\ntrait Trait<\'a, \'b> {\n type Out;\n}\n\nimpl<\'a, \'b> Trait<\'a, \'b> for usize {\n type Out = &\'a Foo<\'b>; // error!\n}\n```\n\nHere, the problem is that the compiler cannot be sure that the `\'b` lifetime\nwill live longer than `\'a`, which should be mandatory in order to be sure that\n`Trait::Out` will always have a reference pointing to an existing type. So in\nthis case, we just need to tell the compiler than `\'b` must outlive `\'a`:\n\n```\nstruct Foo<\'a> {\n x: fn(&\'a i32),\n}\n\ntrait Trait<\'a, \'b> {\n type Out;\n}\n\nimpl<\'a, \'b: \'a> Trait<\'a, \'b> for usize { // we added the lifetime enforcement\n type Out = &\'a Foo<\'b>; // it now works!\n}\n```\n"),
(E0492,
"A borrow of a constant containing interior mutability was attempted.\n\nErroneous code example:\n\n```compile_fail,E0492\nuse std::sync::atomic::AtomicUsize;\n\nconst A: AtomicUsize = AtomicUsize::new(0);\nconst B: &\'static AtomicUsize = &A;\n// error: cannot borrow a constant which may contain interior mutability,\n// create a static instead\n```\n\nA `const` represents a constant value that should never change. If one takes\na `&` reference to the constant, then one is taking a pointer to some memory\nlocation containing the value. Normally this is perfectly fine: most values\ncan\'t be changed via a shared `&` pointer, but interior mutability would allow\nit. That is, a constant value could be mutated. On the other hand, a `static` is\nexplicitly a single memory location, which can be mutated at will.\n\nSo, in order to solve this error, use statics which are `Sync`:\n\n```\nuse std::sync::atomic::AtomicUsize;\n\nstatic A: AtomicUsize = AtomicUsize::new(0);\nstatic B: &\'static AtomicUsize = &A; // ok!\n```\n\nYou can also have this error while using a cell type:\n\n```compile_fail,E0492\nuse std::cell::Cell;\n\nconst A: Cell<usize> = Cell::new(1);\nconst B: &Cell<usize> = &A;\n// error: cannot borrow a constant which may contain interior mutability,\n// create a static instead\n\n// or:\nstruct C { a: Cell<usize> }\n\nconst D: C = C { a: Cell::new(1) };\nconst E: &Cell<usize> = &D.a; // error\n\n// or:\nconst F: &C = &D; // error\n```\n\nThis is because cell types do operations that are not thread-safe. Due to this,\nthey don\'t implement Sync and thus can\'t be placed in statics.\n\nHowever, if you still wish to use these types, you can achieve this by an unsafe\nwrapper:\n\n```\nuse std::cell::Cell;\n\nstruct NotThreadSafe<T> {\n value: Cell<T>,\n}\n\nunsafe impl<T> Sync for NotThreadSafe<T> {}\n\nstatic A: NotThreadSafe<usize> = NotThreadSafe { value : Cell::new(1) };\nstatic B: &\'static NotThreadSafe<usize> = &A; // ok!\n```\n\nRemember this solution is unsafe! You will have to ensure that accesses to the\ncell are synchronized.\n"),
(E0493,
"A value with a custom `Drop` implementation may be dropped during const-eval.\n\nErroneous code example:\n\n```compile_fail,E0493\nenum DropType {\n A,\n}\n\nimpl Drop for DropType {\n fn drop(&mut self) {}\n}\n\nstruct Foo {\n field1: DropType,\n}\n\nstatic FOO: Foo = Foo { field1: (DropType::A, DropType::A).1 }; // error!\n```\n\nThe problem here is that if the given type or one of its fields implements the\n`Drop` trait, this `Drop` implementation cannot be called within a const\ncontext since it may run arbitrary, non-const-checked code. To prevent this\nissue, ensure all values with a custom `Drop` implementation escape the\ninitializer.\n\n```\nenum DropType {\n A,\n}\n\nimpl Drop for DropType {\n fn drop(&mut self) {}\n}\n\nstruct Foo {\n field1: DropType,\n}\n\nstatic FOO: Foo = Foo { field1: DropType::A }; // We initialize all fields\n // by hand.\n```\n"),
(E0495,
"#### Note: this error code is no longer emitted by the compiler.\n\nA lifetime cannot be determined in the given situation.\n\nErroneous code example:\n\n```compile_fail\nfn transmute_lifetime<\'a, \'b, T>(t: &\'a (T,)) -> &\'b T {\n match (&t,) { // error!\n ((u,),) => u,\n }\n}\n\nlet y = Box::new((42,));\nlet x = transmute_lifetime(&y);\n```\n\nIn this code, you have two ways to solve this issue:\n 1. Enforce that `\'a` lives at least as long as `\'b`.\n 2. Use the same lifetime requirement for both input and output values.\n\nSo for the first solution, you can do it by replacing `\'a` with `\'a: \'b`:\n\n```\nfn transmute_lifetime<\'a: \'b, \'b, T>(t: &\'a (T,)) -> &\'b T {\n match (&t,) { // ok!\n ((u,),) => u,\n }\n}\n```\n\nIn the second you can do it by simply removing `\'b` so they both use `\'a`:\n\n```\nfn transmute_lifetime<\'a, T>(t: &\'a (T,)) -> &\'a T {\n match (&t,) { // ok!\n ((u,),) => u,\n }\n}\n```\n"),
(E0496,
"A lifetime name is shadowing another lifetime name.\n\nErroneous code example:\n\n```compile_fail,E0496\nstruct Foo<\'a> {\n a: &\'a i32,\n}\n\nimpl<\'a> Foo<\'a> {\n fn f<\'a>(x: &\'a i32) { // error: lifetime name `\'a` shadows a lifetime\n // name that is already in scope\n }\n}\n```\n\nPlease change the name of one of the lifetimes to remove this error. Example:\n\n```\nstruct Foo<\'a> {\n a: &\'a i32,\n}\n\nimpl<\'a> Foo<\'a> {\n fn f<\'b>(x: &\'b i32) { // ok!\n }\n}\n\nfn main() {\n}\n```\n"),
(E0497,
"#### Note: this error code is no longer emitted by the compiler.\n\nA stability attribute was used outside of the standard library.\n\nErroneous code example:\n\n```compile_fail\n#[stable] // error: stability attributes may not be used outside of the\n // standard library\nfn foo() {}\n```\n\nIt is not possible to use stability attributes outside of the standard library.\nAlso, for now, it is not possible to write deprecation messages either.\n"),
(E0498,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `plugin` attribute was malformed.\n\nErroneous code example:\n\n```ignore (E0498 is no longer emitted)\n#![feature(plugin)]\n#![plugin(foo(args))] // error: invalid argument\n#![plugin(bar=\"test\")] // error: invalid argument\n```\n\nThe `#[plugin]` attribute should take a single argument: the name of the plugin.\n\nFor example, for the plugin `foo`:\n\n```ignore (requires external plugin crate)\n#![feature(plugin)]\n#![plugin(foo)] // ok!\n```\n\nSee the [`plugin` feature] section of the Unstable book for more details.\n\n[`plugin` feature]: https://doc.rust-lang.org/nightly/unstable-book/language-features/plugin.html\n"),
(E0499,
"A variable was borrowed as mutable more than once.\n\nErroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\nx;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in Rust, you can either have many immutable references, or one\nmutable reference. For more details you may want to read the\n[References & Borrowing][references-and-borrowing] section of the Book.\n\n[references-and-borrowing]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n\nExample:\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\nb;\na;\n```\n"),
(E0500,
"A borrowed variable was used by a closure.\n\nErroneous code example:\n\n```compile_fail,E0500\nfn you_know_nothing(jon_snow: &mut i32) {\n let nights_watch = &jon_snow;\n let starks = || {\n *jon_snow = 3; // error: closure requires unique access to `jon_snow`\n // but it is already borrowed\n };\n println!(\"{}\", nights_watch);\n}\n```\n\nIn here, `jon_snow` is already borrowed by the `nights_watch` reference, so it\ncannot be borrowed by the `starks` closure at the same time. To fix this issue,\nyou can create the closure after the borrow has ended:\n\n```\nfn you_know_nothing(jon_snow: &mut i32) {\n let nights_watch = &jon_snow;\n println!(\"{}\", nights_watch);\n let starks = || {\n *jon_snow = 3;\n };\n}\n```\n\nOr, if the type implements the `Clone` trait, you can clone it between\nclosures:\n\n```\nfn you_know_nothing(jon_snow: &mut i32) {\n let mut jon_copy = jon_snow.clone();\n let starks = || {\n *jon_snow = 3;\n };\n println!(\"{}\", jon_copy);\n}\n```\n"),
(E0501,
"A mutable variable is used but it is already captured by a closure.\n\nErroneous code example:\n\n```compile_fail,E0501\nfn inside_closure(x: &mut i32) {\n // Actions which require unique access\n}\n\nfn outside_closure(x: &mut i32) {\n // Actions which require unique access\n}\n\nfn foo(a: &mut i32) {\n let mut bar = || {\n inside_closure(a)\n };\n outside_closure(a); // error: cannot borrow `*a` as mutable because previous\n // closure requires unique access.\n bar();\n}\n```\n\nThis error indicates that a mutable variable is used while it is still captured\nby a closure. Because the closure has borrowed the variable, it is not available\nuntil the closure goes out of scope.\n\nNote that a capture will either move or borrow a variable, but in this\nsituation, the closure is borrowing the variable. Take a look at the chapter\non [Capturing][capturing] in Rust By Example for more information.\n\n[capturing]: https://doc.rust-lang.org/stable/rust-by-example/fn/closures/capture.html\n\nTo fix this error, you can finish using the closure before using the captured\nvariable:\n\n```\nfn inside_closure(x: &mut i32) {}\nfn outside_closure(x: &mut i32) {}\n\nfn foo(a: &mut i32) {\n let mut bar = || {\n inside_closure(a)\n };\n bar();\n // borrow on `a` ends.\n outside_closure(a); // ok!\n}\n```\n\nOr you can pass the variable as a parameter to the closure:\n\n```\nfn inside_closure(x: &mut i32) {}\nfn outside_closure(x: &mut i32) {}\n\nfn foo(a: &mut i32) {\n let mut bar = |s: &mut i32| {\n inside_closure(s)\n };\n outside_closure(a);\n bar(a);\n}\n```\n\nIt may be possible to define the closure later:\n\n```\nfn inside_closure(x: &mut i32) {}\nfn outside_closure(x: &mut i32) {}\n\nfn foo(a: &mut i32) {\n outside_closure(a);\n let mut bar = || {\n inside_closure(a)\n };\n bar();\n}\n```\n"),
(E0502,
"A variable already borrowed with a certain mutability (either mutable or\nimmutable) was borrowed again with a different mutability.\n\nErroneous code example:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n let y = &a; // a is borrowed as immutable.\n bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n // as immutable\n println!(\"{}\", y);\n}\n```\n\nTo fix this error, ensure that you don\'t have any other references to the\nvariable before trying to access it with a different mutability:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n bar(a);\n let y = &a; // ok!\n println!(\"{}\", y);\n}\n```\n\nFor more information on Rust\'s ownership system, take a look at the\n[References & Borrowing][references-and-borrowing] section of the Book.\n\n[references-and-borrowing]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"),
(E0503,
"A value was used after it was mutably borrowed.\n\nErroneous code example:\n\n```compile_fail,E0503\nfn main() {\n let mut value = 3;\n // Create a mutable borrow of `value`.\n let borrow = &mut value;\n let _sum = value + 1; // error: cannot use `value` because\n // it was mutably borrowed\n println!(\"{}\", borrow);\n}\n```\n\nIn this example, `value` is mutably borrowed by `borrow` and cannot be\nused to calculate `sum`. This is not possible because this would violate\nRust\'s mutability rules.\n\nYou can fix this error by finishing using the borrow before the next use of\nthe value:\n\n```\nfn main() {\n let mut value = 3;\n let borrow = &mut value;\n println!(\"{}\", borrow);\n // The block has ended and with it the borrow.\n // You can now use `value` again.\n let _sum = value + 1;\n}\n```\n\nOr by cloning `value` before borrowing it:\n\n```\nfn main() {\n let mut value = 3;\n // We clone `value`, creating a copy.\n let value_cloned = value.clone();\n // The mutable borrow is a reference to `value` and\n // not to `value_cloned`...\n let borrow = &mut value;\n // ... which means we can still use `value_cloned`,\n let _sum = value_cloned + 1;\n // even though the borrow only ends here.\n println!(\"{}\", borrow);\n}\n```\n\nFor more information on Rust\'s ownership system, take a look at the\n[References & Borrowing][references-and-borrowing] section of the Book.\n\n[references-and-borrowing]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"),
(E0504,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error occurs when an attempt is made to move a borrowed variable into a\nclosure.\n\nErroneous code example:\n\n```compile_fail\nstruct FancyNum {\n num: u8,\n}\n\nfn main() {\n let fancy_num = FancyNum { num: 5 };\n let fancy_ref = &fancy_num;\n\n let x = move || {\n println!(\"child function: {}\", fancy_num.num);\n // error: cannot move `fancy_num` into closure because it is borrowed\n };\n\n x();\n println!(\"main function: {}\", fancy_ref.num);\n}\n```\n\nHere, `fancy_num` is borrowed by `fancy_ref` and so cannot be moved into\nthe closure `x`. There is no way to move a value into a closure while it is\nborrowed, as that would invalidate the borrow.\n\nIf the closure can\'t outlive the value being moved, try using a reference\nrather than moving:\n\n```\nstruct FancyNum {\n num: u8,\n}\n\nfn main() {\n let fancy_num = FancyNum { num: 5 };\n let fancy_ref = &fancy_num;\n\n let x = move || {\n // fancy_ref is usable here because it doesn\'t move `fancy_num`\n println!(\"child function: {}\", fancy_ref.num);\n };\n\n x();\n\n println!(\"main function: {}\", fancy_num.num);\n}\n```\n\nIf the value has to be borrowed and then moved, try limiting the lifetime of\nthe borrow using a scoped block:\n\n```\nstruct FancyNum {\n num: u8,\n}\n\nfn main() {\n let fancy_num = FancyNum { num: 5 };\n\n {\n let fancy_ref = &fancy_num;\n println!(\"main function: {}\", fancy_ref.num);\n // `fancy_ref` goes out of scope here\n }\n\n let x = move || {\n // `fancy_num` can be moved now (no more references exist)\n println!(\"child function: {}\", fancy_num.num);\n };\n\n x();\n}\n```\n\nIf the lifetime of a reference isn\'t enough, such as in the case of threading,\nconsider using an `Arc` to create a reference-counted value:\n\n```\nuse std::sync::Arc;\nuse std::thread;\n\nstruct FancyNum {\n num: u8,\n}\n\nfn main() {\n let fancy_ref1 = Arc::new(FancyNum { num: 5 });\n let fancy_ref2 = fancy_ref1.clone();\n\n let x = thread::spawn(move || {\n // `fancy_ref1` can be moved and has a `\'static` lifetime\n println!(\"child thread: {}\", fancy_ref1.num);\n });\n\n x.join().expect(\"child thread should finish\");\n println!(\"main thread: {}\", fancy_ref2.num);\n}\n```\n"),
(E0505,
"A value was moved out while it was still borrowed.\n\nErroneous code example:\n\n```compile_fail,E0505\nstruct Value {}\n\nfn borrow(val: &Value) {}\n\nfn eat(val: Value) {}\n\nfn main() {\n let x = Value{};\n let _ref_to_val: &Value = &x;\n eat(x);\n borrow(_ref_to_val);\n}\n```\n\nHere, the function `eat` takes ownership of `x`. However,\n`x` cannot be moved because the borrow to `_ref_to_val`\nneeds to last till the function `borrow`.\nTo fix that you can do a few different things:\n\n* Try to avoid moving the variable.\n* Release borrow before move.\n* Implement the `Copy` trait on the type.\n\nExamples:\n\n```\nstruct Value {}\n\nfn borrow(val: &Value) {}\n\nfn eat(val: &Value) {}\n\nfn main() {\n let x = Value{};\n\n let ref_to_val: &Value = &x;\n eat(&x); // pass by reference, if it\'s possible\n borrow(ref_to_val);\n}\n```\n\nOr:\n\n```\nstruct Value {}\n\nfn borrow(val: &Value) {}\n\nfn eat(val: Value) {}\n\nfn main() {\n let x = Value{};\n\n let ref_to_val: &Value = &x;\n borrow(ref_to_val);\n // ref_to_val is no longer used.\n eat(x);\n}\n```\n\nOr:\n\n```\n#[derive(Clone, Copy)] // implement Copy trait\nstruct Value {}\n\nfn borrow(val: &Value) {}\n\nfn eat(val: Value) {}\n\nfn main() {\n let x = Value{};\n let ref_to_val: &Value = &x;\n eat(x); // it will be copied here.\n borrow(ref_to_val);\n}\n```\n\nFor more information on Rust\'s ownership system, take a look at the\n[References & Borrowing][references-and-borrowing] section of the Book.\n\n[references-and-borrowing]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"),
(E0506,
"An attempt was made to assign to a borrowed value.\n\nErroneous code example:\n\n```compile_fail,E0506\nstruct FancyNum {\n num: u8,\n}\n\nlet mut fancy_num = FancyNum { num: 5 };\nlet fancy_ref = &fancy_num;\nfancy_num = FancyNum { num: 6 };\n// error: cannot assign to `fancy_num` because it is borrowed\n\nprintln!(\"Num: {}, Ref: {}\", fancy_num.num, fancy_ref.num);\n```\n\nBecause `fancy_ref` still holds a reference to `fancy_num`, `fancy_num` can\'t\nbe assigned to a new value as it would invalidate the reference.\n\nAlternatively, we can move out of `fancy_num` into a second `fancy_num`:\n\n```\nstruct FancyNum {\n num: u8,\n}\n\nlet mut fancy_num = FancyNum { num: 5 };\nlet moved_num = fancy_num;\nfancy_num = FancyNum { num: 6 };\n\nprintln!(\"Num: {}, Moved num: {}\", fancy_num.num, moved_num.num);\n```\n\nIf the value has to be borrowed, try limiting the lifetime of the borrow using\na scoped block:\n\n```\nstruct FancyNum {\n num: u8,\n}\n\nlet mut fancy_num = FancyNum { num: 5 };\n\n{\n let fancy_ref = &fancy_num;\n println!(\"Ref: {}\", fancy_ref.num);\n}\n\n// Works because `fancy_ref` is no longer in scope\nfancy_num = FancyNum { num: 6 };\nprintln!(\"Num: {}\", fancy_num.num);\n```\n\nOr by moving the reference into a function:\n\n```\nstruct FancyNum {\n num: u8,\n}\n\nfn print_fancy_ref(fancy_ref: &FancyNum){\n println!(\"Ref: {}\", fancy_ref.num);\n}\n\nlet mut fancy_num = FancyNum { num: 5 };\n\nprint_fancy_ref(&fancy_num);\n\n// Works because function borrow has ended\nfancy_num = FancyNum { num: 6 };\nprintln!(\"Num: {}\", fancy_num.num);\n```\n"),
(E0507,
"A borrowed value was moved out.\n\nErroneous code example:\n\n```compile_fail,E0507\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n fn nothing_is_true(self) {}\n}\n\nfn main() {\n let x = RefCell::new(TheDarkKnight);\n\n x.borrow().nothing_is_true(); // error: cannot move out of borrowed content\n}\n```\n\nHere, the `nothing_is_true` method takes the ownership of `self`. However,\n`self` cannot be moved because `.borrow()` only provides an `&TheDarkKnight`,\nwhich is a borrow of the content owned by the `RefCell`. To fix this error,\nyou have three choices:\n\n* Try to avoid moving the variable.\n* Somehow reclaim the ownership.\n* Implement the `Copy` trait on the type.\n\nThis can also happen when using a type implementing `Fn` or `FnMut`, as neither\nallows moving out of them (they usually represent closures which can be called\nmore than once). Much of the text following applies equally well to non-`FnOnce`\nclosure bodies.\n\nExamples:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n fn nothing_is_true(&self) {} // First case, we don\'t take ownership\n}\n\nfn main() {\n let x = RefCell::new(TheDarkKnight);\n\n x.borrow().nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n fn nothing_is_true(self) {}\n}\n\nfn main() {\n let x = RefCell::new(TheDarkKnight);\n let x = x.into_inner(); // we get back ownership\n\n x.nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\n#[derive(Clone, Copy)] // we implement the Copy trait\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n fn nothing_is_true(self) {}\n}\n\nfn main() {\n let x = RefCell::new(TheDarkKnight);\n\n x.borrow().nothing_is_true(); // ok!\n}\n```\n\nMoving a member out of a mutably borrowed struct will also cause E0507 error:\n\n```compile_fail,E0507\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n fn nothing_is_true(self) {}\n}\n\nstruct Batcave {\n knight: TheDarkKnight\n}\n\nfn main() {\n let mut cave = Batcave {\n knight: TheDarkKnight\n };\n let borrowed = &mut cave;\n\n borrowed.knight.nothing_is_true(); // E0507\n}\n```\n\nIt is fine only if you put something back. `mem::replace` can be used for that:\n\n```\n# struct TheDarkKnight;\n# impl TheDarkKnight { fn nothing_is_true(self) {} }\n# struct Batcave { knight: TheDarkKnight }\nuse std::mem;\n\nlet mut cave = Batcave {\n knight: TheDarkKnight\n};\nlet borrowed = &mut cave;\n\nmem::replace(&mut borrowed.knight, TheDarkKnight).nothing_is_true(); // ok!\n```\n\nFor more information on Rust\'s ownership system, take a look at the\n[References & Borrowing][references-and-borrowing] section of the Book.\n\n[references-and-borrowing]: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"),
(E0508,
"A value was moved out of a non-copy fixed-size array.\n\nErroneous code example:\n\n```compile_fail,E0508\nstruct NonCopy;\n\nfn main() {\n let array = [NonCopy; 1];\n let _value = array[0]; // error: cannot move out of type `[NonCopy; 1]`,\n // a non-copy fixed-size array\n}\n```\n\nThe first element was moved out of the array, but this is not\npossible because `NonCopy` does not implement the `Copy` trait.\n\nConsider borrowing the element instead of moving it:\n\n```\nstruct NonCopy;\n\nfn main() {\n let array = [NonCopy; 1];\n let _value = &array[0]; // Borrowing is allowed, unlike moving.\n}\n```\n\nAlternatively, if your type implements `Clone` and you need to own the value,\nconsider borrowing and then cloning:\n\n```\n#[derive(Clone)]\nstruct NonCopy;\n\nfn main() {\n let array = [NonCopy; 1];\n // Now you can clone the array element.\n let _value = array[0].clone();\n}\n```\n\nIf you really want to move the value out, you can use a destructuring array\npattern to move it:\n\n```\nstruct NonCopy;\n\nfn main() {\n let array = [NonCopy; 1];\n // Destructuring the array\n let [_value] = array;\n}\n```\n"),
(E0509,
"This error occurs when an attempt is made to move out of a value whose type\nimplements the `Drop` trait.\n\nErroneous code example:\n\n```compile_fail,E0509\nstruct FancyNum {\n num: usize\n}\n\nstruct DropStruct {\n fancy: FancyNum\n}\n\nimpl Drop for DropStruct {\n fn drop(&mut self) {\n // Destruct DropStruct, possibly using FancyNum\n }\n}\n\nfn main() {\n let drop_struct = DropStruct{fancy: FancyNum{num: 5}};\n let fancy_field = drop_struct.fancy; // Error E0509\n println!(\"Fancy: {}\", fancy_field.num);\n // implicit call to `drop_struct.drop()` as drop_struct goes out of scope\n}\n```\n\nHere, we tried to move a field out of a struct of type `DropStruct` which\nimplements the `Drop` trait. However, a struct cannot be dropped if one or\nmore of its fields have been moved.\n\nStructs implementing the `Drop` trait have an implicit destructor that gets\ncalled when they go out of scope. This destructor may use the fields of the\nstruct, so moving out of the struct could make it impossible to run the\ndestructor. Therefore, we must think of all values whose type implements the\n`Drop` trait as single units whose fields cannot be moved.\n\nThis error can be fixed by creating a reference to the fields of a struct,\nenum, or tuple using the `ref` keyword:\n\n```\nstruct FancyNum {\n num: usize\n}\n\nstruct DropStruct {\n fancy: FancyNum\n}\n\nimpl Drop for DropStruct {\n fn drop(&mut self) {\n // Destruct DropStruct, possibly using FancyNum\n }\n}\n\nfn main() {\n let drop_struct = DropStruct{fancy: FancyNum{num: 5}};\n let ref fancy_field = drop_struct.fancy; // No more errors!\n println!(\"Fancy: {}\", fancy_field.num);\n // implicit call to `drop_struct.drop()` as drop_struct goes out of scope\n}\n```\n\nNote that this technique can also be used in the arms of a match expression:\n\n```\nstruct FancyNum {\n num: usize\n}\n\nenum DropEnum {\n Fancy(FancyNum)\n}\n\nimpl Drop for DropEnum {\n fn drop(&mut self) {\n // Destruct DropEnum, possibly using FancyNum\n }\n}\n\nfn main() {\n // Creates and enum of type `DropEnum`, which implements `Drop`\n let drop_enum = DropEnum::Fancy(FancyNum{num: 10});\n match drop_enum {\n // Creates a reference to the inside of `DropEnum::Fancy`\n DropEnum::Fancy(ref fancy_field) => // No error!\n println!(\"It was fancy-- {}!\", fancy_field.num),\n }\n // implicit call to `drop_enum.drop()` as drop_enum goes out of scope\n}\n```\n"),
(E0510,
"The matched value was assigned in a match guard.\n\nErroneous code example:\n\n```compile_fail,E0510\nlet mut x = Some(0);\nmatch x {\n None => {}\n Some(_) if { x = None; false } => {} // error!\n Some(_) => {}\n}\n```\n\nWhen matching on a variable it cannot be mutated in the match guards, as this\ncould cause the match to be non-exhaustive.\n\nHere executing `x = None` would modify the value being matched and require us\nto go \"back in time\" to the `None` arm. To fix it, change the value in the match\narm:\n\n```\nlet mut x = Some(0);\nmatch x {\n None => {}\n Some(_) => {\n x = None; // ok!\n }\n}\n```\n"),
(E0511,
"Invalid monomorphization of an intrinsic function was used.\n\nErroneous code example:\n\n```compile_fail,E0511\n#![feature(intrinsics)]\n\n#[rustc_intrinsic]\nunsafe fn simd_add<T>(a: T, b: T) -> T;\n\nfn main() {\n unsafe { simd_add(0, 1); }\n // error: invalid monomorphization of `simd_add` intrinsic\n}\n```\n\nThe generic type has to be a SIMD type. Example:\n\n```\n#![feature(repr_simd)]\n#![feature(intrinsics)]\n\n#[repr(simd)]\n#[derive(Copy, Clone)]\nstruct i32x2([i32; 2]);\n\n#[rustc_intrinsic]\nunsafe fn simd_add<T>(a: T, b: T) -> T;\n\nunsafe { simd_add(i32x2([0, 0]), i32x2([1, 2])); } // ok!\n```\n"),
(E0512,
"Transmute with two differently sized types was attempted.\n\nErroneous code example:\n\n```compile_fail,E0512\nfn takes_u8(_: u8) {}\n\nfn main() {\n unsafe { takes_u8(::std::mem::transmute(0u16)); }\n // error: cannot transmute between types of different sizes,\n // or dependently-sized types\n}\n```\n\nPlease use types with same size or use the expected type directly. Example:\n\n```\nfn takes_u8(_: u8) {}\n\nfn main() {\n unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!\n // or:\n unsafe { takes_u8(0u8); } // ok!\n}\n```\n"),
(E0514,
"Dependency compiled with different version of `rustc`.\n\nExample of erroneous code:\n\n`a.rs`\n```ignore (cannot-link-with-other-tests)\n// compiled with stable `rustc`\n\n#[crate_type = \"lib\"]\n```\n\n`b.rs`\n```ignore (cannot-link-with-other-tests)\n// compiled with nightly `rustc`\n\n#[crate_type = \"lib\"]\n\nextern crate a; // error: found crate `a` compiled by an incompatible version\n // of rustc\n```\n\nThis error is caused when the version of `rustc` used to compile a crate, as\nstored in the binary\'s metadata, differs from the version of one of its\ndependencies. Many parts of Rust binaries are considered unstable. For\ninstance, the Rust ABI is not stable between compiler versions. This means that\nthe compiler cannot be sure about *how* to call a function between compiler\nversions, and therefore this error occurs.\n\nThis error can be fixed by:\n * Using [Cargo](../cargo/index.html), the Rust package manager and\n [Rustup](https://rust-lang.github.io/rustup/), the Rust toolchain installer,\n automatically fixing this issue.\n * Recompiling the crates with a uniform `rustc` version.\n"),
(E0515,
"A reference to a local variable was returned.\n\nErroneous code example:\n\n```compile_fail,E0515\nfn get_dangling_reference() -> &\'static i32 {\n let x = 0;\n &x\n}\n```\n\n```compile_fail,E0515\nuse std::slice::Iter;\nfn get_dangling_iterator<\'a>() -> Iter<\'a, i32> {\n let v = vec![1, 2, 3];\n v.iter()\n}\n```\n\nLocal variables, function parameters and temporaries are all dropped before\nthe end of the function body. A returned reference (or struct containing a\nreference) to such a dropped value would immediately be invalid. Therefore\nit is not allowed to return such a reference.\n\nConsider returning a value that takes ownership of local data instead of\nreferencing it:\n\n```\nuse std::vec::IntoIter;\n\nfn get_integer() -> i32 {\n let x = 0;\n x\n}\n\nfn get_owned_iterator() -> IntoIter<i32> {\n let v = vec![1, 2, 3];\n v.into_iter()\n}\n```\n"),
(E0516,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `typeof` keyword is currently reserved but unimplemented.\n\nErroneous code example:\n\n```compile_fail,E0516\nfn main() {\n let x: typeof(92) = 92;\n}\n```\n\nTry using type inference instead. Example:\n\n```\nfn main() {\n let x = 92;\n}\n```\n"),
(E0517,
"A `#[repr(..)]` attribute was placed on an unsupported item.\n\nExamples of erroneous code:\n\n```compile_fail,E0517\n#[repr(C)]\ntype Foo = u8;\n\n#[repr(packed)]\nenum Foo {Bar, Baz}\n\n#[repr(u8)]\nstruct Foo {bar: bool, baz: bool}\n\n#[repr(C)]\nimpl Foo {\n // ...\n}\n```\n\n* The `#[repr(C)]` attribute can only be placed on structs and enums.\n* The `#[repr(packed)]` and `#[repr(simd)]` attributes only work on structs.\n* The `#[repr(u8)]`, `#[repr(i16)]`, etc attributes only work on enums.\n\nThese attributes do not work on typedefs, since typedefs are just aliases.\n\nRepresentations like `#[repr(u8)]`, `#[repr(i64)]` are for selecting the\ndiscriminant size for enums. For enums with no data fields on any of the\nvariants, e.g. `enum Color {Red, Blue, Green}`, this effectively sets the size\nof the enum to the size of the provided type. Such an enum can be cast to a\nvalue of the same type as well. In short, `#[repr(u8)]` makes a field-less enum\nbehave like an integer with a constrained set of allowed values.\n\nFor a description of how `#[repr(C)]` and representations like `#[repr(u8)]`\naffect the layout of enums with data fields, see [RFC 2195][rfc2195].\n\nOnly field-less enums can be cast to numerical primitives. Representations like\n`#[repr(u8)]` will not apply to structs.\n\n`#[repr(packed)]` reduces padding to make the struct size smaller. The\nrepresentation of enums isn\'t strictly defined in Rust, and this attribute\nwon\'t work on enums.\n\n`#[repr(simd)]` will give a struct consisting of a homogeneous series of machine\ntypes (i.e., `u8`, `i32`, etc) a representation that permits vectorization via\nSIMD. This doesn\'t make much sense for enums since they don\'t consist of a\nsingle list of data.\n\n[rfc2195]: https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md\n"),
(E0518,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn `#[inline(..)]` attribute was incorrectly placed on something other than a\nfunction or method.\n\nExample of erroneous code:\n\n```ignore (no longer emitted)\n#[inline(always)]\nstruct Foo;\n\n#[inline(never)]\nimpl Foo {\n // ...\n}\n```\n\n`#[inline]` hints the compiler whether or not to attempt to inline a method or\nfunction. By default, the compiler does a pretty good job of figuring this out\nitself, but if you feel the need for annotations, `#[inline(always)]` and\n`#[inline(never)]` can override or force the compiler\'s decision.\n\nIf you wish to apply this attribute to all methods in an impl, manually annotate\neach method; it is not possible to annotate the entire impl with an `#[inline]`\nattribute.\n"),
(E0519,
"The current crate is indistinguishable from one of its dependencies, in terms\nof metadata.\n\nExample of erroneous code:\n\n`a.rs`\n```ignore (cannot-link-with-other-tests)\n#![crate_name = \"a\"]\n#![crate_type = \"lib\"]\n\npub fn foo() {}\n```\n\n`b.rs`\n```ignore (cannot-link-with-other-tests)\n#![crate_name = \"a\"]\n#![crate_type = \"lib\"]\n\n// error: the current crate is indistinguishable from one of its dependencies:\n// it has the same crate-name `a` and was compiled with the same\n// `-C metadata` arguments. This will result in symbol conflicts between\n// the two.\nextern crate a;\n\npub fn foo() {}\n\nfn bar() {\n a::foo(); // is this calling the local crate or the dependency?\n}\n```\n\nThe above example compiles two crates with exactly the same name and\n`crate_type` (plus any other metadata). This causes an error because it becomes\nimpossible for the compiler to distinguish between symbols (`pub` item names).\n\nThis error can be fixed by:\n * Using [Cargo](../cargo/index.html), the Rust package manager, automatically\n fixing this issue.\n * Recompiling the crate with different metadata (different name/\n `crate_type`).\n"),
(E0520,
"A non-default implementation was already made on this type so it cannot be\nspecialized further.\n\nErroneous code example:\n\n```compile_fail,E0520\n#![feature(specialization)]\n\ntrait SpaceLlama {\n fn fly(&self);\n}\n\n// applies to all T\nimpl<T> SpaceLlama for T {\n default fn fly(&self) {}\n}\n\n// non-default impl\n// applies to all `Clone` T and overrides the previous impl\nimpl<T: Clone> SpaceLlama for T {\n fn fly(&self) {}\n}\n\n// since `i32` is clone, this conflicts with the previous implementation\nimpl SpaceLlama for i32 {\n default fn fly(&self) {}\n // error: item `fly` is provided by an `impl` that specializes\n // another, but the item in the parent `impl` is not marked\n // `default` and so it cannot be specialized.\n}\n```\n\nSpecialization only allows you to override `default` functions in\nimplementations.\n\nTo fix this error, you need to mark all the parent implementations as default.\nExample:\n\n```\n#![feature(specialization)]\n\ntrait SpaceLlama {\n fn fly(&self);\n}\n\n// applies to all T\nimpl<T> SpaceLlama for T {\n default fn fly(&self) {} // This is a parent implementation.\n}\n\n// applies to all `Clone` T; overrides the previous impl\nimpl<T: Clone> SpaceLlama for T {\n default fn fly(&self) {} // This is a parent implementation but was\n // previously not a default one, causing the error\n}\n\n// applies to i32, overrides the previous two impls\nimpl SpaceLlama for i32 {\n fn fly(&self) {} // And now that\'s ok!\n}\n```\n"),
(E0521,
"Borrowed data escapes outside of closure.\n\nErroneous code example:\n\n```compile_fail,E0521\nlet mut list: Vec<&str> = Vec::new();\n\nlet _add = |el: &str| {\n list.push(el); // error: `el` escapes the closure body here\n};\n```\n\nA type annotation of a closure parameter implies a new lifetime declaration.\nConsider to drop it, the compiler is reliably able to infer them.\n\n```\nlet mut list: Vec<&str> = Vec::new();\n\nlet _add = |el| {\n list.push(el);\n};\n```\n\nSee the [Closure type inference and annotation][closure-infere-annotation] and\n[Lifetime elision][lifetime-elision] sections of the Book for more details.\n\n[closure-infere-annotation]: https://doc.rust-lang.org/book/ch13-01-closures.html#closure-type-inference-and-annotation\n[lifetime-elision]: https://doc.rust-lang.org/reference/lifetime-elision.html\n"),
(E0522,
"The lang attribute was used in an invalid context.\n\nErroneous code example:\n\n```compile_fail,E0522\n#![feature(lang_items)]\n\n#[lang = \"cookie\"]\nfn cookie() -> ! { // error: definition of an unknown lang item: `cookie`\n loop {}\n}\n```\n\nThe lang attribute is intended for marking special items that are built-in to\nRust itself. This includes special traits (like `Copy` and `Sized`) that affect\nhow the compiler behaves, as well as special functions that may be automatically\ninvoked (such as the handler for out-of-bounds accesses when indexing a slice).\n"),
(E0523,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe compiler found multiple library files with the requested crate name.\n\n```compile_fail\n// aux-build:crateresolve-1.rs\n// aux-build:crateresolve-2.rs\n// aux-build:crateresolve-3.rs\n\nextern crate crateresolve;\n//~^ ERROR multiple candidates for `rlib` dependency `crateresolve` found\n\nfn main() {}\n```\n\nThis error can occur in several different cases -- for example, when using\n`extern crate` or passing `--extern` options without crate paths. It can also be\ncaused by caching issues with the build directory, in which case `cargo clean`\nmay help.\n\nIn the above example, there are three different library files, all of which\ndefine the same crate name. Without providing a full path, there is no way for\nthe compiler to know which crate it should use.\n\n*Note that E0523 has been merged into E0464.*\n"),
(E0524,
"A variable which requires unique access is being used in more than one closure\nat the same time.\n\nErroneous code example:\n\n```compile_fail,E0524\nfn set(x: &mut isize) {\n *x += 4;\n}\n\nfn dragoooon(x: &mut isize) {\n let mut c1 = || set(x);\n let mut c2 = || set(x); // error!\n\n c2();\n c1();\n}\n```\n\nTo solve this issue, multiple solutions are available. First, is it required\nfor this variable to be used in more than one closure at a time? If it is the\ncase, use reference counted types such as `Rc` (or `Arc` if it runs\nconcurrently):\n\n```\nuse std::rc::Rc;\nuse std::cell::RefCell;\n\nfn set(x: &mut isize) {\n *x += 4;\n}\n\nfn dragoooon(x: &mut isize) {\n let x = Rc::new(RefCell::new(x));\n let y = Rc::clone(&x);\n let mut c1 = || { let mut x2 = x.borrow_mut(); set(&mut x2); };\n let mut c2 = || { let mut x2 = y.borrow_mut(); set(&mut x2); }; // ok!\n\n c2();\n c1();\n}\n```\n\nIf not, just run closures one at a time:\n\n```\nfn set(x: &mut isize) {\n *x += 4;\n}\n\nfn dragoooon(x: &mut isize) {\n { // This block isn\'t necessary since non-lexical lifetimes, it\'s just to\n // make it more clear.\n let mut c1 = || set(&mut *x);\n c1();\n } // `c1` has been dropped here so we\'re free to use `x` again!\n let mut c2 = || set(&mut *x);\n c2();\n}\n```\n"),
(E0525,
"A closure was used but didn\'t implement the expected trait.\n\nErroneous code example:\n\n```compile_fail,E0525\nstruct X;\n\nfn foo<T>(_: T) {}\nfn bar<T: Fn(u32)>(_: T) {}\n\nfn main() {\n let x = X;\n let closure = |_| foo(x); // error: expected a closure that implements\n // the `Fn` trait, but this closure only\n // implements `FnOnce`\n bar(closure);\n}\n```\n\nIn the example above, `closure` is an `FnOnce` closure whereas the `bar`\nfunction expected an `Fn` closure. In this case, it\'s simple to fix the issue,\nyou just have to implement `Copy` and `Clone` traits on `struct X` and it\'ll\nbe ok:\n\n```\n#[derive(Clone, Copy)] // We implement `Clone` and `Copy` traits.\nstruct X;\n\nfn foo<T>(_: T) {}\nfn bar<T: Fn(u32)>(_: T) {}\n\nfn main() {\n let x = X;\n let closure = |_| foo(x);\n bar(closure); // ok!\n}\n```\n\nTo better understand how these work in Rust, read the [Closures][closures]\nchapter of the Book.\n\n[closures]: https://doc.rust-lang.org/book/ch13-01-closures.html\n"),
(E0527,
"The number of elements in an array or slice pattern differed from the number of\nelements in the array being matched.\n\nExample of erroneous code:\n\n```compile_fail,E0527\nlet r = &[1, 2, 3, 4];\nmatch r {\n &[a, b] => { // error: pattern requires 2 elements but array\n // has 4\n println!(\"a={}, b={}\", a, b);\n }\n}\n```\n\nEnsure that the pattern is consistent with the size of the matched\narray. Additional elements can be matched with `..`:\n\n```\nlet r = &[1, 2, 3, 4];\nmatch r {\n &[a, b, ..] => { // ok!\n println!(\"a={}, b={}\", a, b);\n }\n}\n```\n"),
(E0528,
"An array or slice pattern required more elements than were present in the\nmatched array.\n\nExample of erroneous code:\n\n```compile_fail,E0528\nlet r = &[1, 2];\nmatch r {\n &[a, b, c, rest @ ..] => { // error: pattern requires at least 3\n // elements but array has 2\n println!(\"a={}, b={}, c={} rest={:?}\", a, b, c, rest);\n }\n}\n```\n\nEnsure that the matched array has at least as many elements as the pattern\nrequires. You can match an arbitrary number of remaining elements with `..`:\n\n```\nlet r = &[1, 2, 3, 4, 5];\nmatch r {\n &[a, b, c, rest @ ..] => { // ok!\n // prints `a=1, b=2, c=3 rest=[4, 5]`\n println!(\"a={}, b={}, c={} rest={:?}\", a, b, c, rest);\n }\n}\n```\n"),
(E0529,
"An array or slice pattern was matched against some other type.\n\nExample of erroneous code:\n\n```compile_fail,E0529\nlet r: f32 = 1.0;\nmatch r {\n [a, b] => { // error: expected an array or slice, found `f32`\n println!(\"a={}, b={}\", a, b);\n }\n}\n```\n\nEnsure that the pattern and the expression being matched on are of consistent\ntypes:\n\n```\nlet r = [1.0, 2.0];\nmatch r {\n [a, b] => { // ok!\n println!(\"a={}, b={}\", a, b);\n }\n}\n```\n"),
(E0530,
"A binding shadowed something it shouldn\'t.\n\nA match arm or a variable has a name that is already used by\nsomething else, e.g.\n\n* struct name\n* enum variant\n* static\n* associated constant\n\nThis error may also happen when an enum variant *with fields* is used\nin a pattern, but without its fields.\n\n```compile_fail\nenum Enum {\n WithField(i32)\n}\n\nuse Enum::*;\nmatch WithField(1) {\n WithField => {} // error: missing (_)\n}\n```\n\nMatch bindings cannot shadow statics:\n\n```compile_fail,E0530\nstatic TEST: i32 = 0;\n\nlet r = 123;\nmatch r {\n TEST => {} // error: name of a static\n}\n```\n\nFixed examples:\n\n```\nstatic TEST: i32 = 0;\n\nlet r = 123;\nmatch r {\n some_value => {} // ok!\n}\n```\n\nor\n\n```\nconst TEST: i32 = 0; // const, not static\n\nlet r = 123;\nmatch r {\n TEST => {} // const is ok!\n other_values => {}\n}\n```\n"),
(E0531,
"An unknown tuple struct/variant has been used.\n\nErroneous code example:\n\n```compile_fail,E0531\nlet Type(x) = Type(12); // error!\nmatch Bar(12) {\n Bar(x) => {} // error!\n _ => {}\n}\n```\n\nIn most cases, it\'s either a forgotten import or a typo. However, let\'s look at\nhow you can have such a type:\n\n```edition2018\nstruct Type(u32); // this is a tuple struct\n\nenum Foo {\n Bar(u32), // this is a tuple variant\n}\n\nuse Foo::*; // To use Foo\'s variant directly, we need to import them in\n // the scope.\n```\n\nEither way, it should work fine with our previous code:\n\n```edition2018\nstruct Type(u32);\n\nenum Foo {\n Bar(u32),\n}\nuse Foo::*;\n\nlet Type(x) = Type(12); // ok!\nmatch Type(12) {\n Type(x) => {} // ok!\n _ => {}\n}\n```\n"),
(E0532,
"Pattern arm did not match expected kind.\n\nErroneous code example:\n\n```compile_fail,E0532\nenum State {\n Succeeded,\n Failed(String),\n}\n\nfn print_on_failure(state: &State) {\n match *state {\n // error: expected unit struct, unit variant or constant, found tuple\n // variant `State::Failed`\n State::Failed => println!(\"Failed\"),\n _ => ()\n }\n}\n```\n\nTo fix this error, ensure the match arm kind is the same as the expression\nmatched.\n\nFixed example:\n\n```\nenum State {\n Succeeded,\n Failed(String),\n}\n\nfn print_on_failure(state: &State) {\n match *state {\n State::Failed(ref msg) => println!(\"Failed with {}\", msg),\n _ => ()\n }\n}\n```\n"),
(E0533,
"An item which isn\'t a unit struct, a variant, nor a constant has been used as a\nmatch pattern.\n\nErroneous code example:\n\n```compile_fail,E0533\nstruct Tortoise;\n\nimpl Tortoise {\n fn turtle(&self) -> u32 { 0 }\n}\n\nmatch 0u32 {\n Tortoise::turtle => {} // Error!\n _ => {}\n}\nif let Tortoise::turtle = 0u32 {} // Same error!\n```\n\nIf you want to match against a value returned by a method, you need to bind the\nvalue first:\n\n```\nstruct Tortoise;\n\nimpl Tortoise {\n fn turtle(&self) -> u32 { 0 }\n}\n\nmatch 0u32 {\n x if x == Tortoise.turtle() => {} // Bound into `x` then we compare it!\n _ => {}\n}\n```\n"),
(E0534,
"#### Note: this error code is no longer emitted by the compiler\n\nThis is because it was too specific to the `inline` attribute.\nSimilar diagnostics occur for other attributes too.\nThe example here will now emit `E0805`\n\nThe `inline` attribute was malformed.\n\nErroneous code example:\n\n```compile_fail,E0805\n#[inline()] // error: expected one argument\npub fn something() {}\n\nfn main() {}\n```\n\nThe parenthesized `inline` attribute requires the parameter to be specified:\n\n```\n#[inline(always)]\nfn something() {}\n```\n\nor:\n\n```\n#[inline(never)]\nfn something() {}\n```\n\nAlternatively, a paren-less version of the attribute may be used to hint the\ncompiler about inlining opportunity:\n\n```\n#[inline]\nfn something() {}\n```\n\nFor more information see the [`inline` attribute][inline-attribute] section\nof the Reference.\n\n[inline-attribute]: https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute\n"),
(E0535,
"#### Note: this error code is no longer emitted by the compiler\n\nThis is because it was too specific to the `inline` attribute.\nSimilar diagnostics occur for other attributes too.\nThe example here will now emit `E0539`\n\n\nErroneous code example:\n\n```compile_fail,E0539\n#[inline(unknown)] // error: invalid argument\npub fn something() {}\n\nfn main() {}\n```\n\nThe `inline` attribute only supports two arguments:\n\n * always\n * never\n\nAll other arguments given to the `inline` attribute will return this error.\nExample:\n\n```\n#[inline(never)] // ok!\npub fn something() {}\n\nfn main() {}\n```\n\nFor more information see the [`inline` Attribute][inline-attribute] section\nof the Reference.\n\n[inline-attribute]: https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute\n"),
(E0536,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `not` cfg-predicate was malformed.\n\nErroneous code example (using `cargo doc`):\n\n```ignore, E0536 (only triggers on cargo doc)\n#![feature(doc_cfg)]\n#[doc(cfg(not()))]\npub fn main() {\n\n}\n```\n\nThe `not` predicate expects one cfg-pattern. Example:\n\n```\n#![feature(doc_cfg)]\n#[doc(cfg(not(target_os = \"linux\")))] // ok!\npub fn main() {\n\n}\n```\n\nFor more information about the `cfg` macro, read the section on\n[Conditional Compilation][conditional-compilation] in the Reference.\n\n[conditional-compilation]: https://doc.rust-lang.org/reference/conditional-compilation.html\n"),
(E0537,
"An unknown predicate was used inside the `cfg` attribute.\n\nErroneous code example:\n\n```compile_fail,E0537\n#[cfg(unknown())] // error: invalid predicate `unknown`\npub fn something() {}\n\npub fn main() {}\n```\n\nThe `cfg` attribute supports only three kinds of predicates:\n\n * any\n * all\n * not\n\nExample:\n\n```\n#[cfg(not(target_os = \"linux\"))] // ok!\npub fn something() {}\n\npub fn main() {}\n```\n\nFor more information about the `cfg` attribute, read the section on\n[Conditional Compilation][conditional-compilation] in the Reference.\n\n[conditional-compilation]: https://doc.rust-lang.org/reference/conditional-compilation.html\n"),
(E0538,
"Attribute contains same meta item more than once.\n\nErroneous code example:\n\n```compile_fail,E0538\n#[deprecated(\n since=\"1.0.0\",\n note=\"First deprecation note.\",\n note=\"Second deprecation note.\" // error: multiple same meta item\n)]\nfn deprecated_function() {}\n```\n\nMeta items are the key-value pairs inside of an attribute. Each key may only be\nused once in each attribute.\n\nTo fix the problem, remove all but one of the meta items with the same key.\n\nExample:\n\n```\n#[deprecated(\n since=\"1.0.0\",\n note=\"First deprecation note.\"\n)]\nfn deprecated_function() {}\n```\n"),
(E0539,
"An invalid meta-item was used inside an attribute.\n\nErroneous code example:\n\n```compile_fail,E0539\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[deprecated(note)] // error!\n#[unstable(feature = \"deprecated_fn\", issue = \"123\")]\nfn deprecated() {}\n\n#[unstable(feature = \"unstable_struct\", issue)] // error!\nstruct Unstable;\n\n#[rustc_const_unstable(feature)] // error!\nconst fn unstable_fn() {}\n\n#[stable(feature = \"stable_struct\", since)] // error!\nstruct Stable;\n\n#[rustc_const_stable(feature)] // error!\nconst fn stable_fn() {}\n```\n\nTo fix the above example, you can write the following:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[deprecated(since = \"1.39.0\", note = \"reason\")] // ok!\n#[unstable(feature = \"deprecated_fn\", issue = \"123\")]\nfn deprecated() {}\n\n#[unstable(feature = \"unstable_struct\", issue = \"123\")] // ok!\nstruct Unstable;\n\n#[rustc_const_unstable(feature = \"unstable_fn\", issue = \"124\")] // ok!\nconst fn unstable_fn() {}\n\n#[stable(feature = \"stable_struct\", since = \"1.39.0\")] // ok!\nstruct Stable;\n\n#[stable(feature = \"stable_fn\", since = \"1.39.0\")]\n#[rustc_const_stable(feature = \"stable_fn\", since = \"1.39.0\")] // ok!\nconst fn stable_fn() {}\n```\n\nSeveral causes of this are,\nan attribute may have expected you to give a list but you gave a\n`name = value` pair:\n\n```compile_fail,E0539\n// wrong, should be `#[repr(C)]`\n#[repr = \"C\"]\nstruct Foo {}\n```\n\nOr a `name = value` pair, but you gave a list:\n\n```compile_fail,E0539\n// wrong, should be `note = \"reason\"`\n#[deprecated(since = \"1.0.0\", note(\"reason\"))]\nstruct Foo {}\n```\n\nOr it expected some specific word but you gave an unexpected one:\n\n```compile_fail,E0539\n// should be `always` or `never`\n#[inline(maybe_if_you_feel_like_it)]\nfn foo() {}\n```\n"),
(E0541,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn unknown meta item was used.\n\nErroneous code example:\n\n```compile_fail (no longer emitted)\n#[deprecated(\n since=\"1.0.0\",\n // error: unknown meta item\n reason=\"Example invalid meta item. Should be \'note\'\")\n]\nfn deprecated_function() {}\n```\n\nMeta items are the key-value pairs inside of an attribute. The keys provided\nmust be one of the valid keys for the specified attribute.\n\nTo fix the problem, either remove the unknown meta item, or rename it if you\nprovided the wrong name.\n\nIn the erroneous code example above, the wrong name was provided, so changing\nto a correct one it will fix the error. Example:\n\n```\n#[deprecated(\n since=\"1.0.0\",\n note=\"This is a valid meta item for the deprecated attribute.\"\n)]\nfn deprecated_function() {}\n```\n"),
(E0542,
"The `since` value is missing in a stability attribute.\n\nErroneous code example:\n\n```compile_fail,E0542\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[stable(feature = \"_stable_fn\")] // invalid\nfn _stable_fn() {}\n\n#[rustc_const_stable(feature = \"_stable_const_fn\")] // invalid\nconst fn _stable_const_fn() {}\n\n#[stable(feature = \"_deprecated_fn\", since = \"0.1.0\")]\n#[deprecated(\n note = \"explanation for deprecation\"\n)] // invalid\nfn _deprecated_fn() {}\n```\n\nTo fix this issue, you need to provide the `since` field. Example:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[stable(feature = \"_stable_fn\", since = \"1.0.0\")] // ok!\nfn _stable_fn() {}\n\n#[stable(feature = \"_stable_const_fn\", since = \"1.0.0\")]\n#[rustc_const_stable(feature = \"_stable_const_fn\", since = \"1.0.0\")] // ok!\nconst fn _stable_const_fn() {}\n\n#[stable(feature = \"_deprecated_fn\", since = \"0.1.0\")]\n#[deprecated(\n since = \"1.0.0\",\n note = \"explanation for deprecation\"\n)] // ok!\nfn _deprecated_fn() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0543,
"The `note` value is missing in a stability attribute.\n\nErroneous code example:\n\n```compile_fail,E0543\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[stable(since = \"0.1.0\", feature = \"_deprecated_fn\")]\n#[deprecated(\n since = \"1.0.0\"\n)] // invalid\nfn _deprecated_fn() {}\n```\n\nTo fix this issue, you need to provide the `note` field. Example:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[stable(since = \"0.1.0\", feature = \"_deprecated_fn\")]\n#[deprecated(\n since = \"1.0.0\",\n note = \"explanation for deprecation\"\n)] // ok!\nfn _deprecated_fn() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0544,
"Multiple stability attributes were declared on the same item.\n\nErroneous code example:\n\n```compile_fail,E0544\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"rust1\")]\n\n#[stable(feature = \"rust1\", since = \"1.0.0\")]\n#[stable(feature = \"test\", since = \"2.0.0\")] // invalid\nfn foo() {}\n```\n\nTo fix this issue, ensure that each item has at most one stability attribute.\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"rust1\")]\n\n#[stable(feature = \"test\", since = \"2.0.0\")] // ok!\nfn foo() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0545,
"The `issue` value is incorrect in a stability attribute.\n\nErroneous code example:\n\n```compile_fail,E0545\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[unstable(feature = \"_unstable_fn\", issue = \"0\")] // invalid\nfn _unstable_fn() {}\n\n#[rustc_const_unstable(feature = \"_unstable_const_fn\", issue = \"0\")] // invalid\nconst fn _unstable_const_fn() {}\n```\n\nTo fix this issue, you need to provide a correct value in the `issue` field.\nExample:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[unstable(feature = \"_unstable_fn\", issue = \"none\")] // ok!\nfn _unstable_fn() {}\n\n#[rustc_const_unstable(feature = \"_unstable_const_fn\", issue = \"1\")] // ok!\nconst fn _unstable_const_fn() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0546,
"The `feature` value is missing in a stability attribute.\n\nErroneous code example:\n\n```compile_fail,E0546\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[unstable(issue = \"none\")] // invalid\nfn unstable_fn() {}\n\n#[stable(since = \"1.0.0\")] // invalid\nfn stable_fn() {}\n```\n\nTo fix this issue, you need to provide the `feature` field. Example:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[unstable(feature = \"unstable_fn\", issue = \"none\")] // ok!\nfn unstable_fn() {}\n\n#[stable(feature = \"stable_fn\", since = \"1.0.0\")] // ok!\nfn stable_fn() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0547,
"The `issue` value is missing in a stability attribute.\n\nErroneous code example:\n\n```compile_fail,E0547\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[unstable(feature = \"_unstable_fn\")] // invalid\nfn _unstable_fn() {}\n\n#[rustc_const_unstable(feature = \"_unstable_const_fn\")] // invalid\nconst fn _unstable_const_fn() {}\n```\n\nTo fix this issue, you need to provide the `issue` field. Example:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[unstable(feature = \"_unstable_fn\", issue = \"none\")] // ok!\nfn _unstable_fn() {}\n\n#[rustc_const_unstable(\n feature = \"_unstable_const_fn\",\n issue = \"none\"\n)] // ok!\nconst fn _unstable_const_fn() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0549,
"A `deprecated` attribute wasn\'t paired with a `stable`/`unstable` attribute with\n`#![feature(staged_api)]` enabled.\n\nErroneous code example:\n\n```compile_fail,E0549\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[deprecated(\n since = \"1.0.1\",\n note = \"explanation for deprecation\"\n)] // invalid\nfn _deprecated_fn() {}\n```\n\nTo fix this issue, you need to add also an attribute `stable` or `unstable`.\nExample:\n\n```\n#![feature(staged_api)]\n#![allow(internal_features)]\n#![stable(since = \"1.0.0\", feature = \"test\")]\n\n#[stable(since = \"1.0.0\", feature = \"test\")]\n#[deprecated(\n since = \"1.0.1\",\n note = \"explanation for deprecation\"\n)] // ok!\nfn _deprecated_fn() {}\n```\n\nSee the [How Rust is Made and \u{201c}Nightly Rust\u{201d}][how-rust-made-nightly] appendix\nof the Book and the [Stability attributes][stability-attributes] section of the\nRustc Dev Guide for more details.\n\n[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html\n[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html\n"),
(E0550,
"#### Note: this error code is no longer emitted by the compiler\n\nMore than one `deprecated` attribute has been put on an item.\n\nErroneous code example:\n\n```compile_fail\n#[deprecated(note = \"because why not?\")]\n#[deprecated(note = \"right?\")] // error!\nfn the_banished() {}\n```\n\nThe `deprecated` attribute can only be present **once** on an item.\n\n```\n#[deprecated(note = \"because why not, right?\")]\nfn the_banished() {} // ok!\n```\n"),
(E0551,
"#### Note: this error code is no longer emitted by the compiler\n\nAn invalid meta-item was used inside an attribute.\n\nErroneous code example:\n\n```compile_fail,E0539\n#[deprecated(note)] // error!\nfn i_am_deprecated() {}\n```\n\nMeta items are the key-value pairs inside of an attribute. To fix this issue,\nyou need to give a value to the `note` key. Example:\n\n```\n#[deprecated(note = \"because\")] // ok!\nfn i_am_deprecated() {}\n```\n"),
(E0552,
"A unrecognized representation attribute was used.\n\nErroneous code example:\n\n```compile_fail,E0552\n#[repr(D)] // error: unrecognized representation hint\nstruct MyStruct {\n my_field: usize\n}\n```\n\nYou can use a `repr` attribute to tell the compiler how you want a struct or\nenum to be laid out in memory.\n\nMake sure you\'re using one of the supported options:\n\n```\n#[repr(C)] // ok!\nstruct MyStruct {\n my_field: usize\n}\n```\n\nFor more information about specifying representations, see the [\"Alternative\nRepresentations\" section] of the Rustonomicon.\n\n[\"Alternative Representations\" section]: https://doc.rust-lang.org/nomicon/other-reprs.html\n"),
(E0554,
"Feature attributes are only allowed on the nightly release channel. Stable or\nbeta compilers will not comply.\n\nErroneous code example:\n\n```ignore (depends on release channel)\n#![feature(lang_items)] // error: `#![feature]` may not be used on the\n // stable release channel\n```\n\nIf you need the feature, make sure to use a nightly release of the compiler\n(but be warned that the feature may be removed or altered in the future).\n"),
(E0556,
"The `feature` attribute was badly formed.\n\nErroneous code example:\n\n```compile_fail,E0556\n#![feature(foo_bar_baz, foo(bar), foo = \"baz\", foo)] // error!\n#![feature] // error!\n#![feature = \"foo\"] // error!\n```\n\nThe `feature` attribute only accept a \"feature flag\" and can only be used on\nnightly. Example:\n\n```ignore (only works in nightly)\n#![feature(flag)]\n```\n"),
(E0557,
"A feature attribute named a feature that has been removed.\n\nErroneous code example:\n\n```compile_fail,E0557\n#![feature(managed_boxes)] // error: feature has been removed\n```\n\nDelete the offending feature attribute.\n"),
(E0559,
"An unknown field was specified into an enum\'s structure variant.\n\nErroneous code example:\n\n```compile_fail,E0559\nenum Field {\n Fool { x: u32 },\n}\n\nlet s = Field::Fool { joke: 0 };\n// error: struct variant `Field::Fool` has no field named `joke`\n```\n\nVerify you didn\'t misspell the field\'s name or that the field exists. Example:\n\n```\nenum Field {\n Fool { joke: u32 },\n}\n\nlet s = Field::Fool { joke: 0 }; // ok!\n```\n"),
(E0560,
"An unknown field was specified into a structure.\n\nErroneous code example:\n\n```compile_fail,E0560\nstruct Simba {\n mother: u32,\n}\n\nlet s = Simba { mother: 1, father: 0 };\n// error: structure `Simba` has no field named `father`\n```\n\nVerify you didn\'t misspell the field\'s name or that the field exists. Example:\n\n```\nstruct Simba {\n mother: u32,\n father: u32,\n}\n\nlet s = Simba { mother: 1, father: 0 }; // ok!\n```\n"),
(E0561,
"A non-ident or non-wildcard pattern has been used as a parameter of a function\npointer type.\n\nErroneous code example:\n\n```compile_fail,E0561\ntype A1 = fn(mut param: u8); // error!\ntype A2 = fn(¶m: u32); // error!\n```\n\nWhen using an alias over a function type, you cannot e.g. denote a parameter as\nbeing mutable.\n\nTo fix the issue, remove patterns (`_` is allowed though). Example:\n\n```\ntype A1 = fn(param: u8); // ok!\ntype A2 = fn(_: u32); // ok!\n```\n\nYou can also omit the parameter name:\n\n```\ntype A3 = fn(i16); // ok!\n```\n"),
(E0562,
"`impl Trait` is only allowed as a function return and argument type.\n\nErroneous code example:\n\n```compile_fail,E0562\nfn main() {\n let count_to_ten: impl Iterator<Item=usize> = 0..10;\n // error: `impl Trait` not allowed outside of function and inherent method\n // return types\n for i in count_to_ten {\n println!(\"{}\", i);\n }\n}\n```\n\nMake sure `impl Trait` appears in a function signature.\n\n```\nfn count_to_n(n: usize) -> impl Iterator<Item=usize> {\n 0..n\n}\n\nfn main() {\n for i in count_to_n(10) { // ok!\n println!(\"{}\", i);\n }\n}\n```\n\nSee the [reference] for more details on `impl Trait`.\n\n[reference]: https://doc.rust-lang.org/stable/reference/types/impl-trait.html\n"),
(E0565,
"A literal was used in a built-in attribute that doesn\'t support literals.\n\nErroneous code example:\n\n```compile_fail,E0565\n#[repr(\"C\")] // error: meta item in `repr` must be an identifier\nstruct Repr {}\n\nfn main() {}\n```\n\nNot all attributes support literals in their input,\nand in some cases they expect an identifier instead.\nThat would be the solution in the case of `repr`:\n```\n#[repr(C)] // ok!\nstruct Repr {}\n\nfn main() {}\n```\n"),
(E0566,
"Conflicting representation hints have been used on a same item.\n\nErroneous code example:\n\n```compile_fail,E0566\n#[repr(u32, u64)]\nenum Repr { A }\n```\n\nIn most cases (if not all), using just one representation hint is more than\nenough. If you want to have a representation hint depending on the current\narchitecture, use `cfg_attr`. Example:\n\n```\n#[cfg_attr(linux, repr(u32))]\n#[cfg_attr(not(linux), repr(u64))]\nenum Repr { A }\n```\n"),
(E0567,
"Generics have been used on an auto trait.\n\nErroneous code example:\n\n```compile_fail,E0567\n#![feature(auto_traits)]\n\nauto trait Generic<T> {} // error!\n# fn main() {}\n```\n\nSince an auto trait is implemented on all existing types, the\ncompiler would not be able to infer the types of the trait\'s generic\nparameters.\n\nTo fix this issue, just remove the generics:\n\n```\n#![feature(auto_traits)]\n\nauto trait Generic {} // ok!\n# fn main() {}\n```\n"),
(E0568,
"A super trait has been added to an auto trait.\n\nErroneous code example:\n\n```compile_fail,E0568\n#![feature(auto_traits)]\n\nauto trait Bound : Copy {} // error!\n\nfn main() {}\n```\n\nSince an auto trait is implemented on all existing types, adding a super trait\nwould filter out a lot of those types. In the current example, almost none of\nall the existing types could implement `Bound` because very few of them have the\n`Copy` trait.\n\nTo fix this issue, just remove the super trait:\n\n```\n#![feature(auto_traits)]\n\nauto trait Bound {} // ok!\n\nfn main() {}\n```\n"),
(E0569,
"If an impl has a generic parameter with the `#[may_dangle]` attribute, then\nthat impl must be declared as an `unsafe impl`.\n\nErroneous code example:\n\n```compile_fail,E0569\n#![feature(dropck_eyepatch)]\n\nstruct Foo<X>(X);\nimpl<#[may_dangle] X> Drop for Foo<X> {\n fn drop(&mut self) { }\n}\n```\n\nIn this example, we are asserting that the destructor for `Foo` will not\naccess any data of type `X`, and require this assertion to be true for\noverall safety in our program. The compiler does not currently attempt to\nverify this assertion; therefore we must tag this `impl` as unsafe.\n"),
(E0570,
"The requested ABI is unsupported by the current target.\n\nThe rust compiler maintains for each target a list of unsupported ABIs on\nthat target. If an ABI is present in such a list this usually means that the\ntarget / ABI combination is currently unsupported by llvm.\n\nIf necessary, you can circumvent this check using custom target specifications.\n"),
(E0571,
"A `break` statement with an argument appeared in a non-`loop` loop.\n\nExample of erroneous code:\n\n```compile_fail,E0571\n# let mut i = 1;\n# fn satisfied(n: usize) -> bool { n % 23 == 0 }\nlet result = while true {\n if satisfied(i) {\n break 2 * i; // error: `break` with value from a `while` loop\n }\n i += 1;\n};\n```\n\nThe `break` statement can take an argument (which will be the value of the loop\nexpression if the `break` statement is executed) in `loop` loops, but not\n`for`, `while`, or `while let` loops.\n\nMake sure `break value;` statements only occur in `loop` loops:\n\n```\n# let mut i = 1;\n# fn satisfied(n: usize) -> bool { n % 23 == 0 }\nlet result = loop { // This is now a \"loop\" loop.\n if satisfied(i) {\n break 2 * i; // ok!\n }\n i += 1;\n};\n```\n"),
(E0572,
"A return statement was found outside of a function body.\n\nErroneous code example:\n\n```compile_fail,E0572\nconst FOO: u32 = return 0; // error: return statement outside of function body\n\nfn main() {}\n```\n\nTo fix this issue, just remove the return keyword or move the expression into a\nfunction. Example:\n\n```\nconst FOO: u32 = 0;\n\nfn some_fn() -> u32 {\n return FOO;\n}\n\nfn main() {\n some_fn();\n}\n```\n"),
(E0573,
"Something other than a type has been used when one was expected.\n\nErroneous code examples:\n\n```compile_fail,E0573\nenum Dragon {\n Born,\n}\n\nfn oblivion() -> Dragon::Born { // error!\n Dragon::Born\n}\n\nconst HOBBIT: u32 = 2;\nimpl HOBBIT {} // error!\n\nenum Wizard {\n Gandalf,\n Saruman,\n}\n\ntrait Isengard {\n fn wizard(_: Wizard::Saruman); // error!\n}\n```\n\nIn all these errors, a type was expected. For example, in the first error, if\nwe want to return the `Born` variant from the `Dragon` enum, we must set the\nfunction to return the enum and not its variant:\n\n```\nenum Dragon {\n Born,\n}\n\nfn oblivion() -> Dragon { // ok!\n Dragon::Born\n}\n```\n\nIn the second error, you can\'t implement something on an item, only on types.\nWe would need to create a new type if we wanted to do something similar:\n\n```\nstruct Hobbit(u32); // we create a new type\n\nconst HOBBIT: Hobbit = Hobbit(2);\nimpl Hobbit {} // ok!\n```\n\nIn the third case, we tried to only expect one variant of the `Wizard` enum,\nwhich is not possible. To make this work, we need to using pattern matching\nover the `Wizard` enum:\n\n```\nenum Wizard {\n Gandalf,\n Saruman,\n}\n\ntrait Isengard {\n fn wizard(w: Wizard) { // ok!\n match w {\n Wizard::Saruman => {\n // do something\n }\n _ => {} // ignore everything else\n }\n }\n}\n```\n"),
(E0574,
"Something other than a struct, variant or union has been used when one was\nexpected.\n\nErroneous code example:\n\n```compile_fail,E0574\nmod mordor {}\n\nlet sauron = mordor { x: () }; // error!\n\nenum Jak {\n Daxter { i: isize },\n}\n\nlet eco = Jak::Daxter { i: 1 };\nmatch eco {\n Jak { i } => {} // error!\n}\n```\n\nIn all these errors, a type was expected. For example, in the first error,\nwe tried to instantiate the `mordor` module, which is impossible. If you want\nto instantiate a type inside a module, you can do it as follow:\n\n```\nmod mordor {\n pub struct TheRing {\n pub x: usize,\n }\n}\n\nlet sauron = mordor::TheRing { x: 1 }; // ok!\n```\n\nIn the second error, we tried to bind the `Jak` enum directly, which is not\npossible: you can only bind one of its variants. To do so:\n\n```\nenum Jak {\n Daxter { i: isize },\n}\n\nlet eco = Jak::Daxter { i: 1 };\nmatch eco {\n Jak::Daxter { i } => {} // ok!\n}\n```\n"),
(E0575,
"Something other than a type or an associated type was given.\n\nErroneous code example:\n\n```compile_fail,E0575\nenum Rick { Morty }\n\nlet _: <u8 as Rick>::Morty; // error!\n\ntrait Age {\n type Empire;\n fn Mythology() {}\n}\n\nimpl Age for u8 {\n type Empire = u16;\n}\n\nlet _: <u8 as Age>::Mythology; // error!\n```\n\nIn both cases, we\'re declaring a variable (called `_`) and we\'re giving it a\ntype. However, `<u8 as Rick>::Morty` and `<u8 as Age>::Mythology` aren\'t types,\ntherefore the compiler throws an error.\n\n`<u8 as Rick>::Morty` is an enum variant, you cannot use a variant as a type,\nyou have to use the enum directly:\n\n```\nenum Rick { Morty }\n\nlet _: Rick; // ok!\n```\n\n`<u8 as Age>::Mythology` is a trait method, which is definitely not a type.\nHowever, the `Age` trait provides an associated type `Empire` which can be\nused as a type:\n\n```\ntrait Age {\n type Empire;\n fn Mythology() {}\n}\n\nimpl Age for u8 {\n type Empire = u16;\n}\n\nlet _: <u8 as Age>::Empire; // ok!\n```\n"),
(E0576,
"An associated item wasn\'t found in the given type.\n\nErroneous code example:\n\n```compile_fail,E0576\ntrait Hello {\n type Who;\n\n fn hello() -> <Self as Hello>::You; // error!\n}\n```\n\nIn this example, we tried to use the nonexistent associated type `You` of the\n`Hello` trait. To fix this error, use an existing associated type:\n\n```\ntrait Hello {\n type Who;\n\n fn hello() -> <Self as Hello>::Who; // ok!\n}\n```\n"),
(E0577,
"Something other than a module was found in visibility scope.\n\nErroneous code example:\n\n```compile_fail,E0577,edition2018\npub enum Sea {}\n\npub (in crate::Sea) struct Shark; // error!\n\nfn main() {}\n```\n\n`Sea` is not a module, therefore it is invalid to use it in a visibility path.\nTo fix this error we need to ensure `sea` is a module.\n\nPlease note that the visibility scope can only be applied on ancestors!\n\n```edition2018\npub mod sea {\n pub (in crate::sea) struct Shark; // ok!\n}\n\nfn main() {}\n```\n"),
(E0578,
"#### Note: this error code is no longer emitted by the compiler.\n\nA module cannot be found and therefore, the visibility cannot be determined.\n\nErroneous code example:\n\n```ignore (no longer emitted)\nfoo!();\n\npub (in ::Sea) struct Shark; // error!\n\nfn main() {}\n```\n\nBecause of the call to the `foo` macro, the compiler guesses that the missing\nmodule could be inside it and fails because the macro definition cannot be\nfound.\n\nTo fix this error, please be sure that the module is in scope:\n\n```edition2018\npub mod Sea {\n pub (in crate::Sea) struct Shark;\n}\n\nfn main() {}\n```\n"),
(E0579,
"A lower range wasn\'t less than the upper range.\n\nErroneous code example:\n\n```compile_fail,E0579\n\nfn main() {\n match 5u32 {\n // This range is ok, albeit pointless.\n 1..2 => {}\n // This range is empty, and the compiler can tell.\n 5..5 => {} // error!\n }\n}\n```\n\nWhen matching against an exclusive range, the compiler verifies that the range\nis non-empty. Exclusive range patterns include the start point but not the end\npoint, so this is equivalent to requiring the start of the range to be less\nthan the end of the range.\n"),
(E0580,
"The `main` function was incorrectly declared.\n\nErroneous code example:\n\n```compile_fail,E0580\nfn main(x: i32) { // error: main function has wrong type\n println!(\"{}\", x);\n}\n```\n\nThe `main` function prototype should never take arguments.\nExample:\n\n```\nfn main() {\n // your code\n}\n```\n\nIf you want to get command-line arguments, use `std::env::args`. To exit with a\nspecified exit code, use `std::process::exit`.\n"),
(E0581,
"In a `fn` type, a lifetime appears only in the return type\nand not in the arguments types.\n\nErroneous code example:\n\n```compile_fail,E0581\nfn main() {\n // Here, `\'a` appears only in the return type:\n let x: for<\'a> fn() -> &\'a i32;\n}\n```\n\nThe problem here is that the lifetime isn\'t constrained by any of the arguments,\nmaking it impossible to determine how long it\'s supposed to live.\n\nTo fix this issue, either use the lifetime in the arguments, or use the\n`\'static` lifetime. Example:\n\n```\nfn main() {\n // Here, `\'a` appears only in the return type:\n let x: for<\'a> fn(&\'a i32) -> &\'a i32;\n let y: fn() -> &\'static i32;\n}\n```\n\nNote: The examples above used to be (erroneously) accepted by the\ncompiler, but this was since corrected. See [issue #33685] for more\ndetails.\n\n[issue #33685]: https://github.com/rust-lang/rust/issues/33685\n"),
(E0582,
"A lifetime is only present in an associated-type binding, and not in the input\ntypes to the trait.\n\nErroneous code example:\n\n```compile_fail,E0582\nfn bar<F>(t: F)\n // No type can satisfy this requirement, since `\'a` does not\n // appear in any of the input types (here, `i32`):\n where F: for<\'a> Fn(i32) -> Option<&\'a i32>\n{\n}\n\nfn main() { }\n```\n\nTo fix this issue, either use the lifetime in the inputs, or use\n`\'static`. Example:\n\n```\nfn bar<F, G>(t: F, u: G)\n where F: for<\'a> Fn(&\'a i32) -> Option<&\'a i32>,\n G: Fn(i32) -> Option<&\'static i32>,\n{\n}\n\nfn main() { }\n```\n\nThis error also includes the use of associated types with lifetime parameters.\n```compile_fail,E0582\ntrait Foo {\n type Assoc<\'a>;\n}\n\nstruct Bar<X, F>\nwhere\n X: Foo,\n F: for<\'a> Fn(X::Assoc<\'a>) -> &\'a i32\n{\n x: X,\n f: F\n}\n```\nThe latter scenario encounters this error because `Foo::Assoc<\'a>` could be\nimplemented by a type that does not use the `\'a` parameter, so there is no\nguarantee that `X::Assoc<\'a>` actually uses `\'a`.\n\nTo fix this we can pass a dummy parameter:\n```\n# trait Foo {\n# type Assoc<\'a>;\n# }\nstruct Bar<X, F>\nwhere\n X: Foo,\n F: for<\'a> Fn(X::Assoc<\'a>, /* dummy */ &\'a ()) -> &\'a i32\n{\n x: X,\n f: F\n}\n```\n\nNote: The examples above used to be (erroneously) accepted by the\ncompiler, but this was since corrected. See [issue #33685] for more\ndetails.\n\n[issue #33685]: https://github.com/rust-lang/rust/issues/33685\n"),
(E0583,
"A file wasn\'t found for an out-of-line module.\n\nErroneous code example:\n\n```compile_fail,E0583\nmod file_that_doesnt_exist; // error: file not found for module\n\nfn main() {}\n```\n\nPlease be sure that a file corresponding to the module exists. If you\nwant to use a module named `file_that_doesnt_exist`, you need to have a file\nnamed `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the\nsame directory.\n"),
(E0584,
"A doc comment that is not attached to anything has been encountered.\n\nErroneous code example:\n\n```compile_fail,E0584\ntrait Island {\n fn lost();\n\n /// I\'m lost!\n}\n```\n\nA little reminder: a doc comment has to be placed before the item it\'s supposed\nto document. So if you want to document the `Island` trait, you need to put a\ndoc comment before it, not inside it. Same goes for the `lost` method: the doc\ncomment needs to be before it:\n\n```\n/// I\'m THE island!\ntrait Island {\n /// I\'m lost!\n fn lost();\n}\n```\n"),
(E0585,
"A documentation comment that doesn\'t document anything was found.\n\nErroneous code example:\n\n```compile_fail,E0585\nfn main() {\n // The following doc comment will fail:\n /// This is a useless doc comment!\n}\n```\n\nDocumentation comments need to be followed by items, including functions,\ntypes, modules, etc. Examples:\n\n```\n/// I\'m documenting the following struct:\nstruct Foo;\n\n/// I\'m documenting the following function:\nfn foo() {}\n```\n"),
(E0586,
"An inclusive range was used with no end.\n\nErroneous code example:\n\n```compile_fail,E0586\nfn main() {\n let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];\n let x = &tmp[1..=]; // error: inclusive range was used with no end\n}\n```\n\nAn inclusive range needs an end in order to *include* it. If you just need a\nstart and no end, use a non-inclusive range (with `..`):\n\n```\nfn main() {\n let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];\n let x = &tmp[1..]; // ok!\n}\n```\n\nOr put an end to your inclusive range:\n\n```\nfn main() {\n let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];\n let x = &tmp[1..=3]; // ok!\n}\n```\n"),
(E0587,
"A type has both `packed` and `align` representation hints.\n\nErroneous code example:\n\n```compile_fail,E0587\n#[repr(packed, align(8))] // error!\nstruct Umbrella(i32);\n```\n\nYou cannot use `packed` and `align` hints on a same type. If you want to pack a\ntype to a given size, you should provide a size to packed:\n\n```\n#[repr(packed(8))] // ok!\nstruct Umbrella(i32);\n```\n"),
(E0588,
"A type with `packed` representation hint has a field with `align`\nrepresentation hint.\n\nErroneous code example:\n\n```compile_fail,E0588\n#[repr(align(16))]\nstruct Aligned(i32);\n\n#[repr(packed)] // error!\nstruct Packed(Aligned);\n```\n\nJust like you cannot have both `align` and `packed` representation hints on the\nsame type, a `packed` type cannot contain another type with the `align`\nrepresentation hint. However, you can do the opposite:\n\n```\n#[repr(packed)]\nstruct Packed(i32);\n\n#[repr(align(16))] // ok!\nstruct Aligned(Packed);\n```\n"),
(E0589,
"The value of `N` that was specified for `repr(align(N))` was not a power\nof two, or was greater than 2^29.\n\nErroneous code example:\n\n```compile_fail,E0589\n#[repr(align(15))] // error: invalid `repr(align)` attribute: not a power of two\nenum Foo {\n Bar(u64),\n}\n```\n"),
(E0590,
"`break` or `continue` keywords were used in a condition of a `while` loop\nwithout a label.\n\nErroneous code code:\n\n```compile_fail,E0590\nwhile break {}\n```\n\n`break` or `continue` must include a label when used in the condition of a\n`while` loop.\n\nTo fix this, add a label specifying which loop is being broken out of:\n\n```\n\'foo: while break \'foo {}\n```\n"),
(E0591,
"Per [RFC 401][rfc401], if you have a function declaration `foo`:\n\n```\nstruct S;\n\n// For the purposes of this explanation, all of these\n// different kinds of `fn` declarations are equivalent:\n\nfn foo(x: S) { /* ... */ }\n# #[cfg(for_demonstration_only)]\nextern \"C\" {\n fn foo(x: S);\n}\n# #[cfg(for_demonstration_only)]\nimpl S {\n fn foo(self) { /* ... */ }\n}\n```\n\nthe type of `foo` is **not** `fn(S)`, as one might expect.\nRather, it is a unique, zero-sized marker type written here as `typeof(foo)`.\nHowever, `typeof(foo)` can be _coerced_ to a function pointer `fn(S)`,\nso you rarely notice this:\n\n```\n# struct S;\n# fn foo(_: S) {}\nlet x: fn(S) = foo; // OK, coerces\n```\n\nThe reason that this matter is that the type `fn(S)` is not specific to\nany particular function: it\'s a function _pointer_. So calling `x()` results\nin a virtual call, whereas `foo()` is statically dispatched, because the type\nof `foo` tells us precisely what function is being called.\n\nAs noted above, coercions mean that most code doesn\'t have to be\nconcerned with this distinction. However, you can tell the difference\nwhen using **transmute** to convert a fn item into a fn pointer.\n\nThis is sometimes done as part of an FFI:\n\n```compile_fail,E0591\nextern \"C\" fn foo(userdata: Box<i32>) {\n /* ... */\n}\n\n# fn callback(_: extern \"C\" fn(*mut i32)) {}\n# use std::mem::transmute;\nunsafe {\n let f: extern \"C\" fn(*mut i32) = transmute(foo);\n callback(f);\n}\n```\n\nHere, transmute is being used to convert the types of the fn arguments.\nThis pattern is incorrect because the type of `foo` is a function **item**\n(`typeof(foo)`), which is zero-sized, and the target type (`fn()`)\nis a function pointer, which is not zero-sized.\nThis pattern should be rewritten. There are a few possible ways to do this:\n\n- change the original fn declaration to match the expected signature,\n and do the cast in the fn body (the preferred option)\n- cast the fn item of a fn pointer before calling transmute, as shown here:\n\n```\n# extern \"C\" fn foo(_: Box<i32>) {}\n# use std::mem::transmute;\n# unsafe {\nlet f: extern \"C\" fn(*mut i32) = transmute(foo as extern \"C\" fn(_));\nlet f: extern \"C\" fn(*mut i32) = transmute(foo as usize); // works too\n# }\n```\n\nThe same applies to transmutes to `*mut fn()`, which were observed in practice.\nNote though that use of this type is generally incorrect.\nThe intention is typically to describe a function pointer, but just `fn()`\nalone suffices for that. `*mut fn()` is a pointer to a fn pointer.\n(Since these values are typically just passed to C code, however, this rarely\nmakes a difference in practice.)\n\n[rfc401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md\n"),
(E0592,
"This error occurs when you defined methods or associated functions with same\nname.\n\nErroneous code example:\n\n```compile_fail,E0592\nstruct Foo;\n\nimpl Foo {\n fn bar() {} // previous definition here\n}\n\nimpl Foo {\n fn bar() {} // duplicate definition here\n}\n```\n\nA similar error is E0201. The difference is whether there is one declaration\nblock or not. To avoid this error, you must give each `fn` a unique name.\n\n```\nstruct Foo;\n\nimpl Foo {\n fn bar() {}\n}\n\nimpl Foo {\n fn baz() {} // define with different name\n}\n```\n"),
(E0593,
"You tried to supply an `Fn`-based type with an incorrect number of arguments\nthan what was expected.\n\nErroneous code example:\n\n```compile_fail,E0593\nfn foo<F: Fn()>(x: F) { }\n\nfn main() {\n // [E0593] closure takes 1 argument but 0 arguments are required\n foo(|y| { });\n}\n```\n\nYou have to provide the same number of arguments as expected by the `Fn`-based\ntype. So to fix the previous example, we need to remove the `y` argument:\n\n```\nfn foo<F: Fn()>(x: F) { }\n\nfn main() {\n foo(|| { }); // ok!\n}\n```\n"),
(E0594,
"A non-mutable value was assigned a value.\n\nErroneous code example:\n\n```compile_fail,E0594\nstruct SolarSystem {\n earth: i32,\n}\n\nlet ss = SolarSystem { earth: 3 };\nss.earth = 2; // error!\n```\n\nTo fix this error, declare `ss` as mutable by using the `mut` keyword:\n\n```\nstruct SolarSystem {\n earth: i32,\n}\n\nlet mut ss = SolarSystem { earth: 3 }; // declaring `ss` as mutable\nss.earth = 2; // ok!\n```\n"),
(E0595,
"#### Note: this error code is no longer emitted by the compiler.\n\nClosures cannot mutate immutable captured variables.\n\nErroneous code example:\n\n```compile_fail,E0594\nlet x = 3; // error: closure cannot assign to immutable local variable `x`\nlet mut c = || { x += 1 };\n```\n\nMake the variable binding mutable:\n\n```\nlet mut x = 3; // ok!\nlet mut c = || { x += 1 };\n```\n"),
(E0596,
"This error occurs because you tried to mutably borrow a non-mutable variable.\n\nErroneous code example:\n\n```compile_fail,E0596\nlet x = 1;\nlet y = &mut x; // error: cannot borrow mutably\n```\n\nIn here, `x` isn\'t mutable, so when we try to mutably borrow it in `y`, it\nfails. To fix this error, you need to make `x` mutable:\n\n```\nlet mut x = 1;\nlet y = &mut x; // ok!\n```\n"),
(E0597,
"This error occurs because a value was dropped while it was still borrowed.\n\nErroneous code example:\n\n```compile_fail,E0597\nstruct Foo<\'a> {\n x: Option<&\'a u32>,\n}\n\nlet mut x = Foo { x: None };\n{\n let y = 0;\n x.x = Some(&y); // error: `y` does not live long enough\n}\nprintln!(\"{:?}\", x.x);\n```\n\nHere, `y` is dropped at the end of the inner scope, but it is borrowed by\n`x` until the `println`. To fix the previous example, just remove the scope\nso that `y` isn\'t dropped until after the println\n\n```\nstruct Foo<\'a> {\n x: Option<&\'a u32>,\n}\n\nlet mut x = Foo { x: None };\n\nlet y = 0;\nx.x = Some(&y);\n\nprintln!(\"{:?}\", x.x);\n```\n"),
(E0599,
"This error occurs when a method is used on a type which doesn\'t implement it:\n\nErroneous code example:\n\n```compile_fail,E0599\nstruct Mouth;\n\nlet x = Mouth;\nx.chocolate(); // error: no method named `chocolate` found for type `Mouth`\n // in the current scope\n```\n\nIn this case, you need to implement the `chocolate` method to fix the error:\n\n```\nstruct Mouth;\n\nimpl Mouth {\n fn chocolate(&self) { // We implement the `chocolate` method here.\n println!(\"Hmmm! I love chocolate!\");\n }\n}\n\nlet x = Mouth;\nx.chocolate(); // ok!\n```\n"),
(E0600,
"An unary operator was used on a type which doesn\'t implement it.\n\nErroneous code example:\n\n```compile_fail,E0600\nenum Question {\n Yes,\n No,\n}\n\n!Question::Yes; // error: cannot apply unary operator `!` to type `Question`\n```\n\nIn this case, `Question` would need to implement the `std::ops::Not` trait in\norder to be able to use `!` on it. Let\'s implement it:\n\n```\nuse std::ops::Not;\n\nenum Question {\n Yes,\n No,\n}\n\n// We implement the `Not` trait on the enum.\nimpl Not for Question {\n type Output = bool;\n\n fn not(self) -> bool {\n match self {\n Question::Yes => false, // If the `Answer` is `Yes`, then it\n // returns false.\n Question::No => true, // And here we do the opposite.\n }\n }\n}\n\nassert_eq!(!Question::Yes, false);\nassert_eq!(!Question::No, true);\n```\n"),
(E0601,
"No `main` function was found in a binary crate.\n\nTo fix this error, add a `main` function:\n\n```\nfn main() {\n // Your program will start here.\n println!(\"Hello world!\");\n}\n```\n\nIf you don\'t know the basics of Rust, you can look at the\n[Rust Book][rust-book] to get started.\n\n[rust-book]: https://doc.rust-lang.org/book/\n"),
(E0602,
"An unknown or invalid lint was used on the command line.\n\nErroneous code example:\n\n```sh\nrustc -D bogus rust_file.rs\n```\n\nMaybe you just misspelled the lint name or the lint doesn\'t exist anymore.\nEither way, try to update/remove it in order to fix the error.\n"),
(E0603,
"A private item was used outside its scope.\n\nErroneous code example:\n\n```compile_fail,E0603\nmod foo {\n const PRIVATE: u32 = 0x_a_bad_1dea_u32; // This const is private, so we\n // can\'t use it outside of the\n // `foo` module.\n}\n\nprintln!(\"const value: {}\", foo::PRIVATE); // error: constant `PRIVATE`\n // is private\n```\n\nIn order to fix this error, you need to make the item public by using the `pub`\nkeyword. Example:\n\n```\nmod foo {\n pub const PRIVATE: u32 = 0x_a_bad_1dea_u32; // We set it public by using the\n // `pub` keyword.\n}\n\nprintln!(\"const value: {}\", foo::PRIVATE); // ok!\n```\n"),
(E0604,
"A cast to `char` was attempted on a type other than `u8`.\n\nErroneous code example:\n\n```compile_fail,E0604\n0u32 as char; // error: only `u8` can be cast as `char`, not `u32`\n```\n\n`char` is a Unicode Scalar Value, an integer value from 0 to 0xD7FF and\n0xE000 to 0x10FFFF. (The gap is for surrogate pairs.) Only `u8` always fits in\nthose ranges so only `u8` may be cast to `char`.\n\nTo allow larger values, use `char::from_u32`, which checks the value is valid.\n\n```\nassert_eq!(86u8 as char, \'V\'); // ok!\nassert_eq!(char::from_u32(0x3B1), Some(\'\u{3b1}\')); // ok!\nassert_eq!(char::from_u32(0xD800), None); // not a USV.\n```\n\nFor more information about casts, take a look at the Type cast section in\n[The Reference Book][1].\n\n[1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions\n"),
(E0605,
"An invalid cast was attempted.\n\nErroneous code examples:\n\n```compile_fail,E0605\nlet x = 0u8;\nx as Vec<u8>; // error: non-primitive cast: `u8` as `std::vec::Vec<u8>`\n\n// Another example\n\nlet v = core::ptr::null::<u8>(); // So here, `v` is a `*const u8`.\nv as &u8; // error: non-primitive cast: `*const u8` as `&u8`\n```\n\nOnly primitive types can be cast into each other. Examples:\n\n```\nlet x = 0u8;\nx as u32; // ok!\n\nlet v = core::ptr::null::<u8>();\nv as *const i8; // ok!\n```\n\nFor more information about casts, take a look at the Type cast section in\n[The Reference Book][1].\n\n[1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions\n"),
(E0606,
"An incompatible cast was attempted.\n\nErroneous code example:\n\n```compile_fail,E0606\nlet x = &0u8; // Here, `x` is a `&u8`.\nlet y: u32 = x as u32; // error: casting `&u8` as `u32` is invalid\n```\n\nWhen casting, keep in mind that only primitive types can be cast into each\nother. Example:\n\n```\nlet x = &0u8;\nlet y: u32 = *x as u32; // We dereference it first and then cast it.\n```\n\nFor more information about casts, take a look at the Type cast section in\n[The Reference Book][1].\n\n[1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions\n"),
(E0607,
"A cast between a thin and a wide pointer was attempted.\n\nErroneous code example:\n\n```compile_fail,E0607\nlet v = core::ptr::null::<u8>();\nv as *const [u8];\n```\n\nFirst: what are thin and wide pointers?\n\nThin pointers are \"simple\" pointers: they are purely a reference to a memory\naddress.\n\nWide pointers are pointers referencing Dynamically Sized Types (also called\nDSTs). DSTs don\'t have a statically known size, therefore they can only exist\nbehind some kind of pointer that contains additional information. For example,\nslices and trait objects are DSTs. In the case of slices, the additional\ninformation the wide pointer holds is their size.\n\nTo fix this error, don\'t try to cast directly between thin and wide pointers.\n\nFor more information about type casts, take a look at the section of the\n[The Rust Reference][1] on type cast expressions.\n\n[1]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions\n"),
(E0608,
"Attempted to index a value whose type doesn\'t implement the\n`std::ops::Index` trait.\n\nErroneous code example:\n\n```compile_fail,E0608\n0u8[2]; // error: cannot index into a value of type `u8`\n```\n\nOnly values with types that implement the `std::ops::Index` trait\ncan be indexed with square brackets. Example:\n\n```\nlet v: Vec<u8> = vec![0, 1, 2, 3];\n\n// The `Vec` type implements the `Index` trait so you can do:\nprintln!(\"{}\", v[2]);\n```\n\nTuples and structs are indexed with dot (`.`), not with brackets (`[]`),\nand tuple element names are their positions:\n```ignore(pseudo code)\n// this (pseudo code) expression is true for any tuple:\ntuple == (tuple.0, tuple.1, ...)\n```\n"),
(E0609,
"Attempted to access a nonexistent field in a struct.\n\nErroneous code example:\n\n```compile_fail,E0609\nstruct StructWithFields {\n x: u32,\n}\n\nlet s = StructWithFields { x: 0 };\nprintln!(\"{}\", s.foo); // error: no field `foo` on type `StructWithFields`\n```\n\nTo fix this error, check that you didn\'t misspell the field\'s name or that the\nfield actually exists. Example:\n\n```\nstruct StructWithFields {\n x: u32,\n}\n\nlet s = StructWithFields { x: 0 };\nprintln!(\"{}\", s.x); // ok!\n```\n"),
(E0610,
"Attempted to access a field on a primitive type.\n\nErroneous code example:\n\n```compile_fail,E0610\nlet x: u32 = 0;\nprintln!(\"{}\", x.foo); // error: `{integer}` is a primitive type, therefore\n // doesn\'t have fields\n```\n\nPrimitive types are the most basic types available in Rust and don\'t have\nfields. To access data via named fields, struct types are used. Example:\n\n```\n// We declare struct called `Foo` containing two fields:\nstruct Foo {\n x: u32,\n y: i64,\n}\n\n// We create an instance of this struct:\nlet variable = Foo { x: 0, y: -12 };\n// And we can now access its fields:\nprintln!(\"x: {}, y: {}\", variable.x, variable.y);\n```\n\nFor more information about [primitives] and [structs], take a look at the Book.\n\n[primitives]: https://doc.rust-lang.org/book/ch03-02-data-types.html\n[structs]: https://doc.rust-lang.org/book/ch05-00-structs.html\n"),
(E0614,
"Attempted to dereference a variable which cannot be dereferenced.\n\nErroneous code example:\n\n```compile_fail,E0614\nlet y = 0u32;\n*y; // error: type `u32` cannot be dereferenced\n```\n\nOnly types implementing `std::ops::Deref` can be dereferenced (such as `&T`).\nExample:\n\n```\nlet y = 0u32;\nlet x = &y;\n// So here, `x` is a `&u32`, so we can dereference it:\n*x; // ok!\n```\n"),
(E0615,
"Attempted to access a method like a field.\n\nErroneous code example:\n\n```compile_fail,E0615\nstruct Foo {\n x: u32,\n}\n\nimpl Foo {\n fn method(&self) {}\n}\n\nlet f = Foo { x: 0 };\nf.method; // error: attempted to take value of method `method` on type `Foo`\n```\n\nIf you want to use a method, add `()` after it:\n\n```\n# struct Foo { x: u32 }\n# impl Foo { fn method(&self) {} }\n# let f = Foo { x: 0 };\nf.method();\n```\n\nHowever, if you wanted to access a field of a struct check that the field name\nis spelled correctly. Example:\n\n```\n# struct Foo { x: u32 }\n# impl Foo { fn method(&self) {} }\n# let f = Foo { x: 0 };\nprintln!(\"{}\", f.x);\n```\n"),
(E0616,
"Attempted to access a private field on a struct.\n\nErroneous code example:\n\n```compile_fail,E0616\nmod some_module {\n pub struct Foo {\n x: u32, // So `x` is private in here.\n }\n\n impl Foo {\n pub fn new() -> Foo { Foo { x: 0 } }\n }\n}\n\nlet f = some_module::Foo::new();\nprintln!(\"{}\", f.x); // error: field `x` of struct `some_module::Foo` is private\n```\n\nIf you want to access this field, you have two options:\n\n1) Set the field public:\n\n```\nmod some_module {\n pub struct Foo {\n pub x: u32, // `x` is now public.\n }\n\n impl Foo {\n pub fn new() -> Foo { Foo { x: 0 } }\n }\n}\n\nlet f = some_module::Foo::new();\nprintln!(\"{}\", f.x); // ok!\n```\n\n2) Add a getter function:\n\n```\nmod some_module {\n pub struct Foo {\n x: u32, // So `x` is still private in here.\n }\n\n impl Foo {\n pub fn new() -> Foo { Foo { x: 0 } }\n\n // We create the getter function here:\n pub fn get_x(&self) -> &u32 { &self.x }\n }\n}\n\nlet f = some_module::Foo::new();\nprintln!(\"{}\", f.get_x()); // ok!\n```\n"),
(E0617,
"Attempted to pass an invalid type of variable into a variadic function.\n\nErroneous code example:\n\n```compile_fail,E0617\n# use std::os::raw::{c_char, c_int};\nextern \"C\" {\n fn printf(format: *const c_char, ...) -> c_int;\n}\n\nunsafe {\n printf(\"%f\\n\\0\".as_ptr() as _, 0f32);\n // error: cannot pass an `f32` to variadic function, cast to `c_double`\n}\n```\n\nCertain Rust types must be cast before passing them to a variadic function,\nbecause of arcane ABI rules dictated by the C standard. To fix the error,\ncast the value to the type specified by the error message (which you may need\nto import from `std::os::raw`).\n\nIn this case, `c_double` has the same size as `f64` so we can use it directly:\n\n```no_run\n# use std::os::raw::{c_char, c_int};\n# extern \"C\" {\n# fn printf(format: *const c_char, ...) -> c_int;\n# }\n\nunsafe {\n printf(\"%f\\n\\0\".as_ptr() as _, 0f64); // ok!\n}\n```\n"),
(E0618,
"Attempted to call something which isn\'t a function nor a method.\n\nErroneous code examples:\n\n```compile_fail,E0618\nenum X {\n Entry,\n}\n\nX::Entry(); // error: expected function, tuple struct or tuple variant,\n // found `X::Entry`\n\n// Or even simpler:\nlet x = 0i32;\nx(); // error: expected function, tuple struct or tuple variant, found `i32`\n```\n\nOnly functions and methods can be called using `()`. Example:\n\n```\n// We declare a function:\nfn i_am_a_function() {}\n\n// And we call it:\ni_am_a_function();\n```\n"),
(E0619,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe type-checker needed to know the type of an expression, but that type had not\nyet been inferred.\n\nErroneous code example:\n\n```compile_fail\nlet mut x = vec![];\nmatch x.pop() {\n Some(v) => {\n // Here, the type of `v` is not (yet) known, so we\n // cannot resolve this method call:\n v.to_uppercase(); // error: the type of this value must be known in\n // this context\n }\n None => {}\n}\n```\n\nType inference typically proceeds from the top of the function to the bottom,\nfiguring out types as it goes. In some cases -- notably method calls and\noverloadable operators like `*` -- the type checker may not have enough\ninformation *yet* to make progress. This can be true even if the rest of the\nfunction provides enough context (because the type-checker hasn\'t looked that\nfar ahead yet). In this case, type annotations can be used to help it along.\n\nTo fix this error, just specify the type of the variable. Example:\n\n```\nlet mut x: Vec<String> = vec![]; // We precise the type of the vec elements.\nmatch x.pop() {\n Some(v) => {\n v.to_uppercase(); // Since rustc now knows the type of the vec elements,\n // we can use `v`\'s methods.\n }\n None => {}\n}\n```\n"),
(E0620,
"A cast to an unsized type was attempted.\n\nErroneous code example:\n\n```compile_fail,E0620\nlet x = &[1_usize, 2] as [usize]; // error: cast to unsized type: `&[usize; 2]`\n // as `[usize]`\n```\n\nIn Rust, some types don\'t have a known size at compile-time. For example, in a\nslice type like `[u32]`, the number of elements is not known at compile-time and\nhence the overall size cannot be computed. As a result, such types can only be\nmanipulated through a reference (e.g., `&T` or `&mut T`) or other pointer-type\n(e.g., `Box` or `Rc`). Try casting to a reference instead:\n\n```\nlet x = &[1_usize, 2] as &[usize]; // ok!\n```\n"),
(E0621,
"This error code indicates a mismatch between the lifetimes appearing in the\nfunction signature (i.e., the parameter types and the return type) and the\ndata-flow found in the function body.\n\nErroneous code example:\n\n```compile_fail,E0621\nfn foo<\'a>(x: &\'a i32, y: &i32) -> &\'a i32 { // error: explicit lifetime\n // required in the type of\n // `y`\n if x > y { x } else { y }\n}\n```\n\nIn the code above, the function is returning data borrowed from either `x` or\n`y`, but the `\'a` annotation indicates that it is returning data only from `x`.\nTo fix the error, the signature and the body must be made to match. Typically,\nthis is done by updating the function signature. So, in this case, we change\nthe type of `y` to `&\'a i32`, like so:\n\n```\nfn foo<\'a>(x: &\'a i32, y: &\'a i32) -> &\'a i32 {\n if x > y { x } else { y }\n}\n```\n\nNow the signature indicates that the function data borrowed from either `x` or\n`y`. Alternatively, you could change the body to not return data from `y`:\n\n```\nfn foo<\'a>(x: &\'a i32, y: &i32) -> &\'a i32 {\n x\n}\n```\n"),
(E0622,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn intrinsic was declared without being a function.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\nextern \"C\" {\n #[rustc_intrinsic]\n pub static atomic_singlethreadfence_seqcst: unsafe fn();\n // error: intrinsic must be a function\n}\n\nfn main() { unsafe { atomic_singlethreadfence_seqcst(); } }\n```\n\nAn intrinsic is a function available for use in a given programming language\nwhose implementation is handled specially by the compiler. In order to fix this\nerror, just declare a function. Example:\n\n```ignore (no longer emitted)\n#![feature(intrinsics)]\n#![allow(internal_features)]\n\n#[rustc_intrinsic]\npub unsafe fn atomic_singlethreadfence_seqcst(); // ok!\n\nfn main() { unsafe { atomic_singlethreadfence_seqcst(); } }\n```\n"),
(E0623,
"A lifetime didn\'t match what was expected.\n\nErroneous code example:\n\n```compile_fail,E0623\nstruct Foo<\'a, \'b, T>(std::marker::PhantomData<(&\'a (), &\'b (), T)>)\nwhere\n T: Convert<\'a, \'b>;\n\ntrait Convert<\'a, \'b>: Sized {\n fn cast(&\'a self) -> &\'b Self;\n}\nimpl<\'long: \'short, \'short, T> Convert<\'long, \'short> for T {\n fn cast(&\'long self) -> &\'short T {\n self\n }\n}\n// error\nfn badboi<\'in_, \'out, T>(\n x: Foo<\'in_, \'out, T>,\n sadness: &\'in_ T\n) -> &\'out T {\n sadness.cast()\n}\n```\n\nIn this example, we tried to set a value with an incompatible lifetime to\nanother one (`\'in_` is unrelated to `\'out`). We can solve this issue in\ntwo different ways:\n\nEither we make `\'in_` live at least as long as `\'out`:\n\n```\nstruct Foo<\'a, \'b, T>(std::marker::PhantomData<(&\'a (), &\'b (), T)>)\nwhere\n T: Convert<\'a, \'b>;\n\ntrait Convert<\'a, \'b>: Sized {\n fn cast(&\'a self) -> &\'b Self;\n}\nimpl<\'long: \'short, \'short, T> Convert<\'long, \'short> for T {\n fn cast(&\'long self) -> &\'short T {\n self\n }\n}\nfn badboi<\'in_: \'out, \'out, T>(\n x: Foo<\'in_, \'out, T>,\n sadness: &\'in_ T\n) -> &\'out T {\n sadness.cast()\n}\n```\n\nOr we use only one lifetime:\n\n```\nstruct Foo<\'a, \'b, T>(std::marker::PhantomData<(&\'a (), &\'b (), T)>)\nwhere\n T: Convert<\'a, \'b>;\n\ntrait Convert<\'a, \'b>: Sized {\n fn cast(&\'a self) -> &\'b Self;\n}\nimpl<\'long: \'short, \'short, T> Convert<\'long, \'short> for T {\n fn cast(&\'long self) -> &\'short T {\n self\n }\n}\nfn badboi<\'out, T>(x: Foo<\'out, \'out, T>, sadness: &\'out T) -> &\'out T {\n sadness.cast()\n}\n```\n"),
(E0624,
"A private item was used outside of its scope.\n\nErroneous code example:\n\n```compile_fail,E0624\nmod inner {\n pub struct Foo;\n\n impl Foo {\n fn method(&self) {}\n }\n}\n\nlet foo = inner::Foo;\nfoo.method(); // error: method `method` is private\n```\n\nTwo possibilities are available to solve this issue:\n\n1. Only use the item in the scope it has been defined:\n\n```\nmod inner {\n pub struct Foo;\n\n impl Foo {\n fn method(&self) {}\n }\n\n pub fn call_method(foo: &Foo) { // We create a public function.\n foo.method(); // Which calls the item.\n }\n}\n\nlet foo = inner::Foo;\ninner::call_method(&foo); // And since the function is public, we can call the\n // method through it.\n```\n\n2. Make the item public:\n\n```\nmod inner {\n pub struct Foo;\n\n impl Foo {\n pub fn method(&self) {} // It\'s now public.\n }\n}\n\nlet foo = inner::Foo;\nfoo.method(); // Ok!\n```\n"),
(E0625,
"A compile-time const variable is referring to a thread-local static variable.\n\nErroneous code example:\n\n```compile_fail,E0625\n#![feature(thread_local)]\n\n#[thread_local]\nstatic X: usize = 12;\n\nconst Y: usize = 2 * X;\n```\n\nStatic and const variables can refer to other const variables but a const\nvariable cannot refer to a thread-local static variable. In this example,\n`Y` cannot refer to `X`. To fix this, the value can be extracted as a const\nand then used:\n\n```\n#![feature(thread_local)]\n\nconst C: usize = 12;\n\n#[thread_local]\nstatic X: usize = C;\n\nconst Y: usize = 2 * C;\n```\n"),
(E0626,
"This error occurs because a borrow in a movable coroutine persists across a\nyield point.\n\nErroneous code example:\n\n```compile_fail,E0626\n# #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n# use std::ops::Coroutine;\n# use std::pin::Pin;\nlet mut b = #[coroutine] || {\n let a = &String::new(); // <-- This borrow...\n yield (); // ...is still in scope here, when the yield occurs.\n println!(\"{}\", a);\n};\nPin::new(&mut b).resume(());\n```\n\nCoroutines may be either unmarked, or marked with `static`. If it is unmarked,\nthen the coroutine is considered \"movable\". At present, it is not permitted to\nhave a yield in a movable coroutine that occurs while a borrow is still in\nscope. To resolve this error, the coroutine may be marked `static`:\n\n```\n# #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n# use std::ops::Coroutine;\n# use std::pin::Pin;\nlet mut b = #[coroutine] static || { // <-- note the static keyword\n let a = &String::from(\"hello, world\");\n yield ();\n println!(\"{}\", a);\n};\nlet mut b = std::pin::pin!(b);\nb.as_mut().resume(());\n```\n\nIf the coroutine must remain movable, for example to be used as `Unpin`\nwithout pinning it on the stack or in an allocation, we can alternatively\nresolve the previous example by removing the borrow and just storing the\ntype by value:\n\n```\n# #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n# use std::ops::Coroutine;\n# use std::pin::Pin;\nlet mut b = #[coroutine] || {\n let a = String::from(\"hello, world\");\n yield ();\n println!(\"{}\", a);\n};\nPin::new(&mut b).resume(());\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n# use std::ops::Coroutine;\n# use std::pin::Pin;\nlet mut b = #[coroutine] || {\n let v = vec![1,2,3];\n for &x in &v { // <-- borrow of `v` is still in scope...\n yield x; // ...when this yield occurs.\n }\n};\nPin::new(&mut b).resume(());\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n# use std::ops::Coroutine;\n# use std::pin::Pin;\nlet mut b = #[coroutine] || {\n let v = vec![1,2,3];\n for x in v { // <-- Take ownership of the values instead!\n yield x; // <-- Now yield is OK.\n }\n};\nPin::new(&mut b).resume(());\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n# use std::ops::Coroutine;\n# use std::pin::Pin;\nlet mut b = #[coroutine] || {\n let v = vec![1,2,3];\n let len = v.len(); // (*)\n for i in 0..len {\n let x = v[i]; // (*)\n yield x; // <-- Now yield is OK.\n }\n};\nPin::new(&mut b).resume(());\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"),
(E0627,
"A yield expression was used outside of the coroutine literal.\n\nErroneous code example:\n\n```compile_fail,E0627\n#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n\nfn fake_coroutine() -> &\'static str {\n yield 1;\n return \"foo\"\n}\n\nfn main() {\n let mut coroutine = fake_coroutine;\n}\n```\n\nThe error occurs because keyword `yield` can only be used inside the coroutine\nliteral. This can be fixed by constructing the coroutine correctly.\n\n```\n#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n\nfn main() {\n let mut coroutine = #[coroutine] || {\n yield 1;\n return \"foo\"\n };\n}\n```\n"),
(E0628,
"More than one parameter was used for a coroutine.\n\nErroneous code example:\n\n```compile_fail,E0628\n#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n\nfn main() {\n let coroutine = #[coroutine] |a: i32, b: i32| {\n // error: too many parameters for a coroutine\n // Allowed only 0 or 1 parameter\n yield a;\n };\n}\n```\n\nAt present, it is not permitted to pass more than one explicit\nparameter for a coroutine.This can be fixed by using\nat most 1 parameter for the coroutine. For example, we might resolve\nthe previous example by passing only one parameter.\n\n```\n#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]\n\nfn main() {\n let coroutine = #[coroutine] |a: i32| {\n yield a;\n };\n}\n```\n"),
(E0631,
"This error indicates a type mismatch in closure arguments.\n\nErroneous code example:\n\n```compile_fail,E0631\nfn foo<F: Fn(i32)>(f: F) {\n}\n\nfn main() {\n foo(|x: &str| {});\n}\n```\n\nThe error occurs because `foo` accepts a closure that takes an `i32` argument,\nbut in `main`, it is passed a closure with a `&str` argument.\n\nThis can be resolved by changing the type annotation or removing it entirely\nif it can be inferred.\n\n```\nfn foo<F: Fn(i32)>(f: F) {\n}\n\nfn main() {\n foo(|x: i32| {});\n}\n```\n"),
(E0632,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn explicit generic argument was provided when calling a function that\nuses `impl Trait` in argument position.\n\nErroneous code example:\n\n```ignore (no longer an error)\nfn foo<T: Copy>(a: T, b: impl Clone) {}\n\nfoo::<i32>(0i32, \"abc\".to_string());\n```\n\nEither all generic arguments should be inferred at the call site, or\nthe function definition should use an explicit generic type parameter\ninstead of `impl Trait`. Example:\n\n```\nfn foo<T: Copy>(a: T, b: impl Clone) {}\nfn bar<T: Copy, U: Clone>(a: T, b: U) {}\n\nfoo(0i32, \"abc\".to_string());\n\nbar::<i32, String>(0i32, \"abc\".to_string());\nbar::<_, _>(0i32, \"abc\".to_string());\nbar(0i32, \"abc\".to_string());\n```\n"),
(E0633,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `unwind` attribute was malformed.\n\nErroneous code example:\n\n```compile_fail\n#![feature(unwind_attributes)]\n\n#[unwind()] // error: expected one argument\npub extern \"C\" fn something() {}\n\nfn main() {}\n```\n\nThe `#[unwind]` attribute should be used as follows:\n\n- `#[unwind(aborts)]` -- specifies that if a non-Rust ABI function\n should abort the process if it attempts to unwind. This is the safer\n and preferred option.\n\n- `#[unwind(allowed)]` -- specifies that a non-Rust ABI function\n should be allowed to unwind. This can easily result in Undefined\n Behavior (UB), so be careful.\n\nNB. The default behavior here is \"allowed\", but this is unspecified\nand likely to change in the future.\n"),
(E0634,
"A type has conflicting `packed` representation hints.\n\nErroneous code examples:\n\n```compile_fail,E0634\n#[repr(packed, packed(2))] // error!\nstruct Company(i32);\n\n#[repr(packed(2))] // error!\n#[repr(packed)]\nstruct Company(i32);\n```\n\nYou cannot use conflicting `packed` hints on a same type. If you want to pack a\ntype to a given size, you should provide a size to packed:\n\n```\n#[repr(packed)] // ok!\nstruct Company(i32);\n```\n"),
(E0635,
"The `#![feature]` attribute specified an unknown feature.\n\nErroneous code example:\n\n```compile_fail,E0635\n#![feature(nonexistent_rust_feature)] // error: unknown feature\n```\n"),
(E0636,
"The same feature is enabled multiple times with `#![feature]` attributes\n\nErroneous code example:\n\n```compile_fail,E0636\n#![allow(stable_features)]\n#![feature(rust1)]\n#![feature(rust1)] // error: the feature `rust1` has already been enabled\n```\n"),
(E0637,
"`\'_` lifetime name or `&T` without an explicit lifetime name has been used\nin an illegal place.\n\nErroneous code example:\n\n```compile_fail,E0106,E0637\nfn underscore_lifetime<\'_>(str1: &\'_ str, str2: &\'_ str) -> &\'_ str {\n //^^ `\'_` is a reserved lifetime name\n if str1.len() > str2.len() {\n str1\n } else {\n str2\n }\n}\n\nfn without_explicit_lifetime<T>()\nwhere\n T: Iterator<Item = &u32>,\n //^ `&` without an explicit lifetime name\n{\n}\n\nfn without_hrtb<T>()\nwhere\n T: Into<&u32>,\n //^ `&` without an explicit lifetime name\n{\n}\n```\n\nFirst, `\'_` cannot be used as a lifetime identifier in some places\nbecause it is a reserved for the anonymous lifetime. Second, `&T`\nwithout an explicit lifetime name cannot also be used in some places.\nTo fix them, use a lowercase letter such as `\'a`, or a series\nof lowercase letters such as `\'foo`. For more information about lifetime\nidentifier, see [the book][bk-no]. For more information on using\nthe anonymous lifetime in Rust 2018, see [the Rust 2018 blog post][blog-al].\n\nCorrected example:\n\n```\nfn underscore_lifetime<\'a>(str1: &\'a str, str2: &\'a str) -> &\'a str {\n if str1.len() > str2.len() {\n str1\n } else {\n str2\n }\n}\n\nfn without_explicit_lifetime<\'a, T>()\nwhere\n T: Iterator<Item = &\'a u32>,\n{\n}\n\nfn without_hrtb<T>()\nwhere\n T: for<\'foo> Into<&\'foo u32>,\n{\n}\n```\n\n[bk-no]: https://doc.rust-lang.org/book/appendix-02-operators.html#non-operator-symbols\n[blog-al]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html#more-lifetime-elision-rules\n"),
(E0638,
"This error indicates that the struct, enum or enum variant must be matched\nnon-exhaustively as it has been marked as `non_exhaustive`.\n\nWhen applied within a crate, downstream users of the crate will need to use the\n`_` pattern when matching enums and use the `..` pattern when matching structs.\nDownstream crates cannot match against non-exhaustive enum variants.\n\nFor example, in the below example, since the enum is marked as\n`non_exhaustive`, it is required that downstream crates match non-exhaustively\non it.\n\n```rust,ignore (pseudo-Rust)\n#[non_exhaustive]\npub enum Error {\n Message(String),\n Other,\n}\n\nimpl Display for Error {\n fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {\n // This will not error, despite being marked as non_exhaustive, as this\n // enum is defined within the current crate, it can be matched\n // exhaustively.\n let display = match self {\n Message(s) => s,\n Other => \"other or unknown error\",\n };\n formatter.write_str(display)\n }\n}\n```\n\nAn example of matching non-exhaustively on the above enum is provided below:\n\n```rust,ignore (pseudo-Rust)\nuse mycrate::Error;\n\n// This will not error as the non_exhaustive Error enum has been matched with a\n// wildcard.\nmatch error {\n Message(s) => ...,\n Other => ...,\n _ => ...,\n}\n```\n\nSimilarly, for structs, match with `..` to avoid this error.\n"),
(E0639,
"This error indicates that the struct, enum or enum variant cannot be\ninstantiated from outside of the defining crate as it has been marked\nas `non_exhaustive` and as such more fields/variants may be added in\nfuture that could cause adverse side effects for this code.\n\nErroneous code example:\n\n```ignore (it only works cross-crate)\n#[non_exhaustive]\npub struct NormalStruct {\n pub first_field: u16,\n pub second_field: u16,\n}\n\nlet ns = NormalStruct { first_field: 640, second_field: 480 }; // error!\n```\n\nIt is recommended that you look for a `new` function or equivalent in the\ncrate\'s documentation.\n"),
(E0640,
"#### This error code is internal to the compiler and will not be emitted with normal Rust code.\n#### Note: this error code is no longer emitted by the compiler.\n"),
(E0641,
"Attempted to cast to/from a pointer with an unknown kind.\n\nErroneous code example:\n\n```compile_fail,E0641\nlet b = 0 as *const _; // error\n```\n\nType information must be provided if a pointer type being cast from/into another\ntype which cannot be inferred:\n\n```\n// Creating a pointer from reference: type can be inferred\nlet a = &(String::from(\"Hello world!\")) as *const _; // ok!\n\nlet b = 0 as *const i32; // ok!\n\nlet c: *const i32 = 0 as *const _; // ok!\n```\n"),
(E0642,
"Trait methods currently cannot take patterns as arguments.\n\nErroneous code example:\n\n```compile_fail,E0642\ntrait Foo {\n fn foo((x, y): (i32, i32)); // error: patterns aren\'t allowed\n // in trait methods\n}\n```\n\nYou can instead use a single name for the argument:\n\n```\ntrait Foo {\n fn foo(x_and_y: (i32, i32)); // ok!\n}\n```\n"),
(E0643,
"This error indicates that there is a mismatch between generic parameters and\nimpl Trait parameters in a trait declaration versus its impl.\n\n```compile_fail,E0643\ntrait Foo {\n fn foo(&self, _: &impl Iterator);\n}\nimpl Foo for () {\n fn foo<U: Iterator>(&self, _: &U) { } // error method `foo` has incompatible\n // signature for trait\n}\n```\n"),
(E0644,
"A closure or generator was constructed that references its own type.\n\nErroneous code example:\n\n```compile_fail,E0644\nfn fix<F>(f: &F)\n where F: Fn(&F)\n{\n f(&f);\n}\n\nfn main() {\n fix(&|y| {\n // Here, when `x` is called, the parameter `y` is equal to `x`.\n });\n}\n```\n\nRust does not permit a closure to directly reference its own type,\neither through an argument (as in the example above) or by capturing\nitself through its environment. This restriction helps keep closure\ninference tractable.\n\nThe easiest fix is to rewrite your closure into a top-level function,\nor into a method. In some cases, you may also be able to have your\nclosure call itself by capturing a `&Fn()` object or `fn()` pointer\nthat refers to itself. That is permitting, since the closure would be\ninvoking itself via a virtual call, and hence does not directly\nreference its own *type*.\n"),
(E0646,
"It is not possible to define `main` with a where clause.\n\nErroneous code example:\n\n```compile_fail,E0646\nfn main() where i32: Copy { // error: main function is not allowed to have\n // a where clause\n}\n```\n"),
(E0647,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `start` function was defined with a where clause.\n"),
(E0648,
"An `export_name` attribute contains null characters (`\\0`).\n\nErroneous code example:\n\n```compile_fail,E0648\n#[export_name=\"\\0foo\"] // error: `export_name` may not contain null characters\npub fn bar() {}\n```\n\nTo fix this error, remove the null characters:\n\n```\n#[export_name=\"foo\"] // ok!\npub fn bar() {}\n```\n"),
(E0657,
"An `impl Trait` captured a higher-ranked lifetime, which is not supported.\n\nCurrently, `impl Trait` types are only allowed to capture lifetimes from\ntheir parent items, and not from any `for<\'a>` binders in scope.\n\nErroneous code example:\n\n```compile_fail,E0657\ntrait BorrowInto<\'a> {\n type Target;\n\n fn borrow_into(&\'a self) -> Self::Target;\n}\n\nimpl<\'a> BorrowInto<\'a> for () {\n type Target = &\'a ();\n\n fn borrow_into(&\'a self) -> Self::Target {\n self\n }\n}\n\nfn opaque() -> impl for<\'a> BorrowInto<\'a, Target = impl Sized + \'a> {\n ()\n}\n```\n"),
(E0658,
"An unstable feature was used.\n\nErroneous code example:\n\n```compile_fail,E0658\nuse std::intrinsics; // error: use of unstable library feature `core_intrinsics`\n```\n\nIf you\'re using a stable or a beta version of rustc, you won\'t be able to use\nany unstable features. In order to do so, please switch to a nightly version of\nrustc (by using [rustup]).\n\nIf you\'re using a nightly version of rustc, just add the corresponding feature\nto be able to use it:\n\n```\n#![feature(core_intrinsics)]\n\nuse std::intrinsics; // ok!\n```\n\n[rustup]: https://rust-lang.github.io/rustup/concepts/channels.html\n"),
(E0659,
"An item usage is ambiguous.\n\nErroneous code example:\n\n```compile_fail,edition2018,E0659\npub mod moon {\n pub fn foo() {}\n}\n\npub mod earth {\n pub fn foo() {}\n}\n\nmod collider {\n pub use crate::moon::*;\n pub use crate::earth::*;\n}\n\nfn main() {\n crate::collider::foo(); // ERROR: `foo` is ambiguous\n}\n```\n\nThis error generally appears when two items with the same name are imported into\na module. Here, the `foo` functions are imported and reexported from the\n`collider` module and therefore, when we\'re using `collider::foo()`, both\nfunctions collide.\n\nTo solve this error, the best solution is generally to keep the path before the\nitem when using it. Example:\n\n```edition2018\npub mod moon {\n pub fn foo() {}\n}\n\npub mod earth {\n pub fn foo() {}\n}\n\nmod collider {\n pub use crate::moon;\n pub use crate::earth;\n}\n\nfn main() {\n crate::collider::moon::foo(); // ok!\n crate::collider::earth::foo(); // ok!\n}\n```\n"),
(E0660,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe argument to the `llvm_asm` macro is not well-formed.\n\nErroneous code example:\n\n```ignore (no longer emitted)\nllvm_asm!(\"nop\" \"nop\");\n```\n"),
(E0661,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn invalid syntax was passed to the second argument of an `llvm_asm` macro line.\n\nErroneous code example:\n\n```ignore (no longer emitted)\nlet a;\nllvm_asm!(\"nop\" : \"r\"(a));\n```\n"),
(E0662,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn invalid input operand constraint was passed to the `llvm_asm` macro\n(third line).\n\nErroneous code example:\n\n```ignore (no longer emitted)\nllvm_asm!(\"xor %eax, %eax\"\n :\n : \"=test\"(\"a\")\n );\n```\n"),
(E0663,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn invalid input operand constraint was passed to the `llvm_asm` macro\n(third line).\n\nErroneous code example:\n\n```ignore (no longer emitted)\nllvm_asm!(\"xor %eax, %eax\"\n :\n : \"+test\"(\"a\")\n );\n```\n"),
(E0664,
"#### Note: this error code is no longer emitted by the compiler.\n\nA clobber was surrounded by braces in the `llvm_asm` macro.\n\nErroneous code example:\n\n```ignore (no longer emitted)\nllvm_asm!(\"mov $$0x200, %eax\"\n :\n :\n : \"{eax}\"\n );\n```\n"),
(E0665,
"The `Default` trait was derived on an enum without specifying the default\nvariant.\n\nErroneous code example:\n\n```compile_fail,E0665\n#[derive(Default)]\nenum Food {\n Sweet,\n Salty,\n}\n```\n\nThe `Default` cannot be derived on an enum for the simple reason that the\ncompiler doesn\'t know which value to pick by default whereas it can for a\nstruct as long as all its fields implement the `Default` trait as well.\n\nFor the case where the desired default variant has no payload, you can\nannotate it with `#[default]` to derive it:\n\n```\n#[derive(Default)]\nenum Food {\n #[default]\n Sweet,\n Salty,\n}\n```\n\nIn the case where the default variant does have a payload, you will have to\nimplement `Default` on your enum manually:\n\n```\nenum Food {\n Sweet(i32),\n Salty,\n}\n\nimpl Default for Food {\n fn default() -> Food {\n Food::Sweet(1)\n }\n}\n```\n"),
(E0666,
"`impl Trait` types cannot appear nested in the generic arguments of other\n`impl Trait` types.\n\nErroneous code example:\n\n```compile_fail,E0666\ntrait MyGenericTrait<T> {}\ntrait MyInnerTrait {}\n\nfn foo(\n bar: impl MyGenericTrait<impl MyInnerTrait>, // error!\n) {}\n```\n\nType parameters for `impl Trait` types must be explicitly defined as named\ngeneric parameters:\n\n```\ntrait MyGenericTrait<T> {}\ntrait MyInnerTrait {}\n\nfn foo<T: MyInnerTrait>(\n bar: impl MyGenericTrait<T>, // ok!\n) {}\n```\n"),
(E0667,
"#### Note: this error code is no longer emitted by the compiler.\n\n`impl Trait` is not allowed in path parameters.\n\nErroneous code example:\n\n```ignore (removed error code)\nfn some_fn(mut x: impl Iterator) -> <impl Iterator>::Item { // error!\n x.next().unwrap()\n}\n```\n\nYou cannot use `impl Trait` in path parameters. If you want something\nequivalent, you can do this instead:\n\n```ignore (removed error code)\nfn some_fn<T: Iterator>(mut x: T) -> T::Item { // ok!\n x.next().unwrap()\n}\n```\n"),
(E0668,
"#### Note: this error code is no longer emitted by the compiler.\n\nMalformed inline assembly rejected by LLVM.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(llvm_asm)]\n\nfn main() {\n let rax: u64;\n unsafe {\n llvm_asm!(\"\" :\"={rax\"(rax));\n println!(\"Accumulator is: {}\", rax);\n }\n}\n```\n\nLLVM checks the validity of the constraints and the assembly string passed to\nit. This error implies that LLVM seems something wrong with the inline\nassembly call.\n\nIn particular, it can happen if you forgot the closing bracket of a register\nconstraint (see issue #51430), like in the previous code example.\n"),
(E0669,
"#### Note: this error code is no longer emitted by the compiler.\n\nCannot convert inline assembly operand to a single LLVM value.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(llvm_asm)]\n\nfn main() {\n unsafe {\n llvm_asm!(\"\" :: \"r\"(\"\")); // error!\n }\n}\n```\n\nThis error usually happens when trying to pass in a value to an input inline\nassembly operand that is actually a pair of values. In particular, this can\nhappen when trying to pass in a slice, for instance a `&str`. In Rust, these\nvalues are represented internally as a pair of values, the pointer and its\nlength. When passed as an input operand, this pair of values can not be\ncoerced into a register and thus we must fail with an error.\n"),
(E0670,
"Rust 2015 does not permit the use of `async fn`.\n\nErroneous code example:\n\n```compile_fail,E0670\nasync fn foo() {}\n```\n\nSwitch to the Rust 2018 edition to use `async fn`.\n"),
(E0671,
"#### Note: this error code is no longer emitted by the compiler.\n\nConst parameters cannot depend on type parameters.\nThe following is therefore invalid:\n\n```compile_fail,E0770\nfn const_id<T, const N: T>() -> T { // error\n N\n}\n```\n"),
(E0687,
"#### Note: this error code is no longer emitted by the compiler.\n\nIn-band lifetimes cannot be used in `fn`/`Fn` syntax.\n\nErroneous code examples:\n\n```ignore (feature got removed)\n#![feature(in_band_lifetimes)]\n\nfn foo(x: fn(&\'a u32)) {} // error!\n\nfn bar(x: &Fn(&\'a u32)) {} // error!\n\nfn baz(x: fn(&\'a u32), y: &\'a u32) {} // error!\n\nstruct Foo<\'a> { x: &\'a u32 }\n\nimpl Foo<\'a> {\n fn bar(&self, x: fn(&\'a u32)) {} // error!\n}\n```\n\nLifetimes used in `fn` or `Fn` syntax must be explicitly\ndeclared using `<...>` binders. For example:\n\n```\nfn foo<\'a>(x: fn(&\'a u32)) {} // ok!\n\nfn bar<\'a>(x: &Fn(&\'a u32)) {} // ok!\n\nfn baz<\'a>(x: fn(&\'a u32), y: &\'a u32) {} // ok!\n\nstruct Foo<\'a> { x: &\'a u32 }\n\nimpl<\'a> Foo<\'a> {\n fn bar(&self, x: fn(&\'a u32)) {} // ok!\n}\n```\n"),
(E0688,
"#### Note: this error code is no longer emitted by the compiler.\n\nIn-band lifetimes were mixed with explicit lifetime binders.\n\nErroneous code example:\n\n```ignore (feature got removed)\n#![feature(in_band_lifetimes)]\n\nfn foo<\'a>(x: &\'a u32, y: &\'b u32) {} // error!\n\nstruct Foo<\'a> { x: &\'a u32 }\n\nimpl Foo<\'a> {\n fn bar<\'b>(x: &\'a u32, y: &\'b u32, z: &\'c u32) {} // error!\n}\n\nimpl<\'b> Foo<\'a> { // error!\n fn baz() {}\n}\n```\n\nIn-band lifetimes cannot be mixed with explicit lifetime binders.\nFor example:\n\n```\nfn foo<\'a, \'b>(x: &\'a u32, y: &\'b u32) {} // ok!\n\nstruct Foo<\'a> { x: &\'a u32 }\n\nimpl<\'a> Foo<\'a> {\n fn bar<\'b,\'c>(x: &\'a u32, y: &\'b u32, z: &\'c u32) {} // ok!\n}\n\nimpl<\'a> Foo<\'a> { // ok!\n fn baz() {}\n}\n```\n"),
(E0689,
"A method was called on an ambiguous numeric type.\n\nErroneous code example:\n\n```compile_fail,E0689\n2.0.neg(); // error!\n```\n\nThis error indicates that the numeric value for the method being passed exists\nbut the type of the numeric value or binding could not be identified.\n\nThe error happens on numeric literals and on numeric bindings without an\nidentified concrete type:\n\n```compile_fail,E0689\nlet x = 2.0;\nx.neg(); // same error as above\n```\n\nBecause of this, you must give the numeric literal or binding a type:\n\n```\nuse std::ops::Neg;\n\nlet _ = 2.0_f32.neg(); // ok!\nlet x: f32 = 2.0;\nlet _ = x.neg(); // ok!\nlet _ = (2.0 as f32).neg(); // ok!\n```\n"),
(E0690,
"A struct with the representation hint `repr(transparent)` had two or more fields\nthat were not guaranteed to be zero-sized.\n\nErroneous code example:\n\n```compile_fail,E0690\n#[repr(transparent)]\nstruct LengthWithUnit<U> { // error: transparent struct needs at most one\n value: f32, // non-zero-sized field, but has 2\n unit: U,\n}\n```\n\nBecause transparent structs are represented exactly like one of their fields at\nrun time, said field must be uniquely determined. If there are multiple fields,\nit is not clear how the struct should be represented.\nNote that fields of zero-sized types (e.g., `PhantomData`) can also exist\nalongside the field that contains the actual data, they do not count for this\nerror. When generic types are involved (as in the above example), an error is\nreported because the type parameter could be non-zero-sized.\n\nTo combine `repr(transparent)` with type parameters, `PhantomData` may be\nuseful:\n\n```\nuse std::marker::PhantomData;\n\n#[repr(transparent)]\nstruct LengthWithUnit<U> {\n value: f32,\n unit: PhantomData<U>,\n}\n```\n"),
(E0691,
"#### Note: this error code is no longer emitted by the compiler.\n\nA struct, enum, or union with the `repr(transparent)` representation hint\ncontains a zero-sized field that requires non-trivial alignment.\n\nErroneous code example:\n\n```ignore (error is no longer emitted)\n#![feature(repr_align)]\n\n#[repr(align(32))]\nstruct ForceAlign32;\n\n#[repr(transparent)]\nstruct Wrapper(f32, ForceAlign32); // error: zero-sized field in transparent\n // struct has alignment of 32, which\n // is larger than 1\n```\n\nA transparent struct, enum, or union is supposed to be represented exactly like\nthe piece of data it contains. Zero-sized fields with different alignment\nrequirements potentially conflict with this property. In the example above,\n`Wrapper` would have to be aligned to 32 bytes even though `f32` has a smaller\nalignment requirement.\n\nConsider removing the over-aligned zero-sized field:\n\n```\n#[repr(transparent)]\nstruct Wrapper(f32);\n```\n\nAlternatively, `PhantomData<T>` has alignment 1 for all `T`, so you can use it\nif you need to keep the field for some reason:\n\n```\n#![feature(repr_align)]\n\nuse std::marker::PhantomData;\n\n#[repr(align(32))]\nstruct ForceAlign32;\n\n#[repr(transparent)]\nstruct Wrapper(f32, PhantomData<ForceAlign32>);\n```\n\nNote that empty arrays `[T; 0]` have the same alignment requirement as the\nelement type `T`. Also note that the error is conservatively reported even when\nthe alignment of the zero-sized type is less than or equal to the data field\'s\nalignment.\n"),
(E0692,
"A `repr(transparent)` type was also annotated with other, incompatible\nrepresentation hints.\n\nErroneous code example:\n\n```compile_fail,E0692\n#[repr(transparent, C)] // error: incompatible representation hints\nstruct Grams(f32);\n```\n\nA type annotated as `repr(transparent)` delegates all representation concerns to\nanother type, so adding more representation hints is contradictory. Remove\neither the `transparent` hint or the other hints, like this:\n\n```\n#[repr(transparent)]\nstruct Grams(f32);\n```\n\nAlternatively, move the other attributes to the contained type:\n\n```\n#[repr(C)]\nstruct Foo {\n x: i32,\n // ...\n}\n\n#[repr(transparent)]\nstruct FooWrapper(Foo);\n```\n\nNote that introducing another `struct` just to have a place for the other\nattributes may have unintended side effects on the representation:\n\n```\n#[repr(transparent)]\nstruct Grams(f32);\n\n#[repr(C)]\nstruct Float(f32);\n\n#[repr(transparent)]\nstruct Grams2(Float); // this is not equivalent to `Grams` above\n```\n\nHere, `Grams2` is a not equivalent to `Grams` -- the former transparently wraps\na (non-transparent) struct containing a single float, while `Grams` is a\ntransparent wrapper around a float. This can make a difference for the ABI.\n"),
(E0693,
"`align` representation hint was incorrectly declared.\n\nErroneous code examples:\n\n```compile_fail,E0693\n#[repr(align=8)] // error!\nstruct Align8(i8);\n\n#[repr(align=\"8\")] // error!\nstruct Align8(i8);\n```\n\nThis is a syntax error at the level of attribute declarations. The proper\nsyntax for `align` representation hint is the following:\n\n```\n#[repr(align(8))] // ok!\nstruct Align8(i8);\n```\n"),
(E0695,
"A `break` statement without a label appeared inside a labeled block.\n\nErroneous code example:\n\n```compile_fail,E0695\nloop {\n \'a: {\n break;\n }\n}\n```\n\nMake sure to always label the `break`:\n\n```\n\'l: loop {\n \'a: {\n break \'l;\n }\n}\n```\n\nOr if you want to `break` the labeled block:\n\n```\nloop {\n \'a: {\n break \'a;\n }\n break;\n}\n```\n"),
(E0696,
"A function is using `continue` keyword incorrectly.\n\nErroneous code example:\n\n```compile_fail,E0696\nfn continue_simple() {\n \'b: {\n continue; // error!\n }\n}\nfn continue_labeled() {\n \'b: {\n continue \'b; // error!\n }\n}\nfn continue_crossing() {\n loop {\n \'b: {\n continue; // error!\n }\n }\n}\n```\n\nHere we have used the `continue` keyword incorrectly. As we\nhave seen above that `continue` pointing to a labeled block.\n\nTo fix this we have to use the labeled block properly.\nFor example:\n\n```\nfn continue_simple() {\n \'b: loop {\n continue ; // ok!\n }\n}\nfn continue_labeled() {\n \'b: loop {\n continue \'b; // ok!\n }\n}\nfn continue_crossing() {\n loop {\n \'b: loop {\n continue; // ok!\n }\n }\n}\n```\n"),
(E0697,
"A closure has been used as `static`.\n\nErroneous code example:\n\n```compile_fail,E0697\nfn main() {\n static || {}; // used as `static`\n}\n```\n\nClosures cannot be used as `static`. They \"save\" the environment,\nand as such a static closure would save only a static environment\nwhich would consist only of variables with a static lifetime. Given\nthis it would be better to use a proper function. The easiest fix\nis to remove the `static` keyword.\n"),
(E0698,
"#### Note: this error code is no longer emitted by the compiler.\n\nWhen using coroutines (or async) all type variables must be bound so a\ncoroutine can be constructed.\n\nErroneous code example:\n\n```edition2018,compile_fail,E0282\nasync fn bar<T>() -> () {}\n\nasync fn foo() {\n bar().await; // error: cannot infer type for `T`\n}\n```\n\nIn the above example `T` is unknowable by the compiler.\nTo fix this you must bind `T` to a concrete type such as `String`\nso that a coroutine can then be constructed:\n\n```edition2018\nasync fn bar<T>() -> () {}\n\nasync fn foo() {\n bar::<String>().await;\n // ^^^^^^^^ specify type explicitly\n}\n```\n"),
(E0699,
"#### Note: this error code is no longer emitted by the compiler.\n\nA method was called on a raw pointer whose inner type wasn\'t completely known.\n\nErroneous code example:\n\n```compile_fail,edition2018\n# #![deny(warnings)]\n# fn main() {\nlet foo = &1;\nlet bar = foo as *const _;\nif bar.is_null() {\n // ...\n}\n# }\n```\n\nHere, the type of `bar` isn\'t known; it could be a pointer to anything. Instead,\nspecify a type for the pointer (preferably something that makes sense for the\nthing you\'re pointing to):\n\n```\nlet foo = &1;\nlet bar = foo as *const i32;\nif bar.is_null() {\n // ...\n}\n```\n\nEven though `is_null()` exists as a method on any raw pointer, Rust shows this\nerror because Rust allows for `self` to have arbitrary types (behind the\narbitrary_self_types feature flag).\n\nThis means that someone can specify such a function:\n\n```ignore (cannot-doctest-feature-doesnt-exist-yet)\nimpl Foo {\n fn is_null(self: *const Self) -> bool {\n // do something else\n }\n}\n```\n\nand now when you call `.is_null()` on a raw pointer to `Foo`, there\'s ambiguity.\n\nGiven that we don\'t know what type the pointer is, and there\'s potential\nambiguity for some types, we disallow calling methods on raw pointers when\nthe type is unknown.\n"),
(E0700,
"The `impl Trait` return type captures lifetime parameters that do not\nappear within the `impl Trait` itself.\n\nErroneous code example:\n\n```compile_fail,E0700\nuse std::cell::Cell;\n\ntrait Trait<\'a> { }\n\nimpl<\'a, \'b> Trait<\'b> for Cell<&\'a u32> { }\n\nfn foo<\'x, \'y>(x: Cell<&\'x u32>) -> impl Trait<\'y>\nwhere \'x: \'y\n{\n x\n}\n```\n\nHere, the function `foo` returns a value of type `Cell<&\'x u32>`,\nwhich references the lifetime `\'x`. However, the return type is\ndeclared as `impl Trait<\'y>` -- this indicates that `foo` returns\n\"some type that implements `Trait<\'y>`\", but it also indicates that\nthe return type **only captures data referencing the lifetime `\'y`**.\nIn this case, though, we are referencing data with lifetime `\'x`, so\nthis function is in error.\n\nTo fix this, you must reference the lifetime `\'x` from the return\ntype. For example, changing the return type to `impl Trait<\'y> + \'x`\nwould work:\n\n```\nuse std::cell::Cell;\n\ntrait Trait<\'a> { }\n\nimpl<\'a,\'b> Trait<\'b> for Cell<&\'a u32> { }\n\nfn foo<\'x, \'y>(x: Cell<&\'x u32>) -> impl Trait<\'y> + \'x\nwhere \'x: \'y\n{\n x\n}\n```\n"),
(E0701,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis error indicates that a `#[non_exhaustive]` attribute was incorrectly placed\non something other than a struct or enum.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#[non_exhaustive]\ntrait Foo { }\n```\n"),
(E0703,
"Invalid ABI (Application Binary Interface) used in the code.\n\nErroneous code example:\n\n```compile_fail,E0703\nextern \"invalid\" fn foo() {} // error!\n# fn main() {}\n```\n\nAt present few predefined ABI\'s (like Rust, C, system, etc.) can be\nused in Rust. Verify that the ABI is predefined. For example you can\nreplace the given ABI from \'Rust\'.\n\n```\nextern \"Rust\" fn foo() {} // ok!\n# fn main() { }\n```\n"),
(E0704,
"An incorrect visibility restriction was specified.\n\nErroneous code example:\n\n```compile_fail,E0704\nmod foo {\n pub(foo) struct Bar {\n x: i32\n }\n}\n```\n\nTo make struct `Bar` only visible in module `foo` the `in` keyword should be\nused:\n\n```\nmod foo {\n pub(in crate::foo) struct Bar {\n x: i32\n }\n}\n# fn main() {}\n```\n\nFor more information see the Rust Reference on [Visibility].\n\n[Visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html\n"),
(E0705,
"#### Note: this error code is no longer emitted by the compiler.\n\nA `#![feature]` attribute was used for a feature that is stable in the\ncurrent edition, but not in all editions.\n\nErroneous code example:\n\n```compile_fail\n#![feature(rust_2018_preview)]\n#![feature(test_2018_feature)] // error: the feature\n // `test_2018_feature` is\n // included in the Rust 2018 edition\n```\n"),
(E0706,
"#### Note: this error code is no longer emitted by the compiler.\n\n`async fn`s are not yet supported in traits in Rust.\n\nErroneous code example:\n\n```ignore,edition2018\ntrait T {\n // Neither case is currently supported.\n async fn foo() {}\n async fn bar(&self) {}\n}\n```\n\n`async fn`s return an `impl Future`, making the following two examples\nequivalent:\n\n```ignore,edition2018 (example-of-desugaring-equivalence)\nasync fn foo() -> User {\n unimplemented!()\n}\n// The async fn above gets desugared as follows:\nfn foo(&self) -> impl Future<Output = User> + \'_ {\n unimplemented!()\n}\n```\n\nBut when it comes to supporting this in traits, there are [a few implementation\nissues][async-is-hard]. One of them is returning `impl Trait` in traits is not\nsupported, as it would require [Generic Associated Types] to be supported:\n\n```edition2018,ignore (example-of-desugaring-equivalence)\nimpl MyDatabase {\n async fn get_user(&self) -> User {\n unimplemented!()\n }\n}\n\nimpl MyDatabase {\n fn get_user(&self) -> impl Future<Output = User> + \'_ {\n unimplemented!()\n }\n}\n```\n\nUntil these issues are resolved, you can use the [`async-trait` crate], allowing\nyou to use `async fn` in traits by desugaring to \"boxed futures\"\n(`Pin<Box<dyn Future + Send + \'async>>`).\n\nNote that using these trait methods will result in a heap allocation\nper-function-call. This is not a significant cost for the vast majority of\napplications, but should be considered when deciding whether to use this\nfunctionality in the public API of a low-level function that is expected to be\ncalled millions of times a second.\n\nYou might be interested in visiting the [async book] for further information.\n\n[`async-trait` crate]: https://crates.io/crates/async-trait\n[async-is-hard]: https://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/\n[Generic Associated Types]: https://github.com/rust-lang/rust/issues/44265\n[async book]: https://rust-lang.github.io/async-book/07_workarounds/05_async_in_traits.html\n"),
(E0708,
"#### Note: this error code is no longer emitted by the compiler.\n\n`async` non-`move` closures with parameters are currently not supported.\n\nErroneous code example:\n\n```edition2018\nfn main() {\n let add_one = async |num: u8| {\n num + 1\n };\n}\n```\n\n`async` with non-move is currently not supported with the current\nversion, you can use successfully by using move:\n\n```edition2018\nfn main() {\n let add_one = async move |num: u8| { // ok!\n num + 1\n };\n}\n```\n"),
(E0710,
"An unknown tool name was found in a scoped lint.\n\nErroneous code examples:\n\n```compile_fail,E0710\n#[allow(clipp::filter_map)] // error!\nfn main() {\n // business logic\n}\n```\n\n```compile_fail,E0710\n#[warn(clipp::filter_map)] // error!\nfn main() {\n // business logic\n}\n```\n\nPlease verify you didn\'t misspell the tool\'s name or that you didn\'t\nforget to import it in you project:\n\n```\n#[allow(clippy::filter_map)] // ok!\nfn main() {\n // business logic\n}\n```\n\n```\n#[warn(clippy::filter_map)] // ok!\nfn main() {\n // business logic\n}\n```\n"),
(E0712,
"A borrow of a thread-local variable was made inside a function which outlived\nthe lifetime of the function.\n\nErroneous code example:\n\n```compile_fail,E0712\n#![feature(thread_local)]\n\n#[thread_local]\nstatic FOO: u8 = 3;\n\nfn main() {\n let a = &FOO; // error: thread-local variable borrowed past end of function\n\n std::thread::spawn(move || {\n println!(\"{}\", a);\n });\n}\n```\n"),
(E0713,
"This error occurs when an attempt is made to borrow state past the end of the\nlifetime of a type that implements the `Drop` trait.\n\nErroneous code example:\n\n```compile_fail,E0713\npub struct S<\'a> { data: &\'a mut String }\n\nimpl<\'a> Drop for S<\'a> {\n fn drop(&mut self) { self.data.push_str(\"being dropped\"); }\n}\n\nfn demo<\'a>(s: S<\'a>) -> &\'a mut String { let p = &mut *s.data; p }\n```\n\nHere, `demo` tries to borrow the string data held within its\nargument `s` and then return that borrow. However, `S` is\ndeclared as implementing `Drop`.\n\nStructs implementing the `Drop` trait have an implicit destructor that\ngets called when they go out of scope. This destructor gets exclusive\naccess to the fields of the struct when it runs.\n\nThis means that when `s` reaches the end of `demo`, its destructor\ngets exclusive access to its `&mut`-borrowed string data. allowing\nanother borrow of that string data (`p`), to exist across the drop of\n`s` would be a violation of the principle that `&mut`-borrows have\nexclusive, unaliased access to their referenced data.\n\nThis error can be fixed by changing `demo` so that the destructor does\nnot run while the string-data is borrowed; for example by taking `S`\nby reference:\n\n```\npub struct S<\'a> { data: &\'a mut String }\n\nimpl<\'a> Drop for S<\'a> {\n fn drop(&mut self) { self.data.push_str(\"being dropped\"); }\n}\n\nfn demo<\'a>(s: &\'a mut S<\'a>) -> &\'a mut String { let p = &mut *(*s).data; p }\n```\n\nNote that this approach needs a reference to S with lifetime `\'a`.\nNothing shorter than `\'a` will suffice: a shorter lifetime would imply\nthat after `demo` finishes executing, something else (such as the\ndestructor!) could access `s.data` after the end of that shorter\nlifetime, which would again violate the `&mut`-borrow\'s exclusive\naccess.\n"),
(E0714,
"A `#[marker]` trait contained an associated item.\n\nErroneous code example:\n\n```compile_fail,E0714\n#![feature(marker_trait_attr)]\n#![feature(associated_type_defaults)]\n\n#[marker]\ntrait MarkerConst {\n const N: usize; // error!\n}\n\nfn main() {}\n```\n\nThe items of marker traits cannot be overridden, so there\'s no need to have them\nwhen they cannot be changed per-type anyway. If you wanted them for ergonomic\nreasons, consider making an extension trait instead.\n"),
(E0715,
"An `impl` for a `#[marker]` trait tried to override an associated item.\n\nErroneous code example:\n\n```compile_fail,E0715\n#![feature(marker_trait_attr)]\n\n#[marker]\ntrait Marker {\n const N: usize = 0;\n fn do_something() {}\n}\n\nstruct OverrideConst;\nimpl Marker for OverrideConst { // error!\n const N: usize = 1;\n}\n# fn main() {}\n```\n\nBecause marker traits are allowed to have multiple implementations for the same\ntype, it\'s not allowed to override anything in those implementations, as it\nwould be ambiguous which override should actually be used.\n"),
(E0716,
"A temporary value is being dropped while a borrow is still in active use.\n\nErroneous code example:\n\n```compile_fail,E0716\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet p = bar(&foo());\n // ------ creates a temporary\nlet q = *p;\n```\n\nHere, the expression `&foo()` is borrowing the expression `foo()`. As `foo()` is\na call to a function, and not the name of a variable, this creates a\n**temporary** -- that temporary stores the return value from `foo()` so that it\ncan be borrowed. You could imagine that `let p = bar(&foo());` is equivalent to\nthe following, which uses an explicit temporary variable.\n\nErroneous code example:\n\n```compile_fail,E0597\n# fn foo() -> i32 { 22 }\n# fn bar(x: &i32) -> &i32 { x }\nlet p = {\n let tmp = foo(); // the temporary\n bar(&tmp) // error: `tmp` does not live long enough\n}; // <-- tmp is freed as we exit this block\nlet q = p;\n```\n\nWhenever a temporary is created, it is automatically dropped (freed) according\nto fixed rules. Ordinarily, the temporary is dropped at the end of the enclosing\nstatement -- in this case, after the `let p`. This is illustrated in the example\nabove by showing that `tmp` would be freed as we exit the block.\n\nTo fix this problem, you need to create a local variable to store the value in\nrather than relying on a temporary. For example, you might change the original\nprogram to the following:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = foo(); // dropped at the end of the enclosing block\nlet p = bar(&value);\nlet q = *p;\n```\n\nBy introducing the explicit `let value`, we allocate storage that will last\nuntil the end of the enclosing block (when `value` goes out of scope). When we\nborrow `&value`, we are borrowing a local variable that already exists, and\nhence no temporary is created.\n\nTemporaries are not always dropped at the end of the enclosing statement. In\nsimple cases where the `&` expression is immediately stored into a variable, the\ncompiler will automatically extend the lifetime of the temporary until the end\nof the enclosing block. Therefore, an alternative way to fix the original\nprogram is to write `let tmp = &foo()` and not `let tmp = foo()`:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = &foo();\nlet p = bar(value);\nlet q = *p;\n```\n\nHere, we are still borrowing `foo()`, but as the borrow is assigned directly\ninto a variable, the temporary will not be dropped until the end of the\nenclosing block. Similar rules apply when temporaries are stored into aggregate\nstructures like a tuple or struct:\n\n```\n// Here, two temporaries are created, but\n// as they are stored directly into `value`,\n// they are not dropped until the end of the\n// enclosing block.\nfn foo() -> i32 { 22 }\nlet value = (&foo(), &foo());\n```\n"),
(E0711,
"#### This error code is internal to the compiler and will not be emitted with normal Rust code.\n\nFeature declared with conflicting stability requirements.\n\n```compile_fail,E0711\n// NOTE: this attribute is perma-unstable and should *never* be used outside of\n// stdlib and the compiler.\n#![feature(staged_api)]\n\n#![stable(feature = \"...\", since = \"1.0.0\")]\n\n#[stable(feature = \"foo\", since = \"1.0.0\")]\nfn foo_stable_1_0_0() {}\n\n// error: feature `foo` is declared stable since 1.29.0\n#[stable(feature = \"foo\", since = \"1.29.0\")]\nfn foo_stable_1_29_0() {}\n\n// error: feature `foo` is declared unstable\n#[unstable(feature = \"foo\", issue = \"none\")]\nfn foo_unstable() {}\n```\n\nIn the above example, the `foo` feature is first defined to be stable since\n1.0.0, but is then re-declared stable since 1.29.0. This discrepancy in\nversions causes an error. Furthermore, `foo` is then re-declared as unstable,\nagain the conflict causes an error.\n\nThis error can be fixed by splitting the feature, this allows any\nstability requirements and removes any possibility of conflict.\n"),
(E0717,
"#### This error code is internal to the compiler and will not be emitted with normal Rust code.\n"),
(E0718,
"A `#[lang = \"..\"]` attribute was placed on the wrong item type.\n\nErroneous code example:\n\n```compile_fail,E0718\n#![feature(lang_items)]\n\n#[lang = \"owned_box\"]\nstatic X: u32 = 42;\n```\n"),
(E0719,
"An associated item was specified more than once in a trait object.\n\nErroneous code example:\n\n```compile_fail,E0719\ntrait FooTrait {}\ntrait BarTrait {}\n\n// error: associated type `Item` in trait `Iterator` is specified twice\ntype Foo = dyn Iterator<Item = u32, Item = u32>;\n```\n\nTo fix this, remove the duplicate specifier:\n\nCorrected example:\n\n```\ntype Foo = dyn Iterator<Item = u32>; // ok!\n```\n\nFor more information about associated types, see [the book][bk-at]. For more\ninformation on associated type bounds, see [RFC 2289][rfc-2289].\n\n[bk-at]: https://doc.rust-lang.org/book/ch19-03-advanced-traits.html#specifying-placeholder-types-in-trait-definitions-with-associated-types\n[rfc-2289]: https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html\n"),
(E0720,
"An `impl Trait` type expands to a recursive type.\n\nErroneous code example:\n\n```compile_fail,E0720\nfn make_recursive_type() -> impl Sized {\n [make_recursive_type(), make_recursive_type()]\n}\n```\n\nAn `impl Trait` type must be expandable to a concrete type that contains no\n`impl Trait` types. For example the previous example tries to create an\n`impl Trait` type `T` that is equal to `[T, T]`.\n"),
(E0722,
"#### Note: this error code is no longer emitted by the compiler\n\nThis is because it was too specific to the `optimize` attribute.\nSimilar diagnostics occur for other attributes too.\nThe example here will now emit `E0539`\n\nThe `optimize` attribute was malformed.\n\nErroneous code example:\n\n```compile_fail,E0539\n#![feature(optimize_attribute)]\n\n#[optimize(something)] // error: invalid argument\npub fn something() {}\n```\n\nThe `#[optimize]` attribute should be used as follows:\n\n- `#[optimize(size)]` -- instructs the optimization pipeline to generate code\n that\'s smaller rather than faster\n\n- `#[optimize(speed)]` -- instructs the optimization pipeline to generate code\n that\'s faster rather than smaller\n\nFor example:\n\n```\n#![feature(optimize_attribute)]\n\n#[optimize(size)]\npub fn something() {}\n```\n\nSee [RFC 2412] for more details.\n\n[RFC 2412]: https://rust-lang.github.io/rfcs/2412-optimize-attr.html\n"),
(E0724,
"#### Note: this error code is no longer emitted by the compiler.\n\n\n`#[ffi_returns_twice]` was used on something other than a foreign function\ndeclaration.\n\nErroneous code example:\n\n```compile_fail\n#![feature(ffi_returns_twice)]\n#![crate_type = \"lib\"]\n\n#[ffi_returns_twice] // error!\npub fn foo() {}\n```\n\n`#[ffi_returns_twice]` can only be used on foreign function declarations.\nFor example, we might correct the previous example by declaring\nthe function inside of an\u{a0}`extern`\u{a0}block.\n\n```compile_fail\n#![feature(ffi_returns_twice)]\n\nextern \"C\" {\n #[ffi_returns_twice] // ok!\n pub fn foo();\n}\n```\n"),
(E0725,
"A feature attribute named a feature that was disallowed in the compiler\ncommand line flags.\n\nErroneous code example:\n\n```ignore (can\'t specify compiler flags from doctests)\n#![feature(never_type)] // error: the feature `never_type` is not in\n // the list of allowed features\n```\n\nDelete the offending feature attribute, or add it to the list of allowed\nfeatures in the `-Z allow_features` flag.\n"),
(E0726,
"An argument lifetime was elided in an async function.\n\nErroneous code example:\n\nWhen a struct or a type is bound/declared with a lifetime it is important for\nthe Rust compiler to know, on usage, the lifespan of the type. When the\nlifetime is not explicitly mentioned and the Rust Compiler cannot determine\nthe lifetime of your type, the following error occurs.\n\n```compile_fail,E0726\nuse futures::executor::block_on;\nstruct Content<\'a> {\n title: &\'a str,\n body: &\'a str,\n}\nasync fn create(content: Content) { // error: implicit elided\n // lifetime not allowed here\n println!(\"title: {}\", content.title);\n println!(\"body: {}\", content.body);\n}\nlet content = Content { title: \"Rust\", body: \"is great!\" };\nlet future = create(content);\nblock_on(future);\n```\n\nSpecify desired lifetime of parameter `content` or indicate the anonymous\nlifetime like `content: Content<\'_>`. The anonymous lifetime tells the Rust\ncompiler that `content` is only needed until the `create` function is done with\nits execution.\n\nThe `implicit elision` meaning the omission of suggested lifetime that is\n`pub async fn create<\'a>(content: Content<\'a>) {}` is not allowed here as\nlifetime of the `content` can differ from current context:\n\n```ignore (needs futures dependency)\nasync fn create(content: Content<\'_>) { // ok!\n println!(\"title: {}\", content.title);\n println!(\"body: {}\", content.body);\n}\n```\n\nKnow more about lifetime elision in this [chapter][lifetime-elision] and a\nchapter on lifetimes can be found [here][lifetimes].\n\n[lifetime-elision]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#lifetime-elision\n[lifetimes]: https://doc.rust-lang.org/rust-by-example/scope/lifetime.html\n"),
(E0727,
"A `yield` clause was used in an `async` context.\n\nErroneous code example:\n\n```compile_fail,E0727,edition2018\n#![feature(coroutines, stmt_expr_attributes)]\n\nfn main() {\n let coroutine = #[coroutine] || {\n async {\n yield;\n }\n };\n}\n```\n\nHere, the `yield` keyword is used in an `async` block,\nwhich is not yet supported.\n\nTo fix this error, you have to move `yield` out of the `async` block:\n\n```edition2018\n#![feature(coroutines, stmt_expr_attributes)]\n\nfn main() {\n let coroutine = #[coroutine] || {\n yield;\n };\n}\n```\n"),
(E0728,
"[`await`] has been used outside [`async`] function or [`async`] block.\n\nErroneous code example:\n\n```edition2018,compile_fail,E0728\n# use std::pin::Pin;\n# use std::future::Future;\n# use std::task::{Context, Poll};\n#\n# struct WakeOnceThenComplete(bool);\n#\n# fn wake_and_yield_once() -> WakeOnceThenComplete {\n# WakeOnceThenComplete(false)\n# }\n#\n# impl Future for WakeOnceThenComplete {\n# type Output = ();\n# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<\'_>) -> Poll<()> {\n# if self.0 {\n# Poll::Ready(())\n# } else {\n# cx.waker().wake_by_ref();\n# self.0 = true;\n# Poll::Pending\n# }\n# }\n# }\n#\nfn foo() {\n wake_and_yield_once().await // `await` is used outside `async` context\n}\n```\n\n[`await`] is used to suspend the current computation until the given\nfuture is ready to produce a value. So it is legal only within\nan [`async`] context, like an `async` function or an `async` block.\n\n```edition2018\n# use std::pin::Pin;\n# use std::future::Future;\n# use std::task::{Context, Poll};\n#\n# struct WakeOnceThenComplete(bool);\n#\n# fn wake_and_yield_once() -> WakeOnceThenComplete {\n# WakeOnceThenComplete(false)\n# }\n#\n# impl Future for WakeOnceThenComplete {\n# type Output = ();\n# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<\'_>) -> Poll<()> {\n# if self.0 {\n# Poll::Ready(())\n# } else {\n# cx.waker().wake_by_ref();\n# self.0 = true;\n# Poll::Pending\n# }\n# }\n# }\n#\nasync fn foo() {\n wake_and_yield_once().await // `await` is used within `async` function\n}\n\nfn bar(x: u8) -> impl Future<Output = u8> {\n async move {\n wake_and_yield_once().await; // `await` is used within `async` block\n x\n }\n}\n```\n\n[`async`]: https://doc.rust-lang.org/std/keyword.async.html\n[`await`]: https://doc.rust-lang.org/std/keyword.await.html\n"),
(E0729,
"#### Note: this error code is no longer emitted by the compiler\n\nSupport for Non-Lexical Lifetimes (NLL) has been included in the Rust compiler\nsince 1.31, and has been enabled on the 2015 edition since 1.36. The new borrow\nchecker for NLL uncovered some bugs in the old borrow checker, which in some\ncases allowed unsound code to compile, resulting in memory safety issues.\n\n### What do I do?\n\nChange your code so the warning does no longer trigger. For backwards\ncompatibility, this unsound code may still compile (with a warning) right now.\nHowever, at some point in the future, the compiler will no longer accept this\ncode and will throw a hard error.\n\n### Shouldn\'t you fix the old borrow checker?\n\nThe old borrow checker has known soundness issues that are basically impossible\nto fix. The new NLL-based borrow checker is the fix.\n\n### Can I turn these warnings into errors by denying a lint?\n\nNo.\n\n### When are these warnings going to turn into errors?\n\nNo formal timeline for turning the warnings into errors has been set. See\n[GitHub issue 58781](https://github.com/rust-lang/rust/issues/58781) for more\ninformation.\n\n### Why do I get this message with code that doesn\'t involve borrowing?\n\nThere are some known bugs that trigger this message.\n"),
(E0730,
"An array without a fixed length was pattern-matched.\n\nErroneous code example:\n\n```compile_fail,E0730\nfn is_123<const N: usize>(x: [u32; N]) -> bool {\n match x {\n [1, 2, ..] => true, // error: cannot pattern-match on an\n // array without a fixed length\n _ => false\n }\n}\n```\n\nTo fix this error, you have two solutions:\n 1. Use an array with a fixed length.\n 2. Use a slice.\n\nExample with an array with a fixed length:\n\n```\nfn is_123(x: [u32; 3]) -> bool { // We use an array with a fixed size\n match x {\n [1, 2, ..] => true, // ok!\n _ => false\n }\n}\n```\n\nExample with a slice:\n\n```\nfn is_123(x: &[u32]) -> bool { // We use a slice\n match x {\n [1, 2, ..] => true, // ok!\n _ => false\n }\n}\n```\n"),
(E0731,
"An enum with the representation hint `repr(transparent)` had zero or more than\none variants.\n\nErroneous code example:\n\n```compile_fail,E0731\n#[repr(transparent)]\nenum Status { // error: transparent enum needs exactly one variant, but has 2\n Errno(u32),\n Ok,\n}\n```\n\nBecause transparent enums are represented exactly like one of their variants at\nrun time, said variant must be uniquely determined. If there is no variant, or\nif there are multiple variants, it is not clear how the enum should be\nrepresented.\n"),
(E0732,
"An `enum` with a discriminant must specify a `#[repr(inttype)]`.\n\nErroneous code example:\n\n```compile_fail,E0732\nenum Enum { // error!\n Unit = 1,\n Tuple() = 2,\n Struct{} = 3,\n}\n# fn main() {}\n```\n\nA `#[repr(inttype)]` must be provided on an `enum` if it has a non-unit\nvariant with a discriminant, or where there are both unit variants with\ndiscriminants and non-unit variants. This restriction ensures that there\nis a well-defined way to extract a variant\'s discriminant from a value;\nfor instance:\n\n```\n#[repr(u8)]\nenum Enum {\n Unit = 3,\n Tuple(u16) = 2,\n Struct {\n a: u8,\n b: u16,\n } = 1,\n}\n\nfn discriminant(v : &Enum) -> u8 {\n unsafe { *(v as *const Enum as *const u8) }\n}\n\nfn main() {\n assert_eq!(3, discriminant(&Enum::Unit));\n assert_eq!(2, discriminant(&Enum::Tuple(5)));\n assert_eq!(1, discriminant(&Enum::Struct{a: 7, b: 11}));\n}\n```\n"),
(E0733,
"An [`async`] function used recursion without boxing.\n\nErroneous code example:\n\n```edition2018,compile_fail,E0733\nasync fn foo(n: usize) {\n if n > 0 {\n foo(n - 1).await;\n }\n}\n```\n\nThe recursive invocation can be boxed:\n\n```edition2018\nasync fn foo(n: usize) {\n if n > 0 {\n Box::pin(foo(n - 1)).await;\n }\n}\n```\n\nThe `Box<...>` ensures that the result is of known size, and the pin is\nrequired to keep it in the same place in memory.\n\nAlternatively, the body can be boxed:\n\n```edition2018\nuse std::future::Future;\nuse std::pin::Pin;\nfn foo(n: usize) -> Pin<Box<dyn Future<Output = ()>>> {\n Box::pin(async move {\n if n > 0 {\n foo(n - 1).await;\n }\n })\n}\n```\n\n[`async`]: https://doc.rust-lang.org/std/keyword.async.html\n"),
(E0734,
"A stability attribute has been used outside of the standard library.\n\nErroneous code example:\n\n```compile_fail,E0734\n#[stable(feature = \"a\", since = \"b\")] // invalid\n#[unstable(feature = \"b\", issue = \"none\")] // invalid\nfn foo(){}\n```\n\nThese attributes are meant to only be used by the standard library and are\nrejected in your own crates.\n"),
(E0735,
"Type parameter defaults cannot use `Self` on structs, enums, or unions.\n\nErroneous code example:\n\n```compile_fail,E0735\nstruct Foo<X = Box<Self>> {\n field1: Option<X>,\n field2: Option<X>,\n}\n// error: type parameters cannot use `Self` in their defaults.\n```\n"),
(E0736,
"Functions marked with the `#[naked]` attribute are restricted in what other\nattributes they may be marked with.\n\nNotable attributes that are incompatible with `#[naked]` are:\n\n* `#[inline]`\n* `#[track_caller]`\n* `#[test]`, `#[ignore]`, `#[should_panic]`\n\nErroneous code example:\n\n```compile_fail,E0736\n#[inline]\n#[unsafe(naked)]\nfn foo() {}\n```\n\nThese incompatibilities are due to the fact that naked functions deliberately\nimpose strict restrictions regarding the code that the compiler is\nallowed to produce for this function.\n"),
(E0737,
"`#[track_caller]` requires functions to have the `\"Rust\"` ABI for implicitly\nreceiving caller location. See [RFC 2091] for details on this and other\nrestrictions.\n\nErroneous code example:\n\n```compile_fail,E0737\n#[track_caller]\nextern \"C\" fn foo() {}\n```\n\n[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md\n"),
(E0739,
"#### Note: this error code is no longer emitted by the compiler.\n\n`#[track_caller]` must be applied to a function\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#[track_caller]\nstruct Bar {\n a: u8,\n}\n```\n\n[RFC 2091]: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md\n"),
(E0740,
"A `union` was declared with fields with destructors.\n\nErroneous code example:\n\n```compile_fail,E0740\nunion Test {\n a: A, // error!\n}\n\n#[derive(Debug)]\nstruct A(i32);\n\nimpl Drop for A {\n fn drop(&mut self) { println!(\"A\"); }\n}\n```\n\nA `union` cannot have fields with destructors.\n"),
(E0741,
"A non-structural-match type was used as the type of a const generic parameter.\n\nErroneous code example:\n\n```compile_fail,E0741\n#![feature(adt_const_params)]\n\nstruct A;\n\nstruct B<const X: A>; // error!\n```\n\nOnly structural-match types, which are types that derive `PartialEq` and `Eq`\nand implement `ConstParamTy`, may be used as the types of const generic\nparameters.\n\nTo fix the previous code example, we derive `PartialEq`, `Eq`, and\n`ConstParamTy`:\n\n```\n#![feature(adt_const_params)]\n\nuse std::marker::ConstParamTy;\n\n#[derive(PartialEq, Eq, ConstParamTy)] // We derive both traits here.\nstruct A;\n\nstruct B<const X: A>; // ok!\n```\n"),
(E0742,
"Visibility is restricted to a module which isn\'t an ancestor of the current\nitem.\n\nErroneous code example:\n\n```compile_fail,E0742,edition2018\npub mod sea {}\n\npub (in crate::sea) struct Shark; // error!\n\nfn main() {}\n```\n\nTo fix this error, we need to move the `Shark` struct inside the `sea` module:\n\n```edition2018\npub mod sea {\n pub (in crate::sea) struct Shark; // ok!\n}\n\nfn main() {}\n```\n\nOf course, you can do it as long as the module you\'re referring to is an\nancestor:\n\n```edition2018\npub mod earth {\n pub mod sea {\n pub (in crate::earth) struct Shark; // ok!\n }\n}\n\nfn main() {}\n```\n"),
(E0743,
"The C-variadic type `...` has been nested inside another type.\n\nErroneous code example:\n\n```compile_fail,E0743\nfn foo2(x: u8, y: &...) {} // error!\n```\n\nOnly foreign functions can use the C-variadic type (`...`). In such functions,\n`...` may only occur non-nested. That is, `y: &\'a ...` is not allowed.\n\nA C-variadic type is used to give an undefined number of parameters to a given\nfunction (like `printf` in C). The equivalent in Rust would be to use macros\ndirectly (like `println!` for example).\n"),
(E0744,
"#### Note: this error code is no longer emitted by the compiler.\n\nAn unsupported expression was used inside a const context.\n\nErroneous code example:\n\n```ignore (removed error code)\nconst _: i32 = {\n async { 0 }.await\n};\n```\n\nAt the moment, `.await` is forbidden inside a `const`, `static`, or `const fn`.\n\nThis may be allowed at some point in the future, but the implementation is not\nyet complete. See the tracking issue for [`async`] in `const fn`.\n\n[`async`]: https://github.com/rust-lang/rust/issues/69431\n"),
(E0745,
"The address of temporary value was taken.\n\nErroneous code example:\n\n```compile_fail,E0745\nfn temp_address() {\n let ptr = &raw const 2; // error!\n}\n```\n\nIn this example, `2` is destroyed right after the assignment, which means that\n`ptr` now points to an unavailable location.\n\nTo avoid this error, first bind the temporary to a named local variable:\n\n```\nfn temp_address() {\n let val = 2;\n let ptr = &raw const val; // ok!\n}\n```\n"),
(E0746,
"An unboxed trait object was used as a return value.\n\nErroneous code example:\n\n```compile_fail,E0746\ntrait T {\n fn bar(&self);\n}\nstruct S(usize);\nimpl T for S {\n fn bar(&self) {}\n}\n\n// Having the trait `T` as return type is invalid because\n// unboxed trait objects do not have a statically known size:\nfn foo() -> dyn T { // error!\n S(42)\n}\n```\n\nReturn types cannot be `dyn Trait`s as they must be `Sized`.\n\nTo avoid the error there are a couple of options.\n\nIf there is a single type involved, you can use [`impl Trait`]:\n\n```\n# trait T {\n# fn bar(&self);\n# }\n# struct S(usize);\n# impl T for S {\n# fn bar(&self) {}\n# }\n// The compiler will select `S(usize)` as the materialized return type of this\n// function, but callers will only know that the return type implements `T`.\nfn foo() -> impl T { // ok!\n S(42)\n}\n```\n\nIf there are multiple types involved, the only way you care to interact with\nthem is through the trait\'s interface, and having to rely on dynamic dispatch\nis acceptable, then you can use [trait objects] with `Box`, or other container\ntypes like `Rc` or `Arc`:\n\n```\n# trait T {\n# fn bar(&self);\n# }\n# struct S(usize);\n# impl T for S {\n# fn bar(&self) {}\n# }\nstruct O(&\'static str);\nimpl T for O {\n fn bar(&self) {}\n}\n\n// This now returns a \"trait object\" and callers are only be able to access\n// associated items from `T`.\nfn foo(x: bool) -> Box<dyn T> { // ok!\n if x {\n Box::new(S(42))\n } else {\n Box::new(O(\"val\"))\n }\n}\n```\n\nFinally, if you wish to still be able to access the original type, you can\ncreate a new `enum` with a variant for each type:\n\n```\n# trait T {\n# fn bar(&self);\n# }\n# struct S(usize);\n# impl T for S {\n# fn bar(&self) {}\n# }\n# struct O(&\'static str);\n# impl T for O {\n# fn bar(&self) {}\n# }\nenum E {\n S(S),\n O(O),\n}\n\n// The caller can access the original types directly, but it needs to match on\n// the returned `enum E`.\nfn foo(x: bool) -> E {\n if x {\n E::S(S(42))\n } else {\n E::O(O(\"val\"))\n }\n}\n```\n\nYou can even implement the `trait` on the returned `enum` so the callers\n*don\'t* have to match on the returned value to invoke the associated items:\n\n```\n# trait T {\n# fn bar(&self);\n# }\n# struct S(usize);\n# impl T for S {\n# fn bar(&self) {}\n# }\n# struct O(&\'static str);\n# impl T for O {\n# fn bar(&self) {}\n# }\n# enum E {\n# S(S),\n# O(O),\n# }\nimpl T for E {\n fn bar(&self) {\n match self {\n E::S(s) => s.bar(),\n E::O(o) => o.bar(),\n }\n }\n}\n```\n\nIf you decide to use trait objects, be aware that these rely on\n[dynamic dispatch], which has performance implications, as the compiler needs\nto emit code that will figure out which method to call *at runtime* instead of\nduring compilation. Using trait objects we are trading flexibility for\nperformance.\n\n[`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits\n[trait objects]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types\n[dynamic dispatch]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#trait-objects-perform-dynamic-dispatch\n"),
(E0747,
"Generic arguments were not provided in the same order as the corresponding\ngeneric parameters are declared.\n\nErroneous code example:\n\n```compile_fail,E0747\nstruct S<\'a, T>(&\'a T);\n\ntype X = S<(), \'static>; // error: the type argument is provided before the\n // lifetime argument\n```\n\nThe argument order should be changed to match the parameter declaration\norder, as in the following:\n\n```\nstruct S<\'a, T>(&\'a T);\n\ntype X = S<\'static, ()>; // ok\n```\n"),
(E0748,
"A raw string isn\'t correctly terminated because the trailing `#` count doesn\'t\nmatch its leading `#` count.\n\nErroneous code example:\n\n```compile_fail,E0748\nlet dolphins = r##\"Dolphins!\"#; // error!\n```\n\nTo terminate a raw string, you have to have the same number of `#` at the end\nas at the beginning. Example:\n\n```\nlet dolphins = r#\"Dolphins!\"#; // One `#` at the beginning, one at the end so\n // all good!\n```\n"),
(E0749,
"An item was added on a negative impl.\n\nErroneous code example:\n\n```compile_fail,E0749\n# #![feature(negative_impls)]\ntrait MyTrait {\n type Foo;\n}\n\nimpl !MyTrait for u32 {\n type Foo = i32; // error!\n}\n```\n\nNegative impls are not allowed to have any items. Negative impls declare that a\ntrait is **not** implemented (and never will be) and hence there is no need to\nspecify the values for trait methods or other items.\n\nOne way to fix this is to remove the items in negative impls:\n\n```\n# #![feature(negative_impls)]\ntrait MyTrait {\n type Foo;\n}\n\nimpl !MyTrait for u32 {}\n```\n"),
(E0750,
"A negative impl was made default impl.\n\nErroneous code example:\n\n```compile_fail,E0750\n# #![feature(negative_impls)]\n# #![feature(specialization)]\ntrait MyTrait {\n type Foo;\n}\n\ndefault impl !MyTrait for u32 {} // error!\n# fn main() {}\n```\n\nNegative impls cannot be default impls. A default impl supplies default values\nfor the items within to be used by other impls, whereas a negative impl declares\nthat there are no other impls. Combining it does not make sense.\n"),
(E0751,
"There are both a positive and negative trait implementation for the same type.\n\nErroneous code example:\n\n```compile_fail,E0751\ntrait MyTrait {}\nimpl MyTrait for i32 { }\nimpl !MyTrait for i32 { } // error!\n```\n\nNegative implementations are a promise that the trait will never be implemented\nfor the given types. Therefore, both cannot exist at the same time.\n"),
(E0752,
"The entry point of the program was marked as `async`.\n\nErroneous code example:\n\n```compile_fail,E0752\nasync fn main() -> Result<(), ()> { // error!\n Ok(())\n}\n```\n\n`fn main()` or the specified start function is not allowed to be `async`. Not\nhaving a correct async runtime library setup may cause this error. To fix it,\ndeclare the entry point without `async`:\n\n```\nfn main() -> Result<(), ()> { // ok!\n Ok(())\n}\n```\n"),
(E0753,
"An inner doc comment was used in an invalid context.\n\nErroneous code example:\n\n```compile_fail,E0753\nfn foo() {}\n//! foo\n// ^ error!\nfn main() {}\n```\n\nInner document can only be used before items. For example:\n\n```\n//! A working comment applied to the module!\nfn foo() {\n //! Another working comment!\n}\nfn main() {}\n```\n\nIn case you want to document the item following the doc comment, you might want\nto use outer doc comment:\n\n```\n/// I am an outer doc comment\n#[doc = \"I am also an outer doc comment!\"]\nfn foo() {\n // ...\n}\n```\n"),
(E0754,
"A non-ASCII identifier was used in an invalid context.\n\nErroneous code examples:\n\n```compile_fail,E0754\n\nmod \u{159}\u{173}\u{15b}\u{165}; // error!\n\n#[no_mangle]\nfn \u{159}\u{173}\u{15b}\u{165}() {} // error!\n\nfn main() {}\n```\n\nNon-ASCII can be used as module names if it is inlined or if a `#[path]`\nattribute is specified. For example:\n\n```\nmod \u{159}\u{173}\u{15b}\u{165} { // ok!\n const IS_GREAT: bool = true;\n}\n\nfn main() {}\n```\n"),
(E0755,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `ffi_pure` attribute was used on a non-foreign function.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(ffi_pure)]\n\n#[unsafe(ffi_pure)] // error!\npub fn foo() {}\n# fn main() {}\n```\n\nThe `ffi_pure` attribute can only be used on foreign functions which do not have\nside effects or infinite loops:\n\n```\n#![feature(ffi_pure)]\n\nextern \"C\" {\n #[unsafe(ffi_pure)] // ok!\n pub fn strlen(s: *const i8) -> isize;\n}\n# fn main() {}\n```\n\nYou can find more information about it in the [unstable Rust Book].\n\n[unstable Rust Book]: https://doc.rust-lang.org/unstable-book/language-features/ffi-pure.html\n"),
(E0756,
"#### Note: this error code is no longer emitted by the compiler.\n\nThe `ffi_const` attribute was used on something other than a foreign function\ndeclaration.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(ffi_const)]\n\n#[unsafe(ffi_const)] // error!\npub fn foo() {}\n# fn main() {}\n```\n\nThe `ffi_const` attribute can only be used on foreign function declarations\nwhich have no side effects except for their return value:\n\n```\n#![feature(ffi_const)]\n\nextern \"C\" {\n #[unsafe(ffi_const)] // ok!\n pub fn strlen(s: *const i8) -> i32;\n}\n# fn main() {}\n```\n\nYou can get more information about it in the [unstable Rust Book].\n\n[unstable Rust Book]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-const.html\n"),
(E0757,
"A function was given both the `ffi_const` and `ffi_pure` attributes.\n\nErroneous code example:\n\n```compile_fail,E0757\n#![feature(ffi_const, ffi_pure)]\n\nextern \"C\" {\n #[unsafe(ffi_const)]\n #[unsafe(ffi_pure)]\n //~^ ERROR `#[ffi_const]` function cannot be `#[ffi_pure]`\n pub fn square(num: i32) -> i32;\n}\n```\n\nAs `ffi_const` provides stronger guarantees than `ffi_pure`, remove the\n`ffi_pure` attribute:\n\n```\n#![feature(ffi_const)]\n\nextern \"C\" {\n #[unsafe(ffi_const)]\n pub fn square(num: i32) -> i32;\n}\n```\n\nYou can get more information about `const` and `pure` in the [GCC documentation\non Common Function Attributes]. The unstable Rust Book has more information\nabout [`ffi_const`] and [`ffi_pure`].\n\n[GCC documentation on Common Function Attributes]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html\n[`ffi_const`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-const.html\n[`ffi_pure`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/ffi-pure.html\n"),
(E0758,
"A multi-line (doc-)comment is unterminated.\n\nErroneous code example:\n\n```compile_fail,E0758\n/* I am not terminated!\n```\n\nThe same goes for doc comments:\n\n```compile_fail,E0758\n/*! I am not terminated!\n```\n\nYou need to end your multi-line comment with `*/` in order to fix this error:\n\n```\n/* I am terminated! */\n/*! I am also terminated! */\n```\n"),
(E0759,
"#### Note: this error code is no longer emitted by the compiler.\n\nReturn type involving a trait did not require `\'static` lifetime.\n\nErroneous code examples:\n\n```compile_fail\nuse std::fmt::Debug;\n\nfn foo(x: &i32) -> impl Debug { // error!\n x\n}\n\nfn bar(x: &i32) -> Box<dyn Debug> { // error!\n Box::new(x)\n}\n```\n\nAdd `\'static` requirement to fix them:\n\n```\n# use std::fmt::Debug;\nfn foo(x: &\'static i32) -> impl Debug + \'static { // ok!\n x\n}\n\nfn bar(x: &\'static i32) -> Box<dyn Debug + \'static> { // ok!\n Box::new(x)\n}\n```\n\nBoth [`dyn Trait`] and [`impl Trait`] in return types have an implicit\n`\'static` requirement, meaning that the value implementing them that is being\nreturned has to be either a `\'static` borrow or an owned value.\n\nIn order to change the requirement from `\'static` to be a lifetime derived from\nits arguments, you can add an explicit bound, either to an anonymous lifetime\n`\'_` or some appropriate named lifetime.\n\n```\n# use std::fmt::Debug;\nfn foo(x: &i32) -> impl Debug + \'_ {\n x\n}\nfn bar(x: &i32) -> Box<dyn Debug + \'_> {\n Box::new(x)\n}\n```\n\nThese are equivalent to the following explicit lifetime annotations:\n\n```\n# use std::fmt::Debug;\nfn foo<\'a>(x: &\'a i32) -> impl Debug + \'a {\n x\n}\nfn bar<\'a>(x: &\'a i32) -> Box<dyn Debug + \'a> {\n Box::new(x)\n}\n```\n\n[`dyn Trait`]: https://doc.rust-lang.org/book/ch17-02-trait-objects.html#using-trait-objects-that-allow-for-values-of-different-types\n[`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#returning-types-that-implement-traits\n"),
(E0760,
"#### Note: this error code is no longer emitted by the compiler.\n\n`async fn`/`impl trait` return type cannot contain a projection\nor `Self` that references lifetimes from a parent scope.\n\nErroneous code example:\n\n```ignore,edition2018\nstruct S<\'a>(&\'a i32);\n\nimpl<\'a> S<\'a> {\n async fn new(i: &\'a i32) -> Self {\n S(&22)\n }\n}\n```\n\nTo fix this error we need to spell out `Self` to `S<\'a>`:\n\n```edition2018\nstruct S<\'a>(&\'a i32);\n\nimpl<\'a> S<\'a> {\n async fn new(i: &\'a i32) -> S<\'a> {\n S(&22)\n }\n}\n```\n\nThis will be allowed at some point in the future,\nbut the implementation is not yet complete.\nSee the [issue-61949] for this limitation.\n\n[issue-61949]: https://github.com/rust-lang/rust/issues/61949\n"),
(E0761,
"Multiple candidate files were found for an out-of-line module.\n\nErroneous code example:\n\n```ignore (Multiple source files are required for compile_fail.)\n// file: ambiguous_module/mod.rs\n\nfn foo() {}\n\n// file: ambiguous_module.rs\n\nfn foo() {}\n\n// file: lib.rs\n\nmod ambiguous_module; // error: file for module `ambiguous_module`\n // found at both ambiguous_module.rs and\n // ambiguous_module/mod.rs\n```\n\nPlease remove this ambiguity by deleting/renaming one of the candidate files.\n"),
(E0762,
"A character literal wasn\'t ended with a quote.\n\nErroneous code example:\n\n```compile_fail,E0762\nstatic C: char = \'\u{25cf}; // error!\n```\n\nTo fix this error, add the missing quote:\n\n```\nstatic C: char = \'\u{25cf}\'; // ok!\n```\n"),
(E0763,
"A byte constant wasn\'t correctly ended.\n\nErroneous code example:\n\n```compile_fail,E0763\nlet c = b\'a; // error!\n```\n\nTo fix this error, add the missing quote:\n\n```\nlet c = b\'a\'; // ok!\n```\n"),
(E0764,
"A mutable reference was used in a constant.\n\nErroneous code example:\n\n```compile_fail,E0764\nfn main() {\n const OH_NO: &\'static mut usize = &mut 1; // error!\n}\n```\n\nMutable references (`&mut`) can only be used in constant functions, not statics\nor constants. This limitation exists to prevent the creation of constants that\nhave a mutable reference in their final value. If you had a constant of\n`&mut i32` type, you could modify the value through that reference, making the\nconstant essentially mutable.\n\nWhile there could be a more fine-grained scheme in the future that allows\nmutable references if they are not \"leaked\" to the final value, a more\nconservative approach was chosen for now. `const fn` do not have this problem,\nas the borrow checker will prevent the `const fn` from returning new mutable\nreferences.\n\nRemember: you cannot use a function call inside a constant or static. However,\nyou can totally use it in constant functions:\n\n```\nconst fn foo(x: usize) -> usize {\n let mut y = 1;\n let z = &mut y;\n *z += x;\n y\n}\n\nfn main() {\n const FOO: usize = foo(10); // ok!\n}\n```\n"),
(E0765,
"A double quote string (`\"`) was not terminated.\n\nErroneous code example:\n\n```compile_fail,E0765\nlet s = \"; // error!\n```\n\nTo fix this error, add the missing double quote at the end of the string:\n\n```\nlet s = \"\"; // ok!\n```\n"),
(E0766,
"A double quote byte string (`b\"`) was not terminated.\n\nErroneous code example:\n\n```compile_fail,E0766\nlet s = b\"; // error!\n```\n\nTo fix this error, add the missing double quote at the end of the string:\n\n```\nlet s = b\"\"; // ok!\n```\n"),
(E0767,
"An unreachable label was used.\n\nErroneous code example:\n\n```compile_fail,E0767\n\'a: loop {\n || {\n loop { break \'a } // error: use of unreachable label `\'a`\n };\n}\n```\n\nEnsure that the label is within scope. Labels are not reachable through\nfunctions, closures, async blocks or modules. Example:\n\n```\n\'a: loop {\n break \'a; // ok!\n}\n```\n"),
(E0768,
"A number in a non-decimal base has no digits.\n\nErroneous code example:\n\n```compile_fail,E0768\nlet s: i32 = 0b; // error!\n```\n\nTo fix this error, add the missing digits:\n\n```\nlet s: i32 = 0b1; // ok!\n```\n"),
(E0769,
"A tuple struct or tuple variant was used in a pattern as if it were a struct or\nstruct variant.\n\nErroneous code example:\n\n```compile_fail,E0769\nenum E {\n A(i32),\n}\n\nlet e = E::A(42);\n\nmatch e {\n E::A { number } => { // error!\n println!(\"{}\", number);\n }\n}\n```\n\nTo fix this error, you can use the tuple pattern:\n\n```\n# enum E {\n# A(i32),\n# }\n# let e = E::A(42);\nmatch e {\n E::A(number) => { // ok!\n println!(\"{}\", number);\n }\n}\n```\n\nAlternatively, you can also use the struct pattern by using the correct field\nnames and binding them to new identifiers:\n\n```\n# enum E {\n# A(i32),\n# }\n# let e = E::A(42);\nmatch e {\n E::A { 0: number } => { // ok!\n println!(\"{}\", number);\n }\n}\n```\n"),
(E0770,
"The type of a const parameter references other generic parameters.\n\nErroneous code example:\n\n```compile_fail,E0770\nfn foo<T, const N: T>() {} // error!\n```\n\nTo fix this error, use a concrete type for the const parameter:\n\n```\nfn foo<T, const N: usize>() {}\n```\n"),
(E0771,
"#### Note: this error code is no longer emitted by the compiler\n\nA non-`\'static` lifetime was used in a const generic. This is currently not\nallowed.\n\nErroneous code example:\n\n```compile_fail,E0770\n#![feature(adt_const_params, unsized_const_params)]\n\nfn function_with_str<\'a, const STRING: &\'a str>() {} // error!\n```\n\nTo fix this issue, the lifetime in the const generic need to be changed to\n`\'static`:\n\n```\n#![feature(adt_const_params, unsized_const_params)]\n\nfn function_with_str<const STRING: &\'static str>() {} // ok!\n```\n\nFor more information, see [GitHub issue #74052].\n\n[GitHub issue #74052]: https://github.com/rust-lang/rust/issues/74052\n"),
(E0772,
"#### Note: this error code is no longer emitted by the compiler.\n\nA trait object has some specific lifetime `\'1`, but it was used in a way that\nrequires it to have a `\'static` lifetime.\n\nExample of erroneous code:\n\n```compile_fail\ntrait BooleanLike {}\ntrait Person {}\n\nimpl BooleanLike for bool {}\n\nimpl dyn Person {\n fn is_cool(&self) -> bool {\n // hey you, you\'re pretty cool\n true\n }\n}\n\nfn get_is_cool<\'p>(person: &\'p dyn Person) -> impl BooleanLike {\n // error: `person` has an anonymous lifetime `\'p` but calling\n // `print_cool_fn` introduces an implicit `\'static` lifetime\n // requirement\n person.is_cool()\n}\n```\n\nThe trait object `person` in the function `get_is_cool`, while already being\nbehind a reference with lifetime `\'p`, also has it\'s own implicit lifetime,\n`\'2`.\n\nLifetime `\'2` represents the data the trait object might hold inside, for\nexample:\n\n```\ntrait MyTrait {}\n\nstruct MyStruct<\'a>(&\'a i32);\n\nimpl<\'a> MyTrait for MyStruct<\'a> {}\n```\n\nWith this scenario, if a trait object of `dyn MyTrait + \'2` was made from\n`MyStruct<\'a>`, `\'a` must live as long, if not longer than `\'2`. This allows the\ntrait object\'s internal data to be accessed safely from any trait methods. This\nrule also goes for any lifetime any struct made into a trait object may have.\n\nIn the implementation for `dyn Person`, the `\'2` lifetime representing the\ninternal data was omitted, meaning that the compiler inferred the lifetime\n`\'static`. As a result, the implementation\'s `is_cool` is inferred by the\ncompiler to look like this:\n\n```\n# trait Person {}\n#\n# impl dyn Person {\nfn is_cool<\'a>(self: &\'a (dyn Person + \'static)) -> bool {unimplemented!()}\n# }\n```\n\nWhile the `get_is_cool` function is inferred to look like this:\n\n```\n# trait Person {}\n# trait BooleanLike {}\n#\nfn get_is_cool<\'p, R: BooleanLike>(person: &\'p (dyn Person + \'p)) -> R {\n unimplemented!()\n}\n```\n\nWhich brings us to the core of the problem; the assignment of type\n`&\'_ (dyn Person + \'_)` to type `&\'_ (dyn Person + \'static)` is impossible.\n\nFixing it is as simple as being generic over lifetime `\'2`, as to prevent the\ncompiler from inferring it as `\'static`:\n\n```\n# trait Person {}\n#\nimpl<\'d> dyn Person + \'d {/* ... */}\n\n// This works too, and is more elegant:\n//impl dyn Person + \'_ {/* ... */}\n```\n\nSee the [Rust Reference on Trait Object Lifetime Bounds][trait-objects] for\nmore information on trait object lifetimes.\n\n[trait-object-lifetime-bounds]: https://doc.rust-lang.org/reference/types/trait-object.html#trait-object-lifetime-bounds\n"),
(E0773,
"#### Note: this error code is no longer emitted by the compiler.\n\nThis was triggered when multiple macro definitions used the same\n`#[rustc_builtin_macro(..)]`. This is no longer an error.\n"),
(E0774,
"`derive` was applied on something which is not a struct, a union or an enum.\n\nErroneous code example:\n\n```compile_fail,E0774\ntrait Foo {\n #[derive(Clone)] // error!\n type Bar;\n}\n```\n\nAs said above, the `derive` attribute is only allowed on structs, unions or\nenums:\n\n```\n#[derive(Clone)] // ok!\nstruct Bar {\n field: u32,\n}\n```\n\nYou can find more information about `derive` in the [Rust Book].\n\n[Rust Book]: https://doc.rust-lang.org/book/appendix-03-derivable-traits.html\n"),
(E0775,
"#### Note: this error code is no longer emitted by the compiler.\n\n`#[cmse_nonsecure_entry]` is only valid for targets with the TrustZone-M\nextension.\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(cmse_nonsecure_entry)]\n\npub extern \"cmse-nonsecure-entry\" fn entry_function() {}\n```\n\nTo fix this error, compile your code for a Rust target that supports the\nTrustZone-M extension. The current possible targets are:\n* `thumbv8m.main-none-eabi`\n* `thumbv8m.main-none-eabihf`\n* `thumbv8m.base-none-eabi`\n"),
(E0776,
"#### Note: this error code is no longer emitted by the compiler.\n\n`#[cmse_nonsecure_entry]` functions require a C ABI\n\nErroneous code example:\n\n```ignore (no longer emitted)\n#![feature(cmse_nonsecure_entry)]\n\n#[no_mangle]\n#[cmse_nonsecure_entry]\npub fn entry_function(input: Vec<u32>) {}\n```\n\nTo fix this error, declare your entry function with a C ABI, using `extern \"C\"`.\n"),
(E0777,
"A literal value was used inside `#[derive]`.\n\nErroneous code example:\n\n```compile_fail,E0777\n#[derive(\"Clone\")] // error!\nstruct Foo;\n```\n\nOnly paths to traits are allowed as argument inside `#[derive]`. You can find\nmore information about the `#[derive]` attribute in the [Rust Book].\n\n\n```\n#[derive(Clone)] // ok!\nstruct Foo;\n```\n\n[Rust Book]: https://doc.rust-lang.org/book/appendix-03-derivable-traits.html\n"),
(E0778,
"#### Note: this error code is no longer emitted by the compiler\nThe `instruction_set` attribute was malformed.\n\nErroneous code example:\n\n```compile_fail\n#![feature(isa_attribute)]\n\n#[instruction_set()] // error: expected one argument\npub fn something() {}\nfn main() {}\n```\n\nThe parenthesized `instruction_set` attribute requires the parameter to be\nspecified:\n\n```\n#![feature(isa_attribute)]\n\n#[cfg_attr(target_arch=\"arm\", instruction_set(arm::a32))]\nfn something() {}\n```\n\nor:\n\n```\n#![feature(isa_attribute)]\n\n#[cfg_attr(target_arch=\"arm\", instruction_set(arm::t32))]\nfn something() {}\n```\n\nFor more information see the [`instruction_set` attribute][isa-attribute]\nsection of the Reference.\n\n[isa-attribute]: https://doc.rust-lang.org/reference/attributes/codegen.html\n"),
(E0779,
"#### Note: this error code is no longer emitted by the compiler\nAn unknown argument was given to the `instruction_set` attribute.\n\nErroneous code example:\n\n```compile_fail\n#![feature(isa_attribute)]\n\n#[instruction_set(intel::x64)] // error: invalid argument\npub fn something() {}\nfn main() {}\n```\n\nThe `instruction_set` attribute only supports two arguments currently:\n\n * arm::a32\n * arm::t32\n\nAll other arguments given to the `instruction_set` attribute will return this\nerror. Example:\n\n```\n#![feature(isa_attribute)]\n\n#[cfg_attr(target_arch=\"arm\", instruction_set(arm::a32))] // ok!\npub fn something() {}\nfn main() {}\n```\n\nFor more information see the [`instruction_set` attribute][isa-attribute]\nsection of the Reference.\n\n[isa-attribute]: https://doc.rust-lang.org/reference/attributes/codegen.html\n"),
(E0780,
"Cannot use `doc(inline)` with anonymous imports\n\nErroneous code example:\n\n```ignore (cannot-doctest-multicrate-project)\n\n#[doc(inline)] // error: invalid doc argument\npub use foo::Foo as _;\n```\n\nAnonymous imports are always rendered with `#[doc(no_inline)]`. To fix this\nerror, remove the `#[doc(inline)]` attribute.\n\nExample:\n\n```ignore (cannot-doctest-multicrate-project)\n\npub use foo::Foo as _;\n```\n"),
(E0781,
"The `cmse-nonsecure-call` ABI can only be used with function pointers.\n\nErroneous code example:\n\n```compile_fail,E0781\n#![feature(abi_cmse_nonsecure_call)]\n\npub extern \"cmse-nonsecure-call\" fn test() {}\n```\n\nThe `cmse-nonsecure-call` ABI should be used by casting function pointers to\nspecific addresses.\n"),
(E0782,
"Trait objects must include the `dyn` keyword.\n\nErroneous code example:\n\n```edition2021,compile_fail,E0782\ntrait Foo {}\nfn test(arg: Box<Foo>) {} // error!\n```\n\nTrait objects are a way to call methods on types that are not known until\nruntime but conform to some trait.\n\nTrait objects should be formed with `Box<dyn Foo>`, but in the code above\n`dyn` is left off.\n\nThis makes it harder to see that `arg` is a trait object and not a\nsimply a heap allocated type called `Foo`.\n\nTo fix this issue, add `dyn` before the trait name.\n\n```edition2021\ntrait Foo {}\nfn test(arg: Box<dyn Foo>) {} // ok!\n```\n\nThis used to be allowed before edition 2021, but is now an error.\n"),
(E0783,
"The range pattern `...` is no longer allowed.\n\nErroneous code example:\n\n```edition2021,compile_fail,E0783\nmatch 2u8 {\n 0...9 => println!(\"Got a number less than 10\"), // error!\n _ => println!(\"Got a number 10 or more\"),\n}\n```\n\nOlder Rust code using previous editions allowed `...` to stand for inclusive\nranges which are now signified using `..=`.\n\nTo make this code compile replace the `...` with `..=`.\n\n```edition2021\nmatch 2u8 {\n 0..=9 => println!(\"Got a number less than 10\"), // ok!\n _ => println!(\"Got a number 10 or more\"),\n}\n```\n"),
(E0784,
"A union expression does not have exactly one field.\n\nErroneous code example:\n\n```compile_fail,E0784\nunion Bird {\n pigeon: u8,\n turtledove: u16,\n}\n\nlet bird = Bird {}; // error\nlet bird = Bird { pigeon: 0, turtledove: 1 }; // error\n```\n\nThe key property of unions is that all fields of a union share common storage.\nAs a result, writes to one field of a union can overwrite its other fields, and\nsize of a union is determined by the size of its largest field.\n\nYou can find more information about the union types in the [Rust reference].\n\nWorking example:\n\n```\nunion Bird {\n pigeon: u8,\n turtledove: u16,\n}\n\nlet bird = Bird { pigeon: 0 }; // OK\n```\n\n[Rust reference]: https://doc.rust-lang.org/reference/items/unions.html\n"),
(E0785,
"An inherent `impl` was written on a dyn auto trait.\n\nErroneous code example:\n\n```compile_fail,E0785\n#![feature(auto_traits)]\n\nauto trait AutoTrait {}\n\nimpl dyn AutoTrait {}\n```\n\nDyn objects allow any number of auto traits, plus at most one non-auto trait.\nThe non-auto trait becomes the \"principal trait\".\n\nWhen checking if an impl on a dyn trait is coherent, the principal trait is\nnormally the only one considered. Since the erroneous code has no principal\ntrait, it cannot be implemented at all.\n\nWorking example:\n\n```\n#![feature(auto_traits)]\n\ntrait PrincipalTrait {}\n\nauto trait AutoTrait {}\n\nimpl dyn PrincipalTrait + AutoTrait + Send {}\n```\n"),
(E0786,
"A metadata file was invalid.\n\nErroneous code example:\n\n```ignore (needs extern files)\nuse ::foo; // error: found invalid metadata files for crate `foo`\n```\n\nWhen loading crates, each crate must have a valid metadata file.\nInvalid files could be caused by filesystem corruption,\nan IO error while reading the file, or (rarely) a bug in the compiler itself.\n\nConsider deleting the file and recreating it,\nor reporting a bug against the compiler.\n"),
(E0787,
"An unsupported naked function definition.\n\nErroneous code example:\n\n```compile_fail,E0787\n#[unsafe(naked)]\npub extern \"C\" fn f() -> u32 {\n 42\n}\n```\n\nThe naked function must be defined using a single `naked_asm!` assembly block.\n\nThe execution must never fall through past the end of the assembly\ncode, so it must either return or diverge. The asm block can also\nuse `att_syntax` and `raw` options, but others options are not allowed.\n\nThe asm block must not contain any operands other than `const` and\n`sym`.\n\n### Additional information\n\nFor more information, please see [RFC 2972].\n\n[RFC 2972]: https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md\n"),
(E0788,
"#### Note: this error code is no longer emitted by the compiler.\n\nA `#[coverage(off|on)]` attribute was found in a position where it is not\nallowed.\n\nCoverage attributes can be applied to:\n- Function and method declarations that have a body, including trait methods\n that have a default implementation.\n- Closure expressions, in situations where attributes can be applied to\n expressions.\n- `impl` blocks (inherent or trait), and modules.\n\nExample of erroneous code:\n\n```ignore (no longer emitted)\nunsafe extern \"C\" {\n #[coverage(off)]\n fn foreign_fn();\n}\n```\n\nWhen using the `-C instrument-coverage` flag, coverage attributes act as a\nhint to the compiler that it should instrument or not instrument the\ncorresponding function or enclosed functions. The precise effect of applying\na coverage attribute is not guaranteed and may change in future compiler\nversions.\n"),
(E0789,
"#### This error code is internal to the compiler and will not be emitted with normal Rust code.\n\nThe internal `rustc_allowed_through_unstable_modules` attribute must be used\non an item with a `stable` attribute.\n\nErroneous code example:\n\n```compile_fail,E0789\n// NOTE: both of these attributes are perma-unstable and should *never* be\n// used outside of the compiler and standard library.\n#![feature(rustc_attrs)]\n#![feature(staged_api)]\n#![allow(internal_features)]\n\n#![unstable(feature = \"foo_module\", reason = \"...\", issue = \"123\")]\n\n#[rustc_allowed_through_unstable_modules = \"deprecation message\"]\n// #[stable(feature = \"foo\", since = \"1.0\")]\nstruct Foo;\n// ^^^ error: `rustc_allowed_through_unstable_modules` attribute must be\n// paired with a `stable` attribute\n```\n\nTypically when an item is marked with a `stable` attribute, the modules that\nenclose the item must also be marked with `stable` attributes, otherwise the\nitem becomes *de facto* unstable. `#[rustc_allowed_through_unstable_modules]`\nis a workaround which allows an item to \"escape\" its unstable parent modules.\nThis error occurs when an item is marked with\n`#[rustc_allowed_through_unstable_modules]` but no supplementary `stable`\nattribute exists. See [#99288](https://github.com/rust-lang/rust/pull/99288)\nfor an example of `#[rustc_allowed_through_unstable_modules]` in use.\n"),
(E0790,
"You need to specify a specific implementation of the trait in order to call the\nmethod.\n\nErroneous code example:\n\n```compile_fail,E0790\ntrait Coroutine {\n fn create() -> u32;\n}\n\nstruct Impl;\n\nimpl Coroutine for Impl {\n fn create() -> u32 { 1 }\n}\n\nstruct AnotherImpl;\n\nimpl Coroutine for AnotherImpl {\n fn create() -> u32 { 2 }\n}\n\nlet cont: u32 = Coroutine::create();\n// error, impossible to choose one of Coroutine trait implementation\n// Should it be Impl or AnotherImpl, maybe something else?\n```\n\nThis error can be solved by adding type annotations that provide the missing\ninformation to the compiler. In this case, the solution is to use a concrete\ntype:\n\n```\ntrait Coroutine {\n fn create() -> u32;\n}\n\nstruct AnotherImpl;\n\nimpl Coroutine for AnotherImpl {\n fn create() -> u32 { 2 }\n}\n\nlet gen1 = AnotherImpl::create();\n\n// if there are multiple methods with same name (different traits)\nlet gen2 = <AnotherImpl as Coroutine>::create();\n```\n"),
(E0791,
"Static variables with the `#[linkage]` attribute within external blocks\nmust have one of the following types, which are equivalent to a nullable\npointer in C:\n\n* `*mut T` or `*const T`, where `T` may be any type.\n\n* An enumerator type with no `#[repr]` attribute and with two variants, where\n one of the variants has no fields, and the other has a single field of one of\n the following non-nullable types:\n * Reference type\n * Function pointer type\n\n The variants can appear in either order.\n\nFor example, the following declaration is invalid:\n\n```compile_fail,E0791\n#![feature(linkage)]\n\nextern \"C\" {\n #[linkage = \"extern_weak\"]\n static foo: i8;\n}\n```\n\nThe following declarations are valid:\n\n```\n#![feature(linkage)]\n\nextern \"C\" {\n #[linkage = \"extern_weak\"]\n static foo: Option<unsafe extern \"C\" fn()>;\n\n #[linkage = \"extern_weak\"]\n static bar: Option<&\'static i8>;\n\n #[linkage = \"extern_weak\"]\n static baz: *mut i8;\n}\n```\n"),
(E0792,
"A type alias impl trait can only have its hidden type assigned\nwhen used fully generically (and within their defining scope).\nThis means\n\n```compile_fail,E0792\n#![feature(type_alias_impl_trait)]\n\ntype Foo<T> = impl std::fmt::Debug;\n\n#[define_opaque(Foo)]\nfn foo() -> Foo<u32> {\n 5u32\n}\n```\n\nis not accepted. If it were accepted, one could create unsound situations like\n\n```compile_fail,E0792\n#![feature(type_alias_impl_trait)]\n\ntype Foo<T> = impl Default;\n\n#[define_opaque(Foo)]\nfn foo() -> Foo<u32> {\n 5u32\n}\n\nfn main() {\n let x = Foo::<&\'static mut String>::default();\n}\n```\n\n\nInstead you need to make the function generic:\n\n```\n#![feature(type_alias_impl_trait)]\n\ntype Foo<T> = impl std::fmt::Debug;\n\n#[define_opaque(Foo)]\nfn foo<U>() -> Foo<U> {\n 5u32\n}\n\nfn main() {}\n```\n\nThis means that no matter the generic parameter to `foo`,\nthe hidden type will always be `u32`.\nIf you want to link the generic parameter to the hidden type,\nyou can do that, too:\n\n\n```\n#![feature(type_alias_impl_trait)]\n\nuse std::fmt::Debug;\n\ntype Foo<T: Debug> = impl Debug;\n\n#[define_opaque(Foo)]\nfn foo<U: Debug>() -> Foo<U> {\n Vec::<U>::new()\n}\n\nfn main() {}\n```\n"),
(E0793,
"An unaligned reference to a field of a [packed] `struct` or `union` was created.\n\nThe `#[repr(packed)]` attribute removes padding between fields, which can\ncause fields to be stored at unaligned memory addresses. Creating references\nto such fields violates Rust\'s memory safety guarantees and can lead to\nundefined behavior in optimized code.\n\nErroneous code example:\n\n```compile_fail,E0793\n#[repr(packed)]\npub struct Foo {\n field1: u64,\n field2: u8,\n}\n\nunsafe {\n let foo = Foo { field1: 0, field2: 0 };\n // Accessing the field directly is fine.\n let val = foo.field1;\n // A reference to a packed field causes a error.\n let val = &foo.field1; // ERROR\n // An implicit `&` is added in format strings, causing the same error.\n println!(\"{}\", foo.field1); // ERROR\n}\n```\n\nCreating a reference to an insufficiently aligned packed field is\n[undefined behavior] and therefore disallowed. Using an `unsafe` block does not\nchange anything about this. Instead, the code should do a copy of the data in\nthe packed field or use raw pointers and unaligned accesses.\n\n```\n#[repr(packed)]\npub struct Foo {\n field1: u64,\n field2: u8,\n}\n\nunsafe {\n let foo = Foo { field1: 0, field2: 0 };\n\n // Instead of a reference, we can create a raw pointer...\n let ptr = std::ptr::addr_of!(foo.field1);\n // ... and then (crucially!) access it in an explicitly unaligned way.\n let val = unsafe { ptr.read_unaligned() };\n // This would *NOT* be correct:\n // let val = unsafe { *ptr }; // Undefined Behavior due to unaligned load!\n\n // For formatting, we can create a copy to avoid the direct reference.\n let copy = foo.field1;\n println!(\"{}\", copy);\n\n // Creating a copy can be written in a single line with curly braces.\n // (This is equivalent to the two lines above.)\n println!(\"{}\", { foo.field1 });\n\n // A reference to a field that will always be sufficiently aligned is safe:\n println!(\"{}\", foo.field2);\n}\n```\n\n### Unions\n\nAlthough creating a reference to a `union` field is `unsafe`, this error\nwill still be triggered if the referenced field is not sufficiently\naligned. Use `addr_of!` and raw pointers in the same way as for struct fields.\n\n```compile_fail,E0793\n#[repr(packed)]\npub union Foo {\n field1: u64,\n field2: u8,\n}\n\nunsafe {\n let foo = Foo { field1: 0 };\n // Accessing the field directly is fine.\n let val = foo.field1;\n\n // A reference to a packed union field causes an error.\n let val = &foo.field1; // ERROR\n}\n```\n\n### Additional information\n\nNote that this error is specifically about *references* to packed fields.\nDirect by-value access of those fields is fine, since then the compiler has\nenough information to generate the correct kind of access.\n\nSee [issue #82523] for more information.\n\n[packed]: https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers\n[undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html\n[issue #82523]: https://github.com/rust-lang/rust/issues/82523\n"),
(E0794,
"A lifetime parameter of a function definition is called *late-bound* if it both:\n\n1. appears in an argument type\n2. does not appear in a generic type constraint\n\nYou cannot specify lifetime arguments for late-bound lifetime parameters.\n\nErroneous code example:\n\n```compile_fail,E0794\nfn foo<\'a>(x: &\'a str) -> &\'a str { x }\nlet _ = foo::<\'static>;\n```\n\nThe type of a concrete instance of a generic function is universally quantified\nover late-bound lifetime parameters. This is because we want the function to\nwork for any lifetime instantiated for the late-bound lifetime parameter, no\nmatter where the function is called. Consequently, it doesn\'t make sense to\nspecify arguments for late-bound lifetime parameters, since they are not\nresolved until the function\'s call site(s).\n\nTo fix the issue, remove the specified lifetime:\n\n```\nfn foo<\'a>(x: &\'a str) -> &\'a str { x }\nlet _ = foo;\n```\n\n### Additional information\n\nLifetime parameters that are not late-bound are called *early-bound*.\nConfusion may arise from the fact that late-bound and early-bound\nlifetime parameters are declared the same way in function definitions.\nWhen referring to a function pointer type, universal quantification over\nlate-bound lifetime parameters can be made explicit:\n\n```\ntrait BarTrait<\'a> {}\n\nstruct Bar<\'a> {\n s: &\'a str\n}\n\nimpl<\'a> BarTrait<\'a> for Bar<\'a> {}\n\nfn bar<\'a, \'b, T>(x: &\'a str, _t: T) -> &\'a str\nwhere T: BarTrait<\'b>\n{\n x\n}\n\nlet bar_fn: for<\'a> fn(&\'a str, Bar<\'static>) -> &\'a str = bar; // OK\nlet bar_fn2 = bar::<\'static, Bar>; // Not allowed\nlet bar_fn3 = bar::<Bar>; // OK\n```\n\nIn the definition of `bar`, the lifetime parameter `\'a` is late-bound, while\n`\'b` is early-bound. This is reflected in the type annotation for `bar_fn`,\nwhere `\'a` is universally quantified and `\'b` is instantiated with a specific\nlifetime. It is not allowed to explicitly specify early-bound lifetime\narguments when late-bound lifetime parameters are present (as for `bar_fn2`,\nsee [issue #42868](https://github.com/rust-lang/rust/issues/42868)), although\nthe types that are constrained by early-bound parameters can be specified (as\nfor `bar_fn3`).\n"),
(E0795,
"Invalid argument for the `offset_of!` macro.\n\nErroneous code example:\n\n```compile_fail,E0795\n#![feature(offset_of_enum)]\n\nlet x = std::mem::offset_of!(Option<u8>, Some);\n```\n\nThe `offset_of!` macro gives the offset of a field within a type. It can\nnavigate through enum variants, but the final component of its second argument\nmust be a field and not a variant.\n\nThe offset of the contained `u8` in the `Option<u8>` can be found by specifying\nthe field name `0`:\n\n```\n#![feature(offset_of_enum)]\n\nlet x: usize = std::mem::offset_of!(Option<u8>, Some.0);\n```\n\nThe discriminant of an enumeration may be read with `core::mem::discriminant`,\nbut this is not always a value physically present within the enum.\n\nFurther information about enum layout may be found at\nhttps://rust-lang.github.io/unsafe-code-guidelines/layout/enums.html.\n"),
(E0796,
"#### Note: this error code is no longer emitted by the compiler.\n\nYou have created a reference to a mutable static.\n\nErroneous code example:\n\n```\nstatic mut X: i32 = 23;\nfn work() {\n let _val = unsafe { X };\n}\nlet x_ref = unsafe { &mut X };\nwork();\n// The next line has Undefined Behavior!\n// `x_ref` is a mutable reference and allows no aliases,\n// but `work` has been reading the reference between\n// the moment `x_ref` was created and when it was used.\n// This violates the uniqueness of `x_ref`.\n*x_ref = 42;\n```\n\nA reference to a mutable static has lifetime `\'static`. This is very dangerous\nas it is easy to accidentally overlap the lifetime of that reference with\nother, conflicting accesses to the same static.\n\nReferences to mutable statics are a hard error in the 2024 edition.\n"),
(E0797,
"Struct update syntax was used without a base expression.\n\nErroneous code example:\n\n```compile_fail,E0797\nstruct Foo {\n fizz: u8,\n buzz: u8\n}\n\nlet f1 = Foo { fizz: 10, buzz: 1};\nlet f2 = Foo { fizz: 10, .. }; // error\n```\n\nUsing struct update syntax requires a \'base expression\'.\nThis will be used to fill remaining fields.\n\n```\nstruct Foo {\n fizz: u8,\n buzz: u8\n}\n\nlet f1 = Foo { fizz: 10, buzz: 1};\nlet f2 = Foo { fizz: 10, ..f1 };\n```\n"),
(E0798,
"Functions marked as `cmse-nonsecure-call` place restrictions on their\ninputs and outputs.\n\n- inputs must fit in the 4 available 32-bit argument registers. Alignment\nis relevant.\n- outputs must either fit in 4 bytes, or be a foundational type of\nsize 8 (`i64`, `u64`, `f64`).\n- no generics can be used in the signature\n\nFor more information,\nsee [arm\'s aapcs32](https://github.com/ARM-software/abi-aa/releases).\n\nErroneous code example:\n\n```ignore (host errors will not match for target)\n#![feature(abi_cmse_nonsecure_call)]\n\n#[no_mangle]\npub fn test(\n f: extern \"cmse-nonsecure-call\" fn(u32, u32, u32, u32, u32) -> u32,\n) -> u32 {\n f(1, 2, 3, 4, 5)\n}\n```\n\nArguments\' alignment is respected. In the example below, padding is inserted\nso that the `u64` argument is passed in registers r2 and r3. There is then no\nroom left for the final `f32` argument\n\n```ignore (host errors will not match for target)\n#![feature(abi_cmse_nonsecure_call)]\n\n#[no_mangle]\npub fn test(\n f: extern \"cmse-nonsecure-call\" fn(u32, u64, f32) -> u32,\n) -> u32 {\n f(1, 2, 3.0)\n}\n```\n"),
(E0799,
"Something other than a type or const parameter has been used when one was\nexpected.\n\nErroneous code example:\n\n```compile_fail,E0799\nfn bad1() -> impl Sized + use<main> {}\n\nfn bad2(x: ()) -> impl Sized + use<x> {}\n\nfn main() {}\n```\n\nIn the given examples, for `bad1`, the name `main` corresponds to a function\nrather than a type or const parameter. In `bad2`, the name `x` corresponds to\na function argument rather than a type or const parameter.\n\nOnly type and const parameters, including `Self`, may be captured by\n`use<...>` precise capturing bounds.\n"),
(E0800,
"A type or const parameter of the given name is not in scope.\n\nErroneous code examples:\n\n```compile_fail,E0800\nfn missing() -> impl Sized + use<T> {}\n```\n\nTo fix this error, please verify you didn\'t misspell the type or const\nparameter, or double-check if you forgot to declare the parameter in\nthe list of generics.\n"),
(E0801,
"The `self` parameter in a method has an invalid generic \"receiver type\".\n\nErroneous code example:\n\n```compile_fail,E0801\nstruct Foo;\n\nimpl Foo {\n fn foo<R: std::ops::Deref<Target=Self>>(self: R) {}\n}\n```\n\nor alternatively,\n\n```compile_fail,E0801\nstruct Foo;\n\nimpl Foo {\n fn foo(self: impl std::ops::Deref<Target=Self>) {}\n}\n```\n\nMethods take a special first parameter, termed `self`. It\'s normal to\nuse `self`, `&self` or `&mut self`, which are syntactic sugar for\n`self: Self`, `self: &Self`, and `self: &mut Self` respectively.\nBut it\'s also possible to use more sophisticated types of `self`\nparameter, for instance `std::rc::Rc<Self>`. The set of allowable\n`Self` types is extensible using the nightly feature\n[Arbitrary self types][AST].\nThis will extend the valid set of `Self` types to anything which implements\n`std::ops::Deref<Target=Self>`, for example `Rc<Self>`, `Box<Self>`, or\nyour own smart pointers that do the same.\n\nHowever, even with that feature, the `self` type must be concrete.\nGeneric `self` types are not permitted. Specifically, a `self` type will\nbe rejected if it is a type parameter defined on the method.\n\nThese are OK:\n\n```\nstruct Foo;\n\nimpl Foo {\n fn foo(self) {}\n fn foo2(self: std::rc::Rc<Self>) {} // or some other similar\n // smart pointer if you enable arbitrary self types and\n // the pointer implements Deref<Target=Self>\n}\n```\n\n[AST]: https://doc.rust-lang.org/unstable-book/language-features/arbitrary-self-types.html\n"),
(E0802,
"The target of `derive(CoercePointee)` macro has inadmissible specification for\na meaningful use.\n\nErroneous code examples:\n\nThe target data is not a `struct`.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\nenum NotStruct<\'a, T: ?Sized> {\n Variant(&\'a T),\n}\n```\n\nThe target data has a layout that is not transparent, or `repr(transparent)`\nin other words.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\nstruct NotTransparent<\'a, #[pointee] T: ?Sized> {\n ptr: &\'a T,\n}\n```\n\nThe target data has no data field.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\n#[repr(transparent)]\nstruct NoField<\'a, #[pointee] T: ?Sized> {}\n```\n\nThe target data is not generic over any data, or has no generic type parameter.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\n#[repr(transparent)]\nstruct NoGeneric<\'a>(&\'a u8);\n```\n\nThe target data has multiple generic type parameters, but none is designated as\na pointee for coercion.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\n#[repr(transparent)]\nstruct AmbiguousPointee<\'a, T1: ?Sized, T2: ?Sized> {\n a: (&\'a T1, &\'a T2),\n}\n```\n\nThe target data has multiple generic type parameters that are designated as\npointees for coercion.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\n#[repr(transparent)]\nstruct TooManyPointees<\n \'a,\n #[pointee] A: ?Sized,\n #[pointee] B: ?Sized>\n((&\'a A, &\'a B));\n```\n\nThe type parameter that is designated as a pointee is not marked `?Sized`.\n\n```compile_fail,E0802\n#![feature(coerce_pointee)]\nuse std::marker::CoercePointee;\n#[derive(CoercePointee)]\n#[repr(transparent)]\nstruct NoMaybeSized<\'a, #[pointee] T> {\n ptr: &\'a T,\n}\n```\n\nIn summary, the `CoercePointee` macro demands the type to be a `struct` that is\ngeneric over at least one type or over more types, one of which is marked with\n`#[pointee]`, and has at least one data field and adopts a `repr(transparent)`\nlayout.\nThe only generic type or the type marked with `#[pointee]` has to be also\nmarked as `?Sized`.\n"),
(E0803,
"A trait implementation returns a reference without an\nexplicit lifetime linking it to `self`.\nIt commonly arises in generic trait implementations\nrequiring explicit lifetime bounds.\n\nErroneous code example:\n\n```compile_fail,E0803\ntrait DataAccess<T> {\n fn get_ref(&self) -> T;\n}\n\nstruct Container<\'a> {\n value: &\'a f64,\n}\n\n// Attempting to implement reference return\nimpl<\'a> DataAccess<&f64> for Container<\'a> {\n fn get_ref(&self) -> &f64 { // Error: Lifetime mismatch\n self.value\n }\n}\n```\n\nThe trait method returns &f64 requiring an independent lifetime\nThe struct Container<\'a> carries lifetime parameter \'a\nThe compiler cannot verify if the returned reference satisfies \'a constraints\nSolution\nExplicitly bind lifetimes to clarify constraints:\n```\n// Modified trait with explicit lifetime binding\ntrait DataAccess<\'a, T> {\n fn get_ref(&\'a self) -> T;\n}\n\nstruct Container<\'a> {\n value: &\'a f64,\n}\n\n// Correct implementation (bound lifetimes)\nimpl<\'a> DataAccess<\'a, &\'a f64> for Container<\'a> {\n fn get_ref(&\'a self) -> &\'a f64 {\n self.value\n }\n}\n```\n"),
(E0804,
"An auto trait cannot be added to the bounds of a `dyn Trait` type via\na pointer cast.\n\nErroneous code example:\n\n```rust,edition2021,compile_fail,E0804\nlet ptr: *const dyn core::any::Any = &();\n_ = ptr as *const (dyn core::any::Any + Send);\n```\n\nAdding an auto trait can make the vtable invalid, potentially causing\nUB in safe code afterwards. For example:\n\n```rust,edition2021,no_run\nuse core::{mem::transmute, ptr::NonNull};\n\ntrait Trait {\n fn f(&self)\n where\n Self: Send;\n}\n\nimpl Trait for NonNull<()> {\n fn f(&self) {\n unreachable!()\n }\n}\n\nfn main() {\n let unsend: &dyn Trait = &NonNull::dangling();\n let bad: &(dyn Trait + Send) = unsafe { transmute(unsend) };\n // This crashes, since the vtable for `NonNull as dyn Trait` does\n // not have an entry for `Trait::f`.\n bad.f();\n}\n```\n\nTo fix this error, you can use `transmute` rather than pointer casts,\nbut you must ensure that the vtable is valid for the pointer\'s type\nbefore calling a method on the trait object or allowing other code to\ndo so.\n"),
(E0805,
"An attribute was given an invalid number of arguments\n\nErroneous code example:\n\n```compile_fail,E0805\n#[inline()] // error! should either have a single argument, or no parentheses\nfn foo() {}\n\n#[inline(always, never)] // error! should have only one argument, not two\nfn bar() {}\n```\n\nTo fix this, either give the right number of arguments the attribute needs.\nIn the case of inline, this could be none at all:\n\n```\n#[inline]\nfn foo() {}\n```\n\nor only one:\n\n```\n#[inline(always)]\nfn foo() {}\n```\n"),
(E0806,
"An externally implementable item is not compatible with its declaration.\n\nErroneous code example:\n\n```rust,edition2021,compile_fail,E0806\n#![feature(extern_item_impls)]\n\n#[eii(foo)]\nfn x();\n\n#[foo]\nfn y(a: u64) -> u64 {\n//~^ ERROR E0806\n a\n}\n\n\nfn main() {}\n```\n\nThe error here is caused by the fact that `y` implements the\nexternally implementable item `foo`.\nIt can only do so if the signature of the implementation `y` matches\nthat of the declaration of `foo`.\nSo, to fix this, `y`\'s signature must be changed to match that of `x`:\n\n```rust,edition2021\n#![feature(extern_item_impls)]\n\n#[eii(foo)]\nfn x();\n\n#[foo]\nfn y() {}\n\n\nfn main() {}\n```\n\nOne common way this can be triggered is by using the wrong\nsignature for `#[panic_handler]`.\nThe signature is provided by `core`.\n\n```rust,edition2021,ignore\n#![no_std]\n\n#[panic_handler]\nfn on_panic() -> ! {\n//~^ ERROR E0806\n\n loop {}\n}\n\nfn main() {}\n```\n\nShould be:\n\n```rust,edition2021,ignore\n#![no_std]\n\n#[panic_handler]\nfn on_panic(info: &core::panic::PanicInfo<\'_>) -> ! {\n loop {}\n}\n\nfn main() {}\n```\n")];rustc_error_codes::error_codes!(define_error_code_constants_and_diagnostics_table);