Skip to content

Commit 69511c2

Browse files
committed
auto merge of #6928 : Blei/rust/fix-constructors, r=bstrie
As part of #3853
2 parents b500307 + 1eb3a35 commit 69511c2

Some content is hidden

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

52 files changed

+197
-193
lines changed

src/compiletest/compiletest.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
260260

261261
pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
262262
use core::cell::Cell;
263-
let config = Cell(copy *config);
264-
let testfile = Cell(testfile.to_str());
263+
let config = Cell::new(copy *config);
264+
let testfile = Cell::new(testfile.to_str());
265265
test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
266266
}

src/libextra/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ mod tests {
558558
let arc = ~MutexARC(false);
559559
let arc2 = ~arc.clone();
560560
let (p,c) = comm::oneshot();
561-
let (c,p) = (Cell(c), Cell(p));
561+
let (c,p) = (Cell::new(c), Cell::new(p));
562562
do task::spawn || {
563563
// wait until parent gets in
564564
comm::recv_one(p.take());

src/libextra/flatpipes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ mod test {
660660
#[test]
661661
#[ignore(reason = "ebml failure")]
662662
fn test_serializing_memory_stream() {
663-
let writer = BytesWriter();
663+
let writer = BytesWriter::new();
664664
let chan = serial::writer_chan(writer);
665665

666666
chan.send(10);
@@ -708,7 +708,7 @@ mod test {
708708

709709
#[test]
710710
fn test_pod_memory_stream() {
711-
let writer = BytesWriter();
711+
let writer = BytesWriter::new();
712712
let chan = pod::writer_chan(writer);
713713

714714
chan.send(10);
@@ -791,8 +791,8 @@ mod test {
791791

792792
let addr0 = ip::v4::parse_addr("127.0.0.1");
793793

794-
let begin_connect_chan = Cell(begin_connect_chan);
795-
let accept_chan = Cell(accept_chan);
794+
let begin_connect_chan = Cell::new(begin_connect_chan);
795+
let accept_chan = Cell::new(accept_chan);
796796

797797
// The server task
798798
let addr = copy addr0;

src/libextra/future.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn from_port<A:Owned>(port: PortOne<A>) -> Future<A> {
109109
* waiting for the result to be received on the port.
110110
*/
111111

112-
let port = Cell(port);
112+
let port = Cell::new(port);
113113
do from_fn {
114114
recv_one(port.take())
115115
}
@@ -137,7 +137,7 @@ pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> {
137137

138138
let (port, chan) = oneshot();
139139

140-
let chan = Cell(chan);
140+
let chan = Cell::new(chan);
141141
do task::spawn {
142142
let chan = chan.take();
143143
send_one(chan, blk());
@@ -204,7 +204,7 @@ mod test {
204204
#[test]
205205
fn test_sendable_future() {
206206
let expected = "schlorf";
207-
let f = Cell(do spawn { expected });
207+
let f = Cell::new(do spawn { expected });
208208
do task::spawn {
209209
let mut f = f.take();
210210
let actual = f.get();

src/libextra/net_tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ mod test {
18301830
let (server_po, server_ch) = stream::<~str>();
18311831
let server_ch = SharedChan::new(server_ch);
18321832
let server_ip_addr = ip::v4::parse_addr(server_ip);
1833-
let resp_cell = Cell(resp);
1833+
let resp_cell = Cell::new(resp);
18341834
let listen_result = listen(server_ip_addr, server_port, 128,
18351835
iotask,
18361836
// on_establish_cb -- called when listener is set up
@@ -1842,7 +1842,7 @@ mod test {
18421842
// risky to run this on the loop, but some users
18431843
// will want the POWER
18441844
|new_conn, kill_ch| {
1845-
let resp_cell2 = Cell(resp_cell.take());
1845+
let resp_cell2 = Cell::new(resp_cell.take());
18461846
debug!("SERVER: new connection!");
18471847
let (cont_po, cont_ch) = stream();
18481848
let server_ch = server_ch.clone();

src/libextra/rc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod test_rc {
105105

106106
#[test]
107107
fn test_clone() {
108-
let x = rc_from_owned(Cell(5));
108+
let x = rc_from_owned(Cell::new(5));
109109
let y = x.clone();
110110
do x.borrow().with_mut_ref |inner| {
111111
*inner = 20;
@@ -115,7 +115,7 @@ mod test_rc {
115115

116116
#[test]
117117
fn test_deep_clone() {
118-
let x = rc_from_owned(Cell(5));
118+
let x = rc_from_owned(Cell::new(5));
119119
let y = x.deep_clone();
120120
do x.borrow().with_mut_ref |inner| {
121121
*inner = 20;

src/libextra/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ mod tests {
818818
let s = ~semaphore(1);
819819
let s2 = ~s.clone();
820820
let (p,c) = comm::stream();
821-
let child_data = Cell((s2, c));
821+
let child_data = Cell::new((s2, c));
822822
do s.access {
823823
let (s2, c) = child_data.take();
824824
do task::spawn || {
@@ -999,7 +999,7 @@ mod tests {
999999
let mut sibling_convos = ~[];
10001000
for 2.times {
10011001
let (p,c) = comm::stream();
1002-
let c = Cell(c);
1002+
let c = Cell::new(c);
10031003
sibling_convos.push(p);
10041004
let mi = ~m2.clone();
10051005
// spawn sibling task

src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ pub fn run_test(force_ignore: bool,
568568
fn run_test_inner(desc: TestDesc,
569569
monitor_ch: SharedChan<MonitorMsg>,
570570
testfn: ~fn()) {
571-
let testfn_cell = ::core::cell::Cell(testfn);
571+
let testfn_cell = ::core::cell::Cell::new(testfn);
572572
do task::spawn {
573573
let mut result_future = None; // task::future_result(builder);
574574

src/libextra/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ mod test {
282282

283283
for (times as uint).times {
284284
let mut rng = rand::rng();
285-
let expected = Cell(rng.gen_str(16u));
285+
let expected = Cell::new(rng.gen_str(16u));
286286
let (test_po, test_ch) = stream::<~str>();
287287
let hl_loop_clone = hl_loop.clone();
288288
do task::spawn() {

src/libextra/workcache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl TPrep for Prep {
347347
_ => {
348348
let (port, chan) = oneshot();
349349
let blk = replace(&mut bo, None).unwrap();
350-
let chan = Cell(chan);
350+
let chan = Cell::new(chan);
351351

352352
do task::spawn {
353353
let exe = Exec {

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,7 @@ pub static metadata_encoding_version : &'static [u8] =
14251425
0, 0, 0, 1 ];
14261426

14271427
pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
1428-
let wr = @io::BytesWriter();
1428+
let wr = @io::BytesWriter::new();
14291429
let stats = Stats {
14301430
inline_bytes: 0,
14311431
attr_bytes: 0,

src/librustc/middle/typeck/infer/region_inference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ use middle::typeck::infer::cres;
546546
use util::common::indenter;
547547
use util::ppaux::note_and_explain_region;
548548

549-
use core::cell::{Cell, empty_cell};
549+
use core::cell::Cell;
550550
use core::hashmap::{HashMap, HashSet};
551551
use core::to_bytes;
552552
use core::uint;
@@ -633,7 +633,7 @@ pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings {
633633
RegionVarBindings {
634634
tcx: tcx,
635635
var_spans: ~[],
636-
values: empty_cell(),
636+
values: Cell::new_empty(),
637637
constraints: HashMap::new(),
638638
lubs: HashMap::new(),
639639
glbs: HashMap::new(),

src/librustdoc/astsrv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ fn run<T>(owner: SrvOwner<T>, source: ~str, parse: Parser) -> T {
6565

6666
let (po, ch) = stream();
6767

68-
let source = Cell(source);
69-
let parse = Cell(parse);
68+
let source = Cell::new(source);
69+
let parse = Cell::new(parse);
7070
do task::spawn {
7171
act(&po, source.take(), parse.take());
7272
}

src/librustdoc/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ fn config_from_opts(
178178
}
179179
}
180180
};
181-
let process_output = Cell(process_output);
181+
let process_output = Cell::new(process_output);
182182
let result = do result::chain(result) |config| {
183183
let pandoc_cmd = getopts::opt_maybe_str(matches, opt_pandoc_cmd());
184184
let pandoc_cmd = maybe_find_pandoc(

src/librustdoc/markdown_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use core::vec;
2828
use syntax;
2929

3030
pub fn mk_pass(writer_factory: WriterFactory) -> Pass {
31-
let writer_factory = Cell(writer_factory);
31+
let writer_factory = Cell::new(writer_factory);
3232
Pass {
3333
name: ~"markdown",
3434
f: |srv, doc| run(srv, doc, writer_factory.take())

src/librustdoc/text_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use util::NominalOp;
2323
use core::cell::Cell;
2424

2525
pub fn mk_pass(name: ~str, op: @fn(&str) -> ~str) -> Pass {
26-
let op = Cell(op);
26+
let op = Cell::new(op);
2727
Pass {
2828
name: copy name,
2929
f: |srv: astsrv::Srv, doc: doc::Doc| -> doc::Doc {

src/librusti/rusti.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
365365
}
366366
}
367367

368-
let line = Cell(line);
369-
let r = Cell(copy *repl);
368+
let line = Cell::new(line);
369+
let r = Cell::new(copy *repl);
370370
let result = do task::try {
371371
run(r.take(), line.take())
372372
};

src/libstd/cell.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ pub struct Cell<T> {
2929
priv value: Option<T>
3030
}
3131

32-
/// Creates a new full cell with the given value.
33-
pub fn Cell<T>(value: T) -> Cell<T> {
34-
Cell { value: Some(value) }
35-
}
32+
impl<T> Cell<T> {
33+
/// Creates a new full cell with the given value.
34+
pub fn new(value: T) -> Cell<T> {
35+
Cell { value: Some(value) }
36+
}
3637

37-
/// Creates a new empty cell with no value inside.
38-
pub fn empty_cell<T>() -> Cell<T> {
39-
Cell { value: None }
40-
}
38+
/// Creates a new empty cell with no value inside.
39+
pub fn new_empty() -> Cell<T> {
40+
Cell { value: None }
41+
}
4142

42-
impl<T> Cell<T> {
4343
/// Yields the value, failing if the cell is empty.
4444
pub fn take(&self) -> T {
4545
let this = unsafe { transmute_mut(self) };
@@ -83,7 +83,7 @@ impl<T> Cell<T> {
8383

8484
#[test]
8585
fn test_basic() {
86-
let value_cell = Cell(~10);
86+
let value_cell = Cell::new(~10);
8787
assert!(!value_cell.is_empty());
8888
let value = value_cell.take();
8989
assert!(value == ~10);
@@ -96,22 +96,22 @@ fn test_basic() {
9696
#[should_fail]
9797
#[ignore(cfg(windows))]
9898
fn test_take_empty() {
99-
let value_cell = empty_cell::<~int>();
99+
let value_cell = Cell::new_empty::<~int>();
100100
value_cell.take();
101101
}
102102

103103
#[test]
104104
#[should_fail]
105105
#[ignore(cfg(windows))]
106106
fn test_put_back_non_empty() {
107-
let value_cell = Cell(~10);
107+
let value_cell = Cell::new(~10);
108108
value_cell.put_back(~20);
109109
}
110110

111111
#[test]
112112
fn test_with_ref() {
113113
let good = 6;
114-
let c = Cell(~[1, 2, 3, 4, 5, 6]);
114+
let c = Cell::new(~[1, 2, 3, 4, 5, 6]);
115115
let l = do c.with_ref() |v| { v.len() };
116116
assert_eq!(l, good);
117117
}
@@ -120,7 +120,7 @@ fn test_with_ref() {
120120
fn test_with_mut_ref() {
121121
let good = ~[1, 2, 3];
122122
let v = ~[1, 2];
123-
let c = Cell(v);
123+
let c = Cell::new(v);
124124
do c.with_mut_ref() |v| { v.push(3); }
125125
let v = c.take();
126126
assert_eq!(v, good);

0 commit comments

Comments
 (0)