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

ICE with box syntax and unsized types #87935

Closed
BoxyUwU opened this issue Aug 11, 2021 · 1 comment · Fixed by #88087
Closed

ICE with box syntax and unsized types #87935

BoxyUwU opened this issue Aug 11, 2021 · 1 comment · Fixed by #88087
Assignees
Labels
C-bug Category: This is a bug. 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

@BoxyUwU
Copy link
Member

BoxyUwU commented Aug 11, 2021

Originally reported by @chengniansun here

Code

playground

#![feature(box_syntax)]
fn main() {
    let x: Box<[isize]> = box { loop {} };
}

Meta

rustc --version --verbose:

rustc 1.55.0-nightly (6d820866a 2021-06-29)
binary: rustc
commit-hash: 6d820866a27b1949e237be79b9c8c0145fe728b7
commit-date: 2021-06-29
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

warning: unreachable expression
 --> mutant.rs:3:27
  |
3 |     let x: Box<[isize]> = box { loop {} };
  |                           ^^^^^^-------^^
  |                           |     |
  |                           |     any code following this expression is unreachable
  |                           unreachable expression
  |
  = note: `#[warn(unreachable_code)]` on by default

warning: unused variable: `x`
 --> mutant.rs:3:9
  |
3 |     let x: Box<[isize]> = box { loop {} };
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted

error: internal compiler error: broken MIR in DefId(0:3 ~ mutant[317d]::main) (NoSolution): could not prove Binder(TraitPredicate(<[isize] as std::marker::Sized>), [])
 --> mutant.rs:3:27
  |
3 |     let x: Box<[isize]> = box { loop {} };
  |                           ^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:253:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1022:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (6d820866a 2021-06-29) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
Backtrace

warning: unreachable expression
 --> mutant.rs:3:27
  |
3 |     let x: Box<[isize]> = box { loop {} };
  |                           ^^^^^^-------^^
  |                           |     |
  |                           |     any code following this expression is unreachable
  |                           unreachable expression
  |
  = note: `#[warn(unreachable_code)]` on by default

warning: unused variable: `x`
 --> mutant.rs:3:9
  |
3 |     let x: Box<[isize]> = box { loop {} };
  |         ^ help: if this is intentional, prefix it with an underscore: `_x`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 2 warnings emitted

error: internal compiler error: broken MIR in DefId(0:3 ~ mutant[317d]::main) (NoSolution): could not prove Binder(TraitPredicate(<[isize] as std::marker::Sized>), [])
 --> mutant.rs:3:27
  |
3 |     let x: Box<[isize]> = box { loop {} };
  |                           ^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_mir/src/borrow_check/type_check/mod.rs:253:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1022:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/6d820866a27b1949e237be79b9c8c0145fe728b7/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/6d820866a27b1949e237be79b9c8c0145fe728b7/library/std/src/panicking.rs:457:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
   9: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (6d820866a 2021-06-29) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@BoxyUwU BoxyUwU added 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. C-bug Category: This is a bug. labels Aug 11, 2021
@jesyspa
Copy link
Contributor

jesyspa commented Aug 12, 2021

@rustbot claim

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 20, 2021
Check that a box expression's type is Sized

This resolves [issue 87935](rust-lang#87935).

This makes E0161 (move from an unsized rvalue) much less common.  I've replaced the test to use [this case](https://github.com/rust-lang/rust/blob/master/src/test/ui/object-safety/object-safety-by-value-self-use.rs), when a boxed `dyn` trait is passed by value, but that isn't an error when `unsized_locals` is enabled.  I think it may be possible to get rid of E0161 entirely by checking that case earlier, but I'm not sure if that's desirable?
Alexendoo added a commit to Alexendoo/glacier that referenced this issue Aug 22, 2021
Closes rust-lang#901

The previous version had a separate issue opened for it which was
resolved (rust-lang/rust#87935)
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 26, 2021
…crum

Remove most box syntax uses from the testsuite except for src/test/ui/issues

Removes most box syntax uses from the testsuite outside of the src/test/ui/issues directory. The goal was to only change tests where box syntax is an implementation detail instead of the actual feature being tested. So some tests were left out, like the regression test for rust-lang#87935, or tests where the obtained error message changed significantly.

Mostly this replaces box syntax with `Box::new`, but there are some minor drive by improvements, like formatting improvements or `assert_eq` instead of `assert!( == )`.

Prior PR that removed box syntax from the compiler and tools: rust-lang#87781
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) ❄️ 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.

2 participants