Skip to content

Commit 90df078

Browse files
authored
Rollup merge of rust-lang#35977 - frewsxcv:usize-isize, r=eddyb
Rename {int,uint} methods to {isize,usize}. None
2 parents b65f5a1 + 905644d commit 90df078

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

src/librbml/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ pub mod reader {
726726
fn read_u8(&mut self) -> DecodeResult<u8> {
727727
Ok(doc_as_u8(self.next_doc(EsU8)?))
728728
}
729-
fn read_uint(&mut self) -> DecodeResult<usize> {
729+
fn read_usize(&mut self) -> DecodeResult<usize> {
730730
let v = self._next_int(EsU8, EsU64)?;
731731
if v > (::std::usize::MAX as u64) {
732732
Err(IntTooBig(v as usize))
@@ -747,7 +747,7 @@ pub mod reader {
747747
fn read_i8(&mut self) -> DecodeResult<i8> {
748748
Ok(doc_as_u8(self.next_doc(EsI8)?) as i8)
749749
}
750-
fn read_int(&mut self) -> DecodeResult<isize> {
750+
fn read_isize(&mut self) -> DecodeResult<isize> {
751751
let v = self._next_int(EsI8, EsI64)? as i64;
752752
if v > (isize::MAX as i64) || v < (isize::MIN as i64) {
753753
debug!("FIXME \\#6122: Removing this makes this function miscompile");
@@ -1219,7 +1219,7 @@ pub mod writer {
12191219
Ok(())
12201220
}
12211221

1222-
fn emit_uint(&mut self, v: usize) -> EncodeResult {
1222+
fn emit_usize(&mut self, v: usize) -> EncodeResult {
12231223
self.emit_u64(v as u64)
12241224
}
12251225
fn emit_u64(&mut self, v: u64) -> EncodeResult {
@@ -1247,7 +1247,7 @@ pub mod writer {
12471247
self.wr_tagged_raw_u8(EsU8 as usize, v)
12481248
}
12491249

1250-
fn emit_int(&mut self, v: isize) -> EncodeResult {
1250+
fn emit_isize(&mut self, v: isize) -> EncodeResult {
12511251
self.emit_i64(v as i64)
12521252
}
12531253
fn emit_i64(&mut self, v: i64) -> EncodeResult {

src/librbml/opaque.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
5454
Ok(())
5555
}
5656

57-
fn emit_uint(&mut self, v: usize) -> EncodeResult {
57+
fn emit_usize(&mut self, v: usize) -> EncodeResult {
5858
write_uleb128!(self, v)
5959
}
6060

@@ -75,7 +75,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
7575
Ok(())
7676
}
7777

78-
fn emit_int(&mut self, v: isize) -> EncodeResult {
78+
fn emit_isize(&mut self, v: isize) -> EncodeResult {
7979
write_sleb128!(self, v)
8080
}
8181

@@ -120,7 +120,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
120120
}
121121

122122
fn emit_str(&mut self, v: &str) -> EncodeResult {
123-
self.emit_uint(v.len())?;
123+
self.emit_usize(v.len())?;
124124
let _ = self.cursor.write_all(v.as_bytes());
125125
Ok(())
126126
}
@@ -139,7 +139,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
139139
-> EncodeResult
140140
where F: FnOnce(&mut Self) -> EncodeResult
141141
{
142-
self.emit_uint(v_id)?;
142+
self.emit_usize(v_id)?;
143143
f(self)
144144
}
145145

@@ -221,7 +221,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
221221
fn emit_seq<F>(&mut self, len: usize, f: F) -> EncodeResult
222222
where F: FnOnce(&mut Encoder<'a>) -> EncodeResult
223223
{
224-
self.emit_uint(len)?;
224+
self.emit_usize(len)?;
225225
f(self)
226226
}
227227

@@ -234,7 +234,7 @@ impl<'a> serialize::Encoder for Encoder<'a> {
234234
fn emit_map<F>(&mut self, len: usize, f: F) -> EncodeResult
235235
where F: FnOnce(&mut Encoder<'a>) -> EncodeResult
236236
{
237-
self.emit_uint(len)?;
237+
self.emit_usize(len)?;
238238
f(self)
239239
}
240240

@@ -329,7 +329,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
329329
Ok(value)
330330
}
331331

332-
fn read_uint(&mut self) -> Result<usize, Self::Error> {
332+
fn read_usize(&mut self) -> Result<usize, Self::Error> {
333333
read_uleb128!(self, usize)
334334
}
335335

@@ -351,7 +351,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
351351
unsafe { Ok(::std::mem::transmute(as_u8)) }
352352
}
353353

354-
fn read_int(&mut self) -> Result<isize, Self::Error> {
354+
fn read_isize(&mut self) -> Result<isize, Self::Error> {
355355
read_sleb128!(self, isize)
356356
}
357357

@@ -376,7 +376,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
376376
}
377377

378378
fn read_str(&mut self) -> Result<String, Self::Error> {
379-
let len = self.read_uint()?;
379+
let len = self.read_usize()?;
380380
let s = ::std::str::from_utf8(&self.data[self.position..self.position + len]).unwrap();
381381
self.position += len;
382382
Ok(s.to_string())
@@ -391,7 +391,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
391391
fn read_enum_variant<T, F>(&mut self, _: &[&str], mut f: F) -> Result<T, Self::Error>
392392
where F: FnMut(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
393393
{
394-
let disr = self.read_uint()?;
394+
let disr = self.read_usize()?;
395395
f(self, disr)
396396
}
397397

@@ -404,7 +404,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
404404
fn read_enum_struct_variant<T, F>(&mut self, _: &[&str], mut f: F) -> Result<T, Self::Error>
405405
where F: FnMut(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
406406
{
407-
let disr = self.read_uint()?;
407+
let disr = self.read_usize()?;
408408
f(self, disr)
409409
}
410410

@@ -483,7 +483,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
483483
fn read_seq<T, F>(&mut self, f: F) -> Result<T, Self::Error>
484484
where F: FnOnce(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
485485
{
486-
let len = self.read_uint()?;
486+
let len = self.read_usize()?;
487487
f(self, len)
488488
}
489489

@@ -496,7 +496,7 @@ impl<'a> serialize::Decoder for Decoder<'a> {
496496
fn read_map<T, F>(&mut self, f: F) -> Result<T, Self::Error>
497497
where F: FnOnce(&mut Decoder<'a>, usize) -> Result<T, Self::Error>
498498
{
499-
let len = self.read_uint()?;
499+
let len = self.read_usize()?;
500500
f(self, len)
501501
}
502502

src/libserialize/collection_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ impl<
136136
for item in self {
137137
bits |= item.to_usize();
138138
}
139-
s.emit_uint(bits)
139+
s.emit_usize(bits)
140140
}
141141
}
142142

143143
impl<
144144
T: Decodable + CLike
145145
> Decodable for EnumSet<T> {
146146
fn decode<D: Decoder>(d: &mut D) -> Result<EnumSet<T>, D::Error> {
147-
let bits = d.read_uint()?;
147+
let bits = d.read_usize()?;
148148
let mut set = EnumSet::new();
149149
for bit in 0..(mem::size_of::<usize>()*8) {
150150
if bits & (1 << bit) != 0 {

src/libserialize/json.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,13 @@ impl<'a> ::Encoder for Encoder<'a> {
495495
Ok(())
496496
}
497497

498-
fn emit_uint(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
498+
fn emit_usize(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
499499
fn emit_u64(&mut self, v: u64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
500500
fn emit_u32(&mut self, v: u32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
501501
fn emit_u16(&mut self, v: u16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
502502
fn emit_u8(&mut self, v: u8) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
503503

504-
fn emit_int(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
504+
fn emit_isize(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
505505
fn emit_i64(&mut self, v: i64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
506506
fn emit_i32(&mut self, v: i32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
507507
fn emit_i16(&mut self, v: i16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
@@ -743,13 +743,13 @@ impl<'a> ::Encoder for PrettyEncoder<'a> {
743743
Ok(())
744744
}
745745

746-
fn emit_uint(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
746+
fn emit_usize(&mut self, v: usize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
747747
fn emit_u64(&mut self, v: u64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
748748
fn emit_u32(&mut self, v: u32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
749749
fn emit_u16(&mut self, v: u16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
750750
fn emit_u8(&mut self, v: u8) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
751751

752-
fn emit_int(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
752+
fn emit_isize(&mut self, v: isize) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
753753
fn emit_i64(&mut self, v: i64) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
754754
fn emit_i32(&mut self, v: i32) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
755755
fn emit_i16(&mut self, v: i16) -> EncodeResult { emit_enquoted_if_mapkey!(self, v) }
@@ -2137,12 +2137,12 @@ impl ::Decoder for Decoder {
21372137
expect!(self.pop(), Null)
21382138
}
21392139

2140-
read_primitive! { read_uint, usize }
2140+
read_primitive! { read_usize, usize }
21412141
read_primitive! { read_u8, u8 }
21422142
read_primitive! { read_u16, u16 }
21432143
read_primitive! { read_u32, u32 }
21442144
read_primitive! { read_u64, u64 }
2145-
read_primitive! { read_int, isize }
2145+
read_primitive! { read_isize, isize }
21462146
read_primitive! { read_i8, i8 }
21472147
read_primitive! { read_i16, i16 }
21482148
read_primitive! { read_i32, i32 }

src/libserialize/serialize.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ pub trait Encoder {
2424

2525
// Primitive types:
2626
fn emit_nil(&mut self) -> Result<(), Self::Error>;
27-
fn emit_uint(&mut self, v: usize) -> Result<(), Self::Error>;
27+
fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>;
2828
fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>;
2929
fn emit_u32(&mut self, v: u32) -> Result<(), Self::Error>;
3030
fn emit_u16(&mut self, v: u16) -> Result<(), Self::Error>;
3131
fn emit_u8(&mut self, v: u8) -> Result<(), Self::Error>;
32-
fn emit_int(&mut self, v: isize) -> Result<(), Self::Error>;
32+
fn emit_isize(&mut self, v: isize) -> Result<(), Self::Error>;
3333
fn emit_i64(&mut self, v: i64) -> Result<(), Self::Error>;
3434
fn emit_i32(&mut self, v: i32) -> Result<(), Self::Error>;
3535
fn emit_i16(&mut self, v: i16) -> Result<(), Self::Error>;
@@ -108,12 +108,12 @@ pub trait Decoder {
108108

109109
// Primitive types:
110110
fn read_nil(&mut self) -> Result<(), Self::Error>;
111-
fn read_uint(&mut self) -> Result<usize, Self::Error>;
111+
fn read_usize(&mut self) -> Result<usize, Self::Error>;
112112
fn read_u64(&mut self) -> Result<u64, Self::Error>;
113113
fn read_u32(&mut self) -> Result<u32, Self::Error>;
114114
fn read_u16(&mut self) -> Result<u16, Self::Error>;
115115
fn read_u8(&mut self) -> Result<u8, Self::Error>;
116-
fn read_int(&mut self) -> Result<isize, Self::Error>;
116+
fn read_isize(&mut self) -> Result<isize, Self::Error>;
117117
fn read_i64(&mut self) -> Result<i64, Self::Error>;
118118
fn read_i32(&mut self) -> Result<i32, Self::Error>;
119119
fn read_i16(&mut self) -> Result<i16, Self::Error>;
@@ -200,13 +200,13 @@ pub trait Decodable: Sized {
200200

201201
impl Encodable for usize {
202202
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
203-
s.emit_uint(*self)
203+
s.emit_usize(*self)
204204
}
205205
}
206206

207207
impl Decodable for usize {
208208
fn decode<D: Decoder>(d: &mut D) -> Result<usize, D::Error> {
209-
d.read_uint()
209+
d.read_usize()
210210
}
211211
}
212212

@@ -260,13 +260,13 @@ impl Decodable for u64 {
260260

261261
impl Encodable for isize {
262262
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
263-
s.emit_int(*self)
263+
s.emit_isize(*self)
264264
}
265265
}
266266

267267
impl Decodable for isize {
268268
fn decode<D: Decoder>(d: &mut D) -> Result<isize, D::Error> {
269-
d.read_int()
269+
d.read_isize()
270270
}
271271
}
272272

0 commit comments

Comments
 (0)