Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
matthiaskrgr opened this issue Dec 27, 2023 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-specialization `#![feature(specialization)]` I-cycle Issue: A query cycle occurred while none was expected T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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

@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-specialization `#![feature(specialization)]` labels Dec 27, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 27, 2023
@compiler-errors
Copy link
Member

specialization is not expected to ever be stabilized, for the record

@matthiaskrgr
Copy link
Member Author

Should we mark it as internal then?

@fmease fmease added I-cycle Issue: A query cycle occurred while none was expected and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints F-specialization `#![feature(specialization)]` I-cycle Issue: A query cycle occurred while none was expected T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants