Skip to content

Commit a776d65

Browse files
committed
auto merge of #6690 : erickt/rust/cleanup-warnings, r=brson
Simple patch series to fix up all the warnings a rustc compile is giving at the moment. It also fixes a NOTE in `to_bytes.rs` to remove the `to_bytes::iter_bytes_<N>` functions.
2 parents 4bbc13d + cc4fabc commit a776d65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1303
-1345
lines changed

doc/tutorial.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,6 @@ This code creates a closure that adds a given string to its argument,
14801480
returns it from a function, and then calls it:
14811481

14821482
~~~~
1483-
# extern mod std;
14841483
fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
14851484
// The compiler knows that we intend this closure to be of type @fn
14861485
return |s| s + suffix;
@@ -2292,7 +2291,7 @@ let nonsense = mycircle.radius() * mycircle.area();
22922291
22932292
## Deriving implementations for traits
22942293

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

2544-
## The std library
2543+
## The standard library
25452544

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

2562-
### Core injection and the Rust prelude
2561+
### Standard Library injection and the Rust prelude
25632562

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

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

src/compiletest/compiletest.rc

+36-36
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ pub fn main() {
5050

5151
pub fn parse_config(args: ~[~str]) -> config {
5252
let opts =
53-
~[getopts::reqopt(~"compile-lib-path"),
54-
getopts::reqopt(~"run-lib-path"),
55-
getopts::reqopt(~"rustc-path"), getopts::reqopt(~"src-base"),
56-
getopts::reqopt(~"build-base"), getopts::reqopt(~"aux-base"),
57-
getopts::reqopt(~"stage-id"),
58-
getopts::reqopt(~"mode"), getopts::optflag(~"ignored"),
59-
getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"),
60-
getopts::optflag(~"verbose"),
61-
getopts::optopt(~"logfile"),
62-
getopts::optflag(~"jit"),
63-
getopts::optflag(~"newrt"),
64-
getopts::optopt(~"target"),
65-
getopts::optopt(~"adb-path"),
66-
getopts::optopt(~"adb-test-dir")
53+
~[getopts::reqopt("compile-lib-path"),
54+
getopts::reqopt("run-lib-path"),
55+
getopts::reqopt("rustc-path"), getopts::reqopt("src-base"),
56+
getopts::reqopt("build-base"), getopts::reqopt("aux-base"),
57+
getopts::reqopt("stage-id"),
58+
getopts::reqopt("mode"), getopts::optflag("ignored"),
59+
getopts::optopt("runtool"), getopts::optopt("rustcflags"),
60+
getopts::optflag("verbose"),
61+
getopts::optopt("logfile"),
62+
getopts::optflag("jit"),
63+
getopts::optflag("newrt"),
64+
getopts::optopt("target"),
65+
getopts::optopt("adb-path"),
66+
getopts::optopt("adb-test-dir")
6767
];
6868

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

77-
fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
77+
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
7878
Path(getopts::opt_str(m, nm))
7979
}
8080

8181
config {
82-
compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
83-
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
84-
rustc_path: opt_path(matches, ~"rustc-path"),
85-
src_base: opt_path(matches, ~"src-base"),
86-
build_base: opt_path(matches, ~"build-base"),
87-
aux_base: opt_path(matches, ~"aux-base"),
88-
stage_id: getopts::opt_str(matches, ~"stage-id"),
89-
mode: str_mode(getopts::opt_str(matches, ~"mode")),
90-
run_ignored: getopts::opt_present(matches, ~"ignored"),
82+
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
83+
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
84+
rustc_path: opt_path(matches, "rustc-path"),
85+
src_base: opt_path(matches, "src-base"),
86+
build_base: opt_path(matches, "build-base"),
87+
aux_base: opt_path(matches, "aux-base"),
88+
stage_id: getopts::opt_str(matches, "stage-id"),
89+
mode: str_mode(getopts::opt_str(matches, "mode")),
90+
run_ignored: getopts::opt_present(matches, "ignored"),
9191
filter:
9292
if vec::len(matches.free) > 0u {
9393
option::Some(copy matches.free[0])
9494
} else { option::None },
95-
logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)),
96-
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
97-
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
98-
jit: getopts::opt_present(matches, ~"jit"),
99-
newrt: getopts::opt_present(matches, ~"newrt"),
100-
target: opt_str2(getopts::opt_maybe_str(matches, ~"target")).to_str(),
101-
adb_path: opt_str2(getopts::opt_maybe_str(matches, ~"adb-path")).to_str(),
95+
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
96+
runtool: getopts::opt_maybe_str(matches, "runtool"),
97+
rustcflags: getopts::opt_maybe_str(matches, "rustcflags"),
98+
jit: getopts::opt_present(matches, "jit"),
99+
newrt: getopts::opt_present(matches, "newrt"),
100+
target: opt_str2(getopts::opt_maybe_str(matches, "target")).to_str(),
101+
adb_path: opt_str2(getopts::opt_maybe_str(matches, "adb-path")).to_str(),
102102
adb_test_dir:
103-
opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")).to_str(),
103+
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")).to_str(),
104104
adb_device_status:
105-
if (opt_str2(getopts::opt_maybe_str(matches, ~"target")) ==
105+
if (opt_str2(getopts::opt_maybe_str(matches, "target")) ==
106106
~"arm-linux-androideabi") {
107-
if (opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
107+
if (opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
108108
~"(none)" &&
109-
opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
109+
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
110110
~"") { true }
111111
else { false }
112112
} else { false },
113-
verbose: getopts::opt_present(matches, ~"verbose")
113+
verbose: getopts::opt_present(matches, "verbose")
114114
}
115115
}
116116

src/compiletest/header.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ pub fn load_props(testfile: &Path) -> TestProps {
8787

8888
pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
8989
for iter_header(testfile) |ln| {
90-
if parse_name_directive(ln, ~"xfail-test") { return true; }
90+
if parse_name_directive(ln, "xfail-test") { return true; }
9191
if parse_name_directive(ln, xfail_target()) { return true; }
9292
if config.mode == common::mode_pretty &&
93-
parse_name_directive(ln, ~"xfail-pretty") { return true; }
93+
parse_name_directive(ln, "xfail-pretty") { return true; }
9494
};
9595
return false;
9696

@@ -107,8 +107,7 @@ fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
107107
// Assume that any directives will be found before the first
108108
// module or function. This doesn't seem to be an optimization
109109
// with a warm page cache. Maybe with a cold one.
110-
if str::starts_with(ln, ~"fn")
111-
|| str::starts_with(ln, ~"mod") {
110+
if str::starts_with(ln, "fn") || str::starts_with(ln, "mod") {
112111
return false;
113112
} else { if !(it(ln)) { return false; } }
114113
}

src/compiletest/runtest.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use util::logv;
2525
pub fn run(config: config, testfile: ~str) {
2626
if config.verbose {
2727
// We're going to be dumping a lot of info. Start on a new line.
28-
io::stdout().write_str(~"\n\n");
28+
io::stdout().write_str("\n\n");
2929
}
3030
let testfile = Path(testfile);
3131
debug!("running %s", testfile.to_str());
@@ -231,7 +231,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
231231
// do not optimize debuginfo tests
232232
let mut config = match config.rustcflags {
233233
Some(ref flags) => config {
234-
rustcflags: Some(str::replace(*flags, ~"-O", ~"")),
234+
rustcflags: Some(str::replace(*flags, "-O", "")),
235235
.. copy *config
236236
},
237237
None => copy *config
@@ -249,19 +249,19 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
249249
// write debugger script
250250
let script_str = str::append(cmds, "\nquit\n");
251251
debug!("script_str = %s", script_str);
252-
dump_output_file(config, testfile, script_str, ~"debugger.script");
252+
dump_output_file(config, testfile, script_str, "debugger.script");
253253

254254
// run debugger script with gdb
255255
#[cfg(windows)]
256256
fn debugger() -> ~str { ~"gdb.exe" }
257257
#[cfg(unix)]
258258
fn debugger() -> ~str { ~"gdb" }
259-
let debugger_script = make_out_name(config, testfile, ~"debugger.script");
259+
let debugger_script = make_out_name(config, testfile, "debugger.script");
260260
let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx",
261261
~"-command=" + debugger_script.to_str(),
262262
make_exe_name(config, testfile).to_str()];
263263
let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts};
264-
ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], ~"", None);
264+
ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], "", None);
265265
if ProcRes.status != 0 {
266266
fatal(~"gdb failed to execute");
267267
}
@@ -368,7 +368,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
368368
}
369369

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

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

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

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

