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

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

Closed
astrieanna opened this issue Mar 20, 2013 · 4 comments
Closed

Comments

@astrieanna
Copy link
Contributor

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
@catamorphism
Copy link
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...

@astrieanna
Copy link
Contributor Author

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.

@jdm
Copy link
Contributor

jdm commented Mar 20, 2013

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

@astrieanna
Copy link
Contributor Author

@jdm Thanks! That fixed it. :)

@sanxiyn sanxiyn closed this as completed Mar 21, 2013
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
…, r=phansch

Update documentation for new_ret_no_self

changelog: Update documentation for lint new_ret_no_self to reflect that the return type must only contain `Self`, not be `Self`

The lint was changed to be more lenient than the documentation implies in PR rust-lang#3338 (Related issue rust-lang#3313)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants