Skip to content

Fix example in the docs #4180

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 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6e38e33
Relate the module hierarchy to directory paths in the parser
brson Dec 11, 2012
7d556e1
Fix deriving for single-variant enums
brson Dec 11, 2012
bfb09ee
Merge pull request #4164 from brson/deriving
brson Dec 11, 2012
3ee1adb
libstd: teach workcache to check freshness.
graydon Dec 11, 2012
a55ea48
libstd: refactor future, remove with(), remove ~ indirection.
graydon Dec 11, 2012
76dc781
libstd: Implement read_managed_str for the JSON deserialiser.
huonw Dec 10, 2012
35209cb
fix long line, r=tidypolice.
graydon Dec 12, 2012
6439f2d
Avoid extra error for type mismatches in patterns
catamorphism Dec 11, 2012
a7159be
Remove old deriving
brson Dec 12, 2012
d42bdf1
Auto-deref when checking field and method privacy
catamorphism Dec 12, 2012
b0a01f2
re-fix typo
catamorphism Dec 11, 2012
38bd694
Reverse the order of the results of pipes::stream
catamorphism Dec 11, 2012
4ec658e
Merge pull request #4167 from catamorphism/issue-3637
catamorphism Dec 12, 2012
213773c
Fix tasks tutorial tests
catamorphism Dec 12, 2012
80d6bc8
Add Huon Wilson to AUTHORS.txt
graydon Dec 12, 2012
9cced55
syntax: remove all remaining uses of #ast, and #ast / qquote itself.
graydon Dec 12, 2012
e24ae85
syntax: remove most code handling old-style syntax extensions.
graydon Dec 12, 2012
0138d87
Document pub use foo::* in the reference manual
catamorphism Dec 13, 2012
9a4c669
syntax: remove remaining #syntaxext machinery. Close #3516.
graydon Dec 13, 2012
0494b07
Merge pull request #4172 from graydon/remove-old-syntax-ext
brson Dec 13, 2012
6047dd3
Fix vtable calculations when translating static methods. Closes #4165
brson Dec 13, 2012
948754b
Fix the test for transmute
brson Dec 13, 2012
0d59e86
core: Remove some uses of 'move'
brson Dec 12, 2012
3c8dca4
syntax: normalize paths when parsing, close #4173.
graydon Dec 13, 2012
4c2e4c3
librustc: Make `use` statements crate-relative by default. r=brson
pcwalton Dec 13, 2012
08b1c84
Rename "to_str" to "make_string" in the docs
andrew-d Dec 14, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Gonçalo Cabrita <[email protected]>
Graham Fawcett <[email protected]>
Grahame Bowland <[email protected]>
Haitao Li <[email protected]>
Huon Wilson <[email protected]>
Ian D. Bollinger <[email protected]>
Ivano Coppola <[email protected]>
Jacob Harris Cryer Kragh <[email protected]>
Expand Down
23 changes: 19 additions & 4 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,25 @@ fn main() {

Like items, `use` declarations are private to the containing module, by default.
Also like items, a `use` declaration can be public, if qualified by the `pub` keyword.
Such a `use` declaration serves to _re-export_ a name.
A public `use` declaration can therefore be used to _redirect_ some public name to a different target definition,
even a definition with a private canonical path, inside a different module.
If a sequence of such redirections form a cycle or cannot be unambiguously resolved, they represent a compile-time error.

An example of re-exporting:
~~~~
mod quux {
mod foo {
pub fn bar() { }
pub fn baz() { }
}

pub use foo::*;
}
~~~~

In this example, the module `quux` re-exports all of the public names defined in `foo`.

### Functions

A _function item_ defines a sequence of [statements](#statements) and an optional final [expression](#expressions), along with a name and a set of parameters.
Expand Down Expand Up @@ -2704,18 +2719,18 @@ The special type `self` has a meaning within methods inside an
impl item. It refers to the type of the implicit `self` argument. For
example, in:

~~~~~~~~{.xfail-test}
~~~~~~~~
trait Printable {
fn to_str() -> ~str;
fn make_string() -> ~str;
}

impl ~str: Printable {
fn to_str() -> ~str { copy self }
fn make_string() -> ~str { copy self }
}
~~~~~~~~

`self` refers to the value of type `~str` that is the receiver for a
call to the method `to_str`.
call to the method `make_string`.

## Type kinds

Expand Down
18 changes: 9 additions & 9 deletions doc/tutorial-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ come in a variety of forms, each one appropriate for a different use case. In
what follows, we cover the most commonly used varieties.

The simplest way to create a pipe is to use the `pipes::stream`
function to create a `(Chan, Port)` pair. In Rust parlance, a *channel*
function to create a `(Port, Chan)` pair. In Rust parlance, a *channel*
is a sending endpoint of a pipe, and a *port* is the receiving
endpoint. Consider the following example of calculating two results
concurrently:
Expand All @@ -159,7 +159,7 @@ concurrently:
use task::spawn;
use pipes::{stream, Port, Chan};

let (chan, port): (Chan<int>, Port<int>) = stream();
let (port, chan): (Port<int>, Chan<int>) = stream();

do spawn |move chan| {
let result = some_expensive_computation();
Expand All @@ -179,7 +179,7 @@ a tuple into its component parts).

~~~~
# use pipes::{stream, Chan, Port};
let (chan, port): (Chan<int>, Port<int>) = stream();
let (port, chan): (Port<int>, Chan<int>) = stream();
~~~~

The child task will use the channel to send data to the parent task,
Expand All @@ -191,7 +191,7 @@ spawns the child task.
# use task::spawn;
# use pipes::{stream, Port, Chan};
# fn some_expensive_computation() -> int { 42 }
# let (chan, port) = stream();
# let (port, chan) = stream();
do spawn |move chan| {
let result = some_expensive_computation();
chan.send(result);
Expand All @@ -211,7 +211,7 @@ port:
~~~~
# use pipes::{stream, Port, Chan};
# fn some_other_expensive_computation() {}
# let (chan, port) = stream::<int>();
# let (port, chan) = stream::<int>();
# chan.send(0);
some_other_expensive_computation();
let result = port.recv();
Expand All @@ -227,7 +227,7 @@ following program is ill-typed:
# use task::{spawn};
# use pipes::{stream, Port, Chan};
# fn some_expensive_computation() -> int { 42 }
let (chan, port) = stream();
let (port, chan) = stream();

do spawn |move chan| {
chan.send(some_expensive_computation());
Expand All @@ -247,7 +247,7 @@ Instead we can use a `SharedChan`, a type that allows a single
# use task::spawn;
use pipes::{stream, SharedChan};

let (chan, port) = stream();
let (port, chan) = stream();
let chan = SharedChan(move chan);

for uint::range(0, 3) |init_val| {
Expand Down Expand Up @@ -282,7 +282,7 @@ might look like the example below.

// Create a vector of ports, one for each child task
let ports = do vec::from_fn(3) |init_val| {
let (chan, port) = stream();
let (port, chan) = stream();
do spawn |move chan| {
chan.send(some_expensive_computation(init_val));
}
Expand Down Expand Up @@ -397,7 +397,7 @@ before returning. Hence:
# use task::{spawn, try};
# fn sleep_forever() { loop { task::yield() } }
# do task::try {
let (sender, receiver): (Chan<int>, Port<int>) = stream();
let (receiver, sender): (Port<int>, Chan<int>) = stream();
do spawn |move receiver| { // Bidirectionally linked
// Wait for the supervised child task to exist.
let message = receiver.recv();
Expand Down
29 changes: 14 additions & 15 deletions src/libcargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,25 @@ extern mod std(vers = "0.5");
extern mod rustc(vers = "0.5");
extern mod syntax(vers = "0.5");

use core::*;

#[legacy_exports]
mod pgp;

use syntax::{ast, codemap, parse, visit, attr};
use syntax::diagnostic::span_handler;
use codemap::span;
use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest,
get_cargo_sysroot, libdir};
use syntax::diagnostic;
use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest};
use rustc::metadata::filesearch::{get_cargo_sysroot, libdir};

use result::{Ok, Err};
use io::WriterUtil;
use send_map::linear::LinearMap;
use core::*;

use core::dvec::DVec;
use core::io::WriterUtil;
use core::result::{Ok, Err};
use core::send_map::linear::LinearMap;
use std::getopts::{optflag, optopt, opt_present};
use std::map::HashMap;
use std::{map, json, tempfile, term, sort, getopts};
use map::HashMap;
use to_str::to_str;
use getopts::{optflag, optopt, opt_present};
use dvec::DVec;
use syntax::codemap::span;
use syntax::diagnostic::span_handler;
use syntax::diagnostic;
use syntax::{ast, codemap, parse, visit, attr};

struct Package {
name: ~str,
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub pure fn build_sized<A>(size: uint,
builder: &fn(push: pure fn(v: A))) -> @[A] {
let mut vec: @[const A] = @[];
unsafe { raw::reserve(&mut vec, size); }
builder(|+x| unsafe { raw::push(&mut vec, move x) });
builder(|+x| unsafe { raw::push(&mut vec, x) });
return unsafe { transmute(vec) };
}

Expand Down Expand Up @@ -178,10 +178,10 @@ pub mod raw {
let repr: **VecRepr = ::cast::reinterpret_cast(&v);
let fill = (**repr).unboxed.fill;
if (**repr).unboxed.alloc > fill {
push_fast(v, move initval);
push_fast(v, initval);
}
else {
push_slow(v, move initval);
push_slow(v, initval);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/libcore/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ pub mod tests {

#[test]
pub fn test_transmute() {
use managed::raw::BoxRepr;
unsafe {
let x = @1;
let x: *int = transmute(move x);
assert *x == 1;
let x = @100u8;
let x: *BoxRepr = transmute(move x);
assert (*x).data == 100;
let _x: @int = transmute(move x);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub pure fn escape_unicode(c: char) -> ~str {
{ str::push_str(&mut out, ~"0"); }
str::push_str(&mut out, s);
}
move out
out
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub unsafe fn annihilate() {
assert (*box).header.prev == null();

debug!("freeing box: %x", box as uint);
rt_free(transmute(move box));
rt_free(transmute(box));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ mod core {
#[cfg(test)]
mod std {
extern mod std(vers = "0.5");
pub use std::test;
pub use std::std::test;
}


Expand Down
5 changes: 5 additions & 0 deletions src/libcore/int-template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];

#[cfg(stage0)]
use T = inst::T;
#[cfg(stage1)]
#[cfg(stage2)]
use T = self::inst::T;

use cmp::{Eq, Ord};
use from_str::FromStr;
use num::from_int;
Expand Down
6 changes: 5 additions & 1 deletion src/libcore/int-template/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

//! Operations and constants for `int`

#[cfg(stage0)]
pub use inst::pow;
#[cfg(stage1)]
#[cfg(stage2)]
pub use self::inst::pow;

mod inst {
pub type T = int;
Expand Down Expand Up @@ -54,4 +58,4 @@ mod inst {
assert (min_value <= 0);
assert (min_value + max_value + 1 == 0);
}
}
}
5 changes: 5 additions & 0 deletions src/libcore/iter-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
#[forbid(deprecated_pattern)];

use cmp::{Eq, Ord};

#[cfg(stage0)]
use inst::{IMPL_T, EACH, SIZE_HINT};
#[cfg(stage1)]
#[cfg(stage2)]
use self::inst::{IMPL_T, EACH, SIZE_HINT};

impl<A> IMPL_T<A>: iter::BaseIter<A> {
pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) }
Expand Down
Loading