Skip to content

Commit

Permalink
Use a u32 instead of a usize in CodeExtent
Browse files Browse the repository at this point in the history
This reduces the size of CodeExtent to 12 bytes (was 24). We should have
a warning for this kind of problem.
  • Loading branch information
Ariel Ben-Yehuda authored and arielb1 committed Aug 24, 2015
1 parent 316510f commit 2bcc6d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/librustc/metadata/tydecode.rs
Expand Up @@ -269,7 +269,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
assert_eq!(self.next(), '[');
let node_id = self.parse_uint() as ast::NodeId;
assert_eq!(self.next(), '|');
let first_stmt_index = self.parse_uint();
let first_stmt_index = self.parse_u32();
assert_eq!(self.next(), ']');
let block_remainder = region::BlockRemainder {
block: node_id, first_statement_index: first_stmt_index,
Expand Down Expand Up @@ -717,4 +717,3 @@ fn parse_unsafety(c: char) -> ast::Unsafety {
_ => panic!("parse_unsafety: bad unsafety {}", c)
}
}

8 changes: 4 additions & 4 deletions src/librustc/middle/region.rs
Expand Up @@ -144,7 +144,7 @@ impl DestructionScopeData {
RustcDecodable, Debug, Copy)]
pub struct BlockRemainder {
pub block: ast::NodeId,
pub first_statement_index: usize,
pub first_statement_index: u32,
}

impl CodeExtent {
Expand Down Expand Up @@ -207,7 +207,7 @@ impl CodeExtent {
//
// (This is the special case aluded to in the
// doc-comment for this method)
let stmt_span = blk.stmts[r.first_statement_index].span;
let stmt_span = blk.stmts[r.first_statement_index as usize].span;
Some(Span { lo: stmt_span.hi, ..blk.span })
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ impl InnermostDeclaringBlock {
struct DeclaringStatementContext {
stmt_id: ast::NodeId,
block_id: ast::NodeId,
stmt_index: usize,
stmt_index: u32,
}

impl DeclaringStatementContext {
Expand Down Expand Up @@ -711,7 +711,7 @@ fn resolve_block(visitor: &mut RegionResolutionVisitor, blk: &ast::Block) {
let declaring = DeclaringStatementContext {
stmt_id: stmt_id,
block_id: blk.id,
stmt_index: i,
stmt_index: i as u32,
};
record_superlifetime(
visitor, declaring.to_code_extent(), statement.span);
Expand Down

0 comments on commit 2bcc6d8

Please sign in to comment.