Avoid ICE in Self::Assoc in impl headers
This commit is contained in:
parent
bf95c29c98
commit
8c7d0077ab
@ -918,7 +918,19 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
|
||||
(_, Def::SelfTy(Some(_), Some(impl_def_id))) => {
|
||||
// `Self` in an impl of a trait - we have a concrete self type and a
|
||||
// trait reference.
|
||||
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||
// FIXME: Self type is not always computed when we are here because type parameter
|
||||
// bounds may affect Self type and have to be converted before it.
|
||||
let trait_ref = if impl_def_id.is_local() {
|
||||
tcx.impl_trait_refs.borrow().get(&impl_def_id).cloned().and_then(|x| x)
|
||||
} else {
|
||||
tcx.impl_trait_ref(impl_def_id)
|
||||
};
|
||||
let trait_ref = if let Some(trait_ref) = trait_ref {
|
||||
trait_ref
|
||||
} else {
|
||||
tcx.sess.span_err(span, "`Self` type is used before it's determined");
|
||||
return (tcx.types.err, Def::Err);
|
||||
};
|
||||
let trait_ref = if let Some(free_substs) = self.get_free_substs() {
|
||||
trait_ref.subst(tcx, free_substs)
|
||||
} else {
|
||||
|
@ -18,9 +18,12 @@ impl<T: Tr<Self>> Tr<T> for S {} //~ ERROR `Self` type is used before it's deter
|
||||
impl<T = Self> Tr<T> for S {} //~ ERROR `Self` type is used before it's determined
|
||||
impl Tr for S where Self: Copy {} //~ ERROR `Self` type is used before it's determined
|
||||
impl Tr for S where S<Self>: Copy {} //~ ERROR `Self` type is used before it's determined
|
||||
impl Tr for S where Self::Assoc: Copy {} //~ ERROR `Self` type is used before it's determined
|
||||
//~^ ERROR `Self` type is used before it's determined
|
||||
impl Tr for Self {} //~ ERROR `Self` type is used before it's determined
|
||||
impl Tr for S<Self> {} //~ ERROR `Self` type is used before it's determined
|
||||
impl Self {} //~ ERROR `Self` type is used before it's determined
|
||||
impl S<Self> {} //~ ERROR `Self` type is used before it's determined
|
||||
impl Tr<Self::Assoc> for S {} //~ ERROR `Self` type is used before it's determined
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user