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

Tuples with multiple unsized types shouldn't be valid #31426

Closed
tomaka opened this issue Feb 5, 2016 · 4 comments
Closed

Tuples with multiple unsized types shouldn't be valid #31426

tomaka opened this issue Feb 5, 2016 · 4 comments
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tomaka
Copy link
Contributor

tomaka commented Feb 5, 2016

This code should trigger a compilation error because [u8] isn't sized:

fn test(t: &([u8], [u16])) -> &[u16] {
    &t.1
}

Instead it triggers an LLVM assertion error:

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

(playpen)

@tomaka tomaka changed the title Tuples with unsized types shouldn't be valid Tuples with multiple unsized types shouldn't be valid Feb 5, 2016
@tomaka
Copy link
Contributor Author

tomaka commented Feb 5, 2016

We had a debate on IRC whether or not tuples with multiple unsized types shoud be allowed at all.
For the moment they work as long as you don't use instantiate them (they can be useful for metaprogramming purposes). But it's ambiguous whether they are supposed to work.

@huonw
Copy link
Member

huonw commented Feb 5, 2016

Related to #30276.

@huonw huonw added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-DSTs Area: Dynamically-sized types (DSTs) labels Feb 5, 2016
@tomaka
Copy link
Contributor Author

tomaka commented May 14, 2016

Also related to rust-lang/rfcs#1592

@Mark-Simulacrum
Copy link
Member

This no longer ICEs, and gives the following error, which is correct: closing.

error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied
 --> test.rs:1:1
  |
1 | / fn test(t: &([u8], [u16])) -> &[u16] {
2 | |     &t.1
3 | | }
  | |_^ the trait `std::marker::Sized` is not implemented for `[u8]`
  |
  = note: `[u8]` does not have a constant size known at compile-time
  = note: tuple elements must have `Sized` type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants