Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed length array type with extremely high count causes excessive compile time #15918

Closed
lilyball opened this issue Jul 23, 2014 · 5 comments
Closed
Labels
I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@lilyball
Copy link
Contributor

A local variable with a fixed-length array type with an excessively. This is true even if there's no initializer expression.

fn main() {
    let x: [uint, ..18446744073709551615];
}

I haven't profiled to figure out what the compiler is actually doing. I also have no idea how long this actually runs for; I ended up killing rustc after about 30 seconds.

@thestinger thestinger added the I-compiletime Issue: Problems and improvements with respect to compile times. label Sep 16, 2014
@bluss
Copy link
Member

bluss commented May 7, 2015

This doesn't compile anymore:

error: the type `[usize; 18446744073709551615]` is too big for the current architecture
fn main() {
    let x: [usize; 18446744073709551615];
}

The largest rustc allows is a size of 2^46. It compiles fine, in short time!

fn main() {
    let x: [u8; 1 << 46];
}

@lilyball
Copy link
Contributor Author

This is still a problem with zero-sized types if you have an initializer:

fn main() {
    let x = [(); 18446744073709551615];
}

I let it run for 10 seconds before killing it.

@bluss
Copy link
Member

bluss commented May 14, 2015

Weird, I can't reproduce that. I tried different options like optimization or not, debug info or not.

rustc 1.1.0-nightly (4b88e8f63 2015-05-11) (built 2015-05-12)
binary: rustc
commit-hash: 4b88e8f63eeaf557c916a0a1e73150b028c44c52
commit-date: 2015-05-11
build-date: 2015-05-12
host: x86_64-unknown-linux-gnu
release: 1.1.0-nightly

@lilyball
Copy link
Contributor Author

@bluss Oops, my bad. It's hanging on running the program, not compiling it.

@huonw
Copy link
Member

huonw commented Jan 5, 2016

This seems to be (mostly) expected: without optimisations the very large initializer compiles to a (no-op) loop, which would be setting each element if they needed any setting.

.LBB0_1:
    movq    -16(%rsp), %rax
    addq    $1, %rax
    cmpq    $-1, %rax
    movq    %rax, -16(%rsp)
    jb  .LBB0_1

With optimisations this is of course eliminated. But compile times are very fast in either case, so I'm closing.

@huonw huonw closed this as completed Jan 5, 2016
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 21, 2024
Expand lint tables && make clippy happy 🎉

This PR expands the lint tables on `./Cargo.toml` and thereby makes `cargo clippy` exit successfully! 🎉

Fixes rust-lang#15918

## How?

In the beginning there are some warnings for rustc.

Next, and most importantly, there is the clippy lint table. There are a few sections in there.

First there are the lint groups.

Second there are all lints which are permanently allowed with the reasoning why they are allowed.

Third there is a huge list of temporarily allowed lints. They should be removed in the mid-term, but incur a substantial amount of work, therefore they are allowed for now and can be worked on bit by bit.

Fourth there are all lints which should warn.

Additionally there are a few allow statements in the code for lints which should be permanently allowed in this specific place, but not in the whole code base.

## Follow up work
- [ ] Run clippy in CI
- [ ] Remove tidy test (at least `@Veykril` wrote this in rust-lang#15017)
- [ ] Work on temporarily allowed lints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
Development

No branches or pull requests

4 participants