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

Treating DST constructor as a function aborts compiler #30276

Closed
Stebalien opened this issue Dec 9, 2015 · 11 comments · Fixed by #71710
Closed

Treating DST constructor as a function aborts compiler #30276

Stebalien opened this issue Dec 9, 2015 · 11 comments · Fixed by #71710
Labels
A-dst Area: Dynamically Sized Types C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Stebalien
Copy link
Contributor

Aborts (no backtrace):

struct Test([i32]);
fn main() {
  let x = Test;
}

With:

rustc: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:995: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.

Forked from: #30240.

@Stebalien
Copy link
Contributor Author

According to @Aatch,

The last error is the most complex as it's a weird case of struct Test([i32]) being a perfectly valid type, but fn([i32]) -> Test not being a valid function. We probably need to check whether you're forcing the creation of an invalid function and error somewhere earlier. That's where the error comes from, btw, the creation of the fn Test(_0: [i32]) -> Test { ... } function body.

@Stebalien Stebalien changed the title Treating DST constructor as a function panics. Treating DST constructor as a function aborts compiler Dec 9, 2015
@Aatch
Copy link
Contributor

Aatch commented Dec 9, 2015

The minimum reproduction is this:

struct Test([i32]);
fn main() {
  let x = Test;
}

Just to show that it's not got anything to do with taking a reference.

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 9, 2015
@Stebalien
Copy link
Contributor Author

@Aatch, updated.

bltavares added a commit to bltavares/glacier that referenced this issue Jan 15, 2016
@huonw huonw added the A-dst Area: Dynamically Sized Types label Feb 5, 2016
@steveklabnik
Copy link
Member

This no longer ICEs!

@eddyb
Copy link
Member

eddyb commented Mar 14, 2016

@steveklabnik Not so fast:

struct Test([i32]);
fn main() {
  let x: fn(_) -> Test = Test;
}

Reification is now lazy, Test itself is a zero-sized function item.

@eddyb eddyb reopened this Mar 14, 2016
@nikomatsakis
Copy link
Contributor

cc me

@Stebalien
Copy link
Contributor Author

This appears to have been fixed.

@eddyb eddyb added the E-needs-test Call for participation: Writing correctness tests. label Jun 18, 2016
Stebalien added a commit to Stebalien/rust that referenced this issue Jun 18, 2016
Make sure that treating a DST tuple constructor as a function doesn't ICE.

Closes rust-lang#30276
bors added a commit that referenced this issue Jun 19, 2016
Add test case for #30276

Make sure that treating a DST tuple constructor as a function doesn't ICE.

Closes #30276
@eddyb
Copy link
Member

eddyb commented Oct 28, 2017

This shouldn't have been "fixed", hiding the ICE only happened by accident (#45225 unhides it).

@bjorn3
Copy link
Member

bjorn3 commented Apr 30, 2019

error[E0277]: the size for values of type `[i32]` cannot be known at compilation time
--> src/main.rs:3:36
  |
3 | fn main() { let x: fn(_) -> Test = Test; }
  |                                    ^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `std::marker::Sized` is not implemented for `[i32]`
  = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
  = note: all function arguments must have a statically known size
  = help: unsized locals are gated as an unstable feature

error: aborting due to previous error

Rustc now errors on unsized locals being feature gated.

@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 10, 2020
@workingjubilee
Copy link
Contributor

No longer ICEs (again), but correctly refuses to compile on nightly even with #![feature(unsized_locals)]. Test was removed previously, should the test be brought back, then?

@nikomatsakis
Copy link
Contributor

@workingjubilee seems like yes!

@bors bors closed this as completed in a9eb01a May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dst Area: Dynamically Sized Types C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.