Remove a custom variant of iter::Cloned.
This commit is contained in:
parent
f88c94d8d2
commit
4ad677e5b6
5 changed files with 8 additions and 22 deletions
|
@ -1577,7 +1577,7 @@ fn encode_info_for_items(ecx: &EncodeContext,
|
|||
&krate.module,
|
||||
&[],
|
||||
ast::CRATE_NODE_ID,
|
||||
ast_map::Values([].iter()).chain(None),
|
||||
[].iter().cloned().chain(None),
|
||||
syntax::parse::token::special_idents::invalid,
|
||||
ast::Public);
|
||||
|
||||
|
@ -1949,7 +1949,7 @@ fn encode_misc_info(ecx: &EncodeContext,
|
|||
}
|
||||
|
||||
// Encode reexports for the root module.
|
||||
encode_reexports(ecx, rbml_w, 0, ast_map::Values([].iter()).chain(None));
|
||||
encode_reexports(ecx, rbml_w, 0, [].iter().cloned().chain(None));
|
||||
|
||||
rbml_w.end_tag();
|
||||
rbml_w.end_tag();
|
||||
|
|
|
@ -130,7 +130,7 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata,
|
|||
debug!("> Decoding inlined fn: {:?}::?",
|
||||
{
|
||||
// Do an Option dance to use the path after it is moved below.
|
||||
let s = ast_map::path_to_string(ast_map::Values(path.iter()));
|
||||
let s = ast_map::path_to_string(path.iter().cloned());
|
||||
path_as_str = Some(s);
|
||||
path_as_str.as_ref().map(|x| &x[])
|
||||
});
|
||||
|
|
|
@ -5249,7 +5249,7 @@ pub fn with_path<T, F>(cx: &ctxt, id: ast::DefId, f: F) -> T where
|
|||
if id.krate == ast::LOCAL_CRATE {
|
||||
cx.map.with_path(id.node, f)
|
||||
} else {
|
||||
f(ast_map::Values(csearch::get_item_path(cx, id).iter()).chain(None))
|
||||
f(csearch::get_item_path(cx, id).iter().cloned().chain(None))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ use flate;
|
|||
use serialize::hex::ToHex;
|
||||
use syntax::ast;
|
||||
use syntax::ast_map::{PathElem, PathElems, PathName};
|
||||
use syntax::ast_map;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
|
@ -339,7 +338,7 @@ pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tc
|
|||
let path = [PathName(token::intern(&s[])),
|
||||
gensym_name(name)];
|
||||
let hash = get_symbol_hash(ccx, t);
|
||||
mangle(ast_map::Values(path.iter()), Some(&hash[]))
|
||||
mangle(path.iter().cloned(), Some(&hash[]))
|
||||
}
|
||||
|
||||
pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String {
|
||||
|
|
|
@ -75,21 +75,8 @@ impl<'a> Iterator for LinkedPath<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// HACK(eddyb) move this into libstd (value wrapper for slice::Iter).
|
||||
#[derive(Clone)]
|
||||
pub struct Values<'a, T:'a>(pub slice::Iter<'a, T>);
|
||||
|
||||
impl<'a, T: Copy> Iterator for Values<'a, T> {
|
||||
type Item = T;
|
||||
|
||||
fn next(&mut self) -> Option<T> {
|
||||
let &mut Values(ref mut items) = self;
|
||||
items.next().map(|&x| x)
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of the iterator used by with_path.
|
||||
pub type PathElems<'a, 'b> = iter::Chain<Values<'a, PathElem>, LinkedPath<'b>>;
|
||||
pub type PathElems<'a, 'b> = iter::Chain<iter::Cloned<slice::Iter<'a, PathElem>>, LinkedPath<'b>>;
|
||||
|
||||
pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
|
||||
let itr = token::get_ident_interner();
|
||||
|
@ -458,9 +445,9 @@ impl<'ast> Map<'ast> {
|
|||
if parent == id {
|
||||
match self.find_entry(id) {
|
||||
Some(RootInlinedParent(data)) => {
|
||||
f(Values(data.path.iter()).chain(next))
|
||||
f(data.path.iter().cloned().chain(next))
|
||||
}
|
||||
_ => f(Values([].iter()).chain(next))
|
||||
_ => f([].iter().cloned().chain(next))
|
||||
}
|
||||
} else {
|
||||
self.with_path_next(parent, Some(&LinkedPathNode {
|
||||
|
|
Loading…
Reference in a new issue