Fix wrong handling of bare dyn Trait exposed by canonicalizer fix

The self type in the `dyn Trait` trait ref should always be ^0, but we didn't
put that in there in the bare case.
This commit is contained in:
Florian Diebold 2020-02-21 23:06:18 +01:00
parent 2d5ab63247
commit 463df6720c

View File

@ -239,7 +239,9 @@ impl Ty {
) -> Ty {
let ty = match resolution {
TypeNs::TraitId(trait_) => {
let trait_ref = TraitRef::from_resolved_path(ctx, trait_, resolved_segment, None);
// if this is a bare dyn Trait, we'll directly put the required ^0 for the self type in there
let self_ty = if remaining_segments.len() == 0 { Some(Ty::Bound(0)) } else { None };
let trait_ref = TraitRef::from_resolved_path(ctx, trait_, resolved_segment, self_ty);
return if remaining_segments.len() == 1 {
let segment = remaining_segments.first().unwrap();
let associated_ty = associated_type_by_name_including_super_traits(