Repository navigation
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-trait_alias`#![feature(trait_alias)]``#![feature(trait_alias)]`I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
I tried this code:
#![feature(trait_alias)]
#![feature(impl_trait_in_assoc_type)]
trait Foo {
type Bar: Baz<Self, Self>;
fn bar(&self) -> Self::Bar;
}
struct X;
impl Foo for X {
type Bar = impl Baz<Self, Self>;
fn bar(&self) -> Self::Bar {
|x| x
}
}
trait Baz<A: ?Sized, B: ?Sized> = Baz(&A) -> &B;
fn main() {}It mutates from the following file, but the following code will not cause a hang.
#![feature(trait_alias)]
#![feature(impl_trait_in_assoc_type)]
trait Foo {
type Bar: Baz<Self, Self>;
fn bar(&self) -> Self::Bar;
}
struct X;
impl Foo for X {
type Bar = impl Baz<Self, Self>;
fn bar(&self) -> Self::Bar {
|x| x
}
}
trait Baz<A: ?Sized, B: ?Sized> = Fn(&A) -> &B;
fn main() {}Also, I used impl_trait_in_assoc_type and Baz as search keywords but didn’t find any related issues with open.
Meta
rustc --version --verbose:
rustc 1.85.0-nightly (acabb5248 2024-12-04)
binary: rustc
commit-hash: acabb5248231987ae1f0c215208d1005a5db402d
commit-date: 2024-12-04
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5
Backtrace
<backtrace>
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.F-trait_alias`#![feature(trait_alias)]``#![feature(trait_alias)]`I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.Issue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Activity
cyrgani commentedon Dec 5, 2024
Reduced:
theemathas commentedon Dec 5, 2024
Minimized:
(Hangs without producing any errors or warnings. If the
foodefinition is moved after theBazdefinition, then there's a cycle error before the hang.)jieyouxu commentedon Dec 5, 2024
Triage notes:
hangs on stable (1.83) without the feature gate, which is a bit different from the other minimization which involves the feature gate
[-]Hang[/-][+]Hang from infinitely-self-recursive trait alias[/+]jieyouxu commentedon Dec 5, 2024
I feel like this probably is already reported but I can't find an earlier report.
lqd commentedon Dec 5, 2024
I had the same feeling, we have many reports of superficially similar looking hangs. It could be interesting to bisect this one though, because this looks like a somewhat recent regression (from 1.78).
lqd commentedon Dec 10, 2024
bisects to
nightly-2024-03-09collect_mod_item_typesquery intocheck_well_formed#121500 - oli-obk:track_errors12, r=petrochenkovlqd commentedon Dec 10, 2024
backtrace looks to be in wf checks so I'll just soft ping @oli-obk for #121500, but other PRs and rollups on that nightly also changed related codepaths in
rustc_hir_analysis.oli-obk commentedon Dec 19, 2024
Trying to debug locally it got stuck in the debug-assert-only validation happening in
Binder::bind_with_vars😆oli-obk commentedon Dec 19, 2024
Ok, so it's not an infinite recursion, just an infinite loop growing a value linearly that is then fully visited a few times. Elaboration goes as follows:
T: Baz<i32>-> add implied boundsT: Baz<Option<A>>-> instantiate ->T: Baz<Option<i32>>-> add implied boundsT: Baz<Option<Options<A>>>-> ...Auto merge of rust-lang#134504 - oli-obk:push-rltsvnyttwll, r=compile…