Skip to content

Cleanup warnings #6690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,6 @@ This code creates a closure that adds a given string to its argument,
returns it from a function, and then calls it:

~~~~
# extern mod std;
fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
// The compiler knows that we intend this closure to be of type @fn
return |s| s + suffix;
Expand Down Expand Up @@ -2292,7 +2291,7 @@ let nonsense = mycircle.radius() * mycircle.area();

## Deriving implementations for traits

A small number of traits in `std` and `std` can have implementations
A small number of traits in `std` and `extra` can have implementations
that can be automatically derived. These instances are specified by
placing the `deriving` attribute on a data type declaration. For
example, the following will mean that `Circle` has an implementation
Expand Down Expand Up @@ -2541,9 +2540,9 @@ as well as an inscrutable string of alphanumerics. These are both
part of Rust's library versioning scheme. The alphanumerics are
a hash representing the crate metadata.

## The std library
## The standard library

The Rust std library provides runtime features required by the language,
The Rust standard library provides runtime features required by the language,
including the task scheduler and memory allocators, as well as library
support for Rust built-in types, platform abstractions, and other commonly
used features.
Expand All @@ -2559,7 +2558,7 @@ I/O abstractions ([`io`]), [containers] like [`hashmap`],
common traits ([`kinds`], [`ops`], [`cmp`], [`num`],
[`to_str`], [`clone`]), and complete bindings to the C standard library ([`libc`]).

### Core injection and the Rust prelude
### Standard Library injection and the Rust prelude

