Skip to content

rustc hangs and leaks memory #79714

Closed
@is8ac

Description

@is8ac

In stable, rustc 1.48.0 (7eac88abb 2020-11-16), rustc demo.rs promptly returns overflow evaluating the requirement and exits. This is expected behavior.

In nightly, rustc 1.50.0-nightly (5be3f9f10 2020-12-03), rustc demo.rs hangs indefinitely, using 100% of one core. Memory usage fluctuates but tends to grow over time at ~800 MB per minute on my machine.

Source

pub trait Baz {}
impl Baz for () {}
impl<T> Baz for [T; 3] {}

pub trait Fiz {}
impl Fiz for bool {}

pub trait Corge<S> {
    type Foo;
}

impl<W: Corge<()>> Corge<[(); 3]> for W {
    type Foo = [<W as Corge<()>>::Foo; 3];
}

pub trait Grault
where
    Self::B: Fiz,
{
    type A;
    type B;
}

impl<T: Grault> Grault for [T; 3]
where
    Self::A: Baz,
    Self::B: Fiz,
{
    type A = [T::A; 3];
    type B = T::B;
}

pub trait Quaks<S, W> {
    fn bar() {}
}

impl<S> Quaks<S, bool> for u8
where
    bool: Corge<S>,
    <bool as Corge<S>>::Foo: Grault,
{
}

fn main() {
    <u8 as Quaks<[(); 3], bool>>::bar();
}

rustc --version --verbose:

rustc 1.50.0-nightly (5be3f9f10 2020-12-03)
binary: rustc
commit-hash: 5be3f9f10e9fd59ea03816840a6051413fbdefae
commit-date: 2020-12-03
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions