mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Normalize when equating dyn tails in MIR borrowck
This commit is contained in:
parent
2b78d92096
commit
c6f8672dd5
@ -2330,10 +2330,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
match (cast_ty_from, cast_ty_to) {
|
||||
(Some(CastTy::Ptr(src)), Some(CastTy::Ptr(dst))) => {
|
||||
let mut normalize = |t| self.normalize(t, location);
|
||||
|
||||
// N.B. `struct_tail_with_normalize` only "structurally resolves"
|
||||
// the type. It is not fully normalized, so we have to normalize it
|
||||
// afterwards.
|
||||
let src_tail =
|
||||
tcx.struct_tail_with_normalize(src.ty, &mut normalize, || ());
|
||||
let src_tail = normalize(src_tail);
|
||||
let dst_tail =
|
||||
tcx.struct_tail_with_normalize(dst.ty, &mut normalize, || ());
|
||||
let dst_tail = normalize(dst_tail);
|
||||
|
||||
// This checks (lifetime part of) vtable validity for pointer casts,
|
||||
// which is irrelevant when there are aren't principal traits on both sides (aka only auto traits).
|
||||
|
@ -1,16 +0,0 @@
|
||||
//@ known-bug: rust-lang/rust#128621
|
||||
|
||||
#![feature(ptr_metadata)]
|
||||
use std::{ops::FnMut, ptr::Pointee};
|
||||
|
||||
pub type EmplacerFn<'a, T> = dyn for<'b> FnMut(<T as Pointee>::Metadata) + 'a;
|
||||
|
||||
pub struct Emplacer<'a, T>(EmplacerFn<'a, T>);
|
||||
|
||||
impl<'a, T> Emplacer<'a, T> {
|
||||
pub unsafe fn from_fn<'b>(emplacer_fn: &'b mut EmplacerFn<'a, T>) -> &'b mut Self {
|
||||
unsafe { &mut *((emplacer_fn as *mut EmplacerFn<'a, T>) as *mut Self) }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
@ -1,4 +1,4 @@
|
||||
//@ known-bug: rust-lang/rust#128621
|
||||
//@ check-pass
|
||||
|
||||
trait Trait {
|
||||
type Associated;
|
||||
@ -17,3 +17,5 @@ struct Wrap(TraitObject);
|
||||
fn cast(x: *mut TraitObject) {
|
||||
x as *mut Wrap;
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user