`std` is imported at the topmost level of every crate by default, as
if the first line of each crate was
Expand All @@ -2571,7 +2570,7 @@ with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`,
etc.

Additionally, `std` contains a `prelude` module that reexports many of the
most common std modules, types and traits. The contents of the prelude are
most common standard modules, types and traits. The contents of the prelude are
imported into every *module* by default. Implicitly, all modules behave as if
they contained the following prologue:

Expand Down
72 changes: 36 additions & 36 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ pub fn main() {

pub fn parse_config(args: ~[~str]) -> config {
let opts =
~[getopts::reqopt(~"compile-lib-path"),
getopts::reqopt(~"run-lib-path"),
getopts::reqopt(~"rustc-path"), getopts::reqopt(~"src-base"),
getopts::reqopt(~"build-base"), getopts::reqopt(~"aux-base"),
getopts::reqopt(~"stage-id"),
getopts::reqopt(~"mode"), getopts::optflag(~"ignored"),
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
getopts::optflag(~"verbose"),
getopts::optopt(~"logfile"),
getopts::optflag(~"jit"),
getopts::optflag(~"newrt"),
getopts::optopt(~"target"),
getopts::optopt(~"adb-path"),
getopts::optopt(~"adb-test-dir")
~[getopts::reqopt("compile-lib-path"),
getopts::reqopt("run-lib-path"),
getopts::reqopt("rustc-path"), getopts::reqopt("src-base"),
getopts::reqopt("build-base"), getopts::reqopt("aux-base"),
getopts::reqopt("stage-id"),
getopts::reqopt("mode"), getopts::optflag("ignored"),
getopts::optopt("runtool"), getopts::optopt("rustcflags"),
getopts::optflag("verbose"),
getopts::optopt("logfile"),
getopts::optflag("jit"),
getopts::optflag("newrt"),
getopts::optopt("target"),
getopts::optopt("adb-path"),
getopts::optopt("adb-test-dir")
];

assert!(!args.is_empty());
Expand All @@ -74,43 +74,43 @@ pub fn parse_config(args: ~[~str]) -> config {
Err(f) => fail!(getopts::fail_str(f))
};

fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
Path(getopts::opt_str(m, nm))
}

config {
compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
rustc_path: opt_path(matches, ~"rustc-path"),
src_base: opt_path(matches, ~"src-base"),
build_base: opt_path(matches, ~"build-base"),
aux_base: opt_path(matches, ~"aux-base"),
stage_id: getopts::opt_str(matches, ~"stage-id"),
mode: str_mode(getopts::opt_str(matches, ~"mode")),
run_ignored: getopts::opt_present(matches, ~"ignored"),
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
rustc_path: opt_path(matches, "rustc-path"),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
aux_base: opt_path(matches, "aux-base"),
stage_id: getopts::opt_str(matches, "stage-id"),
mode: str_mode(getopts::opt_str(matches, "mode")),
run_ignored: getopts::opt_present(matches, "ignored"),
filter:
if vec::len(matches.free) > 0u {
option::Some(copy matches.free[0])
} else { option::None },
logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
jit: getopts::opt_present(matches, ~"jit"),
newrt: getopts::opt_present(matches, ~"newrt"),
target: opt_str2(getopts::opt_maybe_str(matches, ~"target")).to_str(),
adb_path: opt_str2(getopts::opt_maybe_str(matches, ~"adb-path")).to_str(),
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
runtool: getopts::opt_maybe_str(matches, "runtool"),
rustcflags: getopts::opt_maybe_str(matches, "rustcflags"),
jit: getopts::opt_present(matches, "jit"),
newrt: getopts::opt_present(matches, "newrt"),
target: opt_str2(getopts::opt_maybe_str(matches, "target")).to_str(),
adb_path: opt_str2(getopts::opt_maybe_str(matches, "adb-path")).to_str(),
adb_test_dir:
opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")).to_str(),
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")).to_str(),
adb_device_status:
if (opt_str2(getopts::opt_maybe_str(matches, ~"target")) ==
if (opt_str2(getopts::opt_maybe_str(matches, "target")) ==
~"arm-linux-androideabi") {
if (opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
if (opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
~"(none)" &&
opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
~"") { true }
else { false }
} else { false },
verbose: getopts::opt_present(matches, ~"verbose")
verbose: getopts::opt_present(matches, "verbose")
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ pub fn load_props(testfile: &Path) -> TestProps {

pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; }
if parse_name_directive(ln, "xfail-test") { return true; }
if parse_name_directive(ln, xfail_target()) { return true; }
if config.mode == common::mode_pretty &&
parse_name_directive(ln, ~"xfail-pretty") { return true; }
parse_name_directive(ln, "xfail-pretty") { return true; }
};
return false;

Expand All @@ -107,8 +107,7 @@ fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
// Assume that any directives will be found before the first
// module or function. This doesn't seem to be an optimization
// with a warm page cache. Maybe with a cold one.
if str::starts_with(ln, ~"fn")
|| str::starts_with(ln, ~"mod") {
if str::starts_with(ln, "fn") || str::starts_with(ln, "mod") {
return false;
} else { if !(it(ln)) { return false; } }
}
Expand Down
28 changes: 14 additions & 14 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use util::logv;
pub fn run(config: config, testfile: ~str) {
if config.verbose {
// We're going to be dumping a lot of info. Start on a new line.
io::stdout().write_str(~"\n\n");
io::stdout().write_str("\n\n");
}
let testfile = Path(testfile);
debug!("running %s", testfile.to_str());
Expand Down Expand Up @@ -231,7 +231,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
// do not optimize debuginfo tests
let mut config = match config.rustcflags {
Some(ref flags) => config {
rustcflags: Some(str::replace(*flags, ~"-O", ~"")),
rustcflags: Some(str::replace(*flags, "-O", "")),
.. copy *config
},
None => copy *config
Expand All @@ -249,19 +249,19 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
// write debugger script
let script_str = str::append(cmds, "\nquit\n");
debug!("script_str = %s", script_str);
dump_output_file(config, testfile, script_str, ~"debugger.script");
dump_output_file(config, testfile, script_str, "debugger.script");

// run debugger script with gdb
#[cfg(windows)]
fn debugger() -> ~str { ~"gdb.exe" }
#[cfg(unix)]
fn debugger() -> ~str { ~"gdb" }
let debugger_script = make_out_name(config, testfile, ~"debugger.script");
let debugger_script = make_out_name(config, testfile, "debugger.script");
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
~"-command=" + debugger_script.to_str(),
make_exe_name(config, testfile).to_str()];
let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts};
ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], ~"", None);
ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], "", None);
if ProcRes.status != 0 {
fatal(~"gdb failed to execute");
}
Expand Down Expand Up @@ -368,7 +368,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
}

// ignore this msg which gets printed at the end
if str::contains(line, ~"aborting due to") {
if str::contains(line, "aborting due to") {
was_expected = true;
}

Expand Down Expand Up @@ -643,7 +643,7 @@ fn program_output(config: &config, testfile: &Path, lib_path: &str, prog: ~str,
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
fn make_cmdline(_libpath: &str, prog: &str, args: &[~str]) -> ~str {
fmt!("%s %s", prog, str::connect(args, ~" "))
fmt!("%s %s", prog, str::connect(args, " "))
}

#[cfg(target_os = "win32")]
Expand All @@ -668,7 +668,7 @@ fn dump_output_file(config: &config, testfile: &Path,
out: &str, extension: &str) {
let outfile = make_out_name(config, testfile, extension);
let writer =
io::file_writer(&outfile, ~[io::Create, io::Truncate]).get();
io::file_writer(&outfile, [io::Create, io::Truncate]).get();
writer.write_str(out);
}

Expand All @@ -692,8 +692,8 @@ fn output_base_name(config: &config, testfile: &Path) -> Path {

fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) {
if config.verbose {
let sep1 = fmt!("------%s------------------------------", ~"stdout");
let sep2 = fmt!("------%s------------------------------", ~"stderr");
let sep1 = fmt!("------%s------------------------------", "stdout");
let sep2 = fmt!("------%s------------------------------", "stderr");
let sep3 = ~"------------------------------------------";
io::stdout().write_line(sep1);
io::stdout().write_line(out);
Expand Down Expand Up @@ -781,10 +781,10 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
newargs_err.push(newcmd_err);

let procsrv::Result{ out: out_out, err: _out_err, status: out_status } =
procsrv::run(~"", config.adb_path, newargs_out, ~[(~"",~"")],
procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")],
Some(~""));
let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } =
procsrv::run(~"", config.adb_path, newargs_err, ~[(~"",~"")],
procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")],
Some(~""));

dump_output(config, testfile, out_out, err_out);
Expand Down Expand Up @@ -818,8 +818,8 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {

if (file.filetype() == Some(~".so")) {

let copy_result = procsrv::run(~"", config.adb_path,
~[~"push", file.to_str(), copy config.adb_test_dir],
let copy_result = procsrv::run("", config.adb_path,
[~"push", file.to_str(), copy config.adb_test_dir],
~[(~"",~"")], Some(~""));

if config.verbose {
Expand Down
18 changes: 7 additions & 11 deletions src/libextra/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
use core::prelude::*;

use core::old_iter;
use core::str;
use core::vec;

pub trait ToBase64 {
fn to_base64(&self) -> ~str;
}
Expand Down Expand Up @@ -242,12 +238,12 @@ mod tests {
#[test]
fn test_from_base64() {
assert_eq!((~"").from_base64(), str::to_bytes(~""));
assert!((~"Zg==").from_base64() == str::to_bytes(~"f"));
assert_eq!((~"Zm8=").from_base64(), str::to_bytes(~"fo"));
assert_eq!((~"Zm9v").from_base64(), str::to_bytes(~"foo"));
assert!((~"Zm9vYg==").from_base64() == str::to_bytes(~"foob"));
assert_eq!((~"Zm9vYmE=").from_base64(), str::to_bytes(~"fooba"))
assert_eq!((~"Zm9vYmFy").from_base64(), str::to_bytes(~"foobar"));
assert_eq!((~"").from_base64(), str::to_bytes(""));
assert!((~"Zg==").from_base64() == str::to_bytes("f"));
assert_eq!((~"Zm8=").from_base64(), str::to_bytes("fo"));
assert_eq!((~"Zm9v").from_base64(), str::to_bytes("foo"));
assert!((~"Zm9vYg==").from_base64() == str::to_bytes("foob"));
assert_eq!((~"Zm9vYmE=").from_base64(), str::to_bytes("fooba"))
assert_eq!((~"Zm9vYmFy").from_base64(), str::to_bytes("foobar"));
}
}
17 changes: 6 additions & 11 deletions src/libextra/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

use core::prelude::*;

use core::vec::from_elem;

struct SmallBitv {
/// only the lowest nbits of this value are used. the rest is undefined.
bits: uint
Expand Down Expand Up @@ -257,7 +255,7 @@ pub impl Bitv {
let nelems = nbits/uint::bits +
if nbits % uint::bits == 0 {0} else {1};
let elem = if init {!0} else {0};
let s = from_elem(nelems, elem);
let s = vec::from_elem(nelems, elem);
Big(~BigBitv::new(s))
};
Bitv {rep: rep, nbits: nbits}
Expand Down Expand Up @@ -502,7 +500,7 @@ impl Clone for Bitv {
Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})}
}
Big(ref b) => {
let mut st = from_elem(self.nbits / uint::bits + 1, 0);
let mut st = vec::from_elem(self.nbits / uint::bits + 1, 0);
let len = st.len();
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: st})}
Expand Down Expand Up @@ -872,17 +870,14 @@ mod tests {
#[test]
fn test_0_elements() {
let mut act;
let exp;
act = Bitv::new(0u, false);
exp = vec::from_elem::<uint>(0u, 0u);
let act = Bitv::new(0u, false);
let exp = vec::from_elem::<uint>(0u, 0u);
assert!(act.eq_vec(exp));
}
#[test]
fn test_1_element() {
let mut act;
act = Bitv::new(1u, false);
let mut act = Bitv::new(1u, false);
assert!(act.eq_vec(~[0u]));
act = Bitv::new(1u, true);
assert!(act.eq_vec(~[1u]));
Expand Down Expand Up @@ -1488,7 +1483,7 @@ mod tests {
#[bench]
fn bench_bitv_big_union(b: &mut BenchHarness) {
let mut b1 = Bitv::new(bench_bits, false);
let mut b2 = Bitv::new(bench_bits, false);
let b2 = Bitv::new(bench_bits, false);
do b.iter {
b1.union(&b2);
}
Expand Down
Loading