Skip to content

Commit 52ba120

Browse files
committed
Remove unhelpful comments and add helpful ones
1 parent dc420a2 commit 52ba120

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2323,6 +2323,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
23232323
let src_tail = tcx.struct_tail_without_normalization(src.ty);
23242324
let dst_tail = tcx.struct_tail_without_normalization(dst.ty);
23252325

2326+
// This checks (lifetime part of) vtable validity for pointer casts,
2327+
// which is irrelevant when there are aren't principal traits on both sides (aka only auto traits).
2328+
//
2329+
// Note that other checks (such as denying `dyn Send` -> `dyn Debug`) are in `rustc_hir_typeck`.
23262330
if let ty::Dynamic(src_tty, ..) = src_tail.kind()
23272331
&& let ty::Dynamic(dst_tty, ..) = dst_tail.kind()
23282332
&& src_tty.principal().is_some()

compiler/rustc_hir_typeck/src/cast.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,9 @@ impl<'a, 'tcx> CastCheck<'tcx> {
838838
// Check that the traits are actually the same
839839
// (this is required as the `Unsize` check below would allow upcasting, etc)
840840
// N.B.: this is only correct as long as we don't support `trait A<T>: A<()>`.
841+
//
842+
// Note that trait upcasting goes through a different mechanism (`coerce_unsized`)
843+
// and is unaffected by this check.
841844
if src_principal.def_id() != dst_principal.def_id() {
842845
return Err(CastError::DifferingKinds);
843846
}
@@ -902,10 +905,6 @@ impl<'a, 'tcx> CastCheck<'tcx> {
902905
)
903906
}
904907

905-
// FIXME: ideally we'd maybe add a flag here, so that borrowck knows that
906-
// it needs to borrowck this ptr cast. this is made annoying by the
907-
// fact that `thir` does not have `CastKind` and mir restores it
908-
// from types.
909908
Ok(CastKind::PtrPtrCast)
910909
}
911910

compiler/rustc_hir_typeck/src/errors.rs

-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ pub struct LossyProvenanceInt2Ptr<'tcx> {
255255

256256
#[derive(LintDiagnostic)]
257257
#[diag(hir_typeck_ptr_cast_add_auto_to_object)]
258-
//#[help]
259258
pub struct PtrCastAddAutoToObject {
260259
pub traits_len: usize,
261260
pub traits: DiagSymbolList<String>,

0 commit comments

Comments
 (0)