- Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
This repository has a basic cargo build
that will demonstrate the issue and reproduce on rustc 1.90.0-nightly (9748d87dc 2025-07-21)
.
An ambiguous glob import results in a misleading error message rather than preferring the more public item.
Error message:
error[E0603]: function `date_range` is private --> src/main.rs:2:27 | 2 | use polars_plan::dsl::date_range; | ^^^^^^^^^^ private function | note: the function `date_range` is defined here --> /usr/local/google/home/cramertj/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/polars-plan-0.48.1/src/dsl/mod.rs:87:5 | 87 | use crate::prelude::*; | ^^^^^^^^^^^^^^ help: import `date_range` directly | 2 - use polars_plan::dsl::date_range; 2 + use polars_time::date_range::date_range; | error[E0603]: function `time_range` is private --> src/main.rs:3:27 | 3 | use polars_plan::dsl::time_range; | ^^^^^^^^^^ private function | note: the function `time_range` is defined here --> /usr/local/google/home/cramertj/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/polars-plan-0.48.1/src/dsl/mod.rs:87:5 | 87 | use crate::prelude::*; | ^^^^^^^^^^^^^^ help: import `time_range` directly | 3 - use polars_plan::dsl::time_range; 3 + use polars_time::date_range::time_range; | For more information about this error, try `rustc --explain E0603`.
date_range
and
time_range
are both defined as pub
and exported under polars_plan::dsl
via the following chain of pub use
statements:
pub mod dsl
inlib.rs
pub use functions::*;
indsl/mod.rs
pub use range::date_range
andpub use range::time_range
indsl/functions/mod.rs
However, rustc
provides an error message pointing at polars_time::date_range::{date_range, time_range}
, despite the fact that
the current crate has no direct dependency on polars_time
.
Furthermore, rustc
thinks that the date_range
and time_range
types were defined in src/dsl/mod.rs:87
:
The prelude does include a pub(crate)
reexport of the types from polars_time
.
However, it also includes a (circular) pub
reexport of the dsl::* types
Based on the (incomplete) Rust reference section on use
,
I would expect an ambiguity error rather than a privacy error.
That said, it would also make sense to allow this example to work and access the public item, as occurs here:
mod priv_fn { fn some_fn() { println!("private") } } mod pub_fn { pub fn some_fn() { println!("public") } } mod reexport_both { pub use crate::priv_fn::*; pub use crate::pub_fn::*; } fn main() { reexport_both::some_fn(); // prints "public" }