Don't do a bogus substitution on the transformed self ty for objects. Closes #8664.
This commit is contained in:
parent
97d2b44f87
commit
ad6eeb843b
@ -938,9 +938,18 @@ impl<'self> LookupContext<'self> {
|
||||
|
||||
// static methods should never have gotten this far:
|
||||
assert!(candidate.method_ty.explicit_self != sty_static);
|
||||
let transformed_self_ty =
|
||||
ty::subst(tcx, &candidate.rcvr_substs,
|
||||
candidate.method_ty.transformed_self_ty.unwrap());
|
||||
|
||||
let transformed_self_ty = match candidate.origin {
|
||||
method_object(*) => {
|
||||
// For annoying reasons, we've already handled the
|
||||
// substitution for object calls.
|
||||
candidate.method_ty.transformed_self_ty.unwrap()
|
||||
}
|
||||
_ => {
|
||||
ty::subst(tcx, &candidate.rcvr_substs,
|
||||
candidate.method_ty.transformed_self_ty.unwrap())
|
||||
}
|
||||
};
|
||||
|
||||
// Determine the values for the type parameters of the method.
|
||||
// If they were not explicitly supplied, just construct fresh
|
||||
|
@ -8,6 +8,26 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// test for #8664
|
||||
|
||||
pub trait Trait2<A> {
|
||||
fn doit(&self);
|
||||
}
|
||||
|
||||
pub struct Impl<A1, A2, A3> {
|
||||
/*
|
||||
* With A2 we get the ICE:
|
||||
* task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1', /home/tortue/rust_compiler_newest/src/librustc/middle/subst.rs:58
|
||||
*/
|
||||
t: ~Trait2<A2>
|
||||
}
|
||||
|
||||
impl<A1, A2, A3> Impl<A1, A2, A3> {
|
||||
pub fn step(&self) {
|
||||
self.t.doit()
|
||||
}
|
||||
}
|
||||
|
||||
// test for #8601
|
||||
|
||||
enum Type<T> { Constant }
|
||||
|
Loading…
x
Reference in New Issue
Block a user