Skip to content

Commit fa82b9a

Browse files
committed
auto merge of #5523 : alexcrichton/rust/less-oldmap, r=thestinger
I started out just removing a few instances of `HashMap` throughout rustc, but it ended up snowballing to remove the entire thing. Most uses translated to just using `@mut LinearMap` instead of `HashMap`, although I tried where possible to drop the `@mut` modifier. This ended up working out some of the time, but definitely not in the major use cases. Things got kinda weird in some cases like: * alexcrichton/rust@mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L39R1587 * alexcrichton/rust@mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L61R3760 * alexcrichton/rust@mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L71R917 * alexcrichton/rust@mozilla:a56ec8c1342453a88be79e192a11501844375d40...alexcrichton:621b63300358cacad088ddd7f78180f29c40e66e#L91R127 I tried to tag them all with bugs which I thought would make them less weird, but I may have the wrong bug in a few places. These cases only came up when I tried to pass around `&mut LinearMap` instead of an `@mut LinearMap`. I also ran into a few bugs when migrating to `LinearMap`, one of which is #5521. There's another set of bugs which a00d779042fb8753c716e07b4f1aac0d5ab7bf66 addresses (all marked with `XXX`). I have a feeling they're all the same bug, but all I've been able is to reproduce them. I tried to whittle down the test cases and try to get some input which causes a failure, but I've been unable to do so. All I know is that it's vaguely related to `*T` pointers being used as `&*T` (return value of `find`). I'm not able to open a very descriptive issue, but I'll do so if there seems no other better route. I realize this is a very large pull request, so if it'd be better to split this up into multiple segments I'd be more than willing to do so. So far the tests all pass locally, although I'm sure bors will turn something up. I also don't mind keeping this up to date with rebasing. This maybe should wait until after 0.6 because it is a fairly large change...
2 parents 3d588c5 + d69108d commit fa82b9a

Some content is hidden

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

106 files changed

+1226
-1636
lines changed

doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,11 @@ expression context, the final namespace qualifier is omitted.
441441
Two examples of paths with type arguments:
442442

443443
~~~~
444-
# use std::oldmap;
444+
# use core::hashmap::linear::LinearMap;
445445
# fn f() {
446446
# fn id<T:Copy>(t: T) -> T { t }
447-
type t = oldmap::HashMap<int,~str>; // Type arguments used in a type expression
448-
let x = id::<int>(10); // Type arguments used in a call expression
447+
type t = LinearMap<int,~str>; // Type arguments used in a type expression
448+
let x = id::<int>(10); // Type arguments used in a call expression
449449
# }
450450
~~~~
451451

doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,8 +1829,8 @@ illegal to copy and pass by value.
18291829
Generic `type`, `struct`, and `enum` declarations follow the same pattern:
18301830

18311831
~~~~
1832-
# use std::oldmap::HashMap;
1833-
type Set<T> = HashMap<T, ()>;
1832+
# use core::hashmap::linear::LinearMap;
1833+
type Set<T> = LinearMap<T, ()>;
18341834
18351835
struct Stack<T> {
18361836
elements: ~[T]

src/libcore/flate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Simple compression
1717
use libc;
1818
use libc::{c_void, size_t, c_int};
1919
use ptr;
20-
use rand::RngUtil;
2120
use vec;
2221

2322
#[cfg(test)] use rand;
23+
#[cfg(test)] use rand::RngUtil;
2424

2525
pub mod rustrt {
2626
use libc::{c_int, c_void, size_t};

src/libcore/hashmap.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,11 @@ pub mod linear {
656656
fn reserve_at_least(&mut self, n: uint) {
657657
self.map.reserve_at_least(n)
658658
}
659+
660+
/// Consumes all of the elements in the set, emptying it out
661+
fn consume(&mut self, f: &fn(T)) {
662+
self.map.consume(|k, _| f(k))
663+
}
659664
}
660665

661666
#[test]

src/libcore/logging.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
//! Logging
1212
13-
use libc;
14-
1513
pub mod rustrt {
1614
use libc;
1715

@@ -49,6 +47,7 @@ pub fn console_off() {
4947
pub fn log_type<T>(level: u32, object: &T) {
5048
use cast::transmute;
5149
use io;
50+
use libc;
5251
use repr;
5352
use vec;
5453

src/libcore/rt/io/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use option::*;
12-
use comm::{GenericPort, GenericChan};
13-
1411
pub mod file;
1512

1613
// FIXME #5370 Strongly want this to be StreamError(&mut Stream)

src/libcore/rt/uv/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ use ptr;
4242
use libc::{c_void, c_int, size_t, malloc, free, ssize_t};
4343
use cast::{transmute, transmute_mut_region};
4444
use ptr::null;
45-
use sys::size_of;
4645
use super::uvll;
4746
use super::uvll::*;
4847
use unstable::finally::Finally;

src/libcore/rt/uvll.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use libc::{size_t, c_int, c_uint, c_void, c_char, uintptr_t};
3333
use libc::{malloc, free};
3434
use prelude::*;
35-
use ptr::to_unsafe_ptr;
3635

3736
pub struct uv_err_t {
3837
code: c_int,

src/librustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ pub fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
642642
643643
pub fn get_symbol_hash(ccx: @CrateContext, t: ty::t) -> @str {
644644
match ccx.type_hashcodes.find(&t) {
645-
Some(h) => h,
645+
Some(&h) => h,
646646
None => {
647647
let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta);
648648
ccx.type_hashcodes.insert(t, hash);

src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg,
246246

247247
// These next two const passes can probably be merged
248248
time(time_passes, ~"const marking", ||
249-
middle::const_eval::process_crate(crate, def_map, ty_cx));
249+
middle::const_eval::process_crate(crate, ty_cx));
250250

251251
time(time_passes, ~"const checking", ||
252252
middle::check_const::check_crate(sess, crate, ast_map, def_map,
@@ -546,11 +546,11 @@ pub fn build_session_options(+binary: ~str,
546546
let flags = vec::append(getopts::opt_strs(matches, level_short),
547547
getopts::opt_strs(matches, level_name));
548548
for flags.each |lint_name| {
549-
let lint_name = @str::replace(*lint_name, ~"-", ~"_");
549+
let lint_name = str::replace(*lint_name, ~"-", ~"_");
550550
match lint_dict.find(&lint_name) {
551551
None => {
552552
early_error(demitter, fmt!("unknown %s flag: %s",
553-
level_name, *lint_name));
553+
level_name, lint_name));
554554
}
555555
Some(lint) => {
556556
lint_opts.push((lint.lint, *level));

0 commit comments

Comments
 (0)