-
-
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.
Handle
pub use Trait as _
cases correctly: the item is unnameable.
- Loading branch information
1 parent
9e3fd5c
commit f34b7f0
Showing
4 changed files
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
publish = false | ||
name = "nested_reexport_as_underscore" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
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,22 @@ | ||
//! This crate does not re-export any *nameable* items. | ||
//! | ||
//! However, glob imports of this file (in the style of a prelude) | ||
//! make `Trait::method()` visible, making `().method()` valid Rust. | ||
//! | ||
//! Docs: https://doc.rust-lang.org/reference/items/use-declarations.html#underscore-imports | ||
mod inner { | ||
pub trait Trait { | ||
fn method(&self) {} | ||
} | ||
|
||
impl Trait for () {} | ||
|
||
pub struct Struct {} | ||
} | ||
|
||
mod second { | ||
pub use Trait as _; | ||
} | ||
|
||
pub use second::*; |
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,9 @@ | ||
[package] | ||
publish = false | ||
name = "reexport_as_underscore" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
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 @@ | ||
//! This crate re-exports only the name `Struct`. | ||
//! | ||
//! However, glob imports of this file (in the style of a prelude) | ||
//! also make `Trait::method()` visible as well, making `().method()` valid Rust. | ||
//! | ||
//! The `_` re-export of the module `hidden` is not nameable at all, and here has no effect. | ||
//! `hidden::UnderscoreImported` is not nameable outside this crate. | ||
//! | ||
//! Docs: https://doc.rust-lang.org/reference/items/use-declarations.html#underscore-imports | ||
mod inner { | ||
pub trait Trait { | ||
fn method(&self) {} | ||
} | ||
|
||
impl Trait for () {} | ||
|
||
pub struct Struct {} | ||
} | ||
|
||
mod hidden { | ||
pub struct UnderscoreImported; | ||
} | ||
|
||
pub use inner::{ | ||
Struct, | ||
Trait as _, | ||
}; | ||
|
||
pub use hidden as _; |