Skip to content

Commit 206ab89

Browse files
committed
librustc: Stop reexporting the standard modules from prelude.
1 parent 4e3d4b3 commit 206ab89

File tree

598 files changed

+1868
-450
lines changed

Some content is hidden

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

598 files changed

+1868
-450
lines changed

doc/rust.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,6 +1840,7 @@ is bounds-checked at run-time. When the check fails, it will put the
18401840
task in a _failing state_.
18411841

18421842
~~~~
1843+
# use std::task;
18431844
# do task::spawn_unlinked {
18441845
18451846
([1, 2, 3, 4])[0];
@@ -2168,7 +2169,7 @@ fn ten_times(f: &fn(int)) {
21682169
}
21692170
}
21702171
2171-
ten_times(|j| io::println(fmt!("hello, %d", j)));
2172+
ten_times(|j| println(fmt!("hello, %d", j)));
21722173
21732174
~~~~
21742175

@@ -2189,7 +2190,7 @@ An example:
21892190
let mut i = 0;
21902191
21912192
while i < 10 {
2192-
io::println("hello\n");
2193+
println("hello\n");
21932194
i = i + 1;
21942195
}
21952196
~~~~
@@ -2335,6 +2336,7 @@ for v.each |e| {
23352336
An example of a for loop over a series of integers:
23362337

23372338
~~~~
2339+
# use std::uint;
23382340
# fn bar(b:uint) { }
23392341
for uint::range(0, 256) |i| {
23402342
bar(i);
@@ -2798,6 +2800,7 @@ the vtable pointer for the `T` implementation of `R`, and the pointer value of `
27982800
An example of an object type:
27992801

28002802
~~~~~~~~
2803+
# use std::int;
28012804
trait Printable {
28022805
fn to_str(&self) -> ~str;
28032806
}
@@ -2807,7 +2810,7 @@ impl Printable for int {
28072810
}
28082811
28092812
fn print(a: @Printable) {
2810-
io::println(a.to_str());
2813+
println(a.to_str());
28112814
}
28122815
28132816
fn main() {

doc/tutorial-ffi.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ A type with the same functionality as owned boxes can be implemented by
149149
wrapping `malloc` and `free`:
150150

151151
~~~~
152+
use std::cast;
152153
use std::libc::{c_void, size_t, malloc, free};
154+
use std::ptr;
153155
use std::unstable::intrinsics;
154156
use std::util;
155157

doc/tutorial-tasks.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ should interleave the output in vaguely random order.
120120
~~~
121121
# use std::io::print;
122122
# use std::task::spawn;
123+
# use std::int;
123124
124125
for int::range(0, 20) |child_task_number| {
125126
do spawn {
@@ -236,6 +237,7 @@ Instead we can use a `SharedChan`, a type that allows a single
236237
~~~
237238
# use std::task::spawn;
238239
# use std::comm::{stream, SharedChan};
240+
# use std::uint;
239241
240242
let (port, chan) = stream();
241243
let chan = SharedChan::new(chan);
@@ -269,6 +271,7 @@ might look like the example below.
269271
~~~
270272
# use std::task::spawn;
271273
# use std::comm::stream;
274+
# use std::vec;
272275
273276
// Create a vector of ports, one for each child task
274277
let ports = do vec::from_fn(3) |init_val| {
@@ -310,6 +313,8 @@ the future needs to be mutable so that it can save the result for next time `get
310313
Here is another example showing how futures allow you to background computations. The workload will
311314
be distributed on the available cores.
312315
~~~
316+
# use std::vec;
317+
# use std::uint;
313318
fn partial_sum(start: uint) -> f64 {
314319
let mut local_sum = 0f64;
315320
for uint::range(start*100000, (start+1)*100000) |num| {
@@ -343,14 +348,17 @@ acts as a reference to the shared data and only this reference is shared and clo
343348
Here is a small example showing how to use ARCs. We wish to run concurrently several computations on
344349
a single large vector of floats. Each task needs the full vector to perform its duty.
345350
~~~
351+
# use std::vec;
352+
# use std::uint;
353+
# use std::rand;
346354
use extra::arc::ARC;
347355
348356
fn pnorm(nums: &~[float], p: uint) -> float {
349357
(vec::foldl(0.0, *nums, |a,b| a+(*b).pow(p as float) )).pow(1f / (p as float))
350358
}
351359
352360
fn main() {
353-
let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
361+
let numbers = vec::from_fn(1000000, |_| rand::random::<float>());
354362
println(fmt!("Inf-norm = %?", numbers.max()));
355363
356364
let numbers_arc = ARC(numbers);
@@ -373,12 +381,16 @@ at the power given as argument and takes the inverse power of this value). The A
373381
created by the line
374382
~~~
375383
# use extra::arc::ARC;
376-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
384+
# use std::vec;
385+
# use std::rand;
386+
# let numbers = vec::from_fn(1000000, |_| rand::random::<float>());
377387
let numbers_arc=ARC(numbers);
378388
~~~
379389
and a clone of it is sent to each task
380390
~~~
381391
# use extra::arc::ARC;
392+
# use std::vec;
393+
# use std::rand;
382394
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
383395
# let numbers_arc = ARC(numbers);
384396
# let (port, chan) = stream();
@@ -389,6 +401,8 @@ copying only the wrapper and not its contents.
389401
Each task recovers the underlying data by
390402
~~~
391403
# use extra::arc::ARC;
404+
# use std::vec;
405+
# use std::rand;
392406
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
393407
# let numbers_arc=ARC(numbers);
394408
# let (port, chan) = stream();
@@ -416,6 +430,7 @@ of all tasks are intertwined: if one fails, so do all the others.
416430

417431
~~~
418432
# use std::task::spawn;
433+
# use std::task;
419434
# fn do_some_work() { loop { task::yield() } }
420435
# do task::try {
421436
// Create a child task that fails
@@ -437,6 +452,7 @@ field (representing a successful result) or an `Err` result (representing
437452
termination with an error).
438453

439454
~~~
455+
# use std::task;
440456
# fn some_condition() -> bool { false }
441457
# fn calculate_result() -> int { 0 }
442458
let result: Result<int, ()> = do task::try {
@@ -479,6 +495,7 @@ By default, task failure is _bidirectionally linked_, which means that if
479495
either task fails, it kills the other one.
480496

481497
~~~
498+
# use std::task;
482499
# fn sleep_forever() { loop { task::yield() } }
483500
# do task::try {
484501
do spawn {
@@ -501,6 +518,7 @@ before returning. Hence:
501518
~~~
502519
# use std::comm::{stream, Chan, Port};
503520
# use std::task::{spawn, try};
521+
# use std::task;
504522
# fn sleep_forever() { loop { task::yield() } }
505523
# do task::try {
506524
let (receiver, sender): (Port<int>, Chan<int>) = stream();
@@ -528,6 +546,7 @@ Supervised task failure propagates across multiple generations even if
528546
an intermediate generation has already exited:
529547

530548
~~~
549+
# use std::task;
531550
# fn sleep_forever() { loop { task::yield() } }
532551
# fn wait_for_a_while() { for 1000.times { task::yield() } }
533552
# do task::try::<int> {
@@ -546,6 +565,7 @@ Finally, tasks can be configured to not propagate failure to each
546565
other at all, using `task::spawn_unlinked` for _isolated failure_.
547566

548567
~~~
568+
# use std::task;
549569
# fn random() -> uint { 100 }
550570
# fn sleep_for(i: uint) { for i.times { task::yield() } }
551571
# do task::try::<()> {
@@ -574,6 +594,7 @@ Here is the function that implements the child task:
574594

575595
~~~~
576596
# use extra::comm::DuplexStream;
597+
# use std::uint;
577598
fn stringifier(channel: &DuplexStream<~str, uint>) {
578599
let mut value: uint;
579600
loop {
@@ -596,6 +617,7 @@ Here is the code for the parent task:
596617

597618
~~~~
598619
# use std::task::spawn;
620+
# use std::uint;
599621
# use extra::comm::DuplexStream;
600622
# fn stringifier(channel: &DuplexStream<~str, uint>) {
601623
# let mut value: uint;

doc/tutorial.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ types.
502502
> items.
503503
504504
~~~~
505+
# use std::float;
505506
fn angle(vector: (float, float)) -> float {
506507
let pi = float::consts::pi;
507508
match vector {
@@ -556,6 +557,7 @@ while cake_amount > 0 {
556557
`loop` denotes an infinite loop, and is the preferred way of writing `while true`:
557558

558559
~~~~
560+
# use std::int;
559561
let mut x = 5;
560562
loop {
561563
x += x - 3;
@@ -699,6 +701,7 @@ get at their contents. All variant constructors can be used as
699701
patterns, as in this definition of `area`:
700702

701703
~~~~
704+
# use std::float;
702705
# struct Point {x: float, y: float}
703706
# enum Shape { Circle(Point, float), Rectangle(Point, Point) }
704707
fn area(sh: Shape) -> float {
@@ -1829,6 +1832,7 @@ vector consisting of the result of applying `function` to each element
18291832
of `vector`:
18301833

18311834
~~~~
1835+
# use std::vec;
18321836
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
18331837
let mut accumulator = ~[];
18341838
for vec::each(vector) |element| {
@@ -2026,6 +2030,7 @@ themselves contain type parameters. A trait for generalized sequence
20262030
types might look like the following:
20272031

20282032
~~~~
2033+
# use std::vec;
20292034
trait Seq<T> {
20302035
fn len(&self) -> uint;
20312036
fn iter(&self, b: &fn(v: &T));

src/compiletest/compiletest.rc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#[no_std];
1717

1818
extern mod core(name = "std", vers = "0.7-pre");
19-
extern mod std(name = "extra", vers = "0.7-pre");
19+
extern mod extra(name = "extra", vers = "0.7-pre");
2020

2121
use core::prelude::*;
2222
use core::*;
2323

24-
use std::getopts;
25-
use std::test;
24+
use extra::getopts;
25+
use extra::test;
2626

2727
use core::result::{Ok, Err};
2828

@@ -42,6 +42,13 @@ pub mod runtest;
4242
pub mod common;
4343
pub mod errors;
4444

45+
mod std {
46+
pub use core::cmp;
47+
pub use core::str;
48+
pub use core::sys;
49+
pub use core::unstable;
50+
}
51+
4552
pub fn main() {
4653
let args = os::args();
4754
let config = parse_config(args);

src/compiletest/errors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
use core::prelude::*;
1212

13+
use core::io;
14+
use core::str;
15+
1316
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
1417

1518
// Load any test directives embedded in the file

src/compiletest/header.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010

1111
use core::prelude::*;
1212

13-
use common;
1413
use common::config;
14+
use common;
15+
16+
use core::io;
17+
use core::os;
18+
use core::str;
1519

1620
pub struct TestProps {
1721
// Lines that should be expected, in order, on standard out

src/compiletest/procsrv.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010

1111
use core::prelude::*;
1212

13+
use core::comm;
14+
use core::io;
15+
use core::libc::c_int;
16+
use core::os;
1317
use core::run;
18+
use core::str;
19+
use core::task;
1420

1521
#[cfg(target_os = "win32")]
1622
fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {

src/compiletest/runtest.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ use procsrv;
2222
use util;
2323
use util::logv;
2424

25+
use core::io;
26+
use core::os;
27+
use core::str;
28+
use core::uint;
29+
use core::vec;
30+
2531
pub fn run(config: config, testfile: ~str) {
2632
if config.verbose {
2733
// We're going to be dumping a lot of info. Start on a new line.

src/compiletest/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use core::prelude::*;
1212

1313
use common::config;
1414

15+
use core::io;
1516
use core::os::getenv;
1617

1718
pub fn make_new_path(path: &str) -> ~str {

0 commit comments

Comments
 (0)