rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.11k stars 12.8k forks source link

Hang in item-bodies checking when dependency contains `pub use crate` #58430

Closed dtolnay closed 5 years ago

dtolnay commented 5 years ago

Compiling the following pair of crates hangs and chews up memory.

src/main.rs

fn main() {
    repro_dep::S.f();
}

dep/src/lib.rs

pub use crate as krate;
pub struct S;

Repro script:

#!/bin/bash

cargo new --bin repro
cargo new --lib repro-dep

echo >repro/src/main.rs '
fn main() {
    repro_dep::S.f();
}
'

echo >>repro/Cargo.toml '
repro-dep = { path = "../repro-dep" }
'

echo >repro-dep/src/lib.rs '
pub use crate as krate;
pub struct S;
'

cargo rustc --manifest-path repro/Cargo.toml -- -Ztime-passes

Mentioning @petrochenkov and @nikomatsakis who worked on #45477. Mentioning @nrc who hit this in a real project.

jonas-schievink commented 5 years ago

https://github.com/rust-lang/rust/issues/57500 is similar, so this might be a duplicate

petrochenkov commented 5 years ago

Same as https://github.com/rust-lang/rust/issues/55779, most probably.

dtolnay commented 5 years ago

Thanks, closing as a duplicate of #57500. #55779 seems somewhat different because it manifests as a compile time stack overflow rather than hang, but it is possible they will be addressed by the same fix.