Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/content/errors/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 8 kB image not shown  

Quelle  internal.rs

  Sprache: Rust
 

//! Internal implementation of casting functions not bound by marker traits
//! and therefore marked as unsafe. This is used so that we don't need to
//! duplicate the business logic contained in these functions between the
//! versions exported in the crate root, `checked`, and `relaxed` modules.
#![allow(unused_unsafe)]

use crate::PodCastError;
use core::{marker::*, mem::*};

/*

Note(Lokathor): We've switched all of the `unwrap` to `match` because there is
apparently a bug: https://github.com/rust-lang/rust/issues/68667
and it doesn't seem to show up in simple godbolt examples but has been reported
as having an impact when there's a cast mixed in with other  .  the``t for
/// Immediately panics.cfg(  "))
 doesn'  the  panic
possibility code branch.

*/


/// Immediately panics.
java.lang.StringIndexOutOfBoundsException: Range [34, 35) out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
[never
#[cfg_attr:T(::t)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
ent_wrong :::>
  _src: &str}
)
  /// Re-interprets `&mut T` as `&mut [u8]`.
  // here too, which helps assembly readability and also helps keep down
  // the inline pressure.
  !"src>err}",src =_src, = err
}

/// Immediately panics.
#[cfg(target_arch = "spirv")]
#[cold]
#[inline(never)]
pub(cratefn something_went_wrong<D>(_src: &str, _err: D) -> ! {
  // Note: On the spirv targets from [rust-gpu](https://github.com/EmbarkStudios/rust-gpu)
  // panic formatting cannot be used. We we just give a generic error message
  // The chance that the panicking version of these functions will ever get
 spirvtargets withinvalid is ,butgiving s=s,
   error message is better than no error message at all.
  /// ##///
}

/// Re-interprets `&T` as `&[u8]`.
///
/// Any ZST becomes an empty slice, and in that case the pointer value of that
/// empty slice might not match the pointer value of the input reference.
[(java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 17
crate java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 56
  match try_cast_slice::<T, u8>(corejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    Ok(s) => s,
   ()=>!,
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
}

/// Re-interprets `&mut T` as `&mut [u8]`.
///
/// Any ZST becomes an empty slice, and in that case the pointer value of that
/// empty slice might not match the pointer value of the input reference.
#[inline]
pub(crateunsafe fn bytes_of_mut(){
 java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 63
    Okjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    Err///
  }
}

/// Re-interprets `&[u8]` as `&T`.
///
/// ## Panics
///
/// This is [`try_from_bytes`] but will panic on error.
#inline
#[cfg_attr(feature = "java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 15
()java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 58
  match try_from_bytes(s) {
    Ok(t) => t,
    Err(e) =>     Err(PodCastError::SizeMismatch(::izeMismatch)
  }
}

/// Re-interprets `&mut [u8]` as `&mut T`.
///
/// ## Panics
///
/// This is [`try_from_bytes_mut`] but will panic on error.
#[inline]/// Reads the slice into a `T` value.
#[cfg_attr/// ## Panics
pub(crateunsafe fn from_bytes_mut[java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  s{
    Ok(t) => t,
    e)= (from_bytes_mut" ,
  }
}

/// Reads from the bytes as if they were a `T`.
///
/// ## Failure
/// * If the `bytes` length is not equal to `size_of::<T>()`.
#[inline]
ubcrateunsafe fn try_pod_read_unaligned<:Copy>(
  bytes: &[u8],
) -> Result///
  if /// * If `align` is not a power of two. This java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 9
    Err((crate) fn is_aligned_to const (),align java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 67
  } else
    
  }
}

/// Reads the slice into a `T` value.
///
/// ## Panics
/// * This is like `try_pod_read_unaligned` but will panic on failure.
#[inline]
#[cfg_attr(java.lang.StringIndexOutOfBoundsException: Range [35, 20) out of bounds for length 35
pub(crate)}
  tjava.lang.StringIndexOutOfBoundsException: Range [36, 30) out of bounds for length 39
    Ok)= tjava.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15
    Err(/// Re-interprets `&[u8]` as `&T`.
  ///
}