693693
fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) {
694694
if config.verbose {
695-
let sep1 = fmt!("------%s------------------------------", ~"stdout");
696-
let sep2 = fmt!("------%s------------------------------", ~"stderr");
695+
let sep1 = fmt!("------%s------------------------------", "stdout");
696+
let sep2 = fmt!("------%s------------------------------", "stderr");
697697
let sep3 = ~"------------------------------------------";
698698
io::stdout().write_line(sep1);
699699
io::stdout().write_line(out);
@@ -781,10 +781,10 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps,
781781
newargs_err.push(newcmd_err);
782782
783783
let procsrv::Result{ out: out_out, err: _out_err, status: out_status } =
784-
procsrv::run(~"", config.adb_path, newargs_out, ~[(~"",~"")],
784+
procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")],
785785
Some(~""));
786786
let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } =
787-
procsrv::run(~"", config.adb_path, newargs_err, ~[(~"",~"")],
787+
procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")],
788788
Some(~""));
789789
790790
dump_output(config, testfile, out_out, err_out);
@@ -818,8 +818,8 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
818818
819819
if (file.filetype() == Some(~".so")) {
820820
821-
let copy_result = procsrv::run(~"", config.adb_path,
822-
~[~"push", file.to_str(), copy config.adb_test_dir],
821+
let copy_result = procsrv::run("", config.adb_path,
822+
[~"push", file.to_str(), copy config.adb_test_dir],
823823
~[(~"",~"")], Some(~""));
824824
825825
if config.verbose {

src/libextra/base64.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
1313
use core::prelude::*;
1414

15-
use core::old_iter;
16-
use core::str;
17-
use core::vec;
18-
1915
pub trait ToBase64 {
2016
fn to_base64(&self) -> ~str;
2117
}
@@ -242,12 +238,12 @@ mod tests {
242238
243239
#[test]
244240
fn test_from_base64() {
245-
assert_eq!((~"").from_base64(), str::to_bytes(~""));
246-
assert!((~"Zg==").from_base64() == str::to_bytes(~"f"));
247-
assert_eq!((~"Zm8=").from_base64(), str::to_bytes(~"fo"));
248-
assert_eq!((~"Zm9v").from_base64(), str::to_bytes(~"foo"));
249-
assert!((~"Zm9vYg==").from_base64() == str::to_bytes(~"foob"));
250-
assert_eq!((~"Zm9vYmE=").from_base64(), str::to_bytes(~"fooba"))
251-
assert_eq!((~"Zm9vYmFy").from_base64(), str::to_bytes(~"foobar"));
241+
assert_eq!((~"").from_base64(), str::to_bytes(""));
242+
assert!((~"Zg==").from_base64() == str::to_bytes("f"));
243+
assert_eq!((~"Zm8=").from_base64(), str::to_bytes("fo"));
244+
assert_eq!((~"Zm9v").from_base64(), str::to_bytes("foo"));
245+
assert!((~"Zm9vYg==").from_base64() == str::to_bytes("foob"));
246+
assert_eq!((~"Zm9vYmE=").from_base64(), str::to_bytes("fooba"))
247+
assert_eq!((~"Zm9vYmFy").from_base64(), str::to_bytes("foobar"));
252248
}
253249
}

src/libextra/bitv.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
use core::prelude::*;
1212

13-
use core::vec::from_elem;
14-
1513
struct SmallBitv {
1614
/// only the lowest nbits of this value are used. the rest is undefined.
1715
bits: uint
@@ -257,7 +255,7 @@ pub impl Bitv {
257255
let nelems = nbits/uint::bits +
258256
if nbits % uint::bits == 0 {0} else {1};
259257
let elem = if init {!0} else {0};
260-
let s = from_elem(nelems, elem);
258+
let s = vec::from_elem(nelems, elem);
261259
Big(~BigBitv::new(s))
262260
};
263261
Bitv {rep: rep, nbits: nbits}
@@ -502,7 +500,7 @@ impl Clone for Bitv {
502500
Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})}
503501
}
504502
Big(ref b) => {
505-
let mut st = from_elem(self.nbits / uint::bits + 1, 0);
503+
let mut st = vec::from_elem(self.nbits / uint::bits + 1, 0);
506504
let len = st.len();
507505
for uint::range(0, len) |i| { st[i] = b.storage[i]; };
508506
Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: st})}
@@ -872,17 +870,14 @@ mod tests {
872870
873871
#[test]
874872
fn test_0_elements() {
875-
let mut act;
876-
let exp;
877-
act = Bitv::new(0u, false);
878-
exp = vec::from_elem::<uint>(0u, 0u);
873+
let act = Bitv::new(0u, false);
874+
let exp = vec::from_elem::<uint>(0u, 0u);
879875
assert!(act.eq_vec(exp));
880876
}
881877
882878
#[test]
883879
fn test_1_element() {
884-
let mut act;
885-
act = Bitv::new(1u, false);
880+
let mut act = Bitv::new(1u, false);
886881
assert!(act.eq_vec(~[0u]));
887882
act = Bitv::new(1u, true);
888883
assert!(act.eq_vec(~[1u]));
@@ -1488,7 +1483,7 @@ mod tests {
14881483
#[bench]
14891484
fn bench_bitv_big_union(b: &mut BenchHarness) {
14901485
let mut b1 = Bitv::new(bench_bits, false);
1491-
let mut b2 = Bitv::new(bench_bits, false);
1486+
let b2 = Bitv::new(bench_bits, false);
14921487
do b.iter {
14931488
b1.union(&b2);
14941489
}

0 commit comments

Comments
 (0)