20
20
use std:: fmt;
21
21
22
22
/// Underlying variable representation.
23
- type RawVar = u16 ;
23
+ type RawVar = usize ;
24
24
25
25
/// A [de Bruijn index], which represents a variable counting the number of
26
26
/// binders between a variable occurrence and the binder that introduced the
@@ -52,7 +52,7 @@ impl Index {
52
52
53
53
/// Returns the previously bound variable, relative to this one.
54
54
pub const fn prev ( self ) -> Index {
55
- Index ( self . 0 + 1 ) // FIXME: check overflow?
55
+ Index ( self . 0 + 1 )
56
56
}
57
57
}
58
58
@@ -99,7 +99,7 @@ impl Level {
99
99
100
100
/// Returns the next bound variable, relative to this one.
101
101
pub const fn next ( self ) -> Level {
102
- Level ( self . 0 + 1 ) // FIXME: check overflow?
102
+ Level ( self . 0 + 1 )
103
103
}
104
104
}
105
105
@@ -154,12 +154,12 @@ impl EnvLen {
154
154
155
155
/// Push an entry onto the environment.
156
156
pub fn push ( & mut self ) {
157
- self . 0 += 1 ; // FIXME: check overflow?
157
+ self . 0 += 1 ;
158
158
}
159
159
160
160
/// Pop an entry off the environment.
161
161
pub fn pop ( & mut self ) {
162
- self . 0 -= 1 ; // FIXME: check underflow?
162
+ self . 0 -= 1 ;
163
163
}
164
164
165
165
/// Truncate the environment to the given length.
@@ -193,7 +193,7 @@ impl<Entry> UniqueEnv<Entry> {
193
193
where
194
194
Entry : Clone ,
195
195
{
196
- self . entries . resize ( usize :: from ( new_len. 0 ) , entry)
196
+ self . entries . resize ( new_len. 0 , entry)
197
197
}
198
198
199
199
/// Push an entry onto the environment.
@@ -209,7 +209,7 @@ impl<Entry> UniqueEnv<Entry> {
209
209
210
210
/// Truncate the environment to the given length.
211
211
pub fn truncate ( & mut self , len : EnvLen ) {
212
- self . entries . truncate ( len. 0 as usize ) ;
212
+ self . entries . truncate ( len. 0 ) ;
213
213
}
214
214
215
215
pub fn reserve ( & mut self , additional : usize ) {
@@ -249,7 +249,7 @@ impl<Entry> SliceEnv<Entry> {
249
249
250
250
/// Lookup an entry in the environment using a level
251
251
pub fn get_level ( & self , level : Level ) -> Option < & Entry > {
252
- self . entries . get ( usize :: from ( level. 0 ) )
252
+ self . entries . get ( level. 0 )
253
253
}
254
254
255
255
/// Lookup an entry in the environment using an index
@@ -259,7 +259,7 @@ impl<Entry> SliceEnv<Entry> {
259
259
260
260
/// Set an entry in the environment using a level
261
261
pub fn set_level ( & mut self , level : Level , entry : Entry ) {
262
- self . entries [ usize :: from ( level. 0 ) ] = entry;
262
+ self . entries [ level. 0 ] = entry;
263
263
}
264
264
265
265
/// Iterate over the elements in the environment.
@@ -329,7 +329,7 @@ impl<Entry> SharedEnv<Entry> {
329
329
330
330
/// Lookup an entry in the environment using a level
331
331
pub fn get_level ( & self , level : Level ) -> Option < & Entry > {
332
- self . entries . get ( usize :: from ( level. 0 ) )
332
+ self . entries . get ( level. 0 )
333
333
}
334
334
335
335
/// Lookup an entry in the environment using an index
@@ -339,7 +339,6 @@ impl<Entry> SharedEnv<Entry> {
339
339
340
340
/// Push an entry onto the environment.
341
341
pub fn push ( & mut self , entry : Entry ) {
342
- assert ! ( self . entries. len( ) < usize :: from( u16 :: MAX ) ) ;
343
342
self . entries . push_back_mut ( entry) ;
344
343
}
345
344
0 commit comments