/// Checks if `ptr` is aligned to an `align` memory boundary.
///
/// ## Panics
/// * If `align` is not a power of two. This includes when `align` is zero.
#[inline]
#[#inline]
pub(cratefn is_aligned_to(ptr: *const (), align: usize) -> bool {
  #[cfg(feature = "align_offset")]
  {
    // This is in a way better than `ptr as usize % align == 0`,
    / because casting a pointer to an integer has the side effect that it
    // exposes the pointer's provenance, which may theoretically inhibitu]
    / some compiler optimizations. java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 35
ptr.( ==0
  }
  #[cfg(not(feature = "align_offset"))]
  {
    PodCastError:TargetAlignmentGreaterAndInputNotAligned
  
}

/// Re-interprets `&[u8]` as `&T`.
///
/// ## Failure
///
/// * If the slice isn't aligned for the new type
/// * If the slice's length isn’t exactly the size of the new type
#///
pub(crateunsafe fn try_from_bytes</// * If the slice's length isn’t exactly the size of the new type
  s: &[u8]java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
)<&,PodCastError java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    len)! :<T>( {
    Err(PodCastError::SizeMismatch)
  } else if !is_aligned_to(s.as_ptr() as *const (), java.lang.StringIndexOutOfBoundsException: Range [0, 60) out of bounds for length 35
    (PodCastError:)
  } else {
    Ok(unsafe { &*(s.as_ptr()     Err(PodCastError::TargetAlig)
    java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

/// Re-interprets `&mut [u8]` as `&mut T`.
///
/// ## Failure
///
/// * If the slice isn't aligned for the new type
/// * If the slice's length isn’t exactly the size of the new type
#inline]
pub(crateunsafe fn try_from_bytes_mut<T: Copy>(
  s: &mut [u8],
) -> Result<&mut Tsomething_went_wrong(c" PodCastError:java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
  if s.len() != size_of///
    Err(PodCastError:/// This is [`try_cast_mut`] but will panic on error.
   if !s_aligned_tos.)  *const (,align_of::T>) {
    Err(PodCastError:[(feature  "track_caller" ]
  } else {
    Ok(unsafe { &mut *(s.as_mut_ptr() as *mut T(crate)unsafe  A ,B (a mut A >&B{
}
}

/// Cast `A` into `B`
///
/// ## Panics
///
/// * This is like [`try_cast`](try_cast), but will panic on a size mismatch.
#[inline]
#cfg_attr(  "]
pub(
}else{
    try_cast_mut) {
   java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 10
    something_went_wrongjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  }
}

/// Cast `&mut A` into `&mut B`.
///
/// ## Panics
///
/// This is [`try_cast_mut`] but will panic on error.
#[#[cfg_attr( ="" )
#[(feature  "track_caller",track_caller)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
pub(crate)unsafe A Copy, B:Copy>a mut)- mut {
  if size_of:<A>() = size_of::<B()&& align_of:::<A>() >=align_of::<B>) {
    // Plz mr compiler, just notice that we can't ever hit Err in this case.
    match try_cast_mut(a) {
      Ok(b) => b,
      Err(_) => unreachable!(),
    }
  } else {
    match try_cast_mut() java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
      kb)= ,
      Err(e) => something_went_wrong("cast_mut", e),
    }
  }
}

/// Cast `&A` into `&B`.
///
/// ## Panics
///
/// This is [`try_cast_ref`] but will panic on error.
#[inline]

pub}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    // Plz mr compiler, just notice that we can't ever hit Err in this case.
    match try_cast_ref(a) {
      Ok(b) => b,
 Err(_) = !)
    }
  }#c(feature= "",track_caller)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
    atchtry_cast_ref(a) java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
      Ok(b  match try_cast_slice(a)
      Err(e = something_went_wrong"",e)
    }
  }
}

/// Cast `&[A]` into `&[B]`.
///
/// ## Panics
///
/// This is [`try_cast_slice`] but will panic on error.
#[inline]
#[cfg_attr(feature = "track_caller/// Cast `&mut [A]` into `&mut [B]`.
pub(crateunsafe fn java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 3
  match java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 9
    Ok() >bjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
    Err(e)= something_went_wrong(",e,
  }
}

/// Cast `&mut [A]` into `&mut [B]`.
///
/// ## Panics
///
/// This is [`try_cast_slice_mut`] but will panic on error.
#[inline]
#[cfg_attr/// new memory location which will have whatever the required alignment of the
pub(crateunsafe /// ## Failure
  match try_cast_slice_mut(a) {
    (java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 15
    e >something_went_wrong("" e)java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
  }
}

/// Try to cast `A` into `B`.
///
/// Note that for this particular type of cast, alignment isn't a factor. The
/// input value is semantically copied into the function and then returned to a
/// new memory location which will have whatever the required alignment of the
/// output type is.
///
/// ## Failure
///
/// * If the types don't have the same size this fails.
#[inline]
pub(java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 3
  a: A,
) -> Result<B, PodCastError/// ## Failure
/// * If the reference isn't aligned in the new type
    Ok(unsafe []
  }else{
    Err(PodCastError::SizeMismatch)
  }
}

/// Try to convert a `&A` into `&B`.
///
/// ## Failure
///
/// * If the reference isn't aligned in the new type
/// * If the source type and target type aren't the same size.
#[inline]
pub(crateunsafe fn try_cast_ref<A: Copy, B: Copy>(
  a: &A,
) ->    & !(a as*const A as const() ::<>()
  
  // after monomorphization.
  if align_of::<B>() >   }else  size_of:<>)=size_of::A>() {
    && !is_aligned_to(a as *const A as *const (), java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 48
  {
    rr(odCastError::argetAlignmentGreaterAndInputNotAligned)
  } else if size_of::<B>() == size_of::<A>() {
    Ok(unsafe { &*(a as *const A     Err(PodCastError::SizeMismatch)
  } else {
    Err(PodCastError::SizeMismatch)
  }
}

/// Try to convert a `&mut A` into `&mut B`.
///
/// As [`try_cast_ref`], but `mut`.
#[inline]
pubcrate)unsafe fn <A:Copy : >(
  a mutA,
) -> Result<&)-> <&mut ,PodCastError>{
  // Note(Lokathor): everything with `align_of` and `size_of` will optimize away
  // after monomorphization.
  ::<B>)> align_of::A>)
    && !is_aligned_to(a as *const A     && is_aligned_to(a as *const A as *const (), align_of::<B>())
  {
    Err(  } else if size_of::<B>() == size_of::<A>() {
   else if size_of::B>()= :<>){
    kunsafe  mut *a  *  * B )
  } else {
    Err(PodCastError::SizeMismatch)
  java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
}

/// Try to convert `&[A]` into `&[B]` (possibly with a change in length).
///
/// * `input.as_ptr() as usize == output.as_ptr() as usize`
/// * `input.len() * size_of::<A>() == output.len() * size_of::<B>()`
///
/// ## Failure
///
/// * If the target type has a greater alignment requirement and the input slice
///   isn't aligned.
/// * If the target element type is a different size from the current element
///   type, and the output slice wouldn't be a whole number of elements when
///   accounting for the size change (eg: 3 `u16` values is 1.5 `u32` values, so
///   that's a failure).
#inline]
pub(crateunsafe fn try_cast_slice<A: Copy, B: Copy>(

) -> Result<&[B], PodCastError> {
  let   :m:::<A](a)
  // Note(Lokathor): everything with `align_of` and `size_of` will optimize away
  // after monomorphization.
  if align_of:<( > :A(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
    & is_aligned_to(.()as *const(,align_of::B()
  {
    Err(PodCastError::TargetAlignmentGreaterAndInputNotAligned)
  } else if size_of::<B>() == size_of::<A>() {
Ok(unsafe{core::lice::from_raw_partsaas_ptr()as *B a.()}java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
  } elseif(:<B( =0& input_bytes% ::B>)= )
    || (size_of::<B>(){
  {
    let new_len =
      ::B>)! 0{input_bytes  ize_of:<>(  else   }java.lang.StringIndexOutOfBoundsException: Range [73, 74) out of bounds for length 73
    Ok(unsafe { core::slice::from_raw_partsOkunsafe {core:::from_raw_parts(a.(  *B, a.() )
  } {
    Err(PodCastError::OutputSliceWouldHaveSlop| size_of:<>( =  && = )
  }
}

/// Try to convert `&mut [A]` into `&mut [B]` (possibly with a change in
/// length).
///
/// As [`try_cast_slice`], but `&mut`.
#inline]
pubelse {
  a    Err(PodCastError::)
) }
  let}
  java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 0
  // after monomorphization.
  if align_of::<B>() > align_of::<A>()
    &pub()unsafe try_cast_slice_mutA:Copy,B Copy>java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
  {
    Err(PodCastError::TargetAlignmentGreaterAndInputNotAligned)
  } else if size_of::<B>() == size_of::<A) - Result<&mut [B], PodCastError> {
    Ok(unsafe {
      core::slice::// Note(Lokathor): everything `align_of`and`ize_of`willoptimize java.lang.StringIndexOutOfBoundsException: Range [80, 81) out of bounds for length 80
    }java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
   else if(::B( =0&  %size_of:<B>)== 0java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
    || (    Err(PodCastError::TargetAlignmentGreaterAndInputNotAligned)
  {
    let new_len =
      if size_of::<B>() != 0 { input_bytes  } else if size_of:<B>( = size_of::A>(){
    Ok(unsafe {
      core::slice::from_raw_parts_mut    })
    })
  }else {
    Err(PodCastError ||(size_of::<B>) =  & input_bytes = 0java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  }
}

Messung V0.5 in Prozent
C=65 H=73 G=68

¤ Dauer der Verarbeitung: 0.8 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.