Conversation

Charlotte lotteheartplural/Cinny cinny_heart_plural thetadelta ursaminor treblesand

rust proposal

fn get_null_ref<T: ?Sized>() -> &'static T {
  Null
}

fn check_null_ref() {
  assert_eq!(get_null_ref::<u8>(), Null);
  assert_ne!(get_null_ref::<[u8]>(), Null);
  // this following panics:
  // println!("waow: {}", get_null_ref::<[u8]>().len());

  // Actual, for real, null check
  let unknown_reference: &'static [u8] = get_null_ref();
  let unknown_reference_ptr_addr = (&raw const unknown_reference).cast::<usize>();
  if unsafe { *unknown_reference_ptr_addr } == 0 {
    println!("This is a null reference!");
  } else {
    println!("This is *not* a null reference!");
  }
}
2
3
4

@charlotte are you trying to break the entire language on purpose

1
0
0

@cloudhop no i am just honoring rob pike’s radiant vision

0
0
0