From e8782eeb6327eb79b132cc3f71bfaf55310dde00 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 11 Jun 2013 02:34:14 +1000 Subject: [PATCH] fix tests, remove some warnings --- doc/rust.md | 12 ++++++------ src/compiletest/errors.rs | 1 - src/compiletest/header.rs | 1 - src/libextra/net_url.rs | 3 +-- src/libextra/rope.rs | 3 +-- src/libextra/semver.rs | 1 - src/libfuzzer/fuzzer.rc | 1 - src/librustc/middle/trans/base.rs | 2 +- src/librustc/middle/trans/build.rs | 4 +--- src/librustc/middle/typeck/check/mod.rs | 1 - src/librustc/middle/typeck/infer/to_str.rs | 1 - src/librustc/util/common.rs | 1 - src/librustpkg/version.rs | 4 ++-- src/libstd/io.rs | 1 - src/libstd/str.rs | 11 +---------- src/libstd/str/ascii.rs | 1 - src/libsyntax/ast_map.rs | 1 - src/libsyntax/ast_util.rs | 1 - src/libsyntax/ext/asm.rs | 1 - src/libsyntax/ext/pipes/liveness.rs | 1 - src/libsyntax/ext/tt/macro_parser.rs | 5 ++--- src/test/run-pass/trait-to-str.rs | 5 +++-- 22 files changed, 18 insertions(+), 44 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index 0a33eb6ab2a53..3c0828def154a 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -802,15 +802,15 @@ Use declarations support a number of convenient shortcuts: An example of `use` declarations: ~~~~ -use std::float::{sin, pow}; -use std::option::Some; +use std::float::sin; +use std::option::{Some, None}; fn main() { - // Equivalent to 'info!(std::float::pow(std::float::sin(1.0), 2.0));' - info!(pow(sin(1.0), 2.0)); + // Equivalent to 'info!(std::float::sin(1.0));' + info!(sin(1.0)); - // Equivalent to 'info!(std::option::Some(1.0));' - info!(Some(1.0)); + // Equivalent to 'info!(~[std::option::Some(1.0), std::option::None]);' + info!(~[Some(1.0), None]); } ~~~~ diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index f524f1424b4f5..cdc0defcbcab0 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -11,7 +11,6 @@ use core::prelude::*; use core::io; -use core::str; pub struct ExpectedError { line: uint, kind: ~str, msg: ~str } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 87f5f4bd3fae1..2888d4223b714 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -16,7 +16,6 @@ use common; use core::iterator::IteratorUtil; use core::io; use core::os; -use core::str; pub struct TestProps { // Lines that should be expected, in order, on standard out diff --git a/src/libextra/net_url.rs b/src/libextra/net_url.rs index c85a866a04a66..83cda31c68089 100644 --- a/src/libextra/net_url.rs +++ b/src/libextra/net_url.rs @@ -19,7 +19,6 @@ use core::cmp::Eq; use core::io::{Reader, ReaderUtil}; use core::io; use core::hashmap::HashMap; -use core::str; use core::to_bytes; use core::uint; @@ -394,7 +393,7 @@ enum Input { // returns userinfo, host, port, and unparsed part, or an error fn get_authority(rawurl: &str) -> Result<(Option, ~str, Option<~str>, ~str), ~str> { - if !raw_url.starts_with("//") { + if !rawurl.starts_with("//") { // there is no authority. return Ok((None, ~"", None, rawurl.to_str())); } diff --git a/src/libextra/rope.rs b/src/libextra/rope.rs index f23a4433289e0..de54964142349 100644 --- a/src/libextra/rope.rs +++ b/src/libextra/rope.rs @@ -40,6 +40,7 @@ use core::prelude::*; use core::iterator::IteratorUtil; use core::uint; use core::vec; +use core::str; /// The type of ropes. pub type Rope = node::Root; @@ -1187,8 +1188,6 @@ pub mod node { pub mod char_iterator { use core::prelude::*; - use core::str; - use rope::node::{Leaf, Node}; use rope::node::leaf_iterator; diff --git a/src/libextra/semver.rs b/src/libextra/semver.rs index c7d2010e609da..3ab8bb1f60bc2 100644 --- a/src/libextra/semver.rs +++ b/src/libextra/semver.rs @@ -20,7 +20,6 @@ use core::cmp; use core::io::{ReaderUtil}; use core::io; use core::option::{Option, Some, None}; -use core::str; use core::to_str::ToStr; use core::uint; diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 416fabb6d8f67..dbeea417a3dd9 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -37,7 +37,6 @@ use std::result; use std::run; use std::str; use std::uint; -use std::vec; use syntax::diagnostic; use syntax::parse::token::ident_interner; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index b913a1b499617..8e015d9a677e1 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1995,7 +1995,7 @@ pub fn trans_enum_variant(ccx: @CrateContext, debug!("trans_enum_variant: name=%s tps=%s repr=%? enum_ty=%s", unsafe { str::raw::from_c_str(llvm::LLVMGetValueName(llfndecl)) }, - ~"[" + ty_param_substs.map(|&t| ty_to_str(ccx.tcx.connect(t)), ", ") + "]", + ~"[" + ty_param_substs.map(|&t| ty_to_str(ccx.tcx, t)).connect(", ") + "]", repr, ty_to_str(ccx.tcx, enum_ty)); adt::trans_start_init(bcx, repr, fcx.llretptr.get(), disr); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 8406444bd097e..8b2814875046a 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -192,9 +192,7 @@ pub fn Invoke(cx: block, terminate(cx, "Invoke"); debug!("Invoke(%s with arguments (%s))", val_str(cx.ccx().tn, Fn), - vec::map(Args.connect(|a| val_str(cx.ccx().tn, - *a).to_owned()), - ", ")); + Args.map(|a| val_str(cx.ccx().tn, *a).to_owned()).connect(", ")); unsafe { count_insn(cx, "invoke"); llvm::LLVMBuildInvoke(B(cx), diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 30dd677396b17..b12b1499759f9 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -115,7 +115,6 @@ use core::iterator::IteratorUtil; use core::cast::transmute; use core::hashmap::HashMap; use core::result; -use core::str; use core::util::replace; use core::vec; use extra::list::Nil; diff --git a/src/librustc/middle/typeck/infer/to_str.rs b/src/librustc/middle/typeck/infer/to_str.rs index d6623f06c3d33..364d8b2d052c3 100644 --- a/src/librustc/middle/typeck/infer/to_str.rs +++ b/src/librustc/middle/typeck/infer/to_str.rs @@ -18,7 +18,6 @@ use middle::typeck::infer::InferCtxt; use middle::typeck::infer::unify::{Redirect, Root, VarValue}; use util::ppaux::{mt_to_str, ty_to_str, trait_ref_to_str}; -use core::str; use core::uint; use syntax::ast; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 8d0cba0e8b712..9556fd3e2574d 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -16,7 +16,6 @@ use syntax::visit; use core::hashmap::HashSet; use core::io; -use core::str; use extra; pub fn time(do_it: bool, what: ~str, thunk: &fn() -> T) -> T { diff --git a/src/librustpkg/version.rs b/src/librustpkg/version.rs index 434583eb79eda..0900d93e498f3 100644 --- a/src/librustpkg/version.rs +++ b/src/librustpkg/version.rs @@ -143,7 +143,7 @@ fn try_parsing_version(s: &str) -> Option { let s = s.trim(); debug!("Attempting to parse: %s", s); let mut parse_state = Start; - for s.iter().advance |&c| { + for s.iter().advance |c| { if char::is_digit(c) { parse_state = SawDigit; } @@ -171,7 +171,7 @@ fn is_url_like(p: &RemotePath) -> bool { /// Otherwise, return None. pub fn split_version<'a>(s: &'a str) -> Option<(&'a str, Version)> { // reject strings with multiple '#'s - if s.splitn_iter('#', 2).count() > 1 { + if s.splitn_iter('#', 2).count() > 2 { return None; } match s.rfind('#') { diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 409882c5cfe5a..58711360c3564 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -1836,7 +1836,6 @@ mod tests { use io; use path::Path; use result; - use str; use u64; use vec; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index e581eff83ad83..8cd69f32e4969 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -1800,7 +1800,7 @@ impl<'self> StrSlice<'self> for &'self str { */ #[inline] fn substr(&self, begin: uint, n: uint) -> &'self str { - s.slice(begin, begin + count_bytes(s, begin, n)) + self.slice(begin, begin + count_bytes(*self, begin, n)) } /// Escape each char in `s` with char::escape_default. #[inline] @@ -2318,7 +2318,6 @@ impl<'self> Iterator for StrBytesRevIterator<'self> { mod tests { use iterator::IteratorUtil; use container::Container; - use char; use option::Some; use libc::c_char; use libc; @@ -3026,14 +3025,6 @@ mod tests { assert_eq!(~"YMCA", map("ymca", |c| unsafe {libc::toupper(c as c_char)} as char)); } - #[test] - fn test_chars() { - let ss = ~"ศไทย中华Việt Nam"; - assert!(~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a', - 'm'] - == to_chars(ss)); - } - #[test] fn test_utf16() { let pairs = diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index a4a1b7a171d33..618d5095777a9 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -202,7 +202,6 @@ impl ToStrConsume for ~[Ascii] { #[cfg(test)] mod tests { use super::*; - use str; macro_rules! v2ascii ( ( [$($e:expr),*]) => ( [$(Ascii{chr:$e}),*]); diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 8a379a6213aac..2e60f7d02dfbc 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -24,7 +24,6 @@ use syntax::parse::token::special_idents; use core::cmp; use core::hashmap::HashMap; -use core::str; use core::vec; pub enum path_elt { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index db7c29edab068..3d6269942fd5b 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -23,7 +23,6 @@ use visit; use core::hashmap::HashMap; use core::int; use core::option; -use core::str; use core::to_bytes; pub fn path_name_i(idents: &[ident]) -> ~str { diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 14cbd170c4822..d3efd07aa045d 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -21,7 +21,6 @@ use ext::base::*; use parse; use parse::token; -use core::str; use core::vec; enum State { diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index cb7386b988003..1076c5d0b98f5 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -42,7 +42,6 @@ use core::prelude::*; use ext::base::ExtCtxt; use ext::pipes::proto::{protocol_}; -use core::str; use extra::bitv::Bitv; pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 0c9ca98fb9d3f..e5a77cc21fb8d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -24,7 +24,6 @@ use parse::token; use core::iterator::IteratorUtil; use core::hashmap::HashMap; -use core::str; use core::uint; use core::vec; @@ -371,14 +370,14 @@ pub fn parse( } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { - let nts = vec::map(bb_eis.connect(|ei| { + let nts = bb_eis.map(|ei| { match ei.elts[ei.idx].node { match_nonterminal(ref bind,ref name,_) => { fmt!("%s ('%s')", *ident_to_str(name), *ident_to_str(bind)) } _ => fail!() - } }), " or "); + } }).connect(" or "); return error(sp, fmt!( "Local ambiguity: multiple parsing options: \ built-in NTs %s or %u other options.", diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index bc167e5124fdb..4029bd18338c3 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -14,7 +14,8 @@ extern mod std; -use std::{str, int, vec}; +use std::str::StrVector; +use std::{int, vec}; trait to_str { fn to_str(&self) -> ~str; @@ -26,7 +27,7 @@ impl to_str for int { impl to_str for ~[T] { fn to_str(&self) -> ~str { - ~"[" + self.map(|e| e.to_str()).connect(", ") + "]" + ~"[" + vec::map(*self, |e| e.to_str()).connect(", ") + "]" } }