-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add `explicit_reexport_of_matching_names` test case. (#72) * Add `explicit_reexport_of_matching_names` test case. * Fix test case. * Conditionally enable the `explicit_reexport_of_matching_names` test. * Avoid clippy lint. * Reformat.
- Loading branch information
1 parent
6138d74
commit c6fc74b
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,8 @@ | ||
[package] | ||
name = "explicit_reexport_of_matching_names" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
30 changes: 30 additions & 0 deletions
30
test_crates/explicit_reexport_of_matching_names/src/lib.rs
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,30 @@ | ||
//! In Rust, type names and value names (including both `fn` and `const`) have different, | ||
//! mutually-disjoint namespaces. It's allowed for those namespaces to have matching names. | ||
//! When the name is used, the surrounding context determines whether it's resolved | ||
//! to the value or to the type by that name. | ||
//! | ||
//! For the love of all that is good in the world, | ||
//! please *do not* actually write code like this. | ||
//! This is peak "do as I say, not as I do" territory. | ||
//! | ||
//! This package exports the following: | ||
//! - the function `Foo`, also as `Bar` and `nested::Foo` | ||
//! - the type `Foo`, also as `Bar` and `nested::Foo` | ||
pub mod nested { | ||
pub struct Foo {} | ||
|
||
#[allow(non_snake_case)] | ||
pub fn Foo() {} | ||
} | ||
|
||
pub use nested::Foo; | ||
pub use Foo as Bar; | ||
|
||
// Proof that both the type and the function are visible. | ||
// Not exported. | ||
#[allow(dead_code)] | ||
fn proof() -> Bar { | ||
Bar(); | ||
Bar {} | ||
} |