1
Fork 0

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.
This commit is contained in:
Ariel Ben-Yehuda 2015-08-19 15:10:18 +03:00 committed by Ariel Ben-Yehuda
parent 316510f5e2
commit 2bcc6d8ec7
2 changed files with 5 additions and 6 deletions

View file

@ -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,
@ -717,4 +717,3 @@ fn parse_unsafety(c: char) -> ast::Unsafety {
_ => panic!("parse_unsafety: bad unsafety {}", c)
}
}

View file

@ -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 {
@ -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 })
}
}
@ -310,7 +310,7 @@ impl InnermostDeclaringBlock {
struct DeclaringStatementContext {
stmt_id: ast::NodeId,
block_id: ast::NodeId,
stmt_index: usize,
stmt_index: u32,
}
impl DeclaringStatementContext {
@ -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);