rust-lang / rust-lang/rust

Diagnostics regressed with 1.92.0

Open
#150,017 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-bug D-verbose needs-triage P-medium regression-from-stable-to-stable T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code

I tried this code:

use diesel::*; // 2.3.4, features = ["postgres", "sqlite"] 

table! {
    posts {
        id -> Integer,
        user_id -> Integer,
        hair_color -> Text,
    }
}

fn main() {
    let mut conn = PgConnection::establish("").unwrap();

    let _ = posts::table
        .group_by(posts::user_id)
        .distinct_on(posts::id)
        .select(posts::user_id)
        .get_results::<i32>(&mut conn);

    println!("Hello, world!");
}

I expected to see this happen: Code emits a clean helpful error message like on 1.91.0:

error[E0277]: the trait bound `SelectStatement<..., ..., ..., ..., ..., ..., ...>: DistinctOnDsl<_>` is not satisfied
  --> src/main.rs:18:10
   |
18 |         .distinct_on(posts::id)
   |          ^^^^^^^^^^^ the trait `DistinctOnDsl<_>` is not implemented for `SelectStatement<FromClause<table>, ..., ..., ..., ..., ..., ...>`
   |
   = note: a `DISTINCT ON` clause is not compatible with various other clauses like `LOCKING` clauses
   = note: a `DISTINCT ON` clause also disallows mixing aggregate and non-aggregate expressions with the `SELECT` clause
   = help: the trait `DistinctOnDsl<Selection>` is implemented for `SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H>`
   = note: the full name for the type has been written to '/tmp/diesel_testing/target-bisector-nightly-2025-09-13-x86_64-unknown-linux-gnu/debug/deps/diesel_testing-a6733609d42d5652.long-type-11794557765803509610.txt'
   = note: consider using `--verbose` to print the full type name to the console

Instead, this happened: Code emits a second non-helpful could not infer type error:

error[E0277]: the trait bound `SelectStatement<..., ..., ..., ..., ..., ..., ...>: DistinctOnDsl<_>` is not satisfied
  --> src/main.rs:18:10
   |
18 |         .distinct_on(posts::id)
   |          ^^^^^^^^^^^ the trait `DistinctOnDsl<_>` is not implemented for `SelectStatement<FromClause<table>, ..., ..., ..., ..., ..., ...>`
   |
   = note: a `DISTINCT ON` clause is not compatible with various other clauses like `LOCKING` clauses
   = note: a `DISTINCT ON` clause also disallows mixing aggregate and non-aggregate expressions with the `SELECT` clause
   = help: the trait `DistinctOnDsl<Selection>` is implemented for `SelectStatement<FromClause<F>, S, D, W, O, LOf, G, H>`
   = note: the full name for the type has been written to '/tmp/diesel_testing/target-bisector-nightly-2025-10-24-x86_64-unknown-linux-gnu/debug/deps/diesel_testing-a6733609d42d5652.long-type-11312178195105605609.txt'
   = note: consider using `--verbose` to print the full type name to the console

error[E0282]: type annotations needed
  --> src/main.rs:16:13
   |
16 |       let _ = posts::table
   |  _____________^
17 | |         .group_by(posts::user_id)
18 | |         .distinct_on(posts::id)
   | |_______________________________^ cannot infer type


To be clear here: It's a regression in what users see, but it's not critically bad. It would be nicer to not have the second error, but if that's not possible for whatever reasons it might be OK to live with it.

Version it worked on

It most recently worked on: 1.91.0

Version with regression

rustc --version --verbose:

rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3

cargo bisect-rustc points to https://github.com/rust-lang/rust/commit/54a8a1db604e4caff93e26e167ad4a6fde9f068, so this was introduced in https://github.com/rust-lang/rust/pull/146885. (cc @lcnr)

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Diesel reproducer in the issue and compare rustc 1.91.0 with 1.92.0. Investigate the diagnostic change introduced by commit 54a8a1db604e4caff93e26e167ad4a6fde9f068, then verify that the regression no longer emits the additional type-inference error while retaining the helpful primary diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.