Skip to content

Commit 65a7611

Browse files
sort error codes in librustc_passes
1 parent 5a8fb7c commit 65a7611

File tree

1 file changed

+161
-162
lines changed

1 file changed

+161
-162
lines changed

src/librustc_passes/error_codes.rs

+161-162
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,67 @@ extern {
5353
```
5454
"##,
5555

56+
// This shouldn't really ever trigger since the repeated value error comes first
57+
E0136: r##"
58+
A binary can only have one entry point, and by default that entry point is the
59+
function `main()`. If there are multiple such functions, please rename one.
60+
"##,
61+
62+
E0137: r##"
63+
More than one function was declared with the `#[main]` attribute.
64+
65+
Erroneous code example:
66+
67+
```compile_fail,E0137
68+
#![feature(main)]
69+
70+
#[main]
71+
fn foo() {}
72+
73+
#[main]
74+
fn f() {} // error: multiple functions with a `#[main]` attribute
75+
```
76+
77+
This error indicates that the compiler found multiple functions with the
78+
`#[main]` attribute. This is an error because there must be a unique entry
79+
point into a Rust program. Example:
80+
81+
```
82+
#![feature(main)]
83+
84+
#[main]
85+
fn f() {} // ok!
86+
```
87+
"##,
88+
89+
E0138: r##"
90+
More than one function was declared with the `#[start]` attribute.
91+
92+
Erroneous code example:
93+
94+
```compile_fail,E0138
95+
#![feature(start)]
96+
97+
#[start]
98+
fn foo(argc: isize, argv: *const *const u8) -> isize {}
99+
100+
#[start]
101+
fn f(argc: isize, argv: *const *const u8) -> isize {}
102+
// error: multiple 'start' functions
103+
```
104+
105+
This error indicates that the compiler found multiple functions with the
106+
`#[start]` attribute. This is an error because there must be a unique entry
107+
point into a Rust program. Example:
108+
109+
```
110+
#![feature(start)]
111+
112+
#[start]
113+
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
114+
```
115+
"##,
116+
56117
E0197: r##"
57118
Inherent implementations (one that do not implement a trait but provide
58119
methods associated with a type) are always safe because they are not
@@ -198,20 +259,30 @@ impl Foo for Bar {
198259
```
199260
"##,
200261

262+
E0512: r##"
263+
Transmute with two differently sized types was attempted. Erroneous code
264+
example:
201265
202-
E0590: r##"
203-
`break` or `continue` must include a label when used in the condition of a
204-
`while` loop.
205-
206-
Example of erroneous code:
266+
```compile_fail,E0512
267+
fn takes_u8(_: u8) {}
207268
208-
```compile_fail
209-
while break {}
269+
fn main() {
270+
unsafe { takes_u8(::std::mem::transmute(0u16)); }
271+
// error: cannot transmute between types of different sizes,
272+
// or dependently-sized types
273+
}
210274
```
211275
212-
To fix this, add a label specifying which loop is being broken out of:
276+
Please use types with same size or use the expected type directly. Example:
277+
213278
```
214-
'foo: while break 'foo {}
279+
fn takes_u8(_: u8) {}
280+
281+
fn main() {
282+
unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
283+
// or:
284+
unsafe { takes_u8(0u8); } // ok!
285+
}
215286
```
216287
"##,
217288

@@ -249,151 +320,20 @@ let result = loop { // ok!
249320
```
250321
"##,
251322

252-
E0642: r##"
253-
Trait methods currently cannot take patterns as arguments.
254-
255-
Example of erroneous code:
256-
257-
```compile_fail,E0642
258-
trait Foo {
259-
fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
260-
// in trait methods
261-
}
262-
```
263-
264-
You can instead use a single name for the argument:
265-
266-
```
267-
trait Foo {
268-
fn foo(x_and_y: (i32, i32)); // ok!
269-
}
270-
```
271-
"##,
272-
273-
E0695: r##"
274-
A `break` statement without a label appeared inside a labeled block.
275-
276-
Example of erroneous code:
277-
278-
```compile_fail,E0695
279-
# #![feature(label_break_value)]
280-
loop {
281-
'a: {
282-
break;
283-
}
284-
}
285-
```
286-
287-
Make sure to always label the `break`:
288-
289-
```
290-
# #![feature(label_break_value)]
291-
'l: loop {
292-
'a: {
293-
break 'l;
294-
}
295-
}
296-
```
297-
298-
Or if you want to `break` the labeled block:
299-
300-
```
301-
# #![feature(label_break_value)]
302-
loop {
303-
'a: {
304-
break 'a;
305-
}
306-
break;
307-
}
308-
```
309-
"##,
310-
311-
E0670: r##"
312-
Rust 2015 does not permit the use of `async fn`.
323+
E0590: r##"
324+
`break` or `continue` must include a label when used in the condition of a
325+
`while` loop.
313326
314327
Example of erroneous code:
315328
316-
```compile_fail,E0670
317-
async fn foo() {}
318-
```
319-
320-
Switch to the Rust 2018 edition to use `async fn`.
321-
"##,
322-
323-
// This shouldn't really ever trigger since the repeated value error comes first
324-
E0136: r##"
325-
A binary can only have one entry point, and by default that entry point is the
326-
function `main()`. If there are multiple such functions, please rename one.
327-
"##,
328-
329-
E0137: r##"
330-
More than one function was declared with the `#[main]` attribute.
331-
332-
Erroneous code example:
333-
334-
```compile_fail,E0137
335-
#![feature(main)]
336-
337-
#[main]
338-
fn foo() {}
339-
340-
#[main]
341-
fn f() {} // error: multiple functions with a `#[main]` attribute
342-
```
343-
344-
This error indicates that the compiler found multiple functions with the
345-
`#[main]` attribute. This is an error because there must be a unique entry
346-
point into a Rust program. Example:
347-
348-
```
349-
#![feature(main)]
350-
351-
#[main]
352-
fn f() {} // ok!
353-
```
354-
"##,
355-
356-
E0138: r##"
357-
More than one function was declared with the `#[start]` attribute.
358-
359-
Erroneous code example:
360-
361-
```compile_fail,E0138
362-
#![feature(start)]
363-
364-
#[start]
365-
fn foo(argc: isize, argv: *const *const u8) -> isize {}
366-
367-
#[start]
368-
fn f(argc: isize, argv: *const *const u8) -> isize {}
369-
// error: multiple 'start' functions
370-
```
371-
372-
This error indicates that the compiler found multiple functions with the
373-
`#[start]` attribute. This is an error because there must be a unique entry
374-
point into a Rust program. Example:
375-
376-
```
377-
#![feature(start)]
378-
379-
#[start]
380-
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
329+
```compile_fail
330+
while break {}
381331
```
382-
"##,
383-
384-
E0601: r##"
385-
No `main` function was found in a binary crate. To fix this error, add a
386-
`main` function. For example:
387332
333+
To fix this, add a label specifying which loop is being broken out of:
388334
```
389-
fn main() {
390-
// Your program will start here.
391-
println!("Hello world!");
392-
}
335+
'foo: while break 'foo {}
393336
```
394-
395-
If you don't know the basics of Rust, you can go look to the Rust Book to get
396-
started: https://doc.rust-lang.org/book/
397337
"##,
398338

399339
E0591: r##"
@@ -474,33 +414,92 @@ makes a difference in practice.)
474414
[rfc401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
475415
"##,
476416

477-
E0512: r##"
478-
Transmute with two differently sized types was attempted. Erroneous code
479-
example:
480-
481-
```compile_fail,E0512
482-
fn takes_u8(_: u8) {}
417+
E0601: r##"
418+
No `main` function was found in a binary crate. To fix this error, add a
419+
`main` function. For example:
483420
421+
```
484422
fn main() {
485-
unsafe { takes_u8(::std::mem::transmute(0u16)); }
486-
// error: cannot transmute between types of different sizes,
487-
// or dependently-sized types
423+
// Your program will start here.
424+
println!("Hello world!");
488425
}
489426
```
490427
491-
Please use types with same size or use the expected type directly. Example:
428+
If you don't know the basics of Rust, you can go look to the Rust Book to get
429+
started: https://doc.rust-lang.org/book/
430+
"##,
431+
432+
E0642: r##"
433+
Trait methods currently cannot take patterns as arguments.
434+
435+
Example of erroneous code:
436+
437+
```compile_fail,E0642
438+
trait Foo {
439+
fn foo((x, y): (i32, i32)); // error: patterns aren't allowed
440+
// in trait methods
441+
}
442+
```
443+
444+
You can instead use a single name for the argument:
492445
493446
```
494-
fn takes_u8(_: u8) {}
447+
trait Foo {
448+
fn foo(x_and_y: (i32, i32)); // ok!
449+
}
450+
```
451+
"##,
495452

496-
fn main() {
497-
unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
498-
// or:
499-
unsafe { takes_u8(0u8); } // ok!
453+
E0695: r##"
454+
A `break` statement without a label appeared inside a labeled block.
455+
456+
Example of erroneous code:
457+
458+
```compile_fail,E0695
459+
# #![feature(label_break_value)]
460+
loop {
461+
'a: {
462+
break;
463+
}
464+
}
465+
```
466+
467+
Make sure to always label the `break`:
468+
469+
```
470+
# #![feature(label_break_value)]
471+
'l: loop {
472+
'a: {
473+
break 'l;
474+
}
475+
}
476+
```
477+
478+
Or if you want to `break` the labeled block:
479+
480+
```
481+
# #![feature(label_break_value)]
482+
loop {
483+
'a: {
484+
break 'a;
485+
}
486+
break;
500487
}
501488
```
502489
"##,
503490

491+
E0670: r##"
492+
Rust 2015 does not permit the use of `async fn`.
493+
494+
Example of erroneous code:
495+
496+
```compile_fail,E0670
497+
async fn foo() {}
498+
```
499+
500+
Switch to the Rust 2018 edition to use `async fn`.
501+
"##,
502+
504503
;
505504
E0226, // only a single explicit lifetime bound is permitted
506505
E0472, // asm! is unsupported on this target

0 commit comments

Comments
 (0)