diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_hir_typeck/src/cast.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_hir_typeck/src/errors.rs | 1 |
3 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index f98ac80a4c9..81ce7418852 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -2323,6 +2323,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let src_tail = tcx.struct_tail_without_normalization(src.ty); let dst_tail = tcx.struct_tail_without_normalization(dst.ty); + // 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). + // + // Note that other checks (such as denying `dyn Send` -> `dyn Debug`) are in `rustc_hir_typeck`. if let ty::Dynamic(src_tty, ..) = src_tail.kind() && let ty::Dynamic(dst_tty, ..) = dst_tail.kind() && src_tty.principal().is_some() diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 840a139b9bf..887d124bd7a 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -838,6 +838,9 @@ impl<'a, 'tcx> CastCheck<'tcx> { // Check that the traits are actually the same // (this is required as the `Unsize` check below would allow upcasting, etc) // N.B.: this is only correct as long as we don't support `trait A<T>: A<()>`. + // + // Note that trait upcasting goes through a different mechanism (`coerce_unsized`) + // and is unaffected by this check. if src_principal.def_id() != dst_principal.def_id() { return Err(CastError::DifferingKinds); } @@ -902,10 +905,6 @@ impl<'a, 'tcx> CastCheck<'tcx> { ) } - // FIXME: ideally we'd maybe add a flag here, so that borrowck knows that - // it needs to borrowck this ptr cast. this is made annoying by the - // fact that `thir` does not have `CastKind` and mir restores it - // from types. Ok(CastKind::PtrPtrCast) } diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index cdc160d13fe..dfc74b0e65d 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -255,7 +255,6 @@ pub struct LossyProvenanceInt2Ptr<'tcx> { #[derive(LintDiagnostic)] #[diag(hir_typeck_ptr_cast_add_auto_to_object)] -//#[help] pub struct PtrCastAddAutoToObject { pub traits_len: usize, pub traits: DiagSymbolList<String>, |
