Skip to content

Internal compiler error: task failed at 'Unsupported constant expr' #5448

Closed

Description

@astrieanna

The code and the compiler backtrace output is in this gist.

The relevant parts of the compiler output seem to be:

rust: task failed at 'Unsupported constant expr', /home/leah/rust-0.5/src/librustc/middle/const_eval.rs:238

and maybe:

rust: task failed at 'explicit failure', /home/leah/rust-0.5/src/librustc/rustc.rc:425

The part of my code that I think causes it is this:

  #[test]
  fn insert_value() {
    let bvt : Level1<int> =  Level1 { data : @mut([@0,..@31]), current : 0};
    bvt.append(@5);
  }

Specifically, [@0,..@31] seems to be the change that triggered this bug.

I'm trying to find a way to create a static mutable array of managed pointers to ints, of size 32. Needing this might very well be a side-effect of my not knowing how to design/implement data structures in rust, but it's what I need to make the types work out at this point (to actually instantiate a Level1), I think.

The output of rustc --version is:

rustc 0.5
host: i686-unknown-linux-gnu

Activity

  1. catamorphism commented on Mar 20, 2013

    @catamorphism
    Contributor

    "@0" means "allocate a box on the managed heap and write 0 into it", so you can't do that statically; the heap doesn't exist statically. I'm not sure if that's clear or not, but I could maybe say more if I knew more about what you're trying to do...

  2. astrieanna commented on Mar 20, 2013

    @astrieanna
    ContributorAuthor

    I'm fairly confused about pointers in Rust generally, but putting @ and mut everywhere seemed to make things compile.

    I'm trying to write a Bitmapped Vector Trie. This means having a bunch of size 32 arrays of pointers. I wanted to be able to express that the array will always be size 32, so I used the [@A * 32] notation in the Level1 type. However, I'm not sure how to make a [@int * 32] when I don't actually care about the values yet.

    I wanted it make it a more functional style data structure (with immutability/structure sharing), but that seemed to be making my pointer-lifetime compiler errors worse, so I'm currently (well, attempting) to use a @mut [@A * 32] to hold the data. I think this means that I have a managed array on the local heap containing 32 managed pointers, and that I can change any of the 32 pointers in the array. The current challenge is making an instance of that type, where I don't actually care about the values.

  3. jdm commented on Mar 20, 2013

    @jdm
    Contributor

    I think you want @mut [@0, ..32].

  4. astrieanna commented on Mar 20, 2013

    @astrieanna
    ContributorAuthor

    @jdm Thanks! That fixed it. :)

  5. added a commit that references this issue on May 2, 2020
  6. added a commit that references this issue on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions