Show one error for duplicated type definitions

For the following code:

```rustc
struct Bar;
struct Bar;

fn main () {
}
```

show

```nocode
error[E0428]: a type named `Bar` has already been defined in this module
  --> src/test/compile-fail/E0428.rs:12:1
   |
11 | struct Bar;
   | ----------- previous definition of `Bar` here
12 | struct Bar;
   | ^^^^^^^^^^^

error: aborting due to previous error
```

instead of

```nocode
error[E0428]: a type named `Bar` has already been defined in this module
  --> src/test/compile-fail/E0428.rs:12:1
   |
11 | struct Bar;
   | ----------- previous definition of `Bar` here
12 | struct Bar;
   | ^^^^^^^^^^^

error[E0428]: a value named `Bar` has already been defined in this module
  --> src/test/compile-fail/E0428.rs:12:1
   |
11 | struct Bar;
   | ----------- previous definition of `Bar` here
12 | struct Bar;
   | ^^^^^^^^^^^

error: aborting due to 2 previous errors
```
This commit is contained in:
Esteban Küber 2016-10-28 00:30:23 -07:00
parent da2ce22768
commit 43aed325aa
5 changed files with 14 additions and 13 deletions

View file

@ -9,11 +9,8 @@
// except according to those terms.
struct Bar; //~ previous definition of `Bar` here
//~| previous definition of `Bar` here
struct Bar; //~ ERROR E0428
//~| NOTE already defined
//~| ERROR E0428
//~| NOTE already defined
fn main () {
}

View file

@ -14,7 +14,6 @@ fn main() {
{
struct Bar;
use foo::Bar;
//~^ ERROR a type named `Bar` has already been defined in this block
//~^^ ERROR a value named `Bar` has already been defined in this block
//~^ ERROR a value named `Bar` has already been defined in this block
}
}

View file

@ -12,7 +12,6 @@ mod foo {
pub use self::bar::X;
use self::bar::X;
//~^ ERROR a value named `X` has already been imported in this module
//~| ERROR a type named `X` has already been imported in this module
mod bar {
pub struct X;

View file

@ -33,17 +33,11 @@ const XUnit: u8 = 0;
extern crate variant_namespacing;
pub use variant_namespacing::XE::*;
//~^ ERROR `XStruct` has already been defined
//~| ERROR `XStruct` has already been defined
//~| ERROR `XTuple` has already been defined
//~| ERROR `XTuple` has already been defined
//~| ERROR `XUnit` has already been defined
//~| ERROR `XUnit` has already been defined
pub use E::*;
//~^ ERROR `Struct` has already been defined
//~| ERROR `Struct` has already been defined
//~| ERROR `Tuple` has already been defined
//~| ERROR `Tuple` has already been defined
//~| ERROR `Unit` has already been defined
//~| ERROR `Unit` has already been defined
fn main() {}