-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-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.
Description
The following test takes an exponential amount of time to type-check the body of huge
(at the time of this writing, reported by -Z time-passes
under "item-types checking"):
#![crate_type = "lib"]
pub fn unit() -> std::iter::Empty<()> {
std::iter::empty()
}
macro_rules! nest {
($inner:expr) => (unit().flat_map(|_| {
$inner
}).flat_map(|_| unit()))
}
macro_rules! nests {
() => (unit());
($_first:tt $($rest:tt)*) => (nest!(nests!($($rest)*)))
}
pub fn huge() -> impl Iterator<Item = ()> {
nests! {
// 1/x * 6/5 seconds.
4096 2048 1024 512 256 128 64 32 16 8 4 2
// x * 6/5 seconds.
1 2 4 8 // 16 32 64
}
}
This has been reduced from an ambiguity-aware parse tree visitor, and you can see a partial reduction here: https://gist.github.com/eddyb/5f20b8f48b68c92f7d4f022a18c374f4#file-repro-rs.
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-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.