Skip to content

Commit b6b75ee

Browse files
committed
Remove a custom variant of iter::Cloned.
1 parent 532bd9b commit b6b75ee

File tree

5 files changed

+8
-21
lines changed

5 files changed

+8
-21
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
15781578
&krate.module,
15791579
&[],
15801580
ast::CRATE_NODE_ID,
1581-
ast_map::Values([].iter()).chain(None),
1581+
[].iter().cloned().chain(None),
15821582
syntax::parse::token::special_idents::invalid,
15831583
ast::Public);
15841584

@@ -1955,7 +1955,7 @@ fn encode_misc_info(ecx: &EncodeContext,
19551955
}
19561956

19571957
// Encode reexports for the root module.
1958-
encode_reexports(ecx, rbml_w, 0, ast_map::Values([].iter()).chain(None));
1958+
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(None));
19591959

19601960
rbml_w.end_tag();
19611961
rbml_w.end_tag();

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata,
130130
debug!("> Decoding inlined fn: {:?}::?",
131131
{
132132
// Do an Option dance to use the path after it is moved below.
133-
let s = ast_map::path_to_string(ast_map::Values(path.iter()));
133+
let s = ast_map::path_to_string(path.iter().cloned());
134134
path_as_str = Some(s);
135135
path_as_str.as_ref().map(|x| &x[])
136136
});

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5258,7 +5258,7 @@ pub fn with_path<T, F>(cx: &ctxt, id: ast::DefId, f: F) -> T where
52585258
if id.krate == ast::LOCAL_CRATE {
52595259
cx.map.with_path(id.node, f)
52605260
} else {
5261-
f(ast_map::Values(csearch::get_item_path(cx, id).iter()).chain(None))
5261+
f(csearch::get_item_path(cx, id).iter().cloned().chain(None))
52625262
}
52635263
}
52645264

src/librustc_trans/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tc
339339
let path = [PathName(token::intern(&s[])),
340340
gensym_name(name)];
341341
let hash = get_symbol_hash(ccx, t);
342-
mangle(ast_map::Values(path.iter()), Some(&hash[]))
342+
mangle(path.iter().cloned(), Some(&hash[]))
343343
}
344344

345345
pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String {

src/libsyntax/ast_map/mod.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,8 @@ impl<'a> Iterator for LinkedPath<'a> {
7575
}
7676
}
7777

78-
// HACK(eddyb) move this into libstd (value wrapper for slice::Iter).
79-
#[derive(Clone)]
80-
pub struct Values<'a, T:'a>(pub slice::Iter<'a, T>);
81-
82-
impl<'a, T: Copy> Iterator for Values<'a, T> {
83-
type Item = T;
84-
85-
fn next(&mut self) -> Option<T> {
86-
let &mut Values(ref mut items) = self;
87-
items.next().map(|&x| x)
88-
}
89-
}
90-
9178
/// The type of the iterator used by with_path.
92-
pub type PathElems<'a, 'b> = iter::Chain<Values<'a, PathElem>, LinkedPath<'b>>;
79+
pub type PathElems<'a, 'b> = iter::Chain<iter::Cloned<slice::Iter<'a, PathElem>>, LinkedPath<'b>>;
9380

9481
pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
9582
let itr = token::get_ident_interner();
@@ -458,9 +445,9 @@ impl<'ast> Map<'ast> {
458445
if parent == id {
459446
match self.find_entry(id) {
460447
Some(RootInlinedParent(data)) => {
461-
f(Values(data.path.iter()).chain(next))
448+
f(data.path.iter().cloned().chain(next))
462449
}
463-
_ => f(Values([].iter()).chain(next))
450+
_ => f([].iter().cloned().chain(next))
464451
}
465452
} else {
466453
self.with_path_next(parent, Some(&LinkedPathNode {

0 commit comments

Comments
 (0)