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

Unsized tuples shouldn't compile #34451

Closed
alecmocatta opened this issue Jun 24, 2016 · 9 comments
Closed

Unsized tuples shouldn't compile #34451

alecmocatta opened this issue Jun 24, 2016 · 9 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@alecmocatta
Copy link
Contributor

alecmocatta commented Jun 24, 2016

rustc 1.11.0-nightly (5522e678b 2016-06-20)
binary: rustc
commit-hash: 5522e678bcefe14cc2ab3d0ab329b7059ce52b36
commit-date: 2016-06-20
host: x86_64-unknown-linux-gnu
release: 1.11.0-nightly
   Compiling shared v0.1.0 (file:///rust)
     Running `rustc /rust/src/lib.rs --crate-name shared --crate-type lib -g --cfg feature=\"job_network\" --cfg feature=\"network\" -C metadata=4a7ff01c4e736677 -C extra-filename=-4a7ff01c4e736677 --out-dir /platform/src/target/debug/deps --emit=dep-info,link -L dependency=/platform/src/target/debug/deps -L dependency=/platform/src/target/debug/deps --extern libc=/platform/src/target/debug/deps/liblibc-6b483f9a7097e9a4.rlib --extern num_cpus=/platform/src/target/debug/deps/libnum_cpus-b50c8a4bade044aa.rlib --extern network=/platform/src/target/debug/deps/libnetwork-185a522f56e53476.rlib --extern time=/platform/src/target/debug/deps/libtime-750bfdd52feafcb7.rlib --extern tenacious=/platform/src/target/debug/deps/libtenacious-02abd60f9f387669.so -L native=/platform/src/target/debug/build/network-7ccf86279f1eaf03/out`
error: internal compiler error: ../src/librustc_trans/type_of.rs:143: size differs (rustc: 8, llvm: 24) for type `(usize, [&[u8]])` / Univariant {
    variant: Struct {
        align: Align {
            raw: 51
        },
        packed: false,
        sized: false,
        offset_after_field: [
            Size {
                raw: 8
            },
            Size {
                raw: 8
            }
        ]
    },
    non_zero: false
}
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:584
stack backtrace:
   1:     0x7f1e5587c62f - std::sys::backtrace::tracing::imp::write::h6528da8103c51ab9
   2:     0x7f1e5588a2ab - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hbe741a5cc3c49508
   3:     0x7f1e55889e48 - std::panicking::default_hook::he0146e6a74621cb4
   4:     0x7f1e5585016e - std::panicking::rust_panic_with_hook::h983af77c1a2e581b
   5:     0x7f1e50bffa67 - std::panicking::begin_panic::hf9f206df23a555af
   6:     0x7f1e50bff3ce - syntax::errors::Handler::bug::hd25802f012f6858b
   7:     0x7f1e51e42b84 - rustc::session::opt_span_bug_fmt::_$u7b$$u7b$closure$u7d$$u7d$::h083e19915ee66466
   8:     0x7f1e51e4298d - rustc::session::opt_span_bug_fmt::h157ddeb5b4622d22
   9:     0x7f1e51e5d366 - rustc::session::bug_fmt::h166f9667daf4dd54
  10:     0x7f1e5328f6bf - rustc_trans::type_of::sizing_type_of::hf1ac5f8b6f66decc
  11:     0x7f1e5328bbb9 - rustc_trans::abi::FnType::unadjusted::hdf4ab7ff60d3c827
  12:     0x7f1e5329a292 - rustc_trans::type_of::in_memory_type_of::h8a5b5f0d28dddacd
  13:     0x7f1e5330068c - rustc_trans::callee::get_fn::hc9dd3345932f2570
  14:     0x7f1e532a69cb - rustc_trans::callee::Callee::def::hc7f23805201545e4
  15:     0x7f1e532d19fc - rustc_trans::base::trans_item::hca2904a0eb6b2a6f
  16:     0x7f1e532e9643 - _<rustc_trans..base..TransItemsWithinModVisitor<'a, 'tcx> as rustc..hir..intravisit..Visitor<'v>>::visit_item::hc86f557d139a067e
  17:     0x7f1e532e7bcf - rustc::hir::intravisit::walk_item::he9a143fadf3af5d7
  18:     0x7f1e532da3f4 - rustc_trans::base::trans_crate::h999c47a06d45abea
  19:     0x7f1e55db9eff - rustc_driver::driver::phase_4_translate_to_llvm::had910d0e745bc40f
  20:     0x7f1e55db7d8d - rustc_driver::driver::compile_input::_$u7b$$u7b$closure$u7d$$u7d$::hf187cb470aad2bf2
  21:     0x7f1e55db44ed - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::hd565ad56c5876a16
  22:     0x7f1e55dadcb9 - rustc::ty::context::TyCtxt::create_and_enter::habef58c7230d34f9
  23:     0x7f1e55d770af - rustc_driver::driver::compile_input::hfd60b020f6d0208d
  24:     0x7f1e55d630a4 - rustc_driver::run_compiler::h884d01d12eb76bbb
  25:     0x7f1e55d6017e - std::panicking::try::call::hd72cf79141f67e60
  26:     0x7f1e5589876b - __rust_try
  27:     0x7f1e5589870e - __rust_maybe_catch_panic
  28:     0x7f1e55d60c64 - _<F as alloc..boxed..FnBox<A>>::call_box::h589d2091babf223a
  29:     0x7f1e558883d4 - std::sys::thread::Thread::new::thread_start::h9c883b6d445ece46
  30:     0x7f1e4d3916f9 - start_thread
  31:     0x7f1e554ceb5c - clone
  32:                0x0 - <unknown>

error: Could not compile `shared`.

Caused by:
  Process didn't exit successfully: `rustc /rust/src/lib.rs --crate-name shared --crate-type lib -g --cfg feature="job_network" --cfg feature="network" -C metadata=4a7ff01c4e736677 -C extra-filename=-4a7ff01c4e736677 --out-dir /platform/src/target/debug/deps --emit=dep-info,link -L dependency=/platform/src/target/debug/deps -L dependency=/platform/src/target/debug/deps --extern libc=/platform/src/target/debug/deps/liblibc-6b483f9a7097e9a4.rlib --extern num_cpus=/platform/src/target/debug/deps/libnum_cpus-b50c8a4bade044aa.rlib --extern network=/platform/src/target/debug/deps/libnetwork-185a522f56e53476.rlib --extern time=/platform/src/target/debug/deps/libtime-750bfdd52feafcb7.rlib --extern tenacious=/platform/src/target/debug/deps/libtenacious-02abd60f9f387669.so -L native=/platform/src/target/debug/build/network-7ccf86279f1eaf03/out` (exit code: 101)

Small testcase here.

@jonas-schievink
Copy link
Contributor

cc @eddyb

@eddyb
Copy link
Member

eddyb commented Jun 24, 2016

Unsized tuples are not implemented yet, did we choose to allow them prematurely? cc @arielb1

@apasel422 apasel422 added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jun 24, 2016
@Mark-Simulacrum
Copy link
Member

Small testcase compiles without errors. E-needstest.

trait A {
	fn b(&self);
}
impl<'c> A for (usize,[&'c [u8]]) {
	fn b(&self) {
	    0;
	}
}

