diff --git a/compiler/rustc_query_impl/src/execution.rs b/compiler/rustc_query_impl/src/execution.rs index 27b6214ed2887..1ebc8a1969103 100644 --- a/compiler/rustc_query_impl/src/execution.rs +++ b/compiler/rustc_query_impl/src/execution.rs @@ -270,7 +270,16 @@ fn wait_for_query<'tcx, C: QueryCache>( (v, Some(index)) } - Err(cycle) => (mk_cycle(query, tcx, cycle.lift()), None), + Err(mut cycle) => { + if let Some(def_id) = key.key_as_def_id() { + if let Some(pos) = cycle.cycle.iter().position(|entry| { + entry.frame.dep_kind == query.dep_kind && entry.frame.def_id == Some(def_id) + }) { + cycle.cycle.rotate_left(pos); + } + } + (mk_cycle(query, tcx, cycle.lift()), None) + } } } diff --git a/tests/ui/parallel-rustc/fn-sig-cycle-ice-153391.rs b/tests/ui/parallel-rustc/fn-sig-cycle-ice-153391.rs new file mode 100644 index 0000000000000..71b14ddb22aad --- /dev/null +++ b/tests/ui/parallel-rustc/fn-sig-cycle-ice-153391.rs @@ -0,0 +1,17 @@ +// Regression test for #153391. +// +//@ edition:2024 +//@ compile-flags: -Z threads=16 +//@ compare-output-by-lines + +trait A { + fn g() -> B; + //~^ ERROR expected a type, found a trait +} + +trait B { + fn bar(&self, x: &A); + //~^ ERROR expected a type, found a trait +} + +fn main() {} diff --git a/tests/ui/parallel-rustc/fn-sig-cycle-ice-153391.stderr b/tests/ui/parallel-rustc/fn-sig-cycle-ice-153391.stderr new file mode 100644 index 0000000000000..b6f8eb3810c56 --- /dev/null +++ b/tests/ui/parallel-rustc/fn-sig-cycle-ice-153391.stderr @@ -0,0 +1,30 @@ +error[E0782]: expected a type, found a trait + | +LL | fn bar(&self, x: &A); + | ^ + | + = note: `A` is dyn-incompatible, otherwise a trait object could be used +help: use a new generic type parameter, constrained by `A` + | +LL - fn bar(&self, x: &A); +LL + fn bar(&self, x: &T); + | +help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference + | +LL | fn bar(&self, x: &impl A); + | ++++ + +error[E0782]: expected a type, found a trait + --> $DIR/fn-sig-cycle-ice-153391.rs:8:15 + | +LL | fn g() -> B; + | ^ + | + | +LL | fn g() -> impl B; + | ++++ + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0782`. \ No newline at end of file