make constructing an Id private to salsa

This way we know that all Id instances came from salsa.

Not sure if that matters, but why not?
This commit is contained in:
Niko Matsakis 2022-08-08 00:06:46 -04:00
parent ac837e2cdc
commit 4400c1b66a
2 changed files with 2 additions and 15 deletions

View file

@ -20,7 +20,7 @@ impl Id {
pub const MAX_USIZE: usize = Self::MAX_U32 as usize;
#[track_caller]
pub fn from_u32(x: u32) -> Self {
pub(crate) fn from_u32(x: u32) -> Self {
assert!(x < Self::MAX_U32);
Id {
value: NonZeroU32::new(x + 1).unwrap(),
@ -32,19 +32,6 @@ impl Id {
}
}
impl From<u32> for Id {
fn from(n: u32) -> Self {
Id::from_u32(n)
}
}
impl From<usize> for Id {
fn from(n: usize) -> Self {
assert!(n < Id::MAX_USIZE);
Id::from_u32(n as u32)
}
}
impl From<Id> for u32 {
fn from(n: Id) -> Self {
n.as_u32()

View file

@ -40,7 +40,7 @@ where
pub fn new_input(&mut self, _runtime: &mut Runtime) -> Id {
let next_id = self.counter;
self.counter += 1;
Id::from_id(crate::Id::from(next_id))
Id::from_id(crate::Id::from_u32(next_id))
}
}