-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Closed
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.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
I have:
- A struct
CodePoint
with aconst fn from(...) -> Self
constructor - A large number of
CodePoint
constants (42.000+) using the constructor
#[repr(transparent)]
pub struct CodePoint {
raw: u32
}
impl CodePoint {
pub const fn from(raw: u32) -> Self {
// debug_assert!(raw <= 0x10FFFF);
CodePoint { raw }
}
}
// include!(...)
// 42508 constants, 3.28MB file
impl CodePoint {
pub const SPACE : CodePoint = CodePoint::from(32u32);
...
}
Building this leads to:
- Compiler busy for 2min+
- Compiler error trying to allocate 1.2GB:
memory allocation of 1207959552 bytes failed
even though I have 12GB of unused RAM
Using struct expressions instead of a const fn
constructor:
impl CodePoint {
pub const SPACE : CodePoint = CodePoint { raw: 32u32 };
...
}
- Compiler finishes within 5s.
Tested on nightly
and stable
, with include!(...)
and copy-pasting: no differences.
Source file to reproduce: reproduce.zip
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.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.