Skip to content

ICE: value ScalarPair(...) cannot be written into local with type &MySlice<[bool]> #121612

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

trait Trait {}
impl Trait for bool {}
struct MySlice<T: FnOnce(&T, Idx) -> Idx>(bool, T);
type MySliceBool = MySlice<[bool]>;
const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]);

fn main() {}

Meta

rustc --version --verbose:

26cd5d862e22c013ecb3396b177d3af80e95c836

Error output

error[E0412]: cannot find type `Idx` in this scope
 --> ice.rs:3:30
  |
3 | struct MySlice<T: FnOnce(&T, Idx) -> Idx>(bool, T);
  |                              ^^^ not found in this scope

error[E0412]: cannot find type `Idx` in this scope
 --> ice.rs:3:38
  |
3 | struct MySlice<T: FnOnce(&T, Idx) -> Idx>(bool, T);
  |                                      ^^^ not found in this scope

error[E0277]: the size for values of type `[bool]` cannot be known at compilation time
 --> ice.rs:5:22
  |
5 | const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]);
  |                      ^^^^^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `[bool]`
note: required by an implicit `Sized` bound in `MySlice`
 --> ice.rs:3:16
  |
3 | struct MySlice<T: FnOnce(&T, Idx) -> Idx>(bool, T);
  |                ^ required by the implicit `Sized` requirement on this type parameter in `MySlice`
help: you could relax the implicit `Sized` bound on `T` if it were used through indirection like `&T` or `Box<T>`
 --> ice.rs:3:16
  |
3 | struct MySlice<T: FnOnce(&T, Idx) -> Idx>(bool, T);
  |                ^                                - ...if indirection were used here: `Box<T>`
  |                |
  |                this could be changed to `T: ?Sized`...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions