-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when creating a module and a struct that both have the same name.
Currently it is possible to do the following: - define a module named `Foo` and then a unit or tuple struct also named `Foo` - define any struct named `Foo` and then a module named `Foo` This commit introduces a warning for both of these cases.
- Loading branch information
Nick Hamann
committed
Oct 22, 2015
1 parent
5692e16
commit f0af1eb
Showing
3 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Also works as a test for #14564 | ||
|
||
#[allow(non_snake_case)] | ||
mod Foo { } | ||
//~^ NOTE first definition of type or module `Foo` | ||
|
||
#[allow(dead_code)] | ||
struct Foo; | ||
//~^ WARNING duplicate definition of type or module `Foo` | ||
|
||
|
||
#[allow(non_snake_case)] | ||
mod Bar { } | ||
//~^ NOTE first definition of type or module `Bar` | ||
|
||
#[allow(dead_code)] | ||
struct Bar(i32); | ||
//~^ WARNING duplicate definition of type or module `Bar` | ||
|
||
|
||
#[allow(dead_code)] | ||
struct Baz(i32); | ||
//~^ NOTE first definition of type or module | ||
|
||
#[allow(non_snake_case)] | ||
mod Baz { } | ||
//~^ WARNING duplicate definition of type or module `Baz` | ||
|
||
|
||
#[allow(dead_code)] | ||
struct Qux { x: bool } | ||
//~^ NOTE first definition of type or module | ||
|
||
#[allow(non_snake_case)] | ||
mod Qux { } | ||
//~^ WARNING duplicate definition of type or module `Qux` | ||
|
||
|
||
#[allow(dead_code)] | ||
struct Quux; | ||
//~^ NOTE first definition of type or module | ||
|
||
#[allow(non_snake_case)] | ||
mod Quux { } | ||
//~^ WARNING duplicate definition of type or module `Quux` | ||
|
||
|
||
#[allow(dead_code)] | ||
enum Corge { A, B } | ||
|
||
#[allow(non_snake_case)] | ||
mod Corge { } | ||
//~^ ERROR duplicate definition of type or module `Corge` | ||
|
||
fn main() { } |
This file was deleted.
Oops, something went wrong.