Skip to content

query cycle: specialisation cycle detected when building specialization graph of trait #119344

@matthiaskrgr

Description

@matthiaskrgr

Code

#![feature(specialization)] trait Trait<T> { type Assoc; } impl<T> Trait<T> for Vec<T> {} impl Trait<u8> for Vec<u32> { type Assoc = u8; } impl<T> Trait<T> for String { type Assoc = (); } impl Trait<<Vec<u8> as Trait<u8>>::Assoc> for String {} fn main() {}

Current output

warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes --> 43273EB829A15349E16F5931020795BF70C210EEDA25D591DFCCF621A1677EA0.rs:1:12 | 1 | #![feature(specialization)] | ^^^^^^^^^^^^^^ | = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default error[E0391]: cycle detected when building specialization graph of trait `Trait` --> 43273EB829A15349E16F5931020795BF70C210EEDA25D591DFCCF621A1677EA0.rs:3:1 | 3 | trait Trait<T> { | ^^^^^^^^^^^^^^ | = note: ...which immediately requires building specialization graph of trait `Trait` again note: cycle used when coherence checking all impls of trait `Trait` --> 43273EB829A15349E16F5931020795BF70C210EEDA25D591DFCCF621A1677EA0.rs:3:1 | 3 | trait Trait<T> { | ^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0391`.

Desired output

We should have a proper diagnostic here pointing out where the cyclic problem is

Rationale and extra context

cc #119321

Other cases

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsF-specialization`#![feature(specialization)]`I-cycleIssue: A query cycle occurred while none was expectedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions