Skip to content

Commit 0fa220a

Browse files
committed
Rollup merge of rust-lang#27084 - GuillaumeGomez:patch-2, r=brson
Part of rust-lang#24407. r? @Manishearth
2 parents caa7374 + 2e919b4 commit 0fa220a

File tree

1 file changed

+154
-7
lines changed

1 file changed

+154
-7
lines changed

src/librustc_resolve/diagnostics.rs

+154-7
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,160 @@ See the 'Use Declarations' section of the reference for more information
272272
on this topic:
273273
274274
http://doc.rust-lang.org/reference.html#use-declarations
275-
"##
275+
"##,
276+
277+
E0403: r##"
278+
Some type parameters have the same name. Example of erroneous code:
279+
280+
```
281+
fn foo<T, T>(s: T, u: T) {} // error: the name `T` is already used for a type
282+
// parameter in this type parameter list
283+
```
284+
285+
Please verify that none of the type parameterss are misspelled, and rename any
286+
clashing parameters. Example:
287+
288+
```
289+
fn foo<T, Y>(s: T, u: Y) {} // ok!
290+
```
291+
"##,
292+
293+
E0404: r##"
294+
You tried to implement something which was not a trait on an object. Example of
295+
erroneous code:
296+
297+
```
298+
struct Foo;
299+
struct Bar;
300+
301+
impl Foo for Bar {} // error: `Foo` is not a trait
302+
```
303+
304+
Please verify that you didn't misspell the trait's name or otherwise use the
305+
wrong identifier. Example:
306+
307+
```
308+
trait Foo {
309+
// some functions
310+
}
311+
struct Bar;
312+
313+
impl Foo for Bar { // ok!
314+
// functions implementation
315+
}
316+
```
317+
"##,
318+
319+
E0405: r##"
320+
An unknown trait was implemented. Example of erroneous code:
321+
322+
```
323+
struct Foo;
324+
325+
impl SomeTrait for Foo {} // error: use of undeclared trait name `SomeTrait`
326+
```
327+
328+
Please verify that the name of the trait wasn't misspelled and ensure that it
329+
was imported. Example:
330+
331+
```
332+
// solution 1:
333+
use some_file::SomeTrait;
334+
335+
// solution 2:
336+
trait SomeTrait {
337+
// some functions
338+
}
339+
340+
struct Foo;
341+
342+
impl SomeTrait for Foo { // ok!
343+
// implements functions
344+
}
345+
```
346+
"##,
347+
348+
E0407: r##"
349+
A definition of a method not in the implemented trait was given in a trait
350+
implementation. Example of erroneous code:
351+
352+
```
353+
trait Foo {
354+
fn a();
355+
}
356+
357+
struct Bar;
358+
359+
impl Foo for Bar {
360+
fn a() {}
361+
fn b() {} // error: method `b` is not a member of trait `Foo`
362+
}
363+
```
364+
365+
Please verify you didn't misspell the method name and you used the correct
366+
trait. First example:
367+
368+
```
369+
trait Foo {
370+
fn a();
371+
fn b();
372+
}
373+
374+
struct Bar;
375+
376+
impl Foo for Bar {
377+
fn a() {}
378+
fn b() {} // ok!
379+
}
380+
```
381+
382+
Second example:
383+
384+
```
385+
trait Foo {
386+
fn a();
387+
}
388+
389+
struct Bar;
390+
391+
impl Foo for Bar {
392+
fn a() {}
393+
}
394+
395+
impl Bar {
396+
fn b() {}
397+
}
398+
```
399+
"##,
400+
401+
E0428: r##"
402+
A type or module has been defined more than once. Example of erroneous
403+
code:
404+
405+
```
406+
struct Bar;
407+
struct Bar; // error: duplicate definition of value `Bar`
408+
```
409+
410+
Please verify you didn't misspell the type/module's name or remove/rename the
411+
duplicated one. Example:
412+
413+
```
414+
struct Bar;
415+
struct Bar2; // ok!
416+
```
417+
"##,
418+
419+
E0433: r##"
420+
Invalid import. Example of erroneous code:
421+
422+
```
423+
use something_which_doesnt_exist;
424+
// error: unresolved import `something_which_doesnt_exist`
425+
```
426+
427+
Please verify you didn't misspell the import's name.
428+
"##,
276429

277430
}
278431

@@ -284,11 +437,7 @@ register_diagnostics! {
284437
E0258,
285438
E0401, // can't use type parameters from outer function
286439
E0402, // cannot use an outer type parameter in this context
287-
E0403, // the name `{}` is already used
288-
E0404, // is not a trait
289-
E0405, // use of undeclared trait name
290440
E0406, // undeclared associated type
291-
E0407, // method is not a member of trait
292441
E0408, // variable from pattern #1 is not bound in pattern #
293442
E0409, // variable is bound with different mode in pattern # than in
294443
// pattern #1
@@ -313,13 +462,11 @@ register_diagnostics! {
313462
E0425, // unresolved name
314463
E0426, // use of undeclared label
315464
E0427, // cannot use `ref` binding mode with ...
316-
E0428, // duplicate definition of ...
317465
E0429, // `self` imports are only allowed within a { } list
318466
E0430, // `self` import can only appear once in the list
319467
E0431, // `self` import can only appear in an import list with a non-empty
320468
// prefix
321469
E0432, // unresolved import
322-
E0433, // failed to resolve
323470
E0434, // can't capture dynamic environment in a fn item
324471
E0435, // attempt to use a non-constant value in a constant
325472
E0437, // type is not a member of trait

0 commit comments

Comments
 (0)