fn main() {}

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 6, 2017
@eddyb
Copy link
Member

eddyb commented May 6, 2017

No, it shouldn't compile, I just don't think we ever bothered banning it.
An ICE not triggering on this example is accidental.

@Mark-Simulacrum Mark-Simulacrum removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 6, 2017
@Mark-Simulacrum
Copy link
Member

Removing E-needstest. @eddyb That seems.. bad. Is that just because in this case the type isn't really used anywhere?

@Mark-Simulacrum Mark-Simulacrum changed the title ICE on impl<'a> A for (usize,[&'a [u8]]) Unsized tuples shouldn't compile May 6, 2017
@eddyb
Copy link
Member

eddyb commented May 6, 2017

The ICE here is a mismatch between LLVM's view of the type and ours but the LLVM type is computed in such a way that I don't think that mismatch is ever possible. Some operations might still ICE.

bors added a commit that referenced this issue Jun 29, 2017
Unsized tuple coercions

Part of #18469. Fixes #32702.

#37685 and #34451 might also be related.

This PR does the following:

- Introduce explicit `Sized` constraints on tuple initializers, similar to that of record-struct initializers. Not much relevant to the main contribution but I noticed this when making tests for unsized tuple coercions.
- Implement `(.., T): Unsize<(.., U)>` where `T: Unsize<U>`.
- Assume `(.., T)` is MaybeUnsizedUnivariant.
- Modify `src/librustc/ty/util.rs` and `src/librustc_trans/glue.rs` so that tuples and structs are uniformly traversed when translating.
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: still compiles without error.

@eddyb
Copy link
Member

eddyb commented Sep 27, 2018

I think unsized tuples are implemented now. cc @nikomatsakis

@alecmocatta
Copy link
Contributor Author

This has compiled for a while now. Unsized tuples are being exercised, incl by tests related to #42877. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants