Skip to content

Commit 53f45c4

Browse files
author
Lukas Markeffsky
committed
borrowck: use subtyping instead of equality for ptr-to-ptr casts
1 parent 8302f2e commit 53f45c4

File tree

3 files changed

+2
-29
lines changed

3 files changed

+2
-29
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
24372437

24382438
debug!(?src_tty, ?dst_tty, ?src_obj, ?dst_obj);
24392439

2440-
self.eq_types(
2440+
self.sub_types(
24412441
src_obj,
24422442
dst_obj,
24432443
location.to_locations(),

tests/ui/cast/ptr-to-trait-obj-ok.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ check-fail
1+
//@ check-pass
22

33
trait Trait<'a> {}
44

@@ -37,9 +37,6 @@ fn cast_inherent_lt_wrap<'a, 'b>(
3737

3838
fn cast_away_higher_ranked_wrap<'a>(x: *mut dyn for<'b> Trait<'b>) -> *mut Wrapper<dyn Trait<'a>> {
3939
x as _
40-
//~^ error: lifetime may not live long enough
41-
//~| error: mismatched types
42-
//~| one type is more general than the other
4340
}
4441

4542
fn unprincipled_wrap<'a, 'b>(x: *mut (dyn Send + 'a)) -> *mut Wrapper<dyn Sync + 'b> {

tests/ui/cast/ptr-to-trait-obj-ok.stderr

-24
This file was deleted.

0 commit comments

Comments
 (0)