@@ -32,7 +32,7 @@ use rustc_ast::util::parser::ExprPrecedence;
3232use rustc_data_structures:: fx:: FxHashSet ;
3333use rustc_errors:: codes:: * ;
3434use rustc_errors:: { Applicability , Diag , ErrorGuaranteed } ;
35- use rustc_hir:: def_id:: DefId ;
35+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
3636use rustc_hir:: { self as hir, ExprKind } ;
3737use rustc_infer:: infer:: DefineOpaqueTypes ;
3838use rustc_macros:: { TypeFoldable , TypeVisitable } ;
@@ -63,6 +63,7 @@ pub(crate) struct CastCheck<'tcx> {
6363 cast_ty : Ty < ' tcx > ,
6464 cast_span : Span ,
6565 span : Span ,
66+ pub body_id : LocalDefId ,
6667}
6768
6869/// The kind of pointer and associated metadata (thin, length or vtable) - we
@@ -244,7 +245,8 @@ impl<'a, 'tcx> CastCheck<'tcx> {
244245 span : Span ,
245246 ) -> Result < CastCheck < ' tcx > , ErrorGuaranteed > {
246247 let expr_span = expr. span . find_ancestor_inside ( span) . unwrap_or ( expr. span ) ;
247- let check = CastCheck { expr, expr_ty, expr_span, cast_ty, cast_span, span } ;
248+ let check =
249+ CastCheck { expr, expr_ty, expr_span, cast_ty, cast_span, span, body_id : fcx. body_id } ;
248250
249251 // For better error messages, check for some obviously unsized
250252 // cases now. We do a more thorough check at the end, once
0 commit comments