I’m working on updating the mir2wasm project to the current nightly compiler (as of nightly-2016-09-15, for reference). You can see my current progress here: https://github.com/brson/mir2wasm/pull/39.
I’ll duplicate a little bit of the context from that thread here, and try to describe the problem as concretely as possible.
I’m running into an internal compiler error when translating the following snippet:
pub trait Test {
fn test(&self) { } // removing the body here gets us passed the ICE
}
impl Test for isize {
fn test(&self) { }
}
The error is this: internal compiler error: ../src/librustc/ty/subst.rs:457: Type parameterSelf/#0(Self/0) out of range when substituting (root type=Some(&Self)) substs=[]
I’ve thus far tracked the problem down to translating the body of the default method in the trait (apologies if that’s not the correct terminology). In particular, the crash occurs when trying to compute the concrete layout of the &Self type, which is unbound when translating the trait method itself.
Here are the solutions I can think of:
- Skip translating default trait methods for now (just to see how much further I can get). I think the right place to insert that check is here - but I’m not sure what that condition should look like.
- When visiting each of the
impls of that trait that doesn’t have a corresponding method, either “inject” the default method there, or visit it in that context. Again, I’m not sure how to accomplish this.
Am I on the right track? Any guidance is appreciated.
Thanks!