Skip to content

Commit 2bcc6d8

Browse files
Ariel Ben-Yehudaarielb1
Ariel Ben-Yehuda
authored andcommitted
Use a u32 instead of a usize in CodeExtent
This reduces the size of CodeExtent to 12 bytes (was 24). We should have a warning for this kind of problem.
1 parent 316510f commit 2bcc6d8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
269269
assert_eq!(self.next(), '[');
270270
let node_id = self.parse_uint() as ast::NodeId;
271271
assert_eq!(self.next(), '|');
272-
let first_stmt_index = self.parse_uint();
272+
let first_stmt_index = self.parse_u32();
273273
assert_eq!(self.next(), ']');
274274
let block_remainder = region::BlockRemainder {
275275
block: node_id, first_statement_index: first_stmt_index,
@@ -717,4 +717,3 @@ fn parse_unsafety(c: char) -> ast::Unsafety {
717717
_ => panic!("parse_unsafety: bad unsafety {}", c)
718718
}
719719
}
720-

src/librustc/middle/region.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl DestructionScopeData {
144144
RustcDecodable, Debug, Copy)]
145145
pub struct BlockRemainder {
146146
pub block: ast::NodeId,
147-
pub first_statement_index: usize,
147+
pub first_statement_index: u32,
148148
}
149149

150150
impl CodeExtent {
@@ -207,7 +207,7 @@ impl CodeExtent {
207207
//
208208
// (This is the special case aluded to in the
209209
// doc-comment for this method)
210-
let stmt_span = blk.stmts[r.first_statement_index].span;
210+
let stmt_span = blk.stmts[r.first_statement_index as usize].span;
211211
Some(Span { lo: stmt_span.hi, ..blk.span })
212212
}
213213
}
@@ -310,7 +310,7 @@ impl InnermostDeclaringBlock {
310310
struct DeclaringStatementContext {
311311
stmt_id: ast::NodeId,
312312
block_id: ast::NodeId,
313-
stmt_index: usize,
313+
stmt_index: u32,
314314
}
315315

316316
impl DeclaringStatementContext {
@@ -711,7 +711,7 @@ fn resolve_block(visitor: &mut RegionResolutionVisitor, blk: &ast::Block) {
711711
let declaring = DeclaringStatementContext {
712712
stmt_id: stmt_id,
713713
block_id: blk.id,
714-
stmt_index: i,
714+
stmt_index: i as u32,
715715
};
716716
record_superlifetime(
717717
visitor, declaring.to_code_extent(), statement.span);

0 commit comments

Comments
 (0)