Unexpected `WARN` log in diagnostic output: "rustc_infer::infer::relate::generalize may incompletely handle alias type"
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
trait ToUnit<'a> {
type Unit;
}
trait Overlap<T> {}
type Assoc<'a, T, A> = <T as ToUnit<'a, >>::Unit;
impl<T> Overlap<T> for T {}
impl<T, a> Overlap<for<'a> fn(&'a (), Assoc<'a, T, T>)> for T {}
fn main() {}
Current output
warning: type parameter `a` should have an upper camel case name
--> ./test.rs:13:9
|
13 | impl<T, a> Overlap<for<'a> fn(&'a (), Assoc<'a, T, T>)> for T {}
| ^ help: convert the identifier to upper camel case: `A`
|
= note: `#[warn(non_camel_case_types)]` on by default
error[E0091]: type parameter `A` is never used
--> ./test.rs:9:19
|
9 | type Assoc<'a, T, A> = <T as ToUnit<'a, >>::Unit;
| ^ unused type parameter
|
= help: consider removing `A` or referring to it in the body of the type alias
= help: if you intended `A` to be a const parameter, use `const A: /* Type */` instead
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:17 ~ test[c024]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ test[c024]::ToUnit::Unit), .. }
error[E0207]: the type parameter `a` is not constrained by the impl trait, self type, or predicates
--> ./test.rs:13:9
|
13 | impl<T, a> Overlap<for<'a> fn(&'a (), Assoc<'a, T, T>)> for T {}
| ^ unconstrained type parameter
error: aborting due to 2 previous errors; 1 warning emitted
Some errors have detailed explanations: E0091, E0207.
For more information about an error, try `rustc --explain E0091`.
Desired output
Rationale and extra context
I'm not sure if this WARN log needs to be shown to users, but if it does, it should appear in the formatted style of compiler diagnostics rather than as a confusing internal log.
Other cases
Rust Version
rustc 1.88.0-nightly (e643f59f6 2025-04-07)
binary: rustc
commit-hash: e643f59f6da3a84f43e75dea99afaa5b041ea6bf
commit-date: 2025-04-07
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the provided Rust snippet with the stated rustc 1.88.0-nightly version and inspect the rustc_infer::infer::relate::generalize path associated with the warning. Determine whether the internal WARN should be suppressed or emitted as a formatted compiler diagnostic, then verify that the unexpected log no longer appears or is presented in the intended diagnostic form.
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
- Needs clarification
- Newbie friendliness
- 25/100