Skip to content

Commit 9444414

Browse files
committed
---
yaml --- r: 196254 b: refs/heads/tmp c: 15b58fe h: refs/heads/master v: v3
1 parent cce1a7d commit 9444414

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 9854143cba679834bc4ef932858cd5303f015a0e
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 30b2d9e7643de3a267029c2763edb0b44ff2396e
35+
refs/heads/tmp: 15b58fedcacba7d10a9f7d460a83da645a09ad3e
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: 53a183f0274316596bf9405944d4f0468d8c93e4
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use std::io::prelude::*;
3434
use std::io::{Cursor, SeekFrom};
3535
use syntax::abi;
3636
use syntax::ast::{self, DefId, NodeId};
37-
use syntax::ast_map::{PathElem, PathElems};
38-
use syntax::ast_map;
37+
use syntax::ast_map::{self, LinkedPath, PathElem, PathElems};
3938
use syntax::ast_util::*;
4039
use syntax::ast_util;
4140
use syntax::attr;
@@ -1513,7 +1512,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
15131512
&krate.module,
15141513
&[],
15151514
ast::CRATE_NODE_ID,
1516-
[].iter().cloned().chain(None),
1515+
[].iter().cloned().chain(LinkedPath::empty()),
15171516
syntax::parse::token::special_idents::invalid,
15181517
ast::Public);
15191518

@@ -1874,7 +1873,7 @@ fn encode_misc_info(ecx: &EncodeContext,
18741873
}
18751874

18761875
// Encode reexports for the root module.
1877-
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(None));
1876+
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(LinkedPath::empty()));
18781877

18791878
rbml_w.end_tag();
18801879
rbml_w.end_tag();

branches/tmp/src/libsyntax/ast_map/mod.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,29 @@ impl fmt::Display for PathElem {
5353
}
5454

5555
#[derive(Clone)]
56-
struct LinkedPathNode<'a> {
56+
pub struct LinkedPathNode<'a> {
5757
node: PathElem,
5858
next: LinkedPath<'a>,
5959
}
6060

61-
type LinkedPath<'a> = Option<&'a LinkedPathNode<'a>>;
61+
#[derive(Copy, Clone)]
62+
pub struct LinkedPath<'a>(Option<&'a LinkedPathNode<'a>>);
63+
64+
impl<'a> LinkedPath<'a> {
65+
pub fn empty() -> LinkedPath<'a> {
66+
LinkedPath(None)
67+
}
68+
69+
pub fn from(node: &'a LinkedPathNode) -> LinkedPath<'a> {
70+
LinkedPath(Some(node))
71+
}
72+
}
6273

6374
impl<'a> Iterator for LinkedPath<'a> {
6475
type Item = PathElem;
6576

6677
fn next(&mut self) -> Option<PathElem> {
67-
match *self {
78+
match self.0 {
6879
Some(node) => {
6980
*self = node.next;
7081
Some(node.node)
@@ -384,7 +395,7 @@ impl<'ast> Map<'ast> {
384395
pub fn with_path<T, F>(&self, id: NodeId, f: F) -> T where
385396
F: FnOnce(PathElems) -> T,
386397
{
387-
self.with_path_next(id, None, f)
398+
self.with_path_next(id, LinkedPath::empty(), f)
388399
}
389400

390401
pub fn path_to_string(&self, id: NodeId) -> String {
@@ -422,7 +433,7 @@ impl<'ast> Map<'ast> {
422433
_ => f([].iter().cloned().chain(next))
423434
}
424435
} else {
425-
self.with_path_next(parent, Some(&LinkedPathNode {
436+
self.with_path_next(parent, LinkedPath::from(&LinkedPathNode {
426437
node: self.get_path_elem(id),
427438
next: next
428439
}), f)

0 commit comments

Comments
 (0)