From ee25cf8d75671415e74ff3fe1a3c0ba42e35396a Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 14 Jun 2013 13:43:05 +1000 Subject: [PATCH] std: test-fixes, remove warnings, syntax highlighting for code examples. --- src/compiletest/runtest.rs | 1 - src/librustdoc/astsrv.rs | 2 -- src/librustdoc/desc_to_brief_pass.rs | 8 +++----- src/librustdoc/extract.rs | 2 -- src/librustdoc/markdown_pass.rs | 2 -- src/librustdoc/page_pass.rs | 1 - src/librustdoc/prune_hidden_pass.rs | 2 -- src/librustdoc/prune_private_pass.rs | 1 - src/librustdoc/sectionalize_pass.rs | 3 --- src/libstd/path.rs | 12 ++++++------ src/libstd/str.rs | 6 +++--- 11 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 891935dcadd..e0ceb79a37d 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -24,7 +24,6 @@ use util::logv; use core::io; use core::os; -use core::str; use core::uint; use core::vec; diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index 9d8f750a350..3775aafb569 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -32,8 +32,6 @@ use syntax::ast; use syntax::ast_map; use syntax; -#[cfg(test)] use core::vec; - pub struct Ctxt { ast: @ast::crate, ast_map: ast_map::map diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index d6cae1f2fa3..dc7621f98a0 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -129,14 +129,12 @@ fn first_sentence_(s: &str) -> ~str { } }); match idx { - Some(idx) if idx > 2u => { - str::to_owned(s.slice(0, idx - 1)) - } + Some(idx) if idx > 2u => s.slice(0, idx - 1).to_owned(), _ => { if s.ends_with(".") { - str::to_owned(s) + s.to_owned() } else { - str::to_owned(s) + s.to_owned() } } } diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index f4b6ae8fb32..f8c49f544bc 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -285,8 +285,6 @@ mod test { use extract::{extract, from_srv}; use parse; - use core::vec; - fn mk_doc(source: @str) -> doc::Doc { let ast = parse::from_str(source); extract(ast, ~"") diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 2e020cd9e5a..36df3a5267d 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -537,8 +537,6 @@ mod test { use tystr_pass; use unindent_pass; - use core::str; - fn render(source: ~str) -> ~str { let (srv, doc) = create_doc_srv(source); let markdown = write_markdown_str_srv(srv, doc); diff --git a/src/librustdoc/page_pass.rs b/src/librustdoc/page_pass.rs index bb5d71e8db1..584e6ccc887 100644 --- a/src/librustdoc/page_pass.rs +++ b/src/librustdoc/page_pass.rs @@ -157,7 +157,6 @@ mod test { use doc; use extract; use page_pass::run; - use core::vec; fn mk_doc_( output_style: config::OutputStyle, diff --git a/src/librustdoc/prune_hidden_pass.rs b/src/librustdoc/prune_hidden_pass.rs index 8a90d3f74d3..484eb8c7980 100644 --- a/src/librustdoc/prune_hidden_pass.rs +++ b/src/librustdoc/prune_hidden_pass.rs @@ -77,8 +77,6 @@ mod test { #[test] fn should_prune_hidden_items() { - use core::vec; - let doc = mk_doc(~"#[doc(hidden)] mod a { }"); assert!(doc.cratemod().mods().is_empty()) } diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index e861939c2dd..741da3e265e 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -162,7 +162,6 @@ mod test { use extract; use tystr_pass; use prune_private_pass::run; - use core::vec; fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index c44be7f597e..ba433bf479d 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -170,9 +170,6 @@ mod test { use extract; use sectionalize_pass::run; - use core::str; - use core::vec; - fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { let doc = extract::from_srv(srv.clone(), ~""); diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 400657d0c25..99a7a461ab2 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -515,7 +515,7 @@ impl GenericPath for PosixPath { fn with_filestem(&self, s: &str) -> PosixPath { match self.filetype() { None => self.with_filename(s), - Some(ref t) => self.with_filename(str::to_owned(s) + *t), + Some(ref t) => self.with_filename(s.to_owned() + *t), } } @@ -657,7 +657,7 @@ impl GenericPath for WindowsPath { (None, None) => { host = None; device = None; - rest = str::to_owned(s); + rest = s.to_owned(); } } @@ -729,7 +729,7 @@ impl GenericPath for WindowsPath { fn with_filestem(&self, s: &str) -> WindowsPath { match self.filetype() { None => self.with_filename(s), - Some(ref t) => self.with_filename(str::to_owned(s) + *t), + Some(ref t) => self.with_filename(s.to_owned() + *t), } } @@ -984,7 +984,7 @@ mod tests { fn test_posix_paths() { fn t(wp: &PosixPath, s: &str) { let ss = wp.to_str(); - let sss = str::to_owned(s); + let sss = s.to_owned(); if (ss != sss) { debug!("got %s", ss); debug!("expected %s", sss); @@ -1042,7 +1042,7 @@ mod tests { fn test_normalize() { fn t(wp: &PosixPath, s: &str) { let ss = wp.to_str(); - let sss = str::to_owned(s); + let sss = s.to_owned(); if (ss != sss) { debug!("got %s", ss); debug!("expected %s", sss); @@ -1105,7 +1105,7 @@ mod tests { fn test_windows_paths() { fn t(wp: &WindowsPath, s: &str) { let ss = wp.to_str(); - let sss = str::to_owned(s); + let sss = s.to_owned(); if (ss != sss) { debug!("got %s", ss); debug!("expected %s", sss); diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 89d497177dc..1ab07003b6e 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -1432,7 +1432,7 @@ impl<'self> StrSlice<'self> for &'self str { * * # Example * - * ~~~ + * ~~~ {.rust} * assert_eq!("11foo1bar11".trim_chars(&'1'), "foo1bar") * assert_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar") * assert_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar") @@ -1451,7 +1451,7 @@ impl<'self> StrSlice<'self> for &'self str { * * # Example * - * ~~~ + * ~~~ {.rust} * assert_eq!("11foo1bar11".trim_left_chars(&'1'), "foo1bar11") * assert_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12") * assert_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123") @@ -1473,7 +1473,7 @@ impl<'self> StrSlice<'self> for &'self str { * * # Example * - * ~~~ + * ~~~ {.rust} * assert_eq!("11foo1bar11".trim_right_chars(&'1'), "11foo1bar") * assert_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar") * assert_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar")