Skip to content

Commit

Permalink
borrowck: use subtyping instead of equality for ptr-to-ptr casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Sep 27, 2024
1 parent 8302f2e commit 53f45c4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
5 changes: 1 addition & 4 deletions tests/ui/cast/ptr-to-trait-obj-ok.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ check-fail
//@ check-pass

trait Trait<'a> {}

Expand Down Expand Up @@ -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<dyn Trait<'a>> {
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<dyn Sync + 'b> {
Expand Down
24 changes: 0 additions & 24 deletions tests/ui/cast/ptr-to-trait-obj-ok.stderr

This file was deleted.

0 comments on commit 53f45c4

Please sign in to comment.