Skip to content

Ambiguous glob import in polars_plan results in privacy error #144333

@cramertj

Description

@cramertj

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:

  1. pub mod dsl in lib.rs
  2. pub use functions::*; in dsl/mod.rs
  3. pub use range::date_range and pub use range::time_range in dsl/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:

use crate::prelude::*;

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"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions