1 // Error messages for EXXXX errors.
2 // Each message should start and end with a new line, and be wrapped to 80
3 // characters. In vim you can `:set tw=80` and use `gq` to wrap paragraphs. Use
4 // `:set tw=0` to disable.
5 syntax::register_diagnostics! {
7 Trait objects like `Box<Trait>` can only be constructed when certain
8 requirements are satisfied by the trait in question.
10 Trait objects are a form of dynamic dispatch and use a dynamically sized type
11 for the inner type. So, for a given trait `Trait`, when `Trait` is treated as a
12 type, as in `Box<Trait>`, the inner type is 'unsized'. In such cases the boxed
13 pointer is a 'fat pointer' that contains an extra pointer to a table of methods
14 (among other things) for dynamic dispatch. This design mandates some
15 restrictions on the types of traits that are allowed to be used in trait
16 objects, which are collectively termed as 'object safety' rules.
18 Attempting to create a trait object for a non object-safe trait will trigger
21 There are various rules:
23 ### The trait cannot require `Self: Sized`
25 When `Trait` is treated as a type, the type does not implement the special
26 `Sized` trait, because the type does not have a known size at compile time and
27 can only be accessed behind a pointer. Thus, if we have a trait like the
31 trait Foo where Self: Sized {
36 We cannot create an object of type `Box<Foo>` or `&Foo` since in this case
37 `Self` would not be `Sized`.
39 Generally, `Self: Sized` is used to indicate that the trait should not be used
40 as a trait object. If the trait comes from your own crate, consider removing
43 ### Method references the `Self` type in its parameters or return type
45 This happens when a trait has a method like the following:
49 fn foo(&self) -> Self;
52 impl Trait for String {
53 fn foo(&self) -> Self {
59 fn foo(&self) -> Self {
65 (Note that `&self` and `&mut self` are okay, it's additional `Self` types which
68 In such a case, the compiler cannot predict the return type of `foo()` in a
69 situation like the following:
73 fn foo(&self) -> Self;
76 fn call_foo(x: Box<Trait>) {
77 let y = x.foo(); // What type is y?
82 If only some methods aren't object-safe, you can add a `where Self: Sized` bound
83 on them to mark them as explicitly unavailable to trait objects. The
84 functionality will still be available to all other implementers, including
85 `Box<Trait>` which is itself sized (assuming you `impl Trait for Box<Trait>`).
89 fn foo(&self) -> Self where Self: Sized;
94 Now, `foo()` can no longer be called on a trait object, but you will now be
95 allowed to make a trait object, and that will be able to call any object-safe
96 methods. With such a bound, one can still call `foo()` on types implementing
97 that trait that aren't behind trait objects.
99 ### Method has generic type parameters
101 As mentioned before, trait objects contain pointers to method tables. So, if we
109 impl Trait for String {
123 At compile time each implementation of `Trait` will produce a table containing
124 the various methods (and other items) related to the implementation.
126 This works fine, but when the method gains generic parameters, we can have a
129 Usually, generic parameters get _monomorphized_. For example, if I have
137 The machine code for `foo::<u8>()`, `foo::<bool>()`, `foo::<String>()`, or any
138 other type substitution is different. Hence the compiler generates the
139 implementation on-demand. If you call `foo()` with a `bool` parameter, the
140 compiler will only generate code for `foo::<bool>()`. When we have additional
141 type parameters, the number of monomorphized implementations the compiler
142 generates does not grow drastically, since the compiler will only generate an
143 implementation if the function is called with unparametrized substitutions
144 (i.e., substitutions where none of the substituted types are themselves
147 However, with trait objects we have to make a table containing _every_ object
148 that implements the trait. Now, if it has type parameters, we need to add
149 implementations for every type that implements the trait, and there could
150 theoretically be an infinite number of types.
156 fn foo<T>(&self, on: T);
160 impl Trait for String {
161 fn foo<T>(&self, on: T) {
167 fn foo<T>(&self, on: T) {
172 // 8 more implementations
175 Now, if we have the following code:
177 ```compile_fail,E0038
178 # trait Trait { fn foo<T>(&self, on: T); }
179 # impl Trait for String { fn foo<T>(&self, on: T) {} }
180 # impl Trait for u8 { fn foo<T>(&self, on: T) {} }
181 # impl Trait for bool { fn foo<T>(&self, on: T) {} }
183 fn call_foo(thing: Box<Trait>) {
184 thing.foo(true); // this could be any one of the 8 types above
190 We don't just need to create a table of all implementations of all methods of
191 `Trait`, we need to create such a table, for each different type fed to
192 `foo()`. In this case this turns out to be (10 types implementing `Trait`)*(3
193 types being fed to `foo()`) = 30 implementations!
195 With real world traits these numbers can grow drastically.
197 To fix this, it is suggested to use a `where Self: Sized` bound similar to the
198 fix for the sub-error above if you do not intend to call the method with type
203 fn foo<T>(&self, on: T) where Self: Sized;
208 If this is not an option, consider replacing the type parameter with another
209 trait object (e.g., if `T: OtherTrait`, use `on: Box<OtherTrait>`). If the
210 number of types you intend to feed to this method is limited, consider manually
211 listing out the methods of different types.
213 ### Method has no receiver
215 Methods that do not take a `self` parameter can't be called since there won't be
216 a way to get a pointer to the method table for them.
224 This could be called as `<Foo as Foo>::foo()`, which would not be able to pick
227 Adding a `Self: Sized` bound to these methods will generally make this compile.
231 fn foo() -> u8 where Self: Sized;
235 ### The trait cannot contain associated constants
237 Just like static functions, associated constants aren't stored on the method
238 table. If the trait or any subtrait contain an associated constant, they cannot
239 be made into an object.
241 ```compile_fail,E0038
249 A simple workaround is to use a helper method instead:
257 ### The trait cannot use `Self` as a type parameter in the supertrait listing
259 This is similar to the second sub-error, but subtler. It happens in situations
265 trait Trait: Super<Self> {
270 impl Super<Foo> for Foo{}
272 impl Trait for Foo {}
275 Here, the supertrait might have methods as follows:
279 fn get_a(&self) -> A; // note that this is object safe!
283 If the trait `Foo` was deriving from something like `Super<String>` or
284 `Super<T>` (where `Foo` itself is `Foo<T>`), this is okay, because given a type
285 `get_a()` will definitely return an object of that type.
287 However, if it derives from `Super<Self>`, even though `Super` is object safe,
288 the method `get_a()` would return an object of unknown type when called on the
289 function. `Self` type parameters let us make object safe traits no longer safe,
290 so they are forbidden when specifying supertraits.
292 There's no easy fix for this, generally code will need to be refactored so that
293 you no longer need to derive from `Super<Self>`.
297 When defining a recursive struct or enum, any use of the type being defined
298 from inside the definition must occur behind a pointer (like `Box` or `&`).
299 This is because structs and enums must have a well-defined size, and without
300 the pointer, the size of the type would need to be unbounded.
302 Consider the following erroneous definition of a type for a list of bytes:
304 ```compile_fail,E0072
305 // error, invalid recursive struct type
308 tail: Option<ListNode>,
312 This type cannot have a well-defined size, because it needs to be arbitrarily
313 large (since we would be able to nest `ListNode`s to any depth). Specifically,
316 size of `ListNode` = 1 byte for `head`
317 + 1 byte for the discriminant of the `Option`
321 One way to fix this is by wrapping `ListNode` in a `Box`, like so:
326 tail: Option<Box<ListNode>>,
330 This works because `Box` is a pointer, so its size is well-known.
334 This error indicates that the compiler was unable to sensibly evaluate an
335 constant expression that had to be evaluated. Attempting to divide by 0
336 or causing integer overflow are two ways to induce this error. For example:
338 ```compile_fail,E0080
345 Ensure that the expressions given can be evaluated as the desired integer type.
346 See the FFI section of the Reference for more information about using a custom
349 https://doc.rust-lang.org/reference.html#ffi-attributes
353 This error indicates that a lifetime is missing from a type. If it is an error
354 inside a function signature, the problem may be with failing to adhere to the
355 lifetime elision rules (see below).
357 Here are some simple examples of where you'll run into this error:
359 ```compile_fail,E0106
360 struct Foo1 { x: &bool }
361 // ^ expected lifetime parameter
362 struct Foo2<'a> { x: &'a bool } // correct
364 struct Bar1 { x: Foo2 }
365 // ^^^^ expected lifetime parameter
366 struct Bar2<'a> { x: Foo2<'a> } // correct
368 enum Baz1 { A(u8), B(&bool), }
369 // ^ expected lifetime parameter
370 enum Baz2<'a> { A(u8), B(&'a bool), } // correct
373 // ^ expected lifetime parameter
374 type MyStr2<'a> = &'a str; // correct
377 Lifetime elision is a special, limited kind of inference for lifetimes in
378 function signatures which allows you to leave out lifetimes in certain cases.
379 For more background on lifetime elision see [the book][book-le].
381 The lifetime elision rules require that any function signature with an elided
382 output lifetime must either have
384 - exactly one input lifetime
385 - or, multiple input lifetimes, but the function must also be a method with a
386 `&self` or `&mut self` receiver
388 In the first case, the output lifetime is inferred to be the same as the unique
389 input lifetime. In the second case, the lifetime is instead inferred to be the
390 same as the lifetime on `&self` or `&mut self`.
392 Here are some examples of elision errors:
394 ```compile_fail,E0106
395 // error, no input lifetimes
398 // error, `x` and `y` have distinct lifetimes inferred
399 fn bar(x: &str, y: &str) -> &str { }
401 // error, `y`'s lifetime is inferred to be distinct from `x`'s
402 fn baz<'a>(x: &'a str, y: &str) -> &str { }
405 [book-le]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html#lifetime-elision
409 There are conflicting trait implementations for the same type.
410 Example of erroneous code:
412 ```compile_fail,E0119
414 fn get(&self) -> usize;
417 impl<T> MyTrait for T {
418 fn get(&self) -> usize { 0 }
425 impl MyTrait for Foo { // error: conflicting implementations of trait
426 // `MyTrait` for type `Foo`
427 fn get(&self) -> usize { self.value }
431 When looking for the implementation for the trait, the compiler finds
432 both the `impl<T> MyTrait for T` where T is all types and the `impl
433 MyTrait for Foo`. Since a trait cannot be implemented multiple times,
434 this is an error. So, when you write:
438 fn get(&self) -> usize;
441 impl<T> MyTrait for T {
442 fn get(&self) -> usize { 0 }
446 This makes the trait implemented on all types in the scope. So if you
447 try to implement it on another one after that, the implementations will
452 fn get(&self) -> usize;
455 impl<T> MyTrait for T {
456 fn get(&self) -> usize { 0 }
464 f.get(); // the trait is implemented so we can use it
471 #### Note: this error code is no longer emitted by the compiler.
473 There are various restrictions on transmuting between types in Rust; for example
474 types being transmuted must have the same size. To apply all these restrictions,
475 the compiler must know the exact types that may be transmuted. When type
476 parameters are involved, this cannot always be done.
478 So, for example, the following is not allowed:
481 use std::mem::transmute;
483 struct Foo<T>(Vec<T>);
485 fn foo<T>(x: Vec<T>) {
486 // we are transmuting between Vec<T> and Foo<F> here
487 let y: Foo<T> = unsafe { transmute(x) };
488 // do something with y
492 In this specific case there's a good chance that the transmute is harmless (but
493 this is not guaranteed by Rust). However, when alignment and enum optimizations
494 come into the picture, it's quite likely that the sizes may or may not match
495 with different type parameter substitutions. It's not possible to check this for
496 _all_ possible types, so `transmute()` simply only accepts types without any
497 unsubstituted type parameters.
499 If you need this, there's a good chance you're doing something wrong. Keep in
500 mind that Rust doesn't guarantee much about the layout of different structs
501 (even two structs with identical declarations may have different layouts). If
502 there is a solution that avoids the transmute entirely, try it instead.
504 If it's possible, hand-monomorphize the code by writing the function for each
505 possible type substitution. It's possible to use traits to do this cleanly,
509 use std::mem::transmute;
511 struct Foo<T>(Vec<T>);
513 trait MyTransmutableType: Sized {
514 fn transmute(_: Vec<Self>) -> Foo<Self>;
517 impl MyTransmutableType for u8 {
518 fn transmute(x: Vec<u8>) -> Foo<u8> {
519 unsafe { transmute(x) }
523 impl MyTransmutableType for String {
524 fn transmute(x: Vec<String>) -> Foo<String> {
525 unsafe { transmute(x) }
529 // ... more impls for the types you intend to transmute
531 fn foo<T: MyTransmutableType>(x: Vec<T>) {
532 let y: Foo<T> = <T as MyTransmutableType>::transmute(x);
533 // do something with y
537 Each impl will be checked for a size match in the transmute as usual, and since
538 there are no unbound type parameters involved, this should compile unless there
539 is a size mismatch in one of the impls.
541 It is also possible to manually transmute:
545 # let v = Some("value");
546 # type SomeType = &'static [u8];
548 ptr::read(&v as *const _ as *const SomeType) // `v` transmuted to `SomeType`
553 Note that this does not move `v` (unlike `transmute`), and may need a
554 call to `mem::forget(v)` in case you want to avoid destructors being called.
558 A lang item was redefined.
560 Erroneous code example:
562 ```compile_fail,E0152
563 #![feature(lang_items)]
566 struct Foo; // error: duplicate lang item found: `arc`
569 Lang items are already implemented in the standard library. Unless you are
570 writing a free-standing application (e.g., a kernel), you do not need to provide
573 You can build a free-standing crate by adding `#![no_std]` to the crate
576 ```ignore (only-for-syntax-highlight)
580 See also the [unstable book][1].
582 [1]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html#writing-an-executable-without-stdlib
586 A generic type was described using parentheses rather than angle brackets.
589 ```compile_fail,E0214
591 let v: Vec(&str) = vec!["foo"];
595 This is not currently supported: `v` should be defined as `Vec<&str>`.
596 Parentheses are currently only used with generic types when defining parameters
597 for `Fn`-family traits.
601 The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
602 message for when a particular trait isn't implemented on a type placed in a
603 position that needs that trait. For example, when the following code is
607 #![feature(on_unimplemented)]
609 fn foo<T: Index<u8>>(x: T){}
611 #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
612 trait Index<Idx> { /* ... */ }
614 foo(true); // `bool` does not implement `Index<u8>`
617 There will be an error about `bool` not implementing `Index<u8>`, followed by a
618 note saying "the type `bool` cannot be indexed by `u8`".
620 As you can see, you can specify type parameters in curly braces for
621 substitution with the actual types (using the regular format string syntax) in
622 a given situation. Furthermore, `{Self}` will substitute to the type (in this
623 case, `bool`) that we tried to use.
625 This error appears when the curly braces contain an identifier which doesn't
626 match with any of the type parameters or the string `Self`. This might happen
627 if you misspelled a type parameter, or if you intended to use literal curly
628 braces. If it is the latter, escape the curly braces with a second curly brace
629 of the same type; e.g., a literal `{` is `{{`.
633 The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
634 message for when a particular trait isn't implemented on a type placed in a
635 position that needs that trait. For example, when the following code is
639 #![feature(on_unimplemented)]
641 fn foo<T: Index<u8>>(x: T){}
643 #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
644 trait Index<Idx> { /* ... */ }
646 foo(true); // `bool` does not implement `Index<u8>`
649 there will be an error about `bool` not implementing `Index<u8>`, followed by a
650 note saying "the type `bool` cannot be indexed by `u8`".
652 As you can see, you can specify type parameters in curly braces for
653 substitution with the actual types (using the regular format string syntax) in
654 a given situation. Furthermore, `{Self}` will substitute to the type (in this
655 case, `bool`) that we tried to use.
657 This error appears when the curly braces do not contain an identifier. Please
658 add one of the same name as a type parameter. If you intended to use literal
659 braces, use `{{` and `}}` to escape them.
663 The `#[rustc_on_unimplemented]` attribute lets you specify a custom error
664 message for when a particular trait isn't implemented on a type placed in a
665 position that needs that trait. For example, when the following code is
669 #![feature(on_unimplemented)]
671 fn foo<T: Index<u8>>(x: T){}
673 #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
674 trait Index<Idx> { /* ... */ }
676 foo(true); // `bool` does not implement `Index<u8>`
679 there will be an error about `bool` not implementing `Index<u8>`, followed by a
680 note saying "the type `bool` cannot be indexed by `u8`".
682 For this to work, some note must be specified. An empty attribute will not do
683 anything, please remove the attribute or add some helpful note for users of the
688 When using a lifetime like `'a` in a type, it must be declared before being
691 These two examples illustrate the problem:
693 ```compile_fail,E0261
694 // error, use of undeclared lifetime name `'a`
695 fn foo(x: &'a str) { }
698 // error, use of undeclared lifetime name `'a`
703 These can be fixed by declaring lifetime parameters:
710 fn foo<'a>(x: &'a str) {}
713 Impl blocks declare lifetime parameters separately. You need to add lifetime
714 parameters to an impl block if you're implementing a type that has a lifetime
715 parameter of its own.
718 ```compile_fail,E0261
723 // error, use of undeclared lifetime name `'a`
725 fn foo<'a>(x: &'a str) {}
729 This is fixed by declaring the impl block like this:
738 fn foo(x: &'a str) {}
744 Declaring certain lifetime names in parameters is disallowed. For example,
745 because the `'static` lifetime is a special built-in lifetime name denoting
746 the lifetime of the entire program, this is an error:
748 ```compile_fail,E0262
749 // error, invalid lifetime parameter name `'static`
750 fn foo<'static>(x: &'static str) { }
755 A lifetime name cannot be declared more than once in the same scope. For
758 ```compile_fail,E0263
759 // error, lifetime name `'a` declared twice in the same scope
760 fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { }
765 An unknown external lang item was used. Erroneous code example:
767 ```compile_fail,E0264
768 #![feature(lang_items)]
771 #[lang = "cake"] // error: unknown external lang item: `cake`
776 A list of available external lang items is available in
777 `src/librustc/middle/weak_lang_items.rs`. Example:
780 #![feature(lang_items)]
783 #[lang = "panic_impl"] // ok!
790 This is because of a type mismatch between the associated type of some
791 trait (e.g., `T::Bar`, where `T` implements `trait Quux { type Bar; }`)
792 and another type `U` that is required to be equal to `T::Bar`, but is not.
795 Here is a basic example:
797 ```compile_fail,E0271
798 trait Trait { type AssociatedType; }
800 fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
804 impl Trait for i8 { type AssociatedType = &'static str; }
809 Here is that same example again, with some explanatory comments:
811 ```compile_fail,E0271
812 trait Trait { type AssociatedType; }
814 fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
815 // ~~~~~~~~ ~~~~~~~~~~~~~~~~~~
817 // This says `foo` can |
818 // only be used with |
820 // implements `Trait`. |
822 // This says not only must
823 // `T` be an impl of `Trait`
824 // but also that the impl
825 // must assign the type `u32`
826 // to the associated type.
830 impl Trait for i8 { type AssociatedType = &'static str; }
831 //~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
836 // ... but it is an implementation
837 // that assigns `&'static str` to
838 // the associated type.
841 // Here, we invoke `foo` with an `i8`, which does not satisfy
842 // the constraint `<i8 as Trait>::AssociatedType=u32`, and
843 // therefore the type-checker complains with this error code.
846 To avoid those issues, you have to make the types match correctly.
847 So we can fix the previous examples like this:
851 trait Trait { type AssociatedType; }
853 fn foo<T>(t: T) where T: Trait<AssociatedType = &'static str> {
857 impl Trait for i8 { type AssociatedType = &'static str; }
862 let vs = vec![1, 2, 3, 4];
874 This error occurs when there was a recursive trait requirement that overflowed
875 before it could be evaluated. Often this means that there is unbounded
876 recursion in resolving some type bounds.
878 For example, in the following code:
880 ```compile_fail,E0275
885 impl<T> Foo for T where Bar<T>: Foo {}
888 To determine if a `T` is `Foo`, we need to check if `Bar<T>` is `Foo`. However,
889 to do this check, we need to determine that `Bar<Bar<T>>` is `Foo`. To
890 determine this, we check if `Bar<Bar<Bar<T>>>` is `Foo`, and so on. This is
891 clearly a recursive requirement that can't be resolved directly.
893 Consider changing your trait bounds so that they're less self-referential.
897 This error occurs when a bound in an implementation of a trait does not match
898 the bounds specified in the original trait. For example:
900 ```compile_fail,E0276
906 fn foo<T>(x: T) where T: Copy {}
910 Here, all types implementing `Foo` must have a method `foo<T>(x: T)` which can
911 take any type `T`. However, in the `impl` for `bool`, we have added an extra
912 bound that `T` is `Copy`, which isn't compatible with the original trait.
914 Consider removing the bound from the method or adding the bound to the original
915 method definition in the trait.
919 You tried to use a type which doesn't implement some trait in a place which
920 expected that trait. Erroneous code example:
922 ```compile_fail,E0277
923 // here we declare the Foo trait with a bar method
928 // we now declare a function which takes an object implementing the Foo trait
929 fn some_func<T: Foo>(foo: T) {
934 // we now call the method with the i32 type, which doesn't implement
936 some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied
940 In order to fix this error, verify that the type you're using does implement
948 fn some_func<T: Foo>(foo: T) {
949 foo.bar(); // we can now use this method since i32 implements the
953 // we implement the trait on the i32 type
959 some_func(5i32); // ok!
963 Or in a generic context, an erroneous code example would look like:
965 ```compile_fail,E0277
966 fn some_func<T>(foo: T) {
967 println!("{:?}", foo); // error: the trait `core::fmt::Debug` is not
968 // implemented for the type `T`
972 // We now call the method with the i32 type,
973 // which *does* implement the Debug trait.
978 Note that the error here is in the definition of the generic function: Although
979 we only call it with a parameter that does implement `Debug`, the compiler
980 still rejects the function: It must work with all possible input types. In
981 order to make this example compile, we need to restrict the generic type we're
987 // Restrict the input type to types that implement Debug.
988 fn some_func<T: fmt::Debug>(foo: T) {
989 println!("{:?}", foo);
993 // Calling the method is still fine, as i32 implements Debug.
996 // This would fail to compile now:
997 // struct WithoutDebug;
998 // some_func(WithoutDebug);
1002 Rust only looks at the signature of the called function, as such it must
1003 already specify all requirements that will be used for every type parameter.
1007 #### Note: this error code is no longer emitted by the compiler.
1009 You tried to supply a type which doesn't implement some trait in a location
1010 which expected that trait. This error typically occurs when working with
1011 `Fn`-based types. Erroneous code example:
1014 fn foo<F: Fn(usize)>(x: F) { }
1017 // type mismatch: ... implements the trait `core::ops::Fn<(String,)>`,
1018 // but the trait `core::ops::Fn<(usize,)>` is required
1020 foo(|y: String| { });
1024 The issue in this case is that `foo` is defined as accepting a `Fn` with one
1025 argument of type `String`, but the closure we attempted to pass to it requires
1026 one arguments of type `usize`.
1030 This error indicates that type inference did not result in one unique possible
1031 type, and extra information is required. In most cases this can be provided
1032 by adding a type annotation. Sometimes you need to specify a generic type
1035 A common example is the `collect` method on `Iterator`. It has a generic type
1036 parameter with a `FromIterator` bound, which for a `char` iterator is
1037 implemented by `Vec` and `String` among others. Consider the following snippet
1038 that reverses the characters of a string:
1040 ```compile_fail,E0282
1041 let x = "hello".chars().rev().collect();
1044 In this case, the compiler cannot infer what the type of `x` should be:
1045 `Vec<char>` and `String` are both suitable candidates. To specify which type to
1046 use, you can use a type annotation on `x`:
1049 let x: Vec<char> = "hello".chars().rev().collect();
1052 It is not necessary to annotate the full type. Once the ambiguity is resolved,
1053 the compiler can infer the rest:
1056 let x: Vec<_> = "hello".chars().rev().collect();
1059 Another way to provide the compiler with enough information, is to specify the
1060 generic type parameter:
1063 let x = "hello".chars().rev().collect::<Vec<char>>();
1066 Again, you need not specify the full type if the compiler can infer it:
1069 let x = "hello".chars().rev().collect::<Vec<_>>();
1072 Apart from a method or function with a generic type parameter, this error can
1073 occur when a type parameter of a struct or trait cannot be inferred. In that
1074 case it is not always possible to use a type annotation, because all candidates
1075 have the same return type. For instance:
1077 ```compile_fail,E0282
1088 let number = Foo::bar();
1093 This will fail because the compiler does not know which instance of `Foo` to
1094 call `bar` on. Change `Foo::bar()` to `Foo::<T>::bar()` to resolve the error.
1098 This error occurs when the compiler doesn't have enough information
1099 to unambiguously choose an implementation.
1103 ```compile_fail,E0283
1110 impl Generator for Impl {
1111 fn create() -> u32 { 1 }
1116 impl Generator for AnotherImpl {
1117 fn create() -> u32 { 2 }
1121 let cont: u32 = Generator::create();
1122 // error, impossible to choose one of Generator trait implementation
1123 // Should it be Impl or AnotherImpl, maybe something else?
1127 To resolve this error use the concrete type:
1136 impl Generator for AnotherImpl {
1137 fn create() -> u32 { 2 }
1141 let gen1 = AnotherImpl::create();
1143 // if there are multiple methods with same name (different traits)
1144 let gen2 = <AnotherImpl as Generator>::create();
1150 This error occurs when the compiler is unable to unambiguously infer the
1151 return type of a function or method which is generic on return type, such
1152 as the `collect` method for `Iterator`s.
1156 ```compile_fail,E0284
1157 fn foo() -> Result<bool, ()> {
1158 let results = [Ok(true), Ok(false), Err(())].iter().cloned();
1159 let v: Vec<bool> = results.collect()?;
1160 // Do things with v...
1165 Here we have an iterator `results` over `Result<bool, ()>`.
1166 Hence, `results.collect()` can return any type implementing
1167 `FromIterator<Result<bool, ()>>`. On the other hand, the
1168 `?` operator can accept any type implementing `Try`.
1170 The author of this code probably wants `collect()` to return a
1171 `Result<Vec<bool>, ()>`, but the compiler can't be sure
1172 that there isn't another type `T` implementing both `Try` and
1173 `FromIterator<Result<bool, ()>>` in scope such that
1174 `T::Ok == Vec<bool>`. Hence, this code is ambiguous and an error
1177 To resolve this error, use a concrete type for the intermediate expression:
1180 fn foo() -> Result<bool, ()> {
1181 let results = [Ok(true), Ok(false), Err(())].iter().cloned();
1183 let temp: Result<Vec<bool>, ()> = results.collect();
1186 // Do things with v...
1191 Note that the type of `v` can now be inferred from the type of `temp`.
1195 This error occurs when the compiler was unable to infer the concrete type of a
1196 variable. It can occur for several cases, the most common of which is a
1197 mismatch in the expected type that the compiler inferred for a variable's
1198 initializing expression, and the actual type explicitly assigned to the
1203 ```compile_fail,E0308
1204 let x: i32 = "I am not a number!";
1205 // ~~~ ~~~~~~~~~~~~~~~~~~~~
1207 // | initializing expression;
1208 // | compiler infers type `&str`
1210 // type `i32` assigned to variable `x`
1215 The type definition contains some field whose type
1216 requires an outlives annotation. Outlives annotations
1217 (e.g., `T: 'a`) are used to guarantee that all the data in T is valid
1218 for at least the lifetime `'a`. This scenario most commonly
1219 arises when the type contains an associated type reference
1220 like `<T as SomeTrait<'a>>::Output`, as shown in this example:
1222 ```compile_fail,E0309
1223 // This won't compile because the applicable impl of
1224 // `SomeTrait` (below) requires that `T: 'a`, but the struct does
1225 // not have a matching where-clause.
1227 foo: <T as SomeTrait<'a>>::Output,
1230 trait SomeTrait<'a> {
1234 impl<'a, T> SomeTrait<'a> for T
1242 Here, the where clause `T: 'a` that appears on the impl is not known to be
1243 satisfied on the struct. To make this example compile, you have to add
1244 a where-clause like `T: 'a` to the struct definition:
1251 foo: <T as SomeTrait<'a>>::Output
1254 trait SomeTrait<'a> {
1258 impl<'a, T> SomeTrait<'a> for T
1268 Types in type definitions have lifetimes associated with them that represent
1269 how long the data stored within them is guaranteed to be live. This lifetime
1270 must be as long as the data needs to be alive, and missing the constraint that
1271 denotes this will cause this error.
1273 ```compile_fail,E0310
1274 // This won't compile because T is not constrained to the static lifetime
1275 // the reference needs
1281 This will compile, because it has the constraint on the type parameter:
1284 struct Foo<T: 'static> {
1291 Reference's lifetime of borrowed content doesn't match the expected lifetime.
1293 Erroneous code example:
1295 ```compile_fail,E0312
1296 pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'static str {
1297 if maybestr.is_none() {
1300 let s: &'a str = maybestr.as_ref().unwrap();
1301 s // Invalid lifetime!
1306 To fix this error, either lessen the expected lifetime or find a way to not have
1307 to use this reference outside of its current scope (by running the code directly
1308 in the same block for example?):
1311 // In this case, we can fix the issue by switching from "static" lifetime to 'a
1312 pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {
1313 if maybestr.is_none() {
1316 let s: &'a str = maybestr.as_ref().unwrap();
1324 This error occurs when an `if` expression without an `else` block is used in a
1325 context where a type other than `()` is expected, for example a `let`
1328 ```compile_fail,E0317
1331 let a = if x == 5 { 1 };
1335 An `if` expression without an `else` block has the type `()`, so this is a type
1336 error. To resolve it, add an `else` block having the same type as the `if`
1341 This error indicates that some types or traits depend on each other
1342 and therefore cannot be constructed.
1344 The following example contains a circular dependency between two traits:
1346 ```compile_fail,E0391
1347 trait FirstTrait : SecondTrait {
1351 trait SecondTrait : FirstTrait {
1358 #### Note: this error code is no longer emitted by the compiler.
1360 In Rust 1.3, the default object lifetime bounds are expected to change, as
1361 described in [RFC 1156]. You are getting a warning because the compiler
1362 thinks it is possible that this change will cause a compilation error in your
1363 code. It is possible, though unlikely, that this is a false alarm.
1365 The heart of the change is that where `&'a Box<SomeTrait>` used to default to
1366 `&'a Box<SomeTrait+'a>`, it now defaults to `&'a Box<SomeTrait+'static>` (here,
1367 `SomeTrait` is the name of some trait type). Note that the only types which are
1368 affected are references to boxes, like `&Box<SomeTrait>` or
1369 `&[Box<SomeTrait>]`. More common types like `&SomeTrait` or `Box<SomeTrait>`
1372 To silence this warning, edit your code to use an explicit bound. Most of the
1373 time, this means that you will want to change the signature of a function that
1374 you are calling. For example, if the error is reported on a call like `foo(x)`,
1375 and `foo` is defined as follows:
1378 # trait SomeTrait {}
1379 fn foo(arg: &Box<SomeTrait>) { /* ... */ }
1382 You might change it to:
1385 # trait SomeTrait {}
1386 fn foo<'a>(arg: &'a Box<SomeTrait+'a>) { /* ... */ }
1389 This explicitly states that you expect the trait object `SomeTrait` to contain
1390 references (with a maximum lifetime of `'a`).
1392 [RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md
1396 An invalid lint attribute has been given. Erroneous code example:
1398 ```compile_fail,E0452
1399 #![allow(foo = "")] // error: malformed lint attribute
1402 Lint attributes only accept a list of identifiers (where each identifier is a
1403 lint name). Ensure the attribute is of this form:
1406 #![allow(foo)] // ok!
1408 #![allow(foo, foo2)] // ok!
1413 A lint check attribute was overruled by a `forbid` directive set as an
1414 attribute on an enclosing scope, or on the command line with the `-F` option.
1416 Example of erroneous code:
1418 ```compile_fail,E0453
1419 #![forbid(non_snake_case)]
1421 #[allow(non_snake_case)]
1423 let MyNumber = 2; // error: allow(non_snake_case) overruled by outer
1424 // forbid(non_snake_case)
1428 The `forbid` lint setting, like `deny`, turns the corresponding compiler
1429 warning into a hard error. Unlike `deny`, `forbid` prevents itself from being
1430 overridden by inner attributes.
1432 If you're sure you want to override the lint check, you can change `forbid` to
1433 `deny` (or use `-D` instead of `-F` if the `forbid` setting was given as a
1434 command-line option) to allow the inner lint check attribute:
1437 #![deny(non_snake_case)]
1439 #[allow(non_snake_case)]
1441 let MyNumber = 2; // ok!
1445 Otherwise, edit the code to pass the lint check, and remove the overruled
1449 #![forbid(non_snake_case)]
1458 A lifetime bound was not satisfied.
1460 Erroneous code example:
1462 ```compile_fail,E0478
1463 // Check that the explicit lifetime bound (`'SnowWhite`, in this example) must
1464 // outlive all the superbounds from the trait (`'kiss`, in this example).
1466 trait Wedding<'t>: 't { }
1468 struct Prince<'kiss, 'SnowWhite> {
1469 child: Box<Wedding<'kiss> + 'SnowWhite>,
1470 // error: lifetime bound not satisfied
1474 In this example, the `'SnowWhite` lifetime is supposed to outlive the `'kiss`
1475 lifetime but the declaration of the `Prince` struct doesn't enforce it. To fix
1476 this issue, you need to specify it:
1479 trait Wedding<'t>: 't { }
1481 struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'kiss must live
1482 // longer than 'SnowWhite.
1483 child: Box<Wedding<'kiss> + 'SnowWhite>, // And now it's all good!
1489 A reference has a longer lifetime than the data it references.
1491 Erroneous code example:
1493 ```compile_fail,E0491
1494 trait SomeTrait<'a> {
1498 impl<'a, T> SomeTrait<'a> for T {
1499 type Output = &'a T; // compile error E0491
1503 Here, the problem is that a reference type like `&'a T` is only valid
1504 if all the data in T outlives the lifetime `'a`. But this impl as written
1505 is applicable to any lifetime `'a` and any type `T` -- we have no guarantee
1506 that `T` outlives `'a`. To fix this, you can add a where clause like
1510 trait SomeTrait<'a> {
1514 impl<'a, T> SomeTrait<'a> for T
1518 type Output = &'a T; // compile error E0491
1524 A lifetime name is shadowing another lifetime name. Erroneous code example:
1526 ```compile_fail,E0496
1532 fn f<'a>(x: &'a i32) { // error: lifetime name `'a` shadows a lifetime
1533 // name that is already in scope
1538 Please change the name of one of the lifetimes to remove this error. Example:
1546 fn f<'b>(x: &'b i32) { // ok!
1556 A stability attribute was used outside of the standard library. Erroneous code
1560 #[stable] // error: stability attributes may not be used outside of the
1565 It is not possible to use stability attributes outside of the standard library.
1566 Also, for now, it is not possible to write deprecation messages either.
1570 This error indicates that a `#[repr(..)]` attribute was placed on an
1573 Examples of erroneous code:
1575 ```compile_fail,E0517
1583 struct Foo {bar: bool, baz: bool}
1591 * The `#[repr(C)]` attribute can only be placed on structs and enums.
1592 * The `#[repr(packed)]` and `#[repr(simd)]` attributes only work on structs.
1593 * The `#[repr(u8)]`, `#[repr(i16)]`, etc attributes only work on enums.
1595 These attributes do not work on typedefs, since typedefs are just aliases.
1597 Representations like `#[repr(u8)]`, `#[repr(i64)]` are for selecting the
1598 discriminant size for enums with no data fields on any of the variants, e.g.
1599 `enum Color {Red, Blue, Green}`, effectively setting the size of the enum to
1600 the size of the provided type. Such an enum can be cast to a value of the same
1601 type as well. In short, `#[repr(u8)]` makes the enum behave like an integer
1602 with a constrained set of allowed values.
1604 Only field-less enums can be cast to numerical primitives, so this attribute
1605 will not apply to structs.
1607 `#[repr(packed)]` reduces padding to make the struct size smaller. The
1608 representation of enums isn't strictly defined in Rust, and this attribute
1609 won't work on enums.
1611 `#[repr(simd)]` will give a struct consisting of a homogeneous series of machine
1612 types (i.e., `u8`, `i32`, etc) a representation that permits vectorization via
1613 SIMD. This doesn't make much sense for enums since they don't consist of a
1614 single list of data.
1618 This error indicates that an `#[inline(..)]` attribute was incorrectly placed
1619 on something other than a function or method.
1621 Examples of erroneous code:
1623 ```compile_fail,E0518
1633 `#[inline]` hints the compiler whether or not to attempt to inline a method or
1634 function. By default, the compiler does a pretty good job of figuring this out
1635 itself, but if you feel the need for annotations, `#[inline(always)]` and
1636 `#[inline(never)]` can override or force the compiler's decision.
1638 If you wish to apply this attribute to all methods in an impl, manually annotate
1639 each method; it is not possible to annotate the entire impl with an `#[inline]`
1644 The lang attribute is intended for marking special items that are built-in to
1645 Rust itself. This includes special traits (like `Copy` and `Sized`) that affect
1646 how the compiler behaves, as well as special functions that may be automatically
1647 invoked (such as the handler for out-of-bounds accesses when indexing a slice).
1648 Erroneous code example:
1650 ```compile_fail,E0522
1651 #![feature(lang_items)]
1654 fn cookie() -> ! { // error: definition of an unknown language item: `cookie`
1661 A closure was used but didn't implement the expected trait.
1663 Erroneous code example:
1665 ```compile_fail,E0525
1669 fn bar<T: Fn(u32)>(_: T) {}
1673 let closure = |_| foo(x); // error: expected a closure that implements
1674 // the `Fn` trait, but this closure only
1675 // implements `FnOnce`
1680 In the example above, `closure` is an `FnOnce` closure whereas the `bar`
1681 function expected an `Fn` closure. In this case, it's simple to fix the issue,
1682 you just have to implement `Copy` and `Clone` traits on `struct X` and it'll
1686 #[derive(Clone, Copy)] // We implement `Clone` and `Copy` traits.
1690 fn bar<T: Fn(u32)>(_: T) {}
1694 let closure = |_| foo(x);
1695 bar(closure); // ok!
1699 To understand better how closures work in Rust, read:
1700 https://doc.rust-lang.org/book/ch13-01-closures.html
1704 Conflicting representation hints have been used on a same item.
1706 Erroneous code example:
1709 #[repr(u32, u64)] // warning!
1713 In most cases (if not all), using just one representation hint is more than
1714 enough. If you want to have a representation hint depending on the current
1715 architecture, use `cfg_attr`. Example:
1718 #[cfg_attr(linux, repr(u32))]
1719 #[cfg_attr(not(linux), repr(u64))]
1725 The `main` function was incorrectly declared.
1727 Erroneous code example:
1729 ```compile_fail,E0580
1730 fn main(x: i32) { // error: main function has wrong type
1735 The `main` function prototype should never take arguments.
1744 If you want to get command-line arguments, use `std::env::args`. To exit with a
1745 specified exit code, use `std::process::exit`.
1749 Abstract return types (written `impl Trait` for some trait `Trait`) are only
1750 allowed as function and inherent impl return types.
1752 Erroneous code example:
1754 ```compile_fail,E0562
1756 let count_to_ten: impl Iterator<Item=usize> = 0..10;
1757 // error: `impl Trait` not allowed outside of function and inherent method
1759 for i in count_to_ten {
1765 Make sure `impl Trait` only appears in return-type position.
1768 fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
1773 for i in count_to_n(10) { // ok!
1779 See [RFC 1522] for more details.
1781 [RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
1785 You tried to supply an `Fn`-based type with an incorrect number of arguments
1786 than what was expected.
1788 Erroneous code example:
1790 ```compile_fail,E0593
1791 fn foo<F: Fn()>(x: F) { }
1794 // [E0593] closure takes 1 argument but 0 arguments are required
1801 An unknown lint was used on the command line.
1806 rustc -D bogus omse_file.rs
1809 Maybe you just misspelled the lint name or the lint doesn't exist anymore.
1810 Either way, try to update/remove it in order to fix the error.
1814 This error code indicates a mismatch between the lifetimes appearing in the
1815 function signature (i.e., the parameter types and the return type) and the
1816 data-flow found in the function body.
1818 Erroneous code example:
1820 ```compile_fail,E0621
1821 fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 { // error: explicit lifetime
1822 // required in the type of
1824 if x > y { x } else { y }
1828 In the code above, the function is returning data borrowed from either `x` or
1829 `y`, but the `'a` annotation indicates that it is returning data only from `x`.
1830 To fix the error, the signature and the body must be made to match. Typically,
1831 this is done by updating the function signature. So, in this case, we change
1832 the type of `y` to `&'a i32`, like so:
1835 fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
1836 if x > y { x } else { y }
1840 Now the signature indicates that the function data borrowed from either `x` or
1841 `y`. Alternatively, you could change the body to not return data from `y`:
1844 fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
1851 The `#![feature]` attribute specified an unknown feature.
1853 Erroneous code example:
1855 ```compile_fail,E0635
1856 #![feature(nonexistent_rust_feature)] // error: unknown feature
1862 A `#![feature]` attribute was declared multiple times.
1864 Erroneous code example:
1866 ```compile_fail,E0636
1867 #![allow(stable_features)]
1869 #![feature(rust1)] // error: the feature `rust1` has already been declared
1875 A closure or generator was constructed that references its own type.
1879 ```compile-fail,E0644
1888 // Here, when `x` is called, the parameter `y` is equal to `x`.
1893 Rust does not permit a closure to directly reference its own type,
1894 either through an argument (as in the example above) or by capturing
1895 itself through its environment. This restriction helps keep closure
1896 inference tractable.
1898 The easiest fix is to rewrite your closure into a top-level function,
1899 or into a method. In some cases, you may also be able to have your
1900 closure call itself by capturing a `&Fn()` object or `fn()` pointer
1901 that refers to itself. That is permitting, since the closure would be
1902 invoking itself via a virtual call, and hence does not directly
1903 reference its own *type*.
1908 A `repr(transparent)` type was also annotated with other, incompatible
1909 representation hints.
1911 Erroneous code example:
1913 ```compile_fail,E0692
1914 #[repr(transparent, C)] // error: incompatible representation hints
1918 A type annotated as `repr(transparent)` delegates all representation concerns to
1919 another type, so adding more representation hints is contradictory. Remove
1920 either the `transparent` hint or the other hints, like this:
1923 #[repr(transparent)]
1927 Alternatively, move the other attributes to the contained type:
1936 #[repr(transparent)]
1937 struct FooWrapper(Foo);
1940 Note that introducing another `struct` just to have a place for the other
1941 attributes may have unintended side effects on the representation:
1944 #[repr(transparent)]
1950 #[repr(transparent)]
1951 struct Grams2(Float); // this is not equivalent to `Grams` above
1954 Here, `Grams2` is a not equivalent to `Grams` -- the former transparently wraps
1955 a (non-transparent) struct containing a single float, while `Grams` is a
1956 transparent wrapper around a float. This can make a difference for the ABI.
1960 When using generators (or async) all type variables must be bound so a
1961 generator can be constructed.
1963 Erroneous code example:
1965 ```edition2018,compile-fail,E0698
1966 async fn bar<T>() -> () {}
1969 bar().await; // error: cannot infer type for `T`
1973 In the above example `T` is unknowable by the compiler.
1974 To fix this you must bind `T` to a concrete type such as `String`
1975 so that a generator can then be constructed:
1978 async fn bar<T>() -> () {}
1981 bar::<String>().await;
1982 // ^^^^^^^^ specify type explicitly
1988 The `impl Trait` return type captures lifetime parameters that do not
1989 appear within the `impl Trait` itself.
1991 Erroneous code example:
1993 ```compile-fail,E0700
1994 use std::cell::Cell;
1998 impl<'a, 'b> Trait<'b> for Cell<&'a u32> { }
2000 fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y>
2007 Here, the function `foo` returns a value of type `Cell<&'x u32>`,
2008 which references the lifetime `'x`. However, the return type is
2009 declared as `impl Trait<'y>` -- this indicates that `foo` returns
2010 "some type that implements `Trait<'y>`", but it also indicates that
2011 the return type **only captures data referencing the lifetime `'y`**.
2012 In this case, though, we are referencing data with lifetime `'x`, so
2013 this function is in error.
2015 To fix this, you must reference the lifetime `'x` from the return
2016 type. For example, changing the return type to `impl Trait<'y> + 'x`
2020 use std::cell::Cell;
2024 impl<'a,'b> Trait<'b> for Cell<&'a u32> { }
2026 fn foo<'x, 'y>(x: Cell<&'x u32>) -> impl Trait<'y> + 'x
2035 This error indicates that a `#[non_exhaustive]` attribute was incorrectly placed
2036 on something other than a struct or enum.
2038 Examples of erroneous code:
2040 ```compile_fail,E0701
2041 # #![feature(non_exhaustive)]
2049 This error indicates that a `#[lang = ".."]` attribute was placed
2050 on the wrong type of item.
2052 Examples of erroneous code:
2054 ```compile_fail,E0718
2055 #![feature(lang_items)]
2063 A stability attribute has been used outside of the standard library.
2065 Erroneous code examples:
2067 ```compile_fail,E0734
2068 #[rustc_deprecated(since = "b", reason = "text")] // invalid
2069 #[stable(feature = "a", since = "b")] // invalid
2070 #[unstable(feature = "b", issue = "0")] // invalid
2074 These attributes are meant to only be used by the standard library and are
2075 rejected in your own crates.
2079 // E0006, // merged with E0005
2080 // E0101, // replaced with E0282
2081 // E0102, // replaced with E0282
2084 // E0272, // on_unimplemented #0
2085 // E0273, // on_unimplemented #1
2086 // E0274, // on_unimplemented #2
2087 E0278, // requirement is not satisfied
2088 E0279, // requirement is not satisfied
2089 E0280, // requirement is not satisfied
2090 // E0285, // overflow evaluation builtin bounds
2091 // E0296, // replaced with a generic attribute input check
2092 // E0300, // unexpanded macro
2093 // E0304, // expected signed integer constant
2094 // E0305, // expected constant
2095 E0311, // thing may not live long enough
2096 E0313, // lifetime of borrowed pointer outlives lifetime of captured
2098 E0314, // closure outlives stack frame
2099 E0315, // cannot invoke closure outside of its lifetime
2100 E0316, // nested quantification of lifetimes
2101 E0320, // recursive overflow during dropck
2102 E0473, // dereference of reference outside its lifetime
2103 E0474, // captured variable `..` does not outlive the enclosing closure
2104 E0475, // index of slice outside its lifetime
2105 E0476, // lifetime of the source pointer does not outlive lifetime bound...
2106 E0477, // the type `..` does not fulfill the required lifetime...
2107 E0479, // the type `..` (provided as the value of a type parameter) is...
2108 E0480, // lifetime of method receiver does not outlive the method call
2109 E0481, // lifetime of function argument does not outlive the function call
2110 E0482, // lifetime of return value does not outlive the function call
2111 E0483, // lifetime of operand does not outlive the operation
2112 E0484, // reference is not valid at the time of borrow
2113 E0485, // automatically reference is not valid at the time of borrow
2114 E0486, // type of expression contains references that are not valid during..
2115 E0487, // unsafe use of destructor: destructor might be called while...
2116 E0488, // lifetime of variable does not enclose its declaration
2117 E0489, // type/lifetime parameter not in scope here
2118 E0490, // a value of type `..` is borrowed for too long
2119 E0495, // cannot infer an appropriate lifetime due to conflicting
2121 E0623, // lifetime mismatch where both parameters are anonymous regions
2122 E0628, // generators cannot have explicit parameters
2123 E0631, // type mismatch in closure arguments
2124 E0637, // "'_" is not a valid lifetime bound
2125 E0657, // `impl Trait` can only capture lifetimes bound at the fn level
2126 E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax
2127 E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders
2128 E0697, // closures cannot be static
2129 E0707, // multiple elided lifetimes used in arguments of `async fn`
2130 E0708, // `async` non-`move` closures with parameters are not currently
2132 E0709, // multiple different lifetimes used in arguments of `async fn`
2133 E0710, // an unknown tool name found in scoped lint
2134 E0711, // a feature has been declared with conflicting stability attributes
2135 // E0702, // replaced with a generic attribute input check
2136 E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
2137 E0727, // `async` generators are not yet supported
2138 E0728, // `await` must be in an `async` function or block