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! {
8 In types, the `+` type operator has low precedence, so it is often necessary
17 w: &'a Foo + Copy, // error, use &'a (Foo + Copy)
18 x: &'a Foo + 'a, // error, use &'a (Foo + 'a)
19 y: &'a mut Foo + 'a, // error, use &'a mut (Foo + 'a)
20 z: fn() -> Foo + 'a, // error, use fn() -> (Foo + 'a)
24 More details can be found in [RFC 438].
26 [RFC 438]: https://github.com/rust-lang/rfcs/pull/438
30 A file wasn't found for an out-of-line module.
32 Erroneous code example:
34 ```ignore (compile_fail not working here; see Issue #43707)
35 mod file_that_doesnt_exist; // error: file not found for module
40 Please be sure that a file corresponding to the module exists. If you
41 want to use a module named `file_that_doesnt_exist`, you need to have a file
42 named `file_that_doesnt_exist.rs` or `file_that_doesnt_exist/mod.rs` in the
47 A doc comment that is not attached to anything has been encountered.
49 Erroneous code example:
59 A little reminder: a doc comment has to be placed before the item it's supposed
60 to document. So if you want to document the `Island` trait, you need to put a
61 doc comment before it, not inside it. Same goes for the `lost` method: the doc
62 comment needs to be before it:
74 A documentation comment that doesn't document anything was found.
76 Erroneous code example:
80 // The following doc comment will fail:
81 /// This is a useless doc comment!
85 Documentation comments need to be followed by items, including functions,
86 types, modules, etc. Examples:
89 /// I'm documenting the following struct:
92 /// I'm documenting the following function:
98 An inclusive range was used with no end.
100 Erroneous code example:
102 ```compile_fail,E0586
104 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
105 let x = &tmp[1..=]; // error: inclusive range was used with no end
109 An inclusive range needs an end in order to *include* it. If you just need a
110 start and no end, use a non-inclusive range (with `..`):
114 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
115 let x = &tmp[1..]; // ok!
119 Or put an end to your inclusive range:
123 let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
124 let x = &tmp[1..=3]; // ok!
130 This error indicates that a incorrect visibility restriction was specified.
132 Example of erroneous code:
134 ```compile_fail,E0704
136 pub(foo) struct Bar {
142 To make struct `Bar` only visible in module `foo` the `in` keyword should be
146 pub(in crate::foo) struct Bar {
153 For more information see the Rust Reference on [Visibility].
155 [Visibility]: https://doc.rust-lang.org/reference/visibility-and-privacy.html
159 C-variadic has been used on a non-foreign function.
161 Erroneous code example:
163 ```compile_fail,E0743
164 fn foo2(x: u8, ...) {} // error!
167 Only foreign functions can use C-variadic (`...`). It is used to give an
168 undefined number of parameters to a given function (like `printf` in C). The
169 equivalent in Rust would be to use macros directly.