Constant rustc_typeck::DIAGNOSTICS
[−]
[src]
pub const DIAGNOSTICS: [(&'static str, &'static str); 130]=
[("E0045", "\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. Examples of erroneous code:\n\n```compile_fail\n#![feature(unboxed_closures)]\n\nextern \"rust-call\" { fn foo(x: u8, ...); }\n\n// or\n\nfn foo(x: u8, ...) {}\n```\n\nTo fix such code, put them in an extern \"C\" block:\n\n```\nextern \"C\" {\n fn foo (x: u8, ...);\n}\n```\n"), ("E0131", "\nIt is not possible to define `main` with type parameters, or even with function\nparameters. When `main` is present, it must take no arguments and return `()`.\nErroneous code example:\n\n```compile_fail,E0131\nfn main<T>() { // error: main function is not allowed to have type parameters\n}\n```\n"), ("E0132", "\nA function with the `start` attribute was declared with type parameters.\n\nErroneous code example:\n\n```compile_fail,E0132\n#![feature(start)]\n\n#[start]\nfn f<T>() {}\n```\n\nIt is not possible to declare type parameters on a function that has the `start`\nattribute. Such a function must have the following type signature (for more\ninformation: http://doc.rust-lang.org/stable/book/no-stdlib.html):\n\n```ignore\nfn(isize, *const *const u8) -> isize;\n```\n\nExample:\n\n```\n#![feature(start)]\n\n#[start]\nfn my_start(argc: isize, argv: *const *const u8) -> isize {\n 0\n}\n```\n"), ("E0023", "\nA pattern used to match against an enum variant must provide a sub-pattern for\neach field of the enum variant. This error indicates that a pattern attempted to\nextract an incorrect number of fields from a variant.\n\n```\nenum Fruit {\n Apple(String, String),\n Pear(u32),\n}\n```\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", "\nEach field of a struct can only be bound once in a pattern. Erroneous code\nexample:\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", "\nThis error indicates that a struct pattern attempted to extract a non-existent\nfield from a struct. Struct fields are identified by the name used before the\ncolon `:` so struct patterns should resemble the declaration of the struct type\nbeing matched.\n\n```\n// Correct matching.\nstruct Thing {\n x: u32,\n y: u32\n}\n\nlet thing = Thing { x: 1, y: 2 };\n\nmatch thing {\n Thing { x: xfield, y: yfield } => {}\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.\n\nChange this:\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 } => {}\n}\n```\n\nTo this:\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 } => {}\n}\n```\n"), ("E0027", "\nThis error indicates that a pattern for a struct fails to specify a sub-pattern\nfor every one of the struct\'s fields. Ensure that each field from the struct\'s\ndefinition is mentioned in the pattern, or use `..` to ignore unwanted fields.\n\nFor 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\nThis is correct (explicit):\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", "\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\n```compile_fail,E0029\nlet string = \"salutations !\";\n\n// The ordering relation for strings can\'t 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"), ("E0033", "\nThis error indicates that a pointer to a trait type cannot be implicitly\ndereferenced by a pattern. Every trait defines a type, but because the\nsize of trait implementors isn\'t fixed, this type has no compile-time size.\nTherefore, all accesses to trait types must be through pointers. If you\nencounter this error you should try to avoid dereferencing the pointer.\n\n```ignore\nlet trait_obj: &SomeTrait = ...;\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\nYou can read more about trait objects in the Trait Object section of the\nReference:\n\nhttps://doc.rust-lang.org/reference.html#trait-objects\n"), ("E0034", "\nThe compiler doesn\'t know what method to call because more than one method\nhas the same prototype. Erroneous 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"), ("E0035", "\nYou tried to give a type parameter where it wasn\'t needed. Erroneous code\nexample:\n\n```compile_fail,E0035\nstruct Test;\n\nimpl Test {\n fn method(&self) {}\n}\n\nfn main() {\n let x = Test;\n\n x.method::<i32>(); // Error: Test::method doesn\'t need type parameter!\n}\n```\n\nTo fix this error, just remove the type parameter:\n\n```\nstruct Test;\n\nimpl Test {\n fn method(&self) {}\n}\n\nfn main() {\n let x = Test;\n\n x.method(); // OK, we\'re good!\n}\n```\n"), ("E0036", "\nThis error occurrs when you pass too many or not enough type parameters to\na method. Erroneous code example:\n\n```compile_fail,E0036\nstruct Test;\n\nimpl Test {\n fn method<T>(&self, v: &[T]) -> usize {\n v.len()\n }\n}\n\nfn main() {\n let x = Test;\n let v = &[0];\n\n x.method::<i32, i32>(v); // error: only one type parameter is expected!\n}\n```\n\nTo fix it, just specify a correct number of type parameters:\n\n```\nstruct Test;\n\nimpl Test {\n fn method<T>(&self, v: &[T]) -> usize {\n v.len()\n }\n}\n\nfn main() {\n let x = Test;\n let v = &[0];\n\n x.method::<i32>(v); // OK, we\'re good!\n}\n```\n\nPlease note on the last example that we could have called `method` like this:\n\n```ignore\nx.method(v);\n```\n"), ("E0040", "\nIt is not allowed to manually call destructors in Rust. It is also not\nnecessary to do this since `drop` is called automatically whenever a value goes\nout of scope.\n\nHere\'s an example of this error:\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"), ("E0044", "\nYou can\'t use type parameters on foreign items. Example of erroneous code:\n\n```compile_fail,E0044\nextern { fn some_func<T>(x: T); }\n```\n\nTo fix this, replace the type parameter with the specializations that you\nneed:\n\n```\nextern { fn some_func_i32(x: i32); }\nextern { fn some_func_i64(x: i64); }\n```\n"), ("E0046", "\nItems are missing in a trait implementation. Erroneous 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", "\nThis error indicates that an attempted implementation of a trait method\nhas the wrong number of type parameters.\n\nFor example, the trait below has a method `foo` with a type parameter `T`,\nbut the implementation of `foo` for the type `Bar` is missing this parameter:\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"), ("E0050", "\nThis error indicates that an attempted implementation of a trait method\nhas the wrong number of function parameters.\n\nFor example, the trait below 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:\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"), ("E0053", "\nThe parameters of any trait method must match between a trait implementation\nand the trait definition.\n\nHere are a couple examples of this error:\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", "\nIt is not allowed to cast to a bool. If you are trying to cast a numeric type\nto a bool, you can compare it with zero instead:\n\n```compile_fail,E0054\nlet x = 5;\n\n// Not allowed, won\'t compile\nlet x_is_nonzero = x as bool;\n```\n\n```\nlet x = 5;\n\n// Ok\nlet x_is_nonzero = x != 0;\n```\n"), ("E0055", "\nDuring 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=\"2\"]\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", "\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\nAn example using a closure:\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\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", "\nThe 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", "\nExternal 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```ignore\nextern crate libc;\nuse libc::{ c_char, c_int };\n\nextern \"C\" {\n fn printf(_: *const c_char, ...) -> c_int;\n}\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```ignore\nunsafe {\n use std::ffi::CString;\n\n printf(CString::new(\"test\\n\").unwrap().as_ptr());\n printf(CString::new(\"number = %d\\n\").unwrap().as_ptr(), 3);\n printf(CString::new(\"%d, %d\\n\").unwrap().as_ptr(), 10, 5);\n}\n```\n"), ("E0061", "\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", "\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. Erroneous code\nexample:\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\nEach field should be 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", "\nThis error indicates that during an attempt to build a struct or struct-like\nenum variant, one of the fields was not provided. Erroneous 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"), ("E0066", "\nBox placement expressions (like C++\'s \"placement new\") do not yet support any\nplace expression except the exchange heap (i.e. `std::boxed::HEAP`).\nFurthermore, the syntax is changing to use `in` instead of `box`. See [RFC 470]\nand [RFC 809] for more details.\n\n[RFC 470]: https://github.com/rust-lang/rfcs/pull/470\n[RFC 809]: https://github.com/rust-lang/rfcs/pull/809\n"), ("E0067", "\nThe left-hand side of a compound assignment expression must be an lvalue\nexpression. An lvalue expression represents a memory location and includes\nitem paths (ie, namespaced variables), dereferences, indexing expressions,\nand field references.\n\nLet\'s start with some erroneous code examples:\n\n```compile_fail,E0067\nuse std::collections::LinkedList;\n\n// Bad: assignment to non-lvalue expression\nLinkedList::new() += 1;\n\n// ...\n\nfn some_func(i: &mut i32) {\n i += 12; // Error : \'+=\' operation cannot be applied on a reference !\n}\n```\n\nAnd now some working examples:\n\n```\nlet mut i : i32 = 0;\n\ni += 12; // Good !\n\n// ...\n\nfn some_func(i: &mut i32) {\n *i += 12; // Good !\n}\n```\n"), ("E0069", "\nThe compiler found a function whose body contains a `return;` statement but\nwhose return type is not `()`. An example of this is:\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", "\nThe left-hand side of an assignment operator must be an lvalue expression. An\nlvalue 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 here:\nhttps://doc.rust-lang.org/reference.html#lvalues-rvalues-and-temporaries\n\nNow, we can go further. Here are some erroneous 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 lvalue!\n some_other_func() = 4; // error : we can\'t 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\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", "\nYou tried to use structure-literal syntax to create an item that is\nnot a structure or 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\nthe correct form of initializer was used.\n\nFor example, the code above can be fixed to:\n\n```\nenum Foo {\n FirstValue(i32)\n}\n\nfn main() {\n let u = Foo::FirstValue(0i32);\n\n let t = 4;\n}\n```\n"), ("E0073", "\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```ignore\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", "\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```ignore\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad<T>(T, T, T);\n```\n\nThis will not:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good(u32, u32, u32);\n```\n"), ("E0075", "\nThe `#[simd]` attribute can only be applied to non empty tuple structs, because\nit doesn\'t make sense to try to use SIMD operations when there are no values to\noperate on.\n\nThis will cause an error:\n\n```compile_fail,E0075\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad;\n```\n\nThis will not:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good(u32);\n```\n"), ("E0076", "\nWhen using the `#[simd]` attribute to automatically use SIMD operations in tuple\nstruct, the types in the struct must all be of the same type, or the compiler\nwill trigger this error.\n\nThis will cause an error:\n\n```compile_fail,E0076\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad(u16, u32, u32);\n```\n\nThis will not:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good(u32, u32, u32);\n```\n"), ("E0077", "\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\nThis will cause an error:\n\n```compile_fail,E0077\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Bad(String);\n```\n\nThis will not:\n\n```\n#![feature(repr_simd)]\n\n#[repr(simd)]\nstruct Good(u32, u32, u32);\n```\n"), ("E0081", "\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 them impossible to tell apart.\n\n```compile_fail,E0081\n// Bad.\nenum Enum {\n P = 3,\n X = 3,\n Y = 5,\n}\n```\n\n```\n// Good.\nenum Enum {\n P,\n X = 3,\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\n}\n```\n\nHere `X` will have already been specified the discriminant 0 by the time `Y` is\nencountered, so a conflict occurs.\n"), ("E0082", "\nWhen you specify enum discriminants with `=`, the compiler expects `isize`\nvalues by default. Or you can add the `repr` attibute to the enum declaration\nfor an explicit choice of the discriminant type. In either cases, the\ndiscriminant values must fall within a valid range for the expected type;\notherwise this error is raised. For example:\n\n```ignore\n#[repr(u8)]\nenum Thing {\n A = 1024,\n B = 5,\n}\n```\n\nHere, 1024 lies outside the valid range for `u8`, so the discriminant for `A` is\ninvalid. Here is another, more subtle example which depends on target word size:\n\n```ignore\nenum DependsOnPointerSize {\n A = 1 << 32,\n}\n```\n\nHere, `1 << 32` is interpreted as an `isize` value. So it is invalid for 32 bit\ntarget (`target_pointer_width = \"32\"`) but valid for 64 bit target.\n\nYou may want to change representation types to fix this, or else change invalid\ndiscriminant values so that they fit within the existing type.\n"), ("E0084", "\nAn 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 represention of your enum:\n\n```\nenum NightsWatch {}\n```\n"), ("E0087", "\nToo many type parameters were supplied for a function. For example:\n\n```compile_fail,E0087\nfn foo<T>() {}\n\nfn main() {\n foo::<f64, bool>(); // error, expected 1 parameter, found 2 parameters\n}\n```\n\nThe number of supplied parameters must exactly match the number of defined type\nparameters.\n"), ("E0088", "\nYou gave too many lifetime parameters. Erroneous code example:\n\n```compile_fail,E0088\nfn f() {}\n\nfn main() {\n f::<\'static>() // error: too many lifetime parameters provided\n}\n```\n\nPlease check you give the right number of lifetime parameters. 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", "\nNot enough type parameters were supplied for a function. For example:\n\n```compile_fail,E0089\nfn foo<T, U>() {}\n\nfn main() {\n foo::<f64>(); // error, expected 2 parameters, found 1 parameter\n}\n```\n\nNote that if a function takes multiple type parameters but you want the compiler\nto infer some of them, you can use type placeholders:\n\n```compile_fail,E0089\nfn foo<T, U>(x: T) {}\n\nfn main() {\n let x: bool = true;\n foo::<f64>(x); // error, expected 2 parameters, found 1 parameter\n foo::<_, f64>(x); // same as `foo::<bool, f64>(x)`\n}\n```\n"), ("E0091", "\nYou gave an unnecessary type parameter in a type alias. Erroneous code\nexample:\n\n```compile_fail,E0091\ntype Foo<T> = u32; // error: type parameter `T` is unused\n// or:\ntype Foo<A,B> = Box<A>; // error: type parameter `B` is unused\n```\n\nPlease check you didn\'t write too many type parameters. Example:\n\n```\ntype Foo = u32; // ok!\ntype Foo2<A> = Box<A>; // ok!\n```\n"), ("E0092", "\nYou tried to declare an undefined atomic operation function.\nErroneous code example:\n\n```compile_fail,E0092\n#![feature(intrinsics)]\n\nextern \"rust-intrinsic\" {\n fn atomic_foo(); // error: unrecognized atomic operation\n // function\n}\n```\n\nPlease check you didn\'t make a mistake in the function\'s name. All intrinsic\nfunctions are defined in librustc_trans/trans/intrinsic.rs and in\nlibcore/intrinsics.rs in the Rust source code. Example:\n\n```\n#![feature(intrinsics)]\n\nextern \"rust-intrinsic\" {\n fn atomic_fence(); // ok!\n}\n```\n"), ("E0093", "\nYou declared an unknown intrinsic function. Erroneous code example:\n\n```compile_fail,E0093\n#![feature(intrinsics)]\n\nextern \"rust-intrinsic\" {\n fn foo(); // error: unrecognized intrinsic function: `foo`\n}\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 librustc_trans/trans/intrinsic.rs and in\nlibcore/intrinsics.rs in the Rust source code. Example:\n\n```\n#![feature(intrinsics)]\n\nextern \"rust-intrinsic\" {\n fn atomic_fence(); // ok!\n}\n\nfn main() {\n unsafe {\n atomic_fence();\n }\n}\n```\n"), ("E0094", "\nYou gave an invalid number of type parameters to an intrinsic function.\nErroneous code example:\n\n```compile_fail,E0094\n#![feature(intrinsics)]\n\nextern \"rust-intrinsic\" {\n fn size_of<T, U>() -> usize; // error: intrinsic has wrong number\n // of type parameters\n}\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\nextern \"rust-intrinsic\" {\n fn size_of<T>() -> usize; // ok!\n}\n```\n"), ("E0101", "\nYou hit this error because the compiler lacks the information to\ndetermine a type for this expression. Erroneous code example:\n\n```compile_fail,E0101\nlet x = |_| {}; // error: cannot determine a type for this expression\n```\n\nYou have two possibilities to solve this situation:\n\n* Give an explicit definition of the expression\n* Infer the expression\n\nExamples:\n\n```\nlet x = |_ : u32| {}; // ok!\n// or:\nlet x = |_| {};\nx(0u32);\n```\n"), ("E0102", "\nYou hit this error because the compiler lacks the information to\ndetermine the type of this variable. Erroneous code example:\n\n```compile_fail,E0102\n// could be an array of anything\nlet x = []; // error: cannot determine a type for this local variable\n```\n\nTo solve this situation, constrain the type of the variable.\nExamples:\n\n```\n#![allow(unused_variables)]\n\nfn main() {\n let x: [u8; 0] = [];\n}\n```\n"), ("E0107", "\nThis error means that an incorrect number of lifetime parameters were provided\nfor a type (like a struct or enum) or trait:\n\n```compile_fail,E0107\nstruct Foo<\'a, \'b>(&\'a str, &\'b str);\nenum Bar { A, B, C }\n\nstruct Baz<\'a> {\n foo: Foo<\'a>, // error: expected 2, found 1\n bar: Bar<\'a>, // error: expected 0, found 1\n}\n```\n"), ("E0109", "\nYou tried to give a type parameter to a type which doesn\'t need it. Erroneous\ncode example:\n\n```compile_fail,E0109\ntype X = u32<i32>; // error: type parameters are not allowed on this type\n```\n\nPlease check that you used the correct type and recheck its definition. Perhaps\nit doesn\'t need the type parameter.\n\nExample:\n\n```\ntype X = u32; // this compiles\n```\n\nNote that type parameters for enum-variant constructors go after the variant,\nnot after the enum (Option::None::<u32>, not Option::<u32>::None).\n"), ("E0110", "\nYou tried to give a lifetime parameter to a type which doesn\'t need it.\nErroneous code example:\n\n```compile_fail,E0110\ntype X = u32<\'static>; // error: lifetime parameters are not allowed on\n // this type\n```\n\nPlease check that the correct type was used and recheck its definition; perhaps\nit doesn\'t need the lifetime parameter. Example:\n\n```\ntype X = u32; // ok!\n```\n"), ("E0116", "\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 below is not allowed\nsince `Vec` is defined in the standard library:\n\n```compile_fail,E0116\nimpl Vec<u8> { } // error\n```\n\nTo fix this problem, you can do either of these things:\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", "\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\nHere\'s one example of this error:\n\n```compile_fail,E0117\nimpl Drop for u32 {}\n```\n\nTo avoid this kind of error, ensure that at least one local type is referenced\nby the `impl`:\n\n```ignore\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}\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/pull/1023\n"), ("E0118", "\nYou\'re trying to write an inherent implementation for something which isn\'t a\nstruct nor an enum. Erroneous code example:\n\n```compile_fail,E0118\nimpl (u8, u8) { // error: no base 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 (u8, u8)\nimpl LiveLongAndProsper for (u8, u8) {\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((u8, u8));\n\nimpl TypeWrapper {\n fn get_state(&self) -> String {\n \"Fascinating!\".to_owned()\n }\n}\n```\n"), ("E0119", "\nThere are conflicting trait implementations for the same type.\nExample of erroneous code:\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", "\nAn attempt was made to implement Drop on a trait, which is not allowed: only\nstructs and enums can implement Drop. An example causing this error:\n\n```compile_fail,E0120\ntrait MyTrait {}\n\nimpl Drop for MyTrait {\n fn drop(&mut self) {}\n}\n```\n\nA workaround for this problem is to wrap the trait up in a struct, and implement\nDrop on that. An example is shown below:\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, wrapping trait objects requires something like the following:\n\n```\ntrait MyTrait {}\n\n//or Box<MyTrait>, if you wanted an owned trait object\nstruct MyWrapper<\'a> { foo: &\'a MyTrait }\n\nimpl <\'a> Drop for MyWrapper<\'a> {\n fn drop(&mut self) {}\n}\n```\n"), ("E0121", "\nIn order to be consistent with Rust\'s lack of global type inference, type\nplaceholders are disallowed by design in item signatures.\n\nExamples of this error include:\n\n```compile_fail,E0121\nfn foo() -> _ { 5 } // error, explicitly write out the return type instead\n\nstatic BAR: _ = \"test\"; // error, explicitly write out the type instead\n```\n"), ("E0122", "\nAn attempt was made to add a generic constraint to a type alias. While Rust will\nallow this with a warning, it will not currently enforce the constraint.\nConsider the example below:\n\n```\ntrait Foo{}\n\ntype MyType<R: Foo> = (R, ());\n\nfn main() {\n let t: MyType<u32>;\n}\n```\n\nWe\'re able to declare a variable of type `MyType<u32>`, despite the fact that\n`u32` does not implement `Foo`. As a result, one should avoid using generic\nconstraints in concert with type aliases.\n"), ("E0124", "\nYou declared two fields of a struct with the same name. Erroneous code\nexample:\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"), ("E0164", "\nThis error means that an attempt was made to match a struct type enum\nvariant as a non-struct type:\n\n```compile_fail,E0164\nenum Foo { B { i: u32 } }\n\nfn bar(foo: Foo) -> u32 {\n match foo {\n Foo::B(i) => i, // error E0164\n }\n}\n```\n\nTry using `{}` instead:\n\n```\nenum Foo { B { i: u32 } }\n\nfn bar(foo: Foo) -> u32 {\n match foo {\n Foo::B{i} => i,\n }\n}\n```\n"), ("E0182", "\nYou bound an associated type in an expression path which is not\nallowed.\n\nErroneous code example:\n\n```compile_fail,E0182\ntrait Foo {\n type A;\n fn bar() -> isize;\n}\n\nimpl Foo for isize {\n type A = usize;\n fn bar() -> isize { 42 }\n}\n\n// error: unexpected binding of associated item in expression path\nlet x: isize = Foo::<A=usize>::bar();\n```\n\nTo give a concrete type when using the Universal Function Call Syntax,\nuse \"Type as Trait\". Example:\n\n```\ntrait Foo {\n type A;\n fn bar() -> isize;\n}\n\nimpl Foo for isize {\n type A = usize;\n fn bar() -> isize { 42 }\n}\n\nlet x: isize = <isize as Foo>::bar(); // ok!\n```\n"), ("E0184", "\nExplicitly implementing both Drop and Copy for a type is currently disallowed.\nThis feature can make some sense in theory, but the current implementation is\nincorrect and can lead to memory unsafety (see [issue #20126][iss20126]), so\nit has been disabled for now.\n\n[iss20126]: https://github.com/rust-lang/rust/issues/20126\n"), ("E0185", "\nAn 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\nHere\'s an example of this error:\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"), ("E0186", "\nAn 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\nHere\'s an example of this error:\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"), ("E0191", "\nTrait objects need to have all associated types specified. Erroneous code\nexample:\n\n```compile_fail,E0191\ntrait Trait {\n type Bar;\n}\n\ntype Foo = Trait; // error: the value of the associated type `Bar` (from\n // the trait `Trait`) must be specified\n```\n\nPlease verify you specified all associated types of the trait and that you\nused the right trait. Example:\n\n```\ntrait Trait {\n type Bar;\n}\n\ntype Foo = Trait<Bar=i32>; // ok!\n```\n"), ("E0192", "\nNegative impls are only allowed for traits with default impls. For more\ninformation see the [opt-in builtin traits RFC](https://github.com/rust-lang/\nrfcs/blob/master/text/0019-opt-in-builtin-traits.md).\n"), ("E0193", "\n`where` clauses must use generic type parameters: it does not make sense to use\nthem otherwise. An example causing this error:\n\n```ignore\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"), ("E0194", "\nA type parameter was declared which shadows an existing one. An example of this\nerror:\n\n```compile_fail,E0194\ntrait Foo<T> {\n fn do_something(&self) -> T;\n fn do_something_else<T: Clone>(&self, bar: T);\n}\n```\n\nIn this example, the trait `Foo` and the trait method `do_something_else` both\ndefine a type parameter `T`. This is not allowed: if the method wishes to\ndefine a type parameter, it must use a different name for it.\n"), ("E0195", "\nYour method\'s lifetime parameters do not match the trait declaration.\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", "\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```compile_fail,E0197\nstruct Foo;\n\n// this will cause this error\nunsafe impl Foo { }\n// converting it to this will fix it\nimpl Foo { }\n```\n"), ("E0198", "\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\n```compile_fail\n#![feature(optin_builtin_traits)]\n\nstruct Foo;\n\n// unsafe is unnecessary\nunsafe impl !Clone for Foo { }\n```\n\nThis will compile:\n\n```\n#![feature(optin_builtin_traits)]\n\nstruct Foo;\n\ntrait Enterprise {}\n\nimpl Enterprise for .. { }\n\nimpl !Enterprise for Foo { }\n```\n\nPlease note that negative impls are only allowed for traits with default impls.\n"), ("E0199", "\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```compile_fail,E0199\nstruct Foo;\n\ntrait Bar { }\n\n// this won\'t compile because Bar is safe\nunsafe impl Bar for Foo { }\n// this will compile\nimpl Bar for Foo { }\n```\n"), ("E0200", "\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```compile_fail,E0200\nstruct Foo;\n\nunsafe trait Bar { }\n\n// this won\'t compile because Bar is unsafe and impl isn\'t unsafe\nimpl Bar for Foo { }\n// this will compile\nunsafe impl Bar for Foo { }\n```\n"), ("E0201", "\nIt is an error to define two associated items (like methods, associated types,\nassociated functions, etc.) with the same identifier.\n\nFor 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"), ("E0202", "\nInherent associated types were part of [RFC 195] but are not yet implemented.\nSee [the tracking issue][iss8995] for the status of this implementation.\n\n[RFC 195]: https://github.com/rust-lang/rfcs/pull/195\n[iss8995]: https://github.com/rust-lang/rust/issues/8995\n"), ("E0204", "\nAn attempt to implement the `Copy` trait for a struct failed because one of the\nfields does not implement `Copy`. To fix this, you must implement `Copy` for the\nmentioned field. Note that this may not be possible, as in the example of\n\n```compile_fail,E0204\nstruct Foo {\n foo : Vec<u32>,\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)]\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"), ("E0206", "\nYou can only implement `Copy` for a struct or enum. Both of the following\nexamples will fail, because neither `i32` (primitive type) nor `&\'static Bar`\n(reference to `Bar`) is a struct or enum:\n\n```compile_fail,E0206\ntype Foo = i32;\nimpl Copy for Foo { } // error\n\n#[derive(Copy, Clone)]\nstruct Bar;\nimpl Copy for &\'static Bar { } // error\n```\n"), ("E0207", "\nAny type parameter or lifetime parameter of an `impl` must meet at least one of\nthe following criteria:\n\n - it appears in the self type of the impl\n - for a trait impl, it appears in the trait reference\n - it is bound as 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 following definition leads to a compiler error:\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\nThe problem is that the parameter `T` does not appear in the self type (`Foo`)\nof the impl. In this case, we can fix the error by moving the type parameter\nfrom the `impl` to the method `get`:\n\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### 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"), ("E0210", "\nThis 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. To understand\nwhat this means, it is perhaps easiest 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\nextern crate collections;\nuse collections::range::RangeArgument;\n\nimpl<T> RangeArgument<T> for T { } // error\n\nfn main() {}\n```\n\nTo work around this, it can be covered with a local type, `MyType`:\n\n```ignore\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```compile_fail\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\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\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). Let `i` be the smallest integer\nsuch that `Ti` is a local type. Then no type parameter can appear in any of the\n`Tj` for `j < i`.\n\nFor information on the design of the orphan rules, see [RFC 1023].\n\n[RFC 1023]: https://github.com/rust-lang/rfcs/pull/1023\n"), ("E0214", "\nA generic type was described using parentheses rather than angle brackets. For\nexample:\n\n```compile_fail,E0214\nfn main() {\n let v: Vec(&str) = vec![\"foo\"];\n}\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"), ("E0220", "\nYou used an associated type which isn\'t defined in the trait.\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", "\nAn attempt was made to retrieve an associated type, but the type was ambiguous.\nFor 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"), ("E0223", "\nAn attempt was made to retrieve an associated type, but the type was ambiguous.\nFor example:\n\n```compile_fail,E0223\ntrait MyTrait {type X; }\n\nfn main() {\n let foo: MyTrait::X;\n}\n```\n\nThe problem here is that we\'re attempting to take the type of X from MyTrait.\nUnfortunately, the type of X is not defined, because it\'s only made concrete in\nimplementations of the trait. A working version of this code might look like:\n\n```\ntrait MyTrait {type X; }\nstruct MyStruct;\n\nimpl MyTrait for MyStruct {\n type X = u32;\n}\n\nfn main() {\n let foo: <MyStruct as MyTrait>::X;\n}\n```\n\nThis syntax specifies that we want the X type from MyTrait, as made concrete in\nMyStruct. The reason that we cannot simply use `MyStruct::X` is that MyStruct\nmight implement two different traits with identically-named associated types.\nThis syntax allows disambiguation between the two.\n"), ("E0225", "\nYou attempted to use multiple types as bounds for a closure or trait object.\nRust does not currently support this. A simple example that causes this error:\n\n```compile_fail,E0225\nfn main() {\n let _: Box<std::io::Read + std::io::Write>;\n}\n```\n\nSend and Sync are an exception to this rule: it\'s possible to have bounds of\none non-builtin trait, plus either or both of Send and Sync. For example, the\nfollowing compiles correctly:\n\n```\nfn main() {\n let _: Box<std::io::Read + Send + Sync>;\n}\n```\n"), ("E0229", "\nAn associated type binding was done outside of the type parameter declaration\nand `where` clause. Erroneous 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 type bindings are not allowed here\n```\n\nTo solve this error, please move the type bindings in the type parameter\ndeclaration:\n\n```ignore\nfn baz<I: Foo<A=Bar>>(x: &<I as Foo>::A) {} // ok!\n```\n\nOr in the `where` clause:\n\n```ignore\nfn baz<I>(x: &<I as Foo>::A) where I: Foo<A=Bar> {}\n```\n"), ("E0230", "\nThe trait has more type parameters specified than appear in its definition.\n\nErroneous example code:\n\n```compile_fail,E0230\n#![feature(on_unimplemented)]\n#[rustc_on_unimplemented = \"Trait error on `{Self}` with `<{A},{B},{C}>`\"]\n// error: there is no type parameter C on trait TraitWithThreeParams\ntrait TraitWithThreeParams<A,B>\n{}\n```\n\nInclude the correct number of type parameters and the compilation should\nproceed:\n\n```\n#![feature(on_unimplemented)]\n#[rustc_on_unimplemented = \"Trait error on `{Self}` with `<{A},{B},{C}>`\"]\ntrait TraitWithThreeParams<A,B,C> // ok!\n{}\n```\n"), ("E0232", "\nThe attribute must have a value. Erroneous code example:\n\n```compile_fail,E0232\n#![feature(on_unimplemented)]\n\n#[rustc_on_unimplemented] // error: this attribute must have a value\ntrait Bar {}\n```\n\nPlease supply the missing value of the attribute. Example:\n\n```\n#![feature(on_unimplemented)]\n\n#[rustc_on_unimplemented = \"foo\"] // ok!\ntrait Bar {}\n```\n"), ("E0243", "\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,E0243\nstruct Foo<T> { x: T }\n\nstruct Bar { x: Foo }\n```\n"), ("E0244", "\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,E0244\nstruct Foo { x: bool }\n\nstruct Bar<S, T> { x: Foo<S, T> }\n```\n"), ("E0569", "\nIf an impl has a generic parameter with the `#[may_dangle]` attribute, then\nthat impl must be declared as an `unsafe impl. For example:\n\n```compile_fail,E0569\n#![feature(generic_param_attrs)]\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"), ("E0318", "\nDefault impls for a trait must be located in the same crate where the trait was\ndefined. For more information see the [opt-in builtin traits RFC](https://github\n.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md).\n"), ("E0321", "\nA cross-crate opt-out trait was implemented on something which wasn\'t a struct\nor enum type. Erroneous code example:\n\n```compile_fail,E0321\n#![feature(optin_builtin_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", "\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", "\nAn associated const was implemented when another trait item was expected.\nErroneous code example:\n\n```compile_fail,E0323\n#![feature(associated_consts)]\n\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```\n#![feature(associated_consts)]\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", "\nA method was implemented when another trait item was expected. Erroneous\ncode example:\n\n```compile_fail,E0324\n#![feature(associated_consts)]\n\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```\n#![feature(associated_consts)]\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", "\nAn associated type was implemented when another trait item was expected.\nErroneous code example:\n\n```compile_fail,E0325\n#![feature(associated_consts)]\n\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```\n#![feature(associated_consts)]\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", "\nThe types of any associated constants in a trait implementation must match the\ntypes in the trait definition. This error indicates that there was a mismatch.\n\nHere\'s an example of this error:\n\n```compile_fail,E0326\n#![feature(associated_consts)]\n\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"), ("E0328", "\nThe 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 [DST coercion system]\n(https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md), use\n[`CoerceUnsized`](https://doc.rust-lang.org/std/ops/trait.CoerceUnsized.html)\ninstead.\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"), ("E0329", "\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```ignore\n#![feature(associated_consts)]\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```ignore\n#![feature(associated_consts)]\n\ntrait Foo {\n const BAR: f64;\n}\n\nstruct MyStruct;\n\nfn get_bar_good() -> f64 {\n <MyStruct as Foo>::BAR\n}\n```\n"), ("E0366", "\nAn 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", "\nAn attempt was made to implement `Drop` on a specialization of a generic type.\nAn example is shown below:\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", "\nThis error indicates that a binary assignment operator like `+=` or `^=` was\napplied to a type that doesn\'t support it. For 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", "\nA binary operation was attempted on a type which doesn\'t support it.\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"), ("E0370", "\nThe maximum value of an enum was reached, so it cannot be automatically\nset in the next enum value. Erroneous code example:\n\n```compile_fail\n#[deny(overflowing_literals)]\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```\nenum Foo {\n X = 0x7fffffffffffffff,\n Y = 0, // ok!\n}\n```\n\nOr:\n\n```\nenum Foo {\n Y = 0, // ok!\n X = 0x7fffffffffffffff,\n}\n```\n"), ("E0371", "\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\nExample:\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"), ("E0374", "\nA struct without a field containing an unsized type cannot implement\n`CoerceUnsized`. An\n[unsized type](https://doc.rust-lang.org/book/unsized-types.html)\nis any type that the compiler doesn\'t know the length or alignment of at\ncompile time. Any struct containing an unsized type is also 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 `CoerceUnsized`.\nimpl<T, U> CoerceUnsized<Foo<U>> for Foo<T>\n where T: CoerceUnsized<U> {}\n```\n\n`CoerceUnsized` is used to coerce one struct containing an unsized type\ninto another struct containing a different unsized type. If the struct\ndoesn\'t have any fields of unsized types then you don\'t need explicit\ncoercion to get the types you want. To fix this you can either\nnot try to implement `CoerceUnsized` or you can add a field that is\nunsized to the struct.\n\nExample:\n\n```\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\n// We don\'t need to impl `CoerceUnsized` here.\nstruct Foo {\n a: i32,\n}\n\n// We add the unsized type field to the struct.\nstruct Bar<T: ?Sized> {\n a: i32,\n b: T,\n}\n\n// The struct has an unsized field so we can implement\n// `CoerceUnsized` for it.\nimpl<T, U> CoerceUnsized<Bar<U>> for Bar<T>\n where T: CoerceUnsized<U> {}\n```\n\nNote that `CoerceUnsized` is mainly used by smart pointers like `Box`, `Rc`\nand `Arc` to be able to mark that they can coerce unsized types that they\nare pointing at.\n"), ("E0375", "\nA struct with more than one field containing an unsized type cannot implement\n`CoerceUnsized`. This only occurs when you are trying to coerce one of the\ntypes in your struct to another type in the struct. In this case we try to\nimpl `CoerceUnsized` from `T` to `U` which are both types that the struct\ntakes. An [unsized type](https://doc.rust-lang.org/book/unsized-types.html)\nis any type that the compiler doesn\'t know the length or alignment of at\ncompile time. Any struct containing an unsized type is also unsized.\n\nExample of erroneous code:\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` only allows for coercion from a structure with a single\nunsized type field to another struct with a single unsized type field.\nIn fact Rust only allows for a struct to have one unsized type in a struct\nand that unsized type must be the last field in the struct. So having two\nunsized types in a single struct is not allowed by the compiler. To fix this\nuse only one field containing an unsized type in the struct and then use\nmultiple structs to manage each unsized type field you need.\n\nExample:\n\n```\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\nstruct Foo<T: ?Sized> {\n a: i32,\n b: T,\n}\n\nimpl <T, U> CoerceUnsized<Foo<U>> for Foo<T>\n where T: CoerceUnsized<U> {}\n\nfn coerce_foo<T: CoerceUnsized<U>, U>(t: T) -> Foo<U> {\n Foo { a: 12i32, b: t } // we use coercion to get the `Foo<U>` type we need\n}\n```\n\n"), ("E0376", "\nThe type you are trying to impl `CoerceUnsized` for is not a struct.\n`CoerceUnsized` can only be implemented for a struct. Unsized types are\nalready able to be coerced without an implementation of `CoerceUnsized`\nwhereas a struct containing an unsized type needs to know the unsized type\nfield it\'s containing is able to be coerced. An\n[unsized type](https://doc.rust-lang.org/book/unsized-types.html)\nis any type that the compiler doesn\'t know the length or alignment of at\ncompile time. Any struct containing an unsized type is also unsized.\n\nExample of erroneous code:\n\n```compile_fail,E0376\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\nThe `CoerceUnsized` trait takes a struct type. Make sure the type you are\nproviding to `CoerceUnsized` is a struct with only the last field containing an\nunsized type.\n\nExample:\n\n```\n#![feature(coerce_unsized)]\nuse std::ops::CoerceUnsized;\n\nstruct Foo<T> {\n a: T,\n}\n\n// The `Foo<U>` is a struct so `CoerceUnsized` can be implemented\nimpl<T, U> CoerceUnsized<Foo<U>> for Foo<T> where T: CoerceUnsized<U> {}\n```\n\nNote that in Rust, structs can only contain an unsized type if the field\ncontaining the unsized type is the last and only unsized type field in the\nstruct.\n"), ("E0380", "\nDefault impls are only allowed for traits with no methods or associated items.\nFor more information see the [opt-in builtin traits RFC](https://github.com/rust\n-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md).\n"), ("E0390", "\nYou tried to implement methods for a primitive type. Erroneous code example:\n\n```compile_fail,E0390\nstruct Foo {\n x: i32\n}\n\nimpl *mut Foo {}\n// error: only a single inherent implementation marked with\n// `#[lang = \"mut_ptr\"]` is allowed for the `*mut T` primitive\n```\n\nThis isn\'t allowed, but using a trait to implement a method is 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"), ("E0392", "\nThis error indicates that a type or lifetime parameter has been declared\nbut not actually used. Here is an example that demonstrates the error:\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\nPhantomData can also be used to express information about unused type\nparameters. You can read more about it in the API documentation:\n\nhttps://doc.rust-lang.org/std/marker/struct.PhantomData.html\n"), ("E0393", "\nA type parameter which references `Self` in its default value was not specified.\nExample of erroneous code:\n\n```compile_fail,E0393\ntrait A<T=Self> {}\n\nfn together_we_will_rule_the_galaxy(son: &A) {}\n// error: the type parameter `T` must be explicitly specified in an\n// object type because its default value `Self` references the\n// type `Self`\n```\n\nA trait object is defined over a single, fully-defined trait. With a regular\ndefault parameter, this parameter can just be substituted 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 substituted 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: &A<i32>) {} // Ok!\n```\n"), ("E0399", "\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```compile_fail,E0399\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"), ("E0439", "\nThe length of the platform-intrinsic function `simd_shuffle`\nwasn\'t specified. Erroneous code example:\n\n```compile_fail,E0439\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```\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"), ("E0440", "\nA platform-specific intrinsic function has the wrong number of type\nparameters. Erroneous code example:\n\n```compile_fail,E0440\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct f64x2(f64, f64);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_movemask_pd<T>(x: f64x2) -> i32;\n // error: platform-specific intrinsic has wrong number of type\n // parameters\n}\n```\n\nPlease refer to the function declaration to see if it corresponds\nwith yours. Example:\n\n```\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct f64x2(f64, f64);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_movemask_pd(x: f64x2) -> i32;\n}\n```\n"), ("E0441", "\nAn unknown platform-specific intrinsic function was used. Erroneous\ncode example:\n\n```compile_fail,E0441\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8;\n // error: unrecognized platform-specific intrinsic function\n}\n```\n\nPlease verify that the function name wasn\'t misspelled, and ensure\nthat it is declared in the rust source code (in the file\nsrc/librustc_platform_intrinsics/x86.rs). Example:\n\n```\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok!\n}\n```\n"), ("E0442", "\nIntrinsic argument(s) and/or return value have the wrong type.\nErroneous code example:\n\n```compile_fail,E0442\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct i8x16(i8, i8, i8, i8, i8, i8, i8, i8,\n i8, i8, i8, i8, i8, i8, i8, i8);\n#[repr(simd)]\nstruct i32x4(i32, i32, i32, i32);\n#[repr(simd)]\nstruct i64x2(i64, i64);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2;\n // error: intrinsic arguments/return value have wrong type\n}\n```\n\nTo fix this error, please refer to the function declaration to give\nit the awaited types. Example:\n\n```\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok!\n}\n```\n"), ("E0443", "\nIntrinsic argument(s) and/or return value have the wrong type.\nErroneous code example:\n\n```compile_fail,E0443\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);\n#[repr(simd)]\nstruct i64x8(i64, i64, i64, i64, i64, i64, i64, i64);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8;\n // error: intrinsic argument/return value has wrong type\n}\n```\n\nTo fix this error, please refer to the function declaration to give\nit the awaited types. Example:\n\n```\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i16x8; // ok!\n}\n```\n"), ("E0444", "\nA platform-specific intrinsic function has wrong number of arguments.\nErroneous code example:\n\n```compile_fail,E0444\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct f64x2(f64, f64);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32;\n // error: platform-specific intrinsic has invalid number of arguments\n}\n```\n\nPlease refer to the function declaration to see if it corresponds\nwith yours. Example:\n\n```\n#![feature(repr_simd)]\n#![feature(platform_intrinsics)]\n\n#[repr(simd)]\nstruct f64x2(f64, f64);\n\nextern \"platform-intrinsic\" {\n fn x86_mm_movemask_pd(x: f64x2) -> i32; // ok!\n}\n```\n"), ("E0516", "\nThe `typeof` keyword is currently reserved but unimplemented.\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"), ("E0520", "\nA non-default implementation was already made on this type so it cannot be\nspecialized further. Erroneous 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"), ("E0527", "\nThe 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\n#![feature(slice_patterns)]\n\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```\n#![feature(slice_patterns)]\n\nlet r = &[1, 2, 3, 4];\nmatch r {\n &[a, b, ..] => { // ok!\n println!(\"a={}, b={}\", a, b);\n }\n}\n```\n"), ("E0528", "\nAn array or slice pattern required more elements than were present in the\nmatched array.\n\nExample of erroneous code:\n\n```compile_fail,E0528\n#![feature(slice_patterns)]\n\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```\n#![feature(slice_patterns)]\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", "\nAn array or slice pattern was matched against some other type.\n\nExample of erroneous code:\n\n```compile_fail,E0529\n#![feature(slice_patterns)]\n\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```\n#![feature(slice_patterns)]\n\nlet r = [1.0, 2.0];\nmatch r {\n [a, b] => { // ok!\n println!(\"a={}, b={}\", a, b);\n }\n}\n```\n"), ("E0559", "\nAn 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", "\nAn 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"), ("E0570", "\nThe requested ABI is unsupported by the current target.\n\nThe rust compiler maintains for each target a blacklist of ABIs unsupported 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"), ("E0572", "\nA 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"), ("E0581", "\nIn 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\nTo fix this issue, either use the lifetime in the arguments, or use\n`\'static`. 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", "\nA lifetime appears only in an associated-type binding,\nand not in the input types 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\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")]
🔬 This is a nightly-only experimental API. (
rustc_private
)