From 82b0b0fcc70593ff13176795f1bc82c86c7c618f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 26 Jan 2015 16:10:22 +0100 Subject: fallout --- src/libsyntax/parse/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 8cb7ee5b337..6dfd1fddcf7 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -854,7 +854,7 @@ mod test { #[test] fn string_to_tts_1 () { let tts = string_to_tts("fn a (b : i32) { b; }".to_string()); - assert_eq!(json::encode(&tts), + assert_eq!(json::encode(&tts).unwrap(), "[\ {\ \"variant\":\"TtToken\",\ -- cgit 1.4.1-3-g733a5 From 57dd4ea78d527f1c81f6009d0132bf210dd8fdfd Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 26 Jan 2015 22:56:50 -0500 Subject: fix #[cfg(test)] warnings --- src/liballoc/heap.rs | 1 + src/libfmt_macros/lib.rs | 2 +- src/librustc_back/rpath.rs | 1 - src/libserialize/json.rs | 3 +-- src/libsyntax/ext/expand.rs | 5 +---- src/libsyntax/print/pprust.rs | 1 - src/libtest/lib.rs | 3 +-- 7 files changed, 5 insertions(+), 11 deletions(-) (limited to 'src/libsyntax') diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index a2643f4d0f7..c87d789901b 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[cfg(not(test))] use core::ptr::PtrExt; // FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias` diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 0ff15327441..57b4a67de36 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -444,7 +444,7 @@ mod tests { use super::*; fn same(fmt: &'static str, p: &[Piece<'static>]) { - let mut parser = Parser::new(fmt); + let parser = Parser::new(fmt); assert!(p == parser.collect::>>()); } diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index bafd5fbe944..47b909df5e8 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -151,7 +151,6 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec { mod test { use super::{RPathConfig}; use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output}; - use syntax::abi; #[test] fn test_rpaths_to_flags() { diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index dad72fbd0e3..f6c76f2c7b8 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2618,7 +2618,7 @@ mod tests { use super::JsonEvent::*; use super::{Json, from_str, DecodeResult, DecoderError, JsonEvent, Parser, StackElement, Stack, Decoder, Encoder, EncoderError}; - use std::{i64, u64, f32, f64, old_io}; + use std::{i64, u64, f32, f64}; use std::collections::BTreeMap; use std::num::Float; use std::string; @@ -3928,7 +3928,6 @@ mod tests { #[test] fn test_encode_hashmap_with_arbitrary_key() { - use std::str::from_utf8; use std::old_io::Writer; use std::collections::HashMap; use std::fmt; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 629991799e7..acf0fe7f6cd 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1433,15 +1433,12 @@ mod test { use super::{pattern_bindings, expand_crate}; use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig}; use ast; - use ast::{Attribute_, AttrOuter, MetaWord, Name}; - use attr; + use ast::Name; use codemap; - use codemap::Spanned; use ext::mtwt; use fold::Folder; use parse; use parse::token; - use ptr::P; use util::parser_testing::{string_to_parser}; use util::parser_testing::{string_to_pat, string_to_crate, strs_to_idents}; use visit; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ae3c4addf38..f9a202523b5 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2975,7 +2975,6 @@ mod test { use ast_util; use codemap; use parse::token; - use ptr::P; #[test] fn test_fun_to_string() { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 2e59b15b6d9..0f3d84ae6ea 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1118,9 +1118,8 @@ pub mod bench { mod tests { use test::{TrFailed, TrIgnored, TrOk, filter_tests, parse_opts, TestDesc, TestDescAndFn, TestOpts, run_test, - Metric, MetricMap, + MetricMap, StaticTestName, DynTestName, DynTestFn, ShouldFail}; - use std::old_io::TempDir; use std::thunk::Thunk; use std::sync::mpsc::channel; -- cgit 1.4.1-3-g733a5 From f88c94d8d2c74402d6f72607a47c4850dcdf3b4d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 19:13:36 +0100 Subject: Simplify the implementation of segments_name_eq. --- src/libsyntax/ast_util.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 5aeea47ac60..07d3290d410 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -670,20 +670,13 @@ pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool { // are two arrays of segments equal when compared unhygienically? pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> bool { - if a.len() != b.len() { - false - } else { - for (idx,seg) in a.iter().enumerate() { - if seg.identifier.name != b[idx].identifier.name - // FIXME #7743: ident -> name problems in lifetime comparison? - // can types contain idents? - || seg.parameters != b[idx].parameters - { - return false; - } - } - true - } + a.len() == b.len() && + a.iter().zip(b.iter()).all(|(s, t)| { + s.identifier.name == t.identifier.name && + // FIXME #7743: ident -> name problems in lifetime comparison? + // can types contain idents? + s.parameters == t.parameters + }) } /// Returns true if this literal is a string and false otherwise. -- cgit 1.4.1-3-g733a5 From 4ad677e5b65b803e15e91e40097e2d77f0209ca7 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 19:22:09 +0100 Subject: Remove a custom variant of iter::Cloned. --- src/librustc/metadata/encoder.rs | 4 ++-- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/ty.rs | 2 +- src/librustc_trans/back/link.rs | 3 +-- src/libsyntax/ast_map/mod.rs | 19 +++---------------- 5 files changed, 8 insertions(+), 22 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index f6c5ba4b52b..783bc881057 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -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(); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 091ef9d52eb..6d296d70ffa 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -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[]) }); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 86cf030c828..bf9c850302b 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -5249,7 +5249,7 @@ pub fn with_path(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)) } } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index f5a6f3d95a2..f6d061ea722 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -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 { diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 96476cabac5..f2be6b22582 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -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 { - 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, LinkedPath<'b>>; +pub type PathElems<'a, 'b> = iter::Chain>, LinkedPath<'b>>; pub fn path_to_string>(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 { -- cgit 1.4.1-3-g733a5 From 7aa27353931c3cad8d43ee7ba82f622a68faac18 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 24 Jan 2015 19:25:25 +0100 Subject: Remove unnecessary to_string() call. --- src/libsyntax/ast_map/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index f2be6b22582..002e003afcb 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -88,7 +88,7 @@ pub fn path_to_string>(path: PI) -> String { } s.push_str(&e[]); s - }).to_string() + }) } #[derive(Copy, Show)] -- cgit 1.4.1-3-g733a5