diff options
| author | bors <bors@rust-lang.org> | 2013-03-19 12:43:14 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-03-19 12:43:14 -0700 |
| commit | e1888948c640f8b8396091b336c2677cb82fdcce (patch) | |
| tree | ff3d02994510a741e117adf3d0f57d39b3623a1f /src/librustc/metadata | |
| parent | a14ec73cd2d15a2454113011835557ccf447f14d (diff) | |
| parent | a6187c62e93ba96dce8f19849fb7016f4f941f8c (diff) | |
| download | rust-e1888948c640f8b8396091b336c2677cb82fdcce.tar.gz rust-e1888948c640f8b8396091b336c2677cb82fdcce.zip | |
auto merge of #5426 : nikomatsakis/rust/issue-4846-lifetimes-in-expl-self, r=pcwalton
(this will be needed for snapshotting at some point) r? @pcwalton
Diffstat (limited to 'src/librustc/metadata')
| -rw-r--r-- | src/librustc/metadata/decoder.rs | 5 | ||||
| -rw-r--r-- | src/librustc/metadata/encoder.rs | 53 |
2 files changed, 38 insertions, 20 deletions
diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 1864e1c06ae..eaf02790537 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -631,7 +631,10 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { 'v' => { return ast::sty_value; } '@' => { return ast::sty_box(get_mutability(string[1])); } '~' => { return ast::sty_uniq(get_mutability(string[1])); } - '&' => { return ast::sty_region(get_mutability(string[1])); } + '&' => { + // FIXME(#4846) expl. region + return ast::sty_region(None, get_mutability(string[1])); + } _ => { fail!(fmt!("unknown self type code: `%c`", self_ty_kind as char)); } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index efbde04d68e..f507d0d8718 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -406,32 +406,47 @@ fn encode_self_type(ebml_w: writer::Encoder, self_type: ast::self_ty_) { ebml_w.start_tag(tag_item_trait_method_self_ty); // Encode the base self type. - let ch; match self_type { - sty_static => { ch = 's' as u8; } - sty_by_ref => { ch = 'r' as u8; } - sty_value => { ch = 'v' as u8; } - sty_region(_) => { ch = '&' as u8; } - sty_box(_) => { ch = '@' as u8; } - sty_uniq(_) => { ch = '~' as u8; } - } - ebml_w.writer.write(&[ ch ]); - - // Encode mutability. - match self_type { - sty_static | sty_by_ref | sty_value => { /* No-op. */ } - sty_region(m_imm) | sty_box(m_imm) | sty_uniq(m_imm) => { - ebml_w.writer.write(&[ 'i' as u8 ]); + sty_static => { + ebml_w.writer.write(&[ 's' as u8 ]); + } + sty_by_ref => { + ebml_w.writer.write(&[ 'r' as u8 ]); + } + sty_value => { + ebml_w.writer.write(&[ 'v' as u8 ]); + } + sty_region(_, m) => { + // FIXME(#4846) encode custom lifetime + ebml_w.writer.write(&[ '&' as u8 ]); + encode_mutability(ebml_w, m); } - sty_region(m_mutbl) | sty_box(m_mutbl) | sty_uniq(m_mutbl) => { - ebml_w.writer.write(&[ 'm' as u8 ]); + sty_box(m) => { + ebml_w.writer.write(&[ '@' as u8 ]); + encode_mutability(ebml_w, m); } - sty_region(m_const) | sty_box(m_const) | sty_uniq(m_const) => { - ebml_w.writer.write(&[ 'c' as u8 ]); + sty_uniq(m) => { + ebml_w.writer.write(&[ '~' as u8 ]); + encode_mutability(ebml_w, m); } } ebml_w.end_tag(); + + fn encode_mutability(ebml_w: writer::Encoder, + m: ast::mutability) { + match m { + m_imm => { + ebml_w.writer.write(&[ 'i' as u8 ]); + } + m_mutbl => { + ebml_w.writer.write(&[ 'm' as u8 ]); + } + m_const => { + ebml_w.writer.write(&[ 'c' as u8 ]); + } + } + } } fn encode_method_sort(ebml_w: writer::Encoder, sort: char) { |
