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

check_match and slice bugginess #30240

Closed
Stebalien opened this issue Dec 6, 2015 · 2 comments
Closed

check_match and slice bugginess #30240

Stebalien opened this issue Dec 6, 2015 · 2 comments
Labels
A-dst Area: Dynamically Sized Types 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

I'm guessing these bugs are all related so I put them in one place.

Errors:

let & ref a =  &[0i32] as &[_]; // slice

With:

tmp.rs:5:9: 5:16 error: refutable pattern in local binding: `[]` not covered [E0005]
tmp.rs:5     let & ref a =  &[0i32] as &[_];

Panics:

let & ref a = "test";

With:

thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', ../src/librustc/middle/check_match.rs:653
stack backtrace:
   1:      0x328f56aa250 - sys::backtrace::tracing::imp::write::h2121cc3fd481a5bfxXt
   2:      0x328f56b0ed5 - panicking::log_panic::_<closure>::closure.41181
   3:      0x328f56b096f - panicking::log_panic::h274f0982d2d31f5d62x
   4:      0x328f5679823 - sys_common::unwind::begin_unwind_inner::ha197e3d3bf39738b4Ps
   5:      0x328f2fa39bf - sys_common::unwind::begin_unwind::begin_unwind::h3566019691569981035
   6:      0x328f2ff32aa - middle::check_match::is_useful::h109f9568fb97479esoj
   7:      0x328f30109ec - middle::check_match::is_useful_specialized::h1f87c7f149d4e543xxj
   8:      0x328f300f7a9 - middle::check_match::is_useful::_<closure>::closure.77994
   9:      0x328f300f4bc - option::_<impl>::map::map::h17883384761112421825
  10:      0x328f2ff3d1c - middle::check_match::is_useful::h109f9568fb97479esoj
  11:      0x328f3014715 - middle::check_match::check_irrefutable::he5695f1d8986f9aeGVj
  12:      0x328f2ff0171 - middle::check_match::check_local::h567799c10f5ef66byTj
  13:      0x328f2ff03a7 - middle::check_match::check_fn::h249cab818f405babpUj
  14:      0x328f2ff0605 - middle::check_match::check_crate::hfb67876efbdaaa5e6Ki
  15:      0x328f5bb4549 - driver::phase_3_run_analysis_passes::_<closure>::closure.25658
  16:      0x328f5b96773 - middle::ty::context::_<impl>::create_and_enter::create_and_enter::h17232051925259053486
  17:      0x328f5b91b2b - driver::phase_3_run_analysis_passes::h15745222629392362635
  18:      0x328f5b63659 - driver::compile_input::h999faf1b9f4a31e5hca
  19:      0x328f5b5575b - run_compiler::h6e3d729b9b1fcaeeLwc
  20:      0x328f5b52416 - sys_common::unwind::try::try_fn::try_fn::h16856740087359761980
  21:      0x328f56a7ee8 - __rust_try
  22:      0x328f569f7eb - sys_common::unwind::try::inner_try::ha6777f044d5d5f33CMs
  23:      0x328f5b52770 - boxed::_<impl>::call_box::call_box::h2933931519396885595
  24:      0x328f56af3f3 - sys::thread::_<impl>::new::thread_start::h552e7664d60f3aa2I5w
  25:      0x328ee9004a3 - start_thread
  26:      0x328f533e13c - clone
  27:                0x0 - <unknown>

May be related to #26510 but doesn't involve slice patterns.

-- edit: last 2 cases moved to separate bug reports.

@sfackler sfackler added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-dst Area: Dynamically Sized Types T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 7, 2015
@Aatch
Copy link
Contributor

Aatch commented Dec 9, 2015

Ok, since I've been working with this stuff already, I took a moment to investigate:

For the first two errors, those are issues with check_match, unsurprisingly.

For the third error, the issue is due to an inconsistency between how the &<pat> pattern handles DSTs and how ref ident expects DST values to be given to it, so & ref ident has the outer pattern passing along a different value to the one the inner inner pattern expects, yay! I fixed one case in #30245, but not the one you're hitting here.

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 Rust DST reborrow pattern bugginess check_match and slice bugginess Dec 9, 2015
@Stebalien
Copy link
Contributor Author

Thanks for looking into this. I've split the last to issues out into their own bugs but left the first two here. Sorry I couldn't come up with a more descriptive name.

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 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

No branches or pull requests

3 participants