Skip to content

Diesel stops building with nightly-2025-12-10 #149845

Closed
diesel-rs/diesel
#4907

Description

@weiznich

Code

I tried this code:

git clone https://github.com/diesel-rs/diesel
cd diesel
cargo check -F postgres --all-targets -p diesel_tests

I expected to see this happen: Code builds without errors
Instead, this happened: Compilation fails with errors

Version it worked on

It most recently worked on:

Version with regression

rustc --version --verbose:

rustc 1.94.0-nightly (c61a3a44d 2025-12-09)
binary: rustc
commit-hash: c61a3a44d1a5bee35914cada6c788a05e0808f5b
commit-date: 2025-12-09
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.5

bisec-rustc points to c61a3a4 (so #147984) for the commit/PR that introduced this regression.

The error message points to #114095
Unfortunately I see no meaningful way for diesel to address this without doing a significant breaking change. To address this without breaking change on our side it would be required to have tooling that lets us import only from a specific namespace (type, function, etc) if several items with the same name exists.

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

Activity

  1. added
    C-bugCategory: This is a bug.
    regression-untriagedUntriaged performance or correctness regression.
    on Dec 10, 2025
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    and removed
    regression-untriagedUntriaged performance or correctness regression.
    on Dec 10, 2025
  3. bjorn3 commented on Dec 10, 2025

    @bjorn3
    Member

    The actual error message as taken from https://github.com/diesel-rs/diesel/actions/runs/20098057029/job/57661673455?pr=4900:

    Details
    error[E0252]: the name `max` is defined multiple times
       --> diesel_tests/tests/select_by.rs:170:9
        |
    169 |     use diesel::dsl::{count_star, max, CountStar};
        |                                   --- previous import of the type `max` here
    170 |     use diesel::helper_types::max;
        |         ^^^^^^^^^^^^^^^^^^^^^^^^^ `max` reimported here
        |
        = note: `max` must be defined only once in the type namespace of this block
    
    error: `max` is ambiguous
       --> diesel_tests/tests/group_by.rs:33:22
        |
     33 |     use diesel::dsl::max;
        |                      ^^^ ambiguous name
        |
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
        = note: ambiguous because of multiple glob imports of a name in the same module
    note: `max` could refer to the type alias defined here
       --> /home/runner/work/diesel/diesel/diesel/src/lib.rs:341:13
        |
    341 |     pub use crate::helper_types::*;
        |             ^^^^^^^^^^^^^^^^^^^
    note: `max` could also refer to the type alias defined here
       --> /home/runner/work/diesel/diesel/diesel/src/lib.rs:344:13
        |
    344 |     pub use crate::expression::dsl::*;
        |             ^^^^^^^^^^^^^^^^^^^^^^
        = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
    
    error: `max` is ambiguous
       --> diesel_tests/tests/select.rs:519:35
        |
    519 |     use diesel::dsl::{count_star, max};
       --> /home/runner/work/diesel/diesel/diesel/src/lib.rs:344:13
        |
    344 |     pub use crate::expression::dsl::*;
        |             ^^^^^^^^^^^^^^^^^^^^^^
    
    error: `nth_value` is ambiguous
       --> diesel_derives/tests/auto_type.rs:722:9
        |
    722 |         nth_value(users::id, 1_i32).over(),
        |         ^^^^^^^^^ ambiguous name
        |
        = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
        = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
        = note: ambiguous because of multiple glob imports of a name in the same module
    note: `nth_value` could refer to the type alias defined here
       --> /home/runner/work/diesel/diesel/diesel/src/lib.rs:341:13
        |
    341 |     pub use crate::helper_types::*;
        |             ^^^^^^^^^^^^^^^^^^^
    note: `nth_value` could also refer to the type alias defined here
       --> /home/runner/work/diesel/diesel/diesel/src/lib.rs:344:13
        |
    344 |     pub use crate::expression::dsl::*;
        |             ^^^^^^^^^^^^^^^^^^^^^^
    
    warning: unused import: `diesel::helper_types::*`
     --> diesel_derives/tests/auto_type.rs:3:5
      |
    3 | use diesel::helper_types::*;
      |     ^^^^^^^^^^^^^^^^^^^^^^^
      |
      = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
    
    warning: `diesel_derives` (test "tests") generated 1 warning
    error: could not compile `diesel_derives` (test "tests") due to 26 previous errors; 1 warning emitted
    warning: build failed, waiting for other jobs to finish...
    For more information about this error, try `rustc --explain E0252`.
    warning: `diesel_tests` (test "integration_tests") generated 1 warning
    error: could not compile `diesel_tests` (test "integration_tests") due to 9 previous errors; 1 warning emitted
    
  4. added
    A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
    on Dec 10, 2025
  5. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Dec 10, 2025
  6. lqd commented on Dec 10, 2025

    @lqd
    Member

    cc @petrochenkov on that bisection

  7. self-assigned this
    on Dec 10, 2025
  8. petrochenkov commented on Dec 10, 2025

    @petrochenkov
    Contributor

    From 74 regressions in #147984 (comment) (due to ambiguous_glob_imports being deny-by-default) a significant part is indeed from depending on diesel diesel::dsl::{max,sum,/*etc*/}.

    I wondered why this hazard in diesel wasn't detected before, and it turns out it was, but diesel does #[allow(ambiguous_glob_reexports)] to ignore it.

  9. petrochenkov commented on Dec 10, 2025

    @petrochenkov
    Contributor

    I'm trying to understand what's going on, but it's hard because diesel uses proc macros to generate code.

    Why do both crate::helper_types::* and crate::expression::dsl::* contain fn max, but different ones?
    The compiler doesn't know which one to choose -> ambiguous_glob_imports is reported, this is a legitimate error.
    Which one is supposed to be chosen?

    it would be required to have tooling that lets us import only from a specific namespace (type, function, etc) if several items with the same name exists

    FWIW, the tooling exists, it's just not pretty.
    I could make a fix if I understood what's going on there.

  10. petrochenkov commented on Dec 10, 2025

    @petrochenkov
    Contributor

    Upd: the correct fix is below - #149845 (comment).

    Possible fix (at least the reproducer command line passes).
    Single imports can be used to explicitly disambiguate the crate::helper_types::* vs crate::expression::dsl::* situation.

    diff --git i/diesel/src/lib.rs w/diesel/src/lib.rs
    index d6e26dc52..2dba34a76 100644
    --- i/diesel/src/lib.rs
    +++ w/diesel/src/lib.rs
    @@ -339,6 +339,7 @@ pub mod dsl {
    
         #[doc(inline)]
         pub use crate::helper_types::*;
    +    pub use crate::helper_types::{max, array_append};
    
         #[doc(inline)]
         pub use crate::expression::dsl::*;
    diff --git i/diesel_tests/tests/select_by.rs w/diesel_tests/tests/select_by.rs
    index 6adaf9717..554f5f27b 100644
    --- i/diesel_tests/tests/select_by.rs
    +++ w/diesel_tests/tests/select_by.rs
    @@ -167,7 +167,6 @@ fn select_can_be_called_on_query_that_is_valid_subselect_but_invalid_query() {
     fn selecting_multiple_aggregate_expressions_without_group_by() {
         use self::users::dsl::*;
         use diesel::dsl::{count_star, max, CountStar};
    -    use diesel::helper_types::max;
    
         #[derive(Queryable)]
         struct CountAndMax {
  11. weiznich commented on Dec 10, 2025

    @weiznich
    ContributorAuthor

    Thanks for pointing out how to fix it in diesel. I will try to verify this tomorrow.

    Based on the diff I unfortunately guess that this might exactly be the thing I called breaking change above, as it requires also to change the calling side as demonstrated by the changes to diesel_tests.

    As for the questions around what the code actually expands to: The diesel documentation shows expanded code for the relevant macro: https://docs.diesel.rs/main/diesel/expression/functions/attr.declare_sql_function.html#expanded-code-1

    If that is not sufficient I can try to provide more details tomorrow, I'm currently occupied with other tasks.

  12. 35 remaining items

  13. petrochenkov commented on Jan 13, 2026

    @petrochenkov
    Contributor

    The FCP set it to a deny-by-default lint, not a hard error. It can be set to a warn-by-default lint instead, yes (by introducing a new lint, because the old one is shared with other cases). I'll have the bandwidth after the holidays (around next week).

    Implemented in #151074.

  14. joshtriplett commented on Jan 14, 2026

    @joshtriplett
    Member

    We talked about this in today's @rust-lang/lang meeting. For simplicity's sake, rather than splitting out the external vs intra-crate lint, we'd like to temporarily downgrade the existing lint (covering the use site) to warn-by-default, and wait one release before re-upgrading it, to give an extra six weeks for this to get fixed in the ecosystem.

    (Also, if it's not yet warn-in-deps, please go ahead and make it warn-in-deps.)

  15. petrochenkov commented on Jan 14, 2026

    @petrochenkov
    Contributor

    We talked about this in today's @rust-lang/lang meeting. For simplicity's sake, rather than splitting out the external vs intra-crate lint, we'd like to temporarily downgrade the existing lint (covering the use site) to warn-by-default, and wait one release before re-upgrading it, to give an extra six weeks for this to get fixed in the ecosystem.

    (Also, if it's not yet warn-in-deps, please go ahead and make it warn-in-deps.)

    Implemented in #151130.

  16. added a commit that references this issue on Jan 14, 2026
  17. added a commit that references this issue on Jan 15, 2026
  18. added a commit that references this issue on Jan 15, 2026
  19. weiznich commented on Jan 16, 2026

    @weiznich
    ContributorAuthor

    I would like to thank you all for giving me a bit more time. That's really appropriated. I opened #151198 to add an additional note to the error message to ask users to update their dependencies to resolve this particular issues. Hopefully that's helpful.

  20. added a commit that references this issue on Jan 16, 2026
  21. added a commit that references this issue on Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.I-lang-radarItems that are on lang's radar and will need eventual work or consideration.P-lang-drag-0Lang team prioritization drag level 0.https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamregression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions