Skip to content

Worse error message with TAIT + next_solver #162093

Description

@Dirbaio

Code

#![feature(type_alias_impl_trait)]

#[diagnostic::on_unimplemented(message = "my custom message")]
trait Marker {}

type Ta = impl Marker;

#[define_opaque(Ta)]
fn construct() -> Ta {
    5u32
}

fn main() {}

Current output

error[E0271]: type mismatch resolving `Ta == u32`
 --> src/main.rs:9:19
  |
9 | fn construct() -> Ta {
  |                   ^^ types differ

Desired output

error[E0277]: my custom message
  --> src/main.rs:9:19
   |
 9 | fn construct() -> Ta {
   |                   ^^ the trait `Marker` is not implemented for `u32`
10 |     5u32
   |     ---- return type was inferred to be `u32` here

Rationale and extra context

With the old solver you would get the good error message "u32 doesn't implement Marker".

With the new solver it's just a type mismatch, no indication why.

A consequence of this is the #[on_unimplemented] message is not shown to the user. We were using it in embassy-executor to give better error messages, see here.

Other cases

Rust Version

rustc 1.100.0-nightly (c656540d6 2026-08-21)
binary: rustc
commit-hash: c656540d6467dee1381f0cbd882412d6bd1cd5ae
commit-date: 2026-08-21
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Anything else?

No response

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions