Use resolved types in body of coerce_unsized
This commit is contained in:
parent
32c360b993
commit
ff6e4ee7ad
1 changed files with 7 additions and 3 deletions
|
@ -452,9 +452,13 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
// &[T; n] or &mut [T; n] -> &[T]
|
||||
// or &mut [T; n] -> &mut [T]
|
||||
// or &Concrete -> &Trait, etc.
|
||||
fn coerce_unsized(&self, source: Ty<'tcx>, target: Ty<'tcx>) -> CoerceResult<'tcx> {
|
||||
fn coerce_unsized(&self, mut source: Ty<'tcx>, mut target: Ty<'tcx>) -> CoerceResult<'tcx> {
|
||||
debug!("coerce_unsized(source={:?}, target={:?})", source, target);
|
||||
|
||||
source = self.shallow_resolve(source);
|
||||
target = self.shallow_resolve(target);
|
||||
debug!("coerce_unsized: resolved source={:?} target={:?}", source, target);
|
||||
|
||||
// These 'if' statements require some explanation.
|
||||
// The `CoerceUnsized` trait is special - it is only
|
||||
// possible to write `impl CoerceUnsized<B> for A` where
|
||||
|
@ -476,11 +480,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
|
|||
// the compiler! Therefore, we can be sure that coercion will always fail
|
||||
// when either the source or target type is a type variable. This allows us
|
||||
// to skip performing any trait selection, and immediately bail out.
|
||||
if self.shallow_resolve(source).is_ty_var() {
|
||||
if source.is_ty_var() {
|
||||
debug!("coerce_unsized: source is a TyVar, bailing out");
|
||||
return Err(TypeError::Mismatch);
|
||||
}
|
||||
if self.shallow_resolve(target).is_ty_var() {
|
||||
if target.is_ty_var() {
|
||||
debug!("coerce_unsized: target is a TyVar, bailing out");
|
||||
return Err(TypeError::Mismatch);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue