diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 16e51e82f85..6b17879de26 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -2437,7 +2437,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { debug!(?src_tty, ?dst_tty, ?src_obj, ?dst_obj); - self.eq_types( + self.sub_types( src_obj, dst_obj, location.to_locations(), diff --git a/tests/ui/cast/ptr-to-trait-obj-ok.rs b/tests/ui/cast/ptr-to-trait-obj-ok.rs index f30472667b7..dbeee9d2944 100644 --- a/tests/ui/cast/ptr-to-trait-obj-ok.rs +++ b/tests/ui/cast/ptr-to-trait-obj-ok.rs @@ -1,4 +1,4 @@ -//@ check-fail +//@ check-pass trait Trait<'a> {} @@ -37,9 +37,6 @@ fn cast_inherent_lt_wrap<'a, 'b>( fn cast_away_higher_ranked_wrap<'a>(x: *mut dyn for<'b> Trait<'b>) -> *mut Wrapper> { x as _ - //~^ error: lifetime may not live long enough - //~| error: mismatched types - //~| one type is more general than the other } fn unprincipled_wrap<'a, 'b>(x: *mut (dyn Send + 'a)) -> *mut Wrapper { diff --git a/tests/ui/cast/ptr-to-trait-obj-ok.stderr b/tests/ui/cast/ptr-to-trait-obj-ok.stderr deleted file mode 100644 index 8de07691c21..00000000000 --- a/tests/ui/cast/ptr-to-trait-obj-ok.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error: lifetime may not live long enough - --> $DIR/ptr-to-trait-obj-ok.rs:39:5 - | -LL | fn cast_away_higher_ranked_wrap<'a>(x: *mut dyn for<'b> Trait<'b>) -> *mut Wrapper> { - | -- lifetime `'a` defined here -LL | x as _ - | ^^^^^^ returning this value requires that `'a` must outlive `'static` - | - = note: requirement occurs because of a mutable pointer to `Wrapper>` - = note: mutable pointers are invariant over their type parameter - = help: see for more information about variance - -error[E0308]: mismatched types - --> $DIR/ptr-to-trait-obj-ok.rs:39:5 - | -LL | x as _ - | ^^^^^^ one type is more general than the other - | - = note: expected trait object `dyn for<'b> Trait<'b>` - found trait object `dyn Trait<'_>` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`.