Skip to content

Commit 3e6b03c

Browse files
committed
Auto merge of #27230 - GuillaumeGomez:patch-1, r=brson
Part of #24407. cc @Manishearth
2 parents bbda6f9 + fc65f55 commit 3e6b03c

File tree

1 file changed

+156
-9
lines changed

1 file changed

+156
-9
lines changed

Diff for: src/librustc_resolve/diagnostics.rs

+156-9
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,115 @@ impl Bar {
397397
```
398398
"##,
399399

400+
E0417: r##"
401+
A static variable was referenced in a pattern. Example of erroneous code:
402+
403+
```
404+
static FOO : i32 = 0;
405+
406+
match 0 {
407+
FOO => {} // error: static variables cannot be referenced in a
408+
// pattern, use a `const` instead
409+
_ => {}
410+
}
411+
```
412+
413+
The compiler needs to know the value of the pattern at compile time;
414+
compile-time patterns can defined via const or enum items. Please verify
415+
that the identifier is spelled correctly, and if so, use a const instead
416+
of static to define it. Example:
417+
418+
```
419+
const FOO : i32 = 0;
420+
421+
match 0 {
422+
FOO => {} // ok!
423+
_ => {}
424+
}
425+
```
426+
"##,
427+
428+
E0424: r##"
429+
The `self` keyword was used in a static method. Example of erroneous code:
430+
431+
```
432+
struct Foo;
433+
434+
impl Foo {
435+
fn bar(self) {}
436+
437+
fn foo() {
438+
self.bar(); // error: `self` is not available in a static method.
439+
}
440+
}
441+
```
442+
443+
Please check if the method's argument list should have contained `self`,
444+
`&self`, or `&mut self` (in case you didn't want to create a static
445+
method), and add it if so. Example:
446+
447+
```
448+
struct Foo;
449+
450+
impl Foo {
451+
fn bar(self) {}
452+
453+
fn foo(self) {
454+
self.bar(); // ok!
455+
}
456+
}
457+
```
458+
"##,
459+
460+
E0425: r##"
461+
An unresolved name was used. Example of erroneous codes:
462+
463+
```
464+
something_that_doesnt_exist::foo;
465+
// error: unresolved name `something_that_doesnt_exist::foo`
466+
467+
// or:
468+
trait Foo {
469+
fn bar() {
470+
Self; // error: unresolved name `Self`
471+
}
472+
}
473+
```
474+
475+
Please verify you didn't misspell the name or that you're not using an
476+
invalid object. Example:
477+
478+
```
479+
enum something_that_does_exist {
480+
foo
481+
}
482+
// or:
483+
mod something_that_does_exist {
484+
pub static foo : i32 = 0i32;
485+
}
486+
487+
something_that_does_exist::foo; // ok!
488+
```
489+
"##,
490+
491+
E0426: r##"
492+
An undeclared label was used. Example of erroneous code:
493+
494+
```
495+
loop {
496+
break 'a; // error: use of undeclared label `'a`
497+
}
498+
```
499+
500+
Please verify you spelt or declare the label correctly. Example:
501+
502+
```
503+
'a: loop {
504+
break 'a; // ok!
505+
}
506+
```
507+
"##,
508+
400509
E0428: r##"
401510
A type or module has been defined more than once. Example of erroneous
402511
code:
@@ -415,6 +524,53 @@ struct Bar2; // ok!
415524
```
416525
"##,
417526

527+
E0430: r##"
528+
The `self` import appears more than once in the list. Erroneous code example:
529+
530+
```
531+
use something::{self, self}; // error: `self` import can only appear once in
532+
// the list
533+
```
534+
535+
Please verify you didn't misspell the import name or remove the duplicated
536+
`self` import. Example:
537+
538+
```
539+
use something::self; // ok!
540+
```
541+
"##,
542+
543+
E0431: r##"
544+
`self` import was made. Erroneous code example:
545+
546+
```
547+
use {self}; // error: `self` import can only appear in an import list with a
548+
// non-empty prefix
549+
```
550+
551+
You cannot import the current module into itself, please remove this import
552+
or verify you didn't misspell it.
553+
"##,
554+
555+
E0432: r##"
556+
An import was unresolved. Erroneous code example:
557+
558+
```
559+
use something::Foo; // error: unresolved import `something::Foo`.
560+
```
561+
562+
Please verify you didn't misspell the import name or the import does exist
563+
in the module from where you tried to import it. Example:
564+
565+
```
566+
use something::Foo; // ok!
567+
568+
mod something {
569+
pub struct Foo;
570+
}
571+
```
572+
"##,
573+
418574
E0433: r##"
419575
Invalid import. Example of erroneous code:
420576
@@ -499,24 +655,15 @@ register_diagnostics! {
499655
E0414, // only irrefutable patterns allowed here
500656
E0415, // identifier is bound more than once in this parameter list
501657
E0416, // identifier is bound more than once in the same pattern
502-
E0417, // static variables cannot be referenced in a pattern, use a
503-
// `const` instead
504658
E0418, // is not an enum variant, struct or const
505659
E0419, // unresolved enum variant, struct or const
506660
E0420, // is not an associated const
507661
E0421, // unresolved associated const
508662
E0422, // does not name a structure
509663
E0423, // is a struct variant name, but this expression uses it like a
510664
// function name
511-
E0424, // `self` is not available in a static method.
512-
E0425, // unresolved name
513-
E0426, // use of undeclared label
514665
E0427, // cannot use `ref` binding mode with ...
515666
E0429, // `self` imports are only allowed within a { } list
516-
E0430, // `self` import can only appear once in the list
517-
E0431, // `self` import can only appear in an import list with a non-empty
518-
// prefix
519-
E0432, // unresolved import
520667
E0434, // can't capture dynamic environment in a fn item
521668
E0435, // attempt to use a non-constant value in a constant
522669
}

0 commit comments

Comments
 (0)