@@ -340,21 +340,12 @@ fn fn_abi_of_instance_raw<'tcx>(
340340}
341341
342342/// Returns argument attributes for a scalar argument.
343- ///
344- /// `drop_target_pointee`, if set, causes pointer-typed scalars to be treated like mutable
345- /// references to the given type. This is used to special-case the argument of `ptr::drop_in_place`,
346- /// interpreting it as `&mut T` instead of `*mut T`, for the purposes of attributes (which is valid
347- /// as per its safety contract). If `drop_target_pointee` is set, `offset` must be 0 and `layout.ty`
348- /// must be a pointer to the given type. Note that for wide pointers this function is called twice
349- /// -- once for the data pointer and once for the vtable pointer. `drop_target_pointee` must only
350- /// be set for the data pointer.
351343fn arg_attrs_for_rust_scalar < ' tcx > (
352344 cx : LayoutCx < ' tcx > ,
353345 scalar : Scalar ,
354346 layout : TyAndLayout < ' tcx > ,
355347 offset : Size ,
356348 is_return : bool ,
357- drop_target_pointee : Option < Ty < ' tcx > > ,
358349) -> ArgAttributes {
359350 let mut attrs = ArgAttributes :: new ( ) ;
360351
@@ -374,23 +365,13 @@ fn arg_attrs_for_rust_scalar<'tcx>(
374365
375366 // Set `nonnull` if the validity range excludes zero, or for the argument to `drop_in_place`,
376367 // which must be nonnull per its documented safety requirements.
377- if !valid_range. contains ( 0 ) || drop_target_pointee . is_some ( ) {
368+ if !valid_range. contains ( 0 ) {
378369 attrs. set ( ArgAttribute :: NonNull ) ;
379370 }
380371
381372 let tcx = cx. tcx ( ) ;
382373
383- let drop_target_pointee_info = drop_target_pointee. and_then ( |pointee| {
384- assert_eq ! ( pointee, layout. ty. builtin_deref( true ) . unwrap( ) ) ;
385- assert_eq ! ( offset, Size :: ZERO ) ;
386- // The argument to `drop_in_place` is semantically equivalent to a mutable reference.
387- let mutref = Ty :: new_mut_ref ( tcx, tcx. lifetimes . re_erased , pointee) ;
388- let layout = cx. layout_of ( mutref) . unwrap ( ) ;
389- layout. pointee_info_at ( & cx, offset)
390- } ) ;
391-
392- if let Some ( pointee) = drop_target_pointee_info. or_else ( || layout. pointee_info_at ( & cx, offset) )
393- {
374+ if let Some ( pointee) = layout. pointee_info_at ( & cx, offset) {
394375 if pointee. align > Align :: ONE {
395376 attrs. pointee_align =
396377 Some ( pointee. align . min ( cx. tcx ( ) . sess . target . max_reliable_alignment ( ) ) ) ;
@@ -589,20 +570,10 @@ fn fn_abi_new_uncached<'tcx>(
589570 extra_args
590571 } ;
591572
592- let is_drop_in_place = determined_fn_def_id. is_some_and ( |def_id| {
593- tcx. is_lang_item ( def_id, LangItem :: DropInPlace )
594- || tcx. is_lang_item ( def_id, LangItem :: AsyncDropInPlace )
595- } ) ;
596-
597573 let arg_of = |ty : Ty < ' tcx > , arg_idx : Option < usize > | -> Result < _ , & ' tcx FnAbiError < ' tcx > > {
598574 let span = tracing:: debug_span!( "arg_of" ) ;
599575 let _entered = span. enter ( ) ;
600576 let is_return = arg_idx. is_none ( ) ;
601- let is_drop_target = is_drop_in_place && arg_idx == Some ( 0 ) ;
602- let drop_target_pointee = is_drop_target. then ( || match ty. kind ( ) {
603- ty:: RawPtr ( ty, _) => * ty,
604- _ => bug ! ( "argument to drop_in_place is not a raw ptr: {:?}" , ty) ,
605- } ) ;
606577
607578 let layout = cx. layout_of ( ty) . map_err ( |err| & * tcx. arena . alloc ( FnAbiError :: Layout ( * err) ) ) ?;
608579 let layout = if is_virtual_call && arg_idx == Some ( 0 ) {
@@ -615,16 +586,7 @@ fn fn_abi_new_uncached<'tcx>(
615586 } ;
616587
617588 Ok ( ArgAbi :: new ( cx, layout, |scalar, offset| {
618- arg_attrs_for_rust_scalar (
619- * cx,
620- scalar,
621- layout,
622- offset,
623- is_return,
624- // Only set `drop_target_pointee` for the data part of a wide pointer.
625- // See `arg_attrs_for_rust_scalar` docs for more information.
626- drop_target_pointee. filter ( |_| offset == Size :: ZERO ) ,
627- )
589+ arg_attrs_for_rust_scalar ( * cx, scalar, layout, offset, is_return)
628590 } ) )
629591 } ;
630592
0 commit comments