Skip to content

Commit

Permalink
Rollup merge of rust-lang#35831 - trixnz:error-428, r=jonathandturner
Browse files Browse the repository at this point in the history
Update E0428 to new format

Fixes rust-lang#35798 as part of rust-lang#35233.

r? @jonathandturner
  • Loading branch information
Jonathan Turner committed Aug 20, 2016
2 parents 0d69b88 + d791aa1 commit b22352f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3382,7 +3382,11 @@ impl<'a> Resolver<'a> {
},
(true, _) | (_, true) => struct_span_err!(self.session, span, E0260, "{}", msg),
_ => match (old_binding.is_import(), binding.is_import()) {
(false, false) => struct_span_err!(self.session, span, E0428, "{}", msg),
(false, false) => {
let mut e = struct_span_err!(self.session, span, E0428, "{}", msg);
e.span_label(span, &format!("already defined"));
e
},
(true, true) => {
let mut e = struct_span_err!(self.session, span, E0252, "{}", msg);
e.span_label(span, &format!("already imported"));
Expand Down
7 changes: 5 additions & 2 deletions src/test/compile-fail/E0428.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Bar;
struct Bar; //~ previous definition of `Bar` here
//~| previous definition of `Bar` here
struct Bar; //~ ERROR E0428
//~^ ERROR E0428
//~| NOTE already defined
//~| ERROR E0428
//~| NOTE already defined

fn main () {
}
3 changes: 2 additions & 1 deletion src/test/compile-fail/enum-and-module-in-same-scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

enum Foo { //~ NOTE previous definition
enum Foo { //~ NOTE previous definition of `Foo` here
X
}

mod Foo { //~ ERROR a type named `Foo` has already been defined
//~| NOTE already defined
pub static X: isize = 42;
fn f() { f() } // Check that this does not result in a resolution error
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/compile-fail/issue-21546.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod Foo { }
#[allow(dead_code)]
struct Foo;
//~^ ERROR a module named `Foo` has already been defined in this module
//~| NOTE already defined

#[allow(non_snake_case)]
mod Bar { }
Expand All @@ -25,6 +26,7 @@ mod Bar { }
#[allow(dead_code)]
struct Bar(i32);
//~^ ERROR a module named `Bar` has already been defined
//~| NOTE already defined


#[allow(dead_code)]
Expand All @@ -34,6 +36,7 @@ struct Baz(i32);
#[allow(non_snake_case)]
mod Baz { }
//~^ ERROR a type named `Baz` has already been defined
//~| NOTE already defined


#[allow(dead_code)]
Expand All @@ -43,6 +46,7 @@ struct Qux { x: bool }
#[allow(non_snake_case)]
mod Qux { }
//~^ ERROR a type named `Qux` has already been defined
//~| NOTE already defined


#[allow(dead_code)]
Expand All @@ -52,6 +56,7 @@ struct Quux;
#[allow(non_snake_case)]
mod Quux { }
//~^ ERROR a type named `Quux` has already been defined
//~| NOTE already defined


#[allow(dead_code)]
Expand All @@ -61,5 +66,6 @@ enum Corge { A, B }
#[allow(non_snake_case)]
mod Corge { }
//~^ ERROR a type named `Corge` has already been defined
//~| NOTE already defined

fn main() { }
1 change: 1 addition & 0 deletions src/test/compile-fail/trait-duplicate-methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
trait Foo {
fn orange(&self); //~ NOTE previous definition of `orange` here
fn orange(&self); //~ ERROR a value named `orange` has already been defined in this trait
//~| NOTE already define
}

fn main() {}

0 comments on commit b22352f

Please sign in to comment.