@@ -30,7 +30,7 @@ pub enum SchedulingAction {
3030
3131/// A thread identifier.
3232#[ derive( Clone , Copy , Debug , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
33- pub struct ThreadId ( usize ) ;
33+ pub struct ThreadId ( u32 ) ;
3434
3535/// The main thread. When it terminates, the whole application terminates.
3636const MAIN_THREAD : ThreadId = ThreadId ( 0 ) ;
@@ -43,22 +43,22 @@ impl ThreadId {
4343
4444impl Idx for ThreadId {
4545 fn new ( idx : usize ) -> Self {
46- ThreadId ( idx)
46+ ThreadId ( u32 :: try_from ( idx) . unwrap ( ) )
4747 }
4848 fn index ( self ) -> usize {
49- self . 0
49+ usize :: try_from ( self . 0 ) . unwrap ( )
5050 }
5151}
5252
5353impl From < u64 > for ThreadId {
5454 fn from ( id : u64 ) -> Self {
55- Self ( usize :: try_from ( id) . unwrap ( ) )
55+ Self ( u32 :: try_from ( id) . unwrap ( ) )
5656 }
5757}
5858
5959impl From < u32 > for ThreadId {
6060 fn from ( id : u32 ) -> Self {
61- Self ( usize :: try_from ( id) . unwrap ( ) )
61+ Self ( u32 :: try_from ( id) . unwrap ( ) )
6262 }
6363}
6464
@@ -73,13 +73,11 @@ impl ThreadId {
7373#[ derive( Clone , Copy , Debug , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
7474pub struct BlockSetId ( NonZeroU32 ) ;
7575
76- impl From < u32 > for BlockSetId {
77- fn from ( id : u32 ) -> Self {
76+ impl BlockSetId {
77+ /// Panics if `id` is 0.
78+ pub fn new ( id : u32 ) -> Self {
7879 Self ( NonZeroU32 :: new ( id) . expect ( "0 is not a valid blockset id" ) )
7980 }
80- }
81-
82- impl BlockSetId {
8381 pub fn to_u32_scalar < ' tcx > ( & self ) -> Scalar < Tag > {
8482 Scalar :: from_u32 ( self . 0 . get ( ) )
8583 }
@@ -325,7 +323,7 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
325323 /// Allocate a new blockset id.
326324 fn create_blockset ( & mut self ) -> BlockSetId {
327325 self . blockset_counter = self . blockset_counter . checked_add ( 1 ) . unwrap ( ) ;
328- self . blockset_counter . into ( )
326+ BlockSetId :: new ( self . blockset_counter )
329327 }
330328
331329 /// Block the currently active thread and put it into the given blockset.
0 commit comments