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

Const generic parameter of type &'static [_] causes ICE #73727

Closed
yvt opened this issue Jun 25, 2020 · 2 comments · Fixed by #98334
Closed

Const generic parameter of type &'static [_] causes ICE #73727

yvt opened this issue Jun 25, 2020 · 2 comments · Fixed by #98334
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@yvt
Copy link
Contributor

yvt commented Jun 25, 2020

Code

#![feature(const_generics)]

fn a<const X: &'static [u32]>() {}

fn main() {
    a::<{&[]}>();
}

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (67100f61e 2020-06-24)
binary: rustc
commit-hash: 67100f61e62a86f2bf9e38552ee138e231eddc74
commit-date: 2020-06-24
host: x86_64-apple-darwin
release: 1.46.0-nightly
LLVM version: 10.0

Error output

warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
 --> a.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

error: internal compiler error: unexpected consts: a: Const { ty: &[u32], val: Value(ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), alloc2))] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }, b: Const { ty: &'static [u32], val: Value(ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), alloc2))] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
  |
  = note: delayed at /rustc/67100f61e62a86f2bf9e38552ee138e231eddc74/src/librustc_session/session.rs:436:27

error: internal compiler error: broken MIR in DefId(0:5 ~ a[317d]::main[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ a[317d]::a[0]), UserSubsts { substs: [Const { ty: &'static [u32], val: Unevaluated(DefId(0:6 ~ a[317d]::main[0]::{{constant}}[0]), [], None) }], user_self_ty: None }) }, span: a.rs:6:5: 6:15 (#0), inferred_ty: fn() {a::<{&[]}>} }): bad user type AscribeUserType(fn() {a::<{&[]}>}, DefId(0:3 ~ a[317d]::a[0]) UserSubsts { substs: [Const { ty: &'static [u32], val: Unevaluated(DefId(0:6 ~ a[317d]::main[0]::{{constant}}[0]), [], None) }], user_self_ty: None }): NoSolution
  |
  = note: delayed at src/librustc_mir/borrow_check/type_check/mod.rs:258:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:367:17
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.46.0-nightly (67100f61e 2020-06-24) running on x86_64-apple-darwin
Backtrace

stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   9: core::ptr::drop_in_place
  10: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  11: core::ptr::drop_in_place
  12: rustc_span::with_source_map
  13: rustc_interface::interface::run_compiler_in_existing_thread_pool
  14: scoped_tls::ScopedKey<T>::set

@yvt yvt added 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. labels Jun 25, 2020
yvt added a commit to r3-os/r3 that referenced this issue Jun 25, 2020
…parameters

This commit implements a work-around for this issue:
<rust-lang/rust#73727>
@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` requires-nightly This issue requires a nightly compiler in some way. labels Jun 25, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jun 27, 2020
@varkor
Copy link
Member

varkor commented Sep 13, 2020

This works with min_const_generics because the type is forbidden. However, it continues to ICE with const_generics.

@varkor varkor added fixed-by-const-generics Enabling feature `const_generics` fixes the issue. const-generics-needs-test-for-min_const_generics and removed fixed-by-const-generics Enabling feature `const_generics` fixes the issue. labels Sep 13, 2020
@varkor varkor added fixed-by-const-generics Enabling feature `const_generics` fixes the issue. const-generics-fixed-by-min_const_generics E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed const-generics-needs-test-for-min_const_generics fixed-by-const-generics Enabling feature `const_generics` fixes the issue. labels Oct 1, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 5, 2020
…lcnr,estebank

Fix missing diagnostic span for `impl Trait` with const generics, and add various tests for `min_const_generics` and `const_generics`

Closes rust-lang#61410.

Adds `min_const_generics` tests for:
- rust-lang#73727
- rust-lang#72293
- rust-lang#67375
- rust-lang#75153
- rust-lang#71922
- rust-lang#69913
- rust-lang#67945
- rust-lang#69239

Adds `const_generics` tests for:
- rust-lang#67375
- rust-lang#75153
- rust-lang#71922
- rust-lang#69913
- rust-lang#67945
- rust-lang#69239

(I only added separate `min_const_generics` and `const_generics` tests if they were handled differently by the two features.)

We need to figure out how to deduplicate when `const_generics` is stabilised, but we can discuss that later. For now, we should be checking neither feature breaks, so require regression tests for both. I've given them identical names when I've added both, which should make it easier to spot them later.

r? @lcnr
@JohnTitor JohnTitor removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 9, 2020
@Alexendoo
Copy link
Member

No longer ICEs since #89147

@Alexendoo Alexendoo added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 23, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 21, 2022
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 21, 2022
…rrors

Add a full regression test for rust-lang#73727

Closes rust-lang#73727

This also moves a test to the `issues` directory as it's also tested on the adt_const_params feature.

r? `@compiler-errors`

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jun 21, 2022
…rrors

Add a full regression test for rust-lang#73727

Closes rust-lang#73727

This also moves a test to the `issues` directory as it's also tested on the adt_const_params feature.

r? ``@compiler-errors``

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 22, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#97867 (lub: don't bail out due to empty binders)
 - rust-lang#98099 (interpret: convert_tag_add_extra: allow tagger to raise errors)
 - rust-lang#98199 (Move some tests to more reasonable directories)
 - rust-lang#98334 (Add a full regression test for rust-lang#73727)
 - rust-lang#98336 (Remove the unused-`#[doc(hidden)]` logic from the `unused_attributes` lint)
 - rust-lang#98344 (This comment is out dated and misleading, the arm is about TAITs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 880ac7c Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-const_generics `#![feature(const_generics)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

6 participants