I have some weird code I was using as a workaround for #17893 (comment) but it stopped compiling on the latest nightly. Using -Znext-solver=coherence makes it compile again so it's presumably because of #160895.
I tried to minimize it below:
Code
I tried this code:
#![feature(arbitrary_self_types, derive_coerce_pointee)]
#![allow(dead_code)]
use core::marker::{CoercePointee, PhantomData};
use std::ops::Deref;
#[derive(CoercePointee)]
#[repr(transparent)]
struct Ref<#[pointee] T: ?Sized, D: ?Sized + GenericTrait<D>> {
ptr: Box<T>,
phantom: PhantomData<D>,
}
impl<T: ?Sized, D: ?Sized + GenericTrait<D>> Deref for Ref<T, D> {
type Target = T;
fn deref(&self) -> &T {
&self.ptr
}
}
trait GenericTrait<D: ?Sized + GenericTrait<D>> {}
trait MyTrait {
fn causes_cycle(self: Ref<Self, dyn MyTrait>);
}
impl GenericTrait<dyn MyTrait> for dyn MyTrait {}
fn main() {}
I expected to see this happen: compiles, as it does with -Znext-solver=coherence
Instead, this happened:
error[E0391]: cycle detected when checking if trait `MyTrait` is dyn-compatible
--> src\main.rs:22:1
|
22 | trait MyTrait {
| ^^^^^^^^^^^^^
|
= note: ...which requires determining dyn-compatibility of trait `MyTrait`...
= note: ...which again requires checking if trait `MyTrait` is dyn-compatible, completing the cycle
note: cycle used when coherence checking all impls of trait `GenericTrait`
--> src\main.rs:20:1
|
20 | trait GenericTrait<D: ?Sized + GenericTrait<D>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: for more information, see <https://rustc-dev-guide.rust-lang.org/overview.html#queries> and <https://rustc-dev-guide.rust-lang.org/query.html>
Version it worked on
Same as below but with -Znext-solver=coherence
Version with regression
rustc 1.100.0-nightly (c656540d6 2026-08-21)
binary: rustc
commit-hash: c656540d6467dee1381f0cbd882412d6bd1cd5ae
commit-date: 2026-08-21
host: x86_64-pc-windows-msvc
release: 1.100.0-nightly
LLVM version: 23.1.0
I have some weird code I was using as a workaround for #17893 (comment) but it stopped compiling on the latest nightly. Using
-Znext-solver=coherencemakes it compile again so it's presumably because of #160895.I tried to minimize it below:
Code
I tried this code:
I expected to see this happen: compiles, as it does with
-Znext-solver=coherenceInstead, this happened:
Version it worked on
Same as below but with
-Znext-solver=coherenceVersion with regression