Skip to content

Commit 90761b6

Browse files
committed
---
yaml --- r: 195551 b: refs/heads/master c: 15b58fe h: refs/heads/master i: 195549: ddc2637 195547: 9e60100 195543: c079f3d 195535: ea653cd 195519: e04daae v: v3
1 parent 06d8077 commit 90761b6

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
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 30b2d9e7643de3a267029c2763edb0b44ff2396e
2+
refs/heads/master: 15b58fedcacba7d10a9f7d460a83da645a09ad3e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b3317d68910900f135f9f38e43a7a699bc736b4a
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf

trunk/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();

trunk/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)