Skip to content

struct Foo(Self) leads to infinite loop #79437

Closed
@SOF3

Description

@SOF3

I tried this code:

use std::io::{Read, Seek, Write};

pub struct ShallowTees<R: Read + Seek, W: Write> {
    read: R,
    write: W,
}

impl<R: Read + Seek, W: Write> ShallowTees<R, W> {

    pub fn tee_take(&mut self, limit: u64) -> impl Read + Seek {
        struct Take(Self);
        Take(self)
    }
}

fn main() {}

Running rustc main.rs does not terminate after a long time. After running for 4 minutes, the rustc process is using 99.2% CPU and about 80 MB memory.

Meta

rustc --version --verbose:

rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-hangIssue: The compiler never terminates, due to infinite loops, deadlock, livelock, etc.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions