Currently Rust only allows importing items of a module or crate.
pub use usize::MAX;
pub use std::primitive::usize::MAX as MAX2;
pub use Foo::MAX as MAX3;
pub struct Foo;
impl Foo {
pub const MAX: usize = 42;
}
Run the above snippet give the following error:
error[E0432]: unresolved import `usize`
--> src/lib.rs:1:9
|
1 | pub use usize::MAX;
| ^^^^^ help: a similar path exists: `std::usize`
error[E0432]: unresolved import `std::primitive::usize`
--> src/lib.rs:2:25
|
2 | pub use std::primitive::usize::MAX as MAX2;
| ^^^^^ `usize` is a builtin type, not a module
error[E0432]: unresolved import `Foo`
--> src/lib.rs:4:9
|
4 | pub use Foo::MAX as MAX3;
| ^^^ `Foo` is a struct, not a module
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0432`.
It would allow simplifying this code in std:
Notes
- We've already allowed to re-import built-in types: https://github.com/rust-lang/rust/blob/4fb54ed484e2239a3e9eff3be17df00d2a162be3/src/libcore/primitive.rs#L34-L35