Remove unhelpful comments and add helpful ones
This commit is contained in:
parent
dc420a282b
commit
52ba120700
@ -2323,6 +2323,10 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
|
|||||||
let src_tail = tcx.struct_tail_without_normalization(src.ty);
|
let src_tail = tcx.struct_tail_without_normalization(src.ty);
|
||||||
let dst_tail = tcx.struct_tail_without_normalization(dst.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()
|
if let ty::Dynamic(src_tty, ..) = src_tail.kind()
|
||||||
&& let ty::Dynamic(dst_tty, ..) = dst_tail.kind()
|
&& let ty::Dynamic(dst_tty, ..) = dst_tail.kind()
|
||||||
&& src_tty.principal().is_some()
|
&& src_tty.principal().is_some()
|
||||||
|
@ -838,6 +838,9 @@ fn check_ptr_ptr_cast(
|
|||||||
// Check that the traits are actually the same
|
// Check that the traits are actually the same
|
||||||
// (this is required as the `Unsize` check below would allow upcasting, etc)
|
// (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<()>`.
|
// 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() {
|
if src_principal.def_id() != dst_principal.def_id() {
|
||||||
return Err(CastError::DifferingKinds);
|
return Err(CastError::DifferingKinds);
|
||||||
}
|
}
|
||||||
@ -902,10 +905,6 @@ fn check_ptr_ptr_cast(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
Ok(CastKind::PtrPtrCast)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,6 @@ pub struct LossyProvenanceInt2Ptr<'tcx> {
|
|||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(hir_typeck_ptr_cast_add_auto_to_object)]
|
#[diag(hir_typeck_ptr_cast_add_auto_to_object)]
|
||||||
//#[help]
|
|
||||||
pub struct PtrCastAddAutoToObject {
|
pub struct PtrCastAddAutoToObject {
|
||||||
pub traits_len: usize,
|
pub traits_len: usize,
|
||||||
pub traits: DiagSymbolList<String>,
|
pub traits: DiagSymbolList<String>,
|
||||||
|
Loading…
Reference in New Issue
Block a user