Skip to content
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

Fix unique pointers occuring in unreachable blocks #3825

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
bdc1b7a
libcore: add a str::with_capacity to match the fn in vec
erickt Oct 9, 2012
25096a2
rustc: fix size computation of structs for the FFI
Blei Oct 10, 2012
97ecde2
Conditional usage of LLVM DebugFlag
lucab Oct 8, 2012
01aaeef
Use gpgv for signature verification in cargo
lucab Oct 14, 2012
ab89b5c
libstd: make Serializer a trait-level typaram
erickt Oct 13, 2012
f6211ab
Add various test cases (xfailed)
catamorphism Oct 15, 2012
7237268
Allow enum discriminator exprs to refer to declared consts
catamorphism Oct 15, 2012
0643466
Fix whitespace
catamorphism Oct 15, 2012
2a1aa9f
Check whether loans conflict with old loans or with themselves.
nikomatsakis Oct 14, 2012
c886629
rustc: Implement monomorphic default methods. r=nmatsakis
pcwalton Oct 8, 2012
4f9e7ba
Un-xfail test for #3521; it works now
catamorphism Oct 15, 2012
c5b82a6
Add test cases for #3668
catamorphism Oct 15, 2012
91ae541
rustc: Merge module and type namespaces. r=brson
pcwalton Oct 15, 2012
7d84505
Error out in resolve if structs try to capture type parameters
catamorphism Oct 15, 2012
d293286
Add test case for Issue 2895
catamorphism Oct 16, 2012
bbc46d5
Add test for Issue 2823
catamorphism Oct 16, 2012
b38092e
In ty::normalize_ty, don't replace self_regions with None
catamorphism Oct 16, 2012
4dc67c5
rustc: Implement intra-crate static methods on anonymous trait implem…
pcwalton Oct 16, 2012
a92c3db
add missing pub from multifile example in sec 12.3
nikomatsakis Oct 17, 2012
1679960
Change a use of map::get to map::find
catamorphism Oct 17, 2012
081a043
Remove integer suffixes
catamorphism Oct 17, 2012
47c83f1
Export std::net_url::encode_component
catamorphism Oct 17, 2012
7f12cc4
Merge pull request #3716 from Blei/fix-3656
catamorphism Oct 17, 2012
ebce097
Merge pull request #3706 from erickt/str-with-capacity
catamorphism Oct 17, 2012
f5e71f5
Merge pull request #3719 from lucab/lucab/to-upstream/pull-2
catamorphism Oct 17, 2012
5cf0c65
Merge pull request #3764 from lucab/lucab/to-upstream/pull-3
catamorphism Oct 17, 2012
e94e82c
Extraneous sigil patrol: ~"string literals"
bstrie Oct 12, 2012
5e1d0ba
Sigil patrol: change fn@ fn& fn~ to @fn &fn ~fn
bstrie Oct 13, 2012
f7ce3dc
Extraneous sigil patrol: turn &[] literals into []
bstrie Oct 13, 2012
ca5506a
fix the indentation of foreign constant
crabtw Oct 8, 2012
66151d0
remove duplicate visibility and fix indentation
crabtw Oct 14, 2012
7236472
word => word_space
catamorphism Oct 17, 2012
b532a8e
Line length
catamorphism Oct 17, 2012
32baf1c
Add a module to getopts to support verbose option definition
killerswan Oct 11, 2012
f2544d8
Fix long lines
catamorphism Oct 17, 2012
fd6be2f
std::treemap - changing types to reflect constraints, adding equality…
Oct 4, 2012
bbc90b6
Fix whitespace
catamorphism Oct 17, 2012
33adb7a
Merge pull request #3739 from killerswan/usagemsg
catamorphism Oct 17, 2012
cf8bded
Enable configure to detect 32 bit systems on 64 bit kernels
arkaitzj Oct 16, 2012
d9f1426
Fix copy warnings in str
catamorphism Oct 17, 2012
7dde840
Fix copy warnings in str
catamorphism Oct 17, 2012
e7e1bab
libsyntax: refactor the parser to consider foreign items as items
Blei Oct 9, 2012
fdd7b4d
core: first working sketch of a condition system.
graydon Oct 17, 2012
0f2fc71
Add examples to the parsing limitations section of the macro tutorial.
paulstansifer Oct 18, 2012
e28a161
Merge pull request #3799 from paulstansifer/master
catamorphism Oct 18, 2012
2c1ed18
Check pandoc's version correctly for >=1.10.
Oct 18, 2012
c0cee3e
libcore: Make run::program_output UTF-8 safe
tychosci Oct 18, 2012
6ce4cf7
rustdoc: Make markdown_writer::pandoc_writer UTF-8 safe
tychosci Oct 18, 2012
4e03ffd
rustc: optimize away some mallocs when building GEP args
erickt Oct 18, 2012
b18a151
Make with_bytes_reader/with_bytes_writer pure
erickt Oct 18, 2012
e3b1471
Rewrite io::ByteBuf into a struct
erickt Oct 18, 2012
95423d2
libcore: call [u8] values bytes, not bufs
erickt Oct 18, 2012
a7ecde3
libcore: minor code cleanup.
erickt Oct 18, 2012
ac50046
Simplify str::to_managed
erickt Oct 18, 2012
fe41cce
Rename str::to_unique to str::to_owned.
erickt Oct 18, 2012
141ef23
Merge pull request #3805 from erickt/incoming
catamorphism Oct 18, 2012
fa38c12
test: Fix failing tests. r=rustbot
pcwalton Oct 18, 2012
b03c71f
Remove dead type definition
catamorphism Oct 18, 2012
55f043d
Merge pull request #3802 from rfw/fix_pandoc_configure
catamorphism Oct 18, 2012
7dda889
Merge pull request #3803 from tychosci/readclose
catamorphism Oct 18, 2012
eeae552
Revert "Simplify str::to_managed"
erickt Oct 18, 2012
754704e
rustc: Implement intra-crate static methods on anonymous trait implem…
pcwalton Oct 18, 2012
acf2d20
core: add previous-handler save and restore for proper nesting.
graydon Oct 18, 2012
33795bc
configure: fix use of bash-specific here strings (also awk, please no…
graydon Oct 18, 2012
e0b71dd
configure: note dep on head.
graydon Oct 18, 2012
3d76a75
configure: check for pandoc version properly.
luqmana Oct 19, 2012
c81953c
Merge pull request #3811 from luqmana/incoming
catamorphism Oct 19, 2012
34aabe5
Add Luqman Aden to AUTHORS
catamorphism Oct 19, 2012
6c4ad31
core: Add type params to condition handling so interface is safe.
graydon Oct 19, 2012
c97944f
core: add potential "simpler interface" to core::condition, also redu…
graydon Oct 19, 2012
10612ee
Remove superfluous by-ref in option::get, option::get_default, option…
catamorphism Oct 19, 2012
8492a02
Fix Windows breakage
catamorphism Oct 19, 2012
81e66ae
Renaming trait name UniqueStr to Trimmable
vertexclique Oct 15, 2012
0243d86
Add Mahmut Bulut to AUTHORS
catamorphism Oct 19, 2012
89de49c
core: add 3rd proposed interface (trap/in) to conditions.
graydon Oct 19, 2012
c05d96c
Valgrind check disable
vertexclique Oct 15, 2012
55d134d
Some tweaks to the valgrind makefile code
brson Oct 20, 2012
15777de
Fix run-pass/issue-2895 for 32-bit archs
brson Oct 20, 2012
0e2437b
uv: implement a way to get client's ip/port.
luqmana Oct 19, 2012
79e538d
uv: use just getpeername for both ipv4 and ipv6.
luqmana Oct 20, 2012
781f8cb
std: Add test for getpeername
brson Oct 20, 2012
9555ee7
std: rename getpeername to get_peer_addr
luqmana Oct 20, 2012
8dd8136
std: Use unique ports in tcp tests
brson Oct 21, 2012
55e40a1
Add new uv functions to rustrt.def.in
brson Oct 21, 2012
4174688
libsyntax: adapt the pretty printer for the new fixed size array syntax
Blei Oct 9, 2012
ac81fff
Remove old fixed-length vector syntax
bstrie Oct 10, 2012
684d945
Fix a pprint test for fixed-length vecs
bstrie Oct 11, 2012
614624a
No longer parse old fixed-length vec sytnax
bstrie Oct 12, 2012
41c37d9
...missed a merge marker on that last rebase
bstrie Oct 12, 2012
f3df50f
Parse and report obsolete fixed-length vector syntax
brson Oct 20, 2012
8a8fbe3
Remove remaining uses of old fixed-length vec syntax
brson Oct 20, 2012
8378757
Remove obsolete fixed-length string test
brson Oct 21, 2012
9980f25
Long lines
brson Oct 21, 2012
191d162
std: Shuffle around test ports some more
brson Oct 21, 2012
4edb881
Talk about ends, rather than means, in macro tutorial introduction.
paulstansifer Oct 21, 2012
082d3d5
Merge pull request #3823 from paulstansifer/master
brson Oct 21, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ Kevin Cantu <me@kevincantu.org>
Lennart Kudling
Lindsey Kuper <lindsey@rockstargirl.org>
Luca Bruno <lucab@debian.org>
Luqman Aden <laden@csclub.uwaterloo.ca>
Magnus Auvinen <magnus.auvinen@gmail.com>
Mahmut Bulut <mahmutbulut0@gmail.com>
Margaret Meyerhofer <mmeyerho@andrew.cmu.edu>
Marijn Haverbeke <marijnh@gmail.com>
Matt Brubeck <mbrubeck@limpet.net>
Expand Down
5 changes: 3 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ ifneq ($(wildcard $(CFG_GIT_DIR)),)
endif
endif

ifdef CFG_DISABLE_VALGRIND
$(info cfg: disabling valgrind (CFG_DISABLE_VALGRIND))
ifdef CFG_ENABLE_VALGRIND
$(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
else
CFG_VALGRIND :=
endif
ifdef CFG_BAD_VALGRIND
Expand Down
26 changes: 21 additions & 5 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ need_cmd cmp
need_cmd mkdir
need_cmd printf
need_cmd cut
need_cmd head
need_cmd grep
need_cmd xargs
need_cmd cp
Expand Down Expand Up @@ -257,6 +258,16 @@ case $CFG_CPUTYPE in
err "unknown CPU type: $CFG_CPUTYPE"
esac

# Detect 64 bit linux systems with 32 bit userland and force 32 bit compilation
if [ $CFG_OSTYPE = unknown-linux-gnu -a $CFG_CPUTYPE = x86_64 ]
then
file -L "$SHELL" | grep -q "x86[_-]64"
if [ $? != 0 ]; then
CFG_CPUTYPE=i686
fi
fi


DEFAULT_HOST_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}"

CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
Expand All @@ -283,7 +294,7 @@ else
fi

opt sharedstd 1 "build libstd as a shared library"
opt valgrind 1 "run tests with valgrind (memcheck by default)"
opt valgrind 0 "run tests with valgrind (memcheck by default)"
opt helgrind 0 "run tests with helgrind instead of memcheck"
opt docs 1 "build documentation"
opt optimize 1 "build optimized rust code"
Expand Down Expand Up @@ -352,11 +363,16 @@ fi

if [ ! -z "$CFG_PANDOC" ]
then
PV=$(pandoc --version | awk '/^pandoc/ {print $2}')
if [ "$PV" \< "1.8" ]
PANDOC_VER_LINE=$(pandoc --version | grep '^pandoc ')
PANDOC_VER=${PANDOC_VER_LINE#pandoc }
PV_MAJOR_MINOR=${PANDOC_VER%.[0-9]*}
PV_MAJOR=${PV_MAJOR_MINOR%%[.][0-9]*}
PV_MINOR=${PV_MAJOR_MINOR#[0-9]*[.]}
PV_MINOR=${PV_MINOR%%[.][0-9]*}
if [ "$PV_MAJOR" -lt "1" ] || [ "$PV_MINOR" -lt "8" ]
then
step_msg "pandoc $PV is too old. disabling"
BAD_PANDOC=1
step_msg "pandoc $PV_MAJOR.$PV_MINOR is too old. disabling"
BAD_PANDOC=1
fi
fi

Expand Down
31 changes: 18 additions & 13 deletions doc/tutorial-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

# Introduction

Functions are the primary tool that programmers can use to build
abstractions. Sometimes, though, programmers want to abstract over
compile-time, syntactic structures rather than runtime values. For example,
the following two code fragments both pattern-match on their input and return
early in one case, doing nothing otherwise:
Functions are the primary tool that programmers can use to build abstractions.
Sometimes, however, programmers want to perform abstractions over things that are not
runtime values. Macros provide a syntactic abstraction. For an example of how this
can be useful, consider the following two code fragments, which both pattern-match
on their input and return early in one case, and do nothing otherwise:

~~~~
# enum t { special_a(uint), special_b(uint) };
Expand Down Expand Up @@ -155,17 +155,22 @@ If it is under more, it'll be repeated, as appropriate.

## Parsing limitations

The macro parser will parse Rust syntax with two limitations:

1. The parser will always parse as much as possible. For example, if the comma
were omitted from the syntax of `early_return!` above, `input_1 [` would've
been interpreted as the beginning of an array index. In fact, invoking the
macro would have been impossible.
2. The parser must have eliminated all ambiguity by the time it reaches a
For technical reasons, there are two limitations to the treatment of syntax
fragments by the macro parser:

1. The parser will always parse as much as possible of a Rust syntactic
fragment. For example, if the comma were omitted from the syntax of
`early_return!` above, `input_1 [` would've been interpreted as the beginning
of an array index. In fact, invoking the macro would have been impossible.
2. The parser must have eliminated all ambiguity by the time it reaches a
`$name:fragment_specifier` declaration. This limitation can result in parse
errors when declarations occur at the beginning of, or immediately after,
a `$(...)*`. Changing the invocation syntax to require a distinctive
token in front can solve the problem.
a `$(...)*`. For example, the grammar `$($t:ty)* $e:expr` will always fail to
parse because the parser would be forced to choose between parsing `t` and
parsing `e`. Changing the invocation syntax to require a distinctive token in
front can solve the problem. In the above example, `$(T $t:ty)* E $e:exp`
solves the problem.

## A final note

Expand Down
66 changes: 26 additions & 40 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1502,9 +1502,9 @@ and [`core::str`]. Here are some examples.
# fn unwrap_crayon(c: Crayon) -> int { 0 }
# fn eat_crayon_wax(i: int) { }
# fn store_crayon_in_nasal_cavity(i: uint, c: Crayon) { }
# fn crayon_to_str(c: Crayon) -> ~str { ~"" }
# fn crayon_to_str(c: Crayon) -> &str { "" }

let crayons = &[Almond, AntiqueBrass, Apricot];
let crayons = [Almond, AntiqueBrass, Apricot];

// Check the length of the vector
assert crayons.len() == 3;
Expand Down Expand Up @@ -1569,7 +1569,7 @@ let bloop = |well, oh: mygoodness| -> what_the { fail oh(well) };
~~~~

There are several forms of closure, each with its own role. The most
common, called a _stack closure_, has type `fn&` and can directly
common, called a _stack closure_, has type `&fn` and can directly
access local variables in the enclosing scope.

~~~~
Expand All @@ -1591,7 +1591,7 @@ pervasively in Rust code.
When you need to store a closure in a data structure, a stack closure
will not do, since the compiler will refuse to let you store it. For
this purpose, Rust provides a type of closure that has an arbitrary
lifetime, written `fn@` (boxed closure, analogous to the `@` pointer
lifetime, written `@fn` (boxed closure, analogous to the `@` pointer
type described earlier). This type of closure *is* first-class.

A managed closure does not directly access its environment, but merely
Expand All @@ -1604,8 +1604,9 @@ returns it from a function, and then calls it:

~~~~
# extern mod std;
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
return fn@(s: ~str) -> ~str { s + suffix };
fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
// The compiler knows that we intend this closure to be of type @fn
return |s| s + suffix;
}

fn main() {
Expand All @@ -1614,22 +1615,9 @@ fn main() {
}
~~~~

This example uses the long closure syntax, `fn@(s: ~str) ...`. Using
this syntax makes it explicit that we are declaring a boxed
closure. In practice, boxed closures are usually defined with the
short closure syntax introduced earlier, in which case the compiler
infers the type of closure. Thus our managed closure example could
also be written:

~~~~
fn mk_appender(suffix: ~str) -> fn@(~str) -> ~str {
return |s| s + suffix;
}
~~~~

## Owned closures

Owned closures, written `fn~` in analogy to the `~` pointer type,
Owned closures, written `~fn` in analogy to the `~` pointer type,
hold on to things that can safely be sent between
processes. They copy the values they close over, much like managed
closures, but they also own them: that is, no other code can access
Expand All @@ -1649,12 +1637,10 @@ callers may pass any kind of closure.

~~~~
fn call_twice(f: fn()) { f(); f(); }
call_twice(|| { ~"I am an inferred stack closure"; } );
call_twice(fn&() { ~"I am also a stack closure"; } );
call_twice(fn@() { ~"I am a managed closure"; });
call_twice(fn~() { ~"I am an owned closure"; });
fn bare_function() { ~"I am a plain function"; }
call_twice(bare_function);
let closure = || { "I'm a closure, and it doesn't matter what type I am"; };
fn function() { "I'm a normal function"; }
call_twice(closure);
call_twice(function);
~~~~

> ***Note:*** Both the syntax and the semantics will be changing
Expand Down Expand Up @@ -1693,7 +1679,7 @@ structure.
~~~~
# fn each(v: &[int], op: fn(v: &int)) { }
# fn do_some_work(i: &int) { }
each(&[1, 2, 3], |n| {
each([1, 2, 3], |n| {
do_some_work(n);
});
~~~~
Expand All @@ -1704,7 +1690,7 @@ call that can be written more like a built-in control structure:
~~~~
# fn each(v: &[int], op: fn(v: &int)) { }
# fn do_some_work(i: &int) { }
do each(&[1, 2, 3]) |n| {
do each([1, 2, 3]) |n| {
do_some_work(n);
}
~~~~
Expand All @@ -1715,7 +1701,7 @@ parentheses, where it looks more like a typical block of
code.

`do` is a convenient way to create tasks with the `task::spawn`
function. `spawn` has the signature `spawn(fn: fn~())`. In other
function. `spawn` has the signature `spawn(fn: ~fn())`. In other
words, it is a function that takes an owned closure that takes no
arguments.

Expand Down Expand Up @@ -1765,9 +1751,9 @@ And using this function to iterate over a vector:
~~~~
# use each = vec::each;
# use println = io::println;
each(&[2, 4, 8, 5, 16], |n| {
each([2, 4, 8, 5, 16], |n| {
if *n % 2 != 0 {
println(~"found odd number!");
println("found odd number!");
false
} else { true }
});
Expand All @@ -1782,9 +1768,9 @@ to the next iteration, write `loop`.
~~~~
# use each = vec::each;
# use println = io::println;
for each(&[2, 4, 8, 5, 16]) |n| {
for each([2, 4, 8, 5, 16]) |n| {
if *n % 2 != 0 {
println(~"found odd number!");
println("found odd number!");
break;
}
}
Expand Down Expand Up @@ -1967,12 +1953,12 @@ impl int: Printable {
fn print() { io::println(fmt!("%d", self)) }
}

impl ~str: Printable {
impl &str: Printable {
fn print() { io::println(self) }
}

# 1.print();
# (~"foo").print();
# ("foo").print();
~~~~

Methods defined in an implementation of a trait may be called just like
Expand Down Expand Up @@ -2120,7 +2106,7 @@ impl @Rectangle: Drawable { fn draw() { ... } }

let c: @Circle = @new_circle();
let r: @Rectangle = @new_rectangle();
draw_all(&[c as @Drawable, r as @Drawable]);
draw_all([c as @Drawable, r as @Drawable]);
~~~~

We omit the code for `new_circle` and `new_rectangle`; imagine that
Expand Down Expand Up @@ -2162,8 +2148,8 @@ additional modules.

~~~~
mod farm {
pub fn chicken() -> ~str { ~"cluck cluck" }
pub fn cow() -> ~str { ~"mooo" }
pub fn chicken() -> &str { "cluck cluck" }
pub fn cow() -> &str { "mooo" }
}

fn main() {
Expand Down Expand Up @@ -2360,13 +2346,13 @@ these two files:
~~~~
// world.rs
#[link(name = "world", vers = "1.0")];
fn explore() -> ~str { ~"world" }
pub fn explore() -> &str { "world" }
~~~~

~~~~ {.xfail-test}
// main.rs
extern mod world;
fn main() { io::println(~"hello " + world::explore()); }
fn main() { io::println("hello " + world::explore()); }
~~~~

Now compile and run like this (adjust to your platform if necessary):
Expand Down
Loading