Commit Graph

16251 Commits

Author SHA1 Message Date
Andrew Paseltiner
3042321b3b syntax: split deriving module into submodules for each trait 2013-03-19 18:44:41 -04:00
Andrew Paseltiner
18a594f49a syntax: move ext/deriving.rs to ext/deriving/mod.rs 2013-03-19 18:41:19 -04:00
bors
5ae76b5bab auto merge of #5428 : thestinger/rust/tutorial, r=catamorphism
My goal is to explain the underlying concepts first (destructors and then ownership) with plenty of step-by-step examples, so that thoroughly explaining the semantics of mutability, boxes, moves, etc. is a breeze. I'm trying to avoid the comparisons with C++ that were done before, because this should be approachable for people coming from any language. C++ programmers already know these concepts so they aren't the audience that needs to be catered to. Comparisons with other languages can be done in separate documents (like [this one](https://github.com/mozilla/rust/wiki/Rust-for-CXX-programmers)).

This still needs examples for ownership (inherited mutability), owned boxes and managed boxes.
2013-03-19 13:58:06 -07:00
Daniel Micay
9967dc81fe rewrite the tutorial section on boxes 2013-03-19 16:27:08 -04:00
bors
e1888948c6 auto merge of #5426 : nikomatsakis/rust/issue-4846-lifetimes-in-expl-self, r=pcwalton
(this will be needed for snapshotting at some point)

r? @pcwalton
2013-03-19 12:43:14 -07:00
bors
a14ec73cd2 auto merge of #5356 : jld/rust/enum-less-magic, r=graydon
Fixes #1645.
2013-03-19 11:43:10 -07:00
bors
58209910bd auto merge of #5433 : lucab/rust/lucab/cfgspec, r=graydon
All current meta items types (word, name-value, list) are now
properly parsed by rustc --cfg command line. Fixes #2399
2013-03-19 10:43:24 -07:00
bors
3c84bac946 auto merge of #5112 : luqmana/rust/3469, r=graydon
So this is a partial fix for #3469. Partial because it only works for simple constant expressions like `32/2` and `2+2` and not for any actual constants.

For example:
```
const FOO: uint = 2+2;
let v: [int * FOO];
```

results in:
```
error: expected constant expr for vector length: Non-constant path in constant expr
```

This seems to be because at the point of error (`typeck::astconv`) the def_map doesn't contain the constant and thus it can't lookup the actual expression (`2+2` in this case).

So, feedback on what I have so far and suggestions for how to address the constant issue?
2013-03-19 09:52:17 -07:00
Luca Bruno
0a34a3f0f5 Make driver::driver::parse_cfgspecs parse any variety of meta_item
All current meta items types (word, name-value, list) are now
properly parsed by rustc --cfg command line. Fixes #2399

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-03-19 14:02:59 +01:00
Luqman Aden
d7d17dc14e Add tests for const exprs in fixed vec length type and vec repeat. 2013-03-18 17:31:42 -07:00
Luqman Aden
da64994f18 Fix pretty printer for fixed length vectors. 2013-03-18 17:31:42 -07:00
Luqman Aden
8b66578e66 Allow expressions that are not just a single value for repeated fixed length vector syntax. 2013-03-18 17:31:41 -07:00
Luqman Aden
787f5bb0db Now actually allow using constants in those constant expressions for [T * n]. 2013-03-18 17:31:41 -07:00
Luqman Aden
42f95d055c Allow constant expressions in [Type * n]. 2013-03-18 17:31:41 -07:00
bors
e67448d397 auto merge of #5412 : pcwalton/rust/purity, r=pcwalton
librustc: Make the compiler ignore purity. …

For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.

There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.

r? @nikomatsakis
2013-03-18 17:24:50 -07:00
Patrick Walton
e78f2e2ac5 librustc: Make the compiler ignore purity.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.

There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
2013-03-18 17:21:16 -07:00
Patrick Walton
c4db4faefa libsyntax: Stop parsing old lifetimes, except for the ones on data type declarations. 2013-03-18 17:21:15 -07:00
Patrick Walton
352c070365 librustc: Convert all uses of old lifetime notation to new lifetime notation. rs=delifetiming 2013-03-18 17:21:14 -07:00
Luqman Aden
7352d919f6 Update rust.vim
Column limit 78 -> 100.
2013-03-18 17:19:40 -07:00
Patrick Walton
dc69018495 librustc: Make the compiler ignore purity.
For bootstrapping purposes, this commit does not remove all uses of
the keyword "pure" -- doing so would cause the compiler to no longer
bootstrap due to some syntax extensions ("deriving" in particular).
Instead, it makes the compiler ignore "pure". Post-snapshot, we can
remove "pure" from the language.

There are quite a few (~100) borrow check errors that were essentially
all the result of mutable fields or partial borrows of `@mut`. Per
discussions with Niko I think we want to allow partial borrows of
`@mut` but detect obvious footguns. We should also improve the error
message when `@mut` is erroneously reborrowed.
2013-03-18 13:21:25 -07:00
Niko Matsakis
a6187c62e9 Make &self permit explicit lifetimes, but don't really use them
(this will be needed for snapshotting at some point).
2013-03-18 15:03:37 -04:00
Patrick Walton
fc8c808908 libsyntax: Stop parsing old lifetimes, except for the ones on data type declarations. 2013-03-18 11:46:00 -07:00
Patrick Walton
299995c2b6 librustc: Convert all uses of old lifetime notation to new lifetime notation. rs=delifetiming 2013-03-18 11:45:59 -07:00
bors
087a015a72 auto merge of #5420 : boggle/rust/sudoku-with-traits, r=graydon
Came back to look at rust and found out that this had been broken by some refactoring work. Fixed and now has tests.
2013-03-18 10:46:21 -07:00
Stefan Plantikow
321a54d26f Refactored sudoku benchmark to use traits and added some tests 2013-03-18 00:42:14 +01:00
bors
f54adca7c9 auto merge of #5374 : z0w0/rust/rustdoc-explicit-self, r=z0w0 2013-03-16 18:57:43 -07:00
Zack Corr
246573d5ae rustdoc: Fix method printing tests 2013-03-17 11:45:22 +10:00
bors
6307d24364 auto merge of #5415 : brson/rust/rustdoc, r=thestinger
r? @thestinger
2013-03-16 16:36:45 -07:00
Brian Anderson
deeeaf0ddb rustdoc: Show all impls of traits. #5406 2013-03-16 16:17:56 -07:00
bors
b53da4b9dd auto merge of #5342 : brson/rust/debug-mem, r=brson
Fixes #5341
2013-03-16 14:27:44 -07:00
Brian Anderson
63d18658c1 rt: Add RUST_DEBUG_MEM to rust_env to avoid races 2013-03-16 14:25:44 -07:00
Zack Corr
d597a19b30 syntax: Fix fun_to_str test 2013-03-16 17:36:39 +10:00
bors
ebba8b4e35 auto merge of #5408 : thestinger/rust/trie, r=pcwalton
The chunk fix is cherry picked from @graydon's `gc` branch.
2013-03-15 22:39:42 -07:00
bors
dc5ad5070d auto merge of #5359 : luqmana/rust/inline-asm, r=pcwalton
Continuation of #5317. Actually use operands properly now, including any number of output operands.

Which means you can do things like call printf:
```Rust
fn main() {
    unsafe {
        do str::as_c_str(~"The answer is %d.\n") |c| {
            let a = 42;
            asm!("mov $0, %rdi\n\t\
                  mov $1, %rsi\n\t\
                  xorl %eax, %eax\n\t\
                  call _printf"
                 :
                 : "r"(c), "r"(a)
                 : "rdi", "rsi", "eax"
                 : "volatile","alignstack"
                 );
        }
    }
}
```

```
% rustc foo.rs
% ./foo
The answer is 42.
```

Or just add 2 numbers:
```Rust
fn add(a: int, b: int) -> int {
    let mut c = 0;
    unsafe {
        asm!("add $2, $0"
             : "=r"(c)
             : "0"(a), "r"(b)
             );
    }
    c
}

fn main() {
    io::println(fmt!("%d", add(1, 2)));
}
```

```
% rustc foo.rs
% ./foo
3
```

Multiple outputs!
```Rust
fn addsub(a: int, b: int) -> (int, int) {
    let mut c = 0;
    let mut d = 0;
    unsafe {
        asm!("add $4, $0\n\t\
              sub $4, $1"
             : "=r"(c), "=r"(d)
             : "0"(a), "1"(a), "r"(b)
             );
    }
    (c, d)
}

fn main() {
    io::println(fmt!("%?", addsub(5, 1)));
}
```
```
% rustc foo.rs
% ./foo
(6, 4)
```

This also classifies inline asm as RvalueStmtExpr instead of the somewhat arbitrary kind I made it initially. There are a few XXX's regarding what to do in the liveness and move passes.
2013-03-15 21:15:46 -07:00
bors
6f1e8ef71a auto merge of #5404 : bstrie/rust/decopy, r=pcwalton
Also turn `copy` into `.clone()` in much of run-pass.
2013-03-15 20:15:44 -07:00
Luqman Aden
83f2d4ab3d Fix type_use for inline asm. 2013-03-15 18:57:19 -07:00
Luqman Aden
d68b98a5bf Don't use by_val for passing asm operands. 2013-03-15 18:55:44 -07:00
Luqman Aden
3d56936be3 Tidy. 2013-03-15 18:55:44 -07:00
Luqman Aden
e182ac4bbd Actually use no or multiple operands properly. 2013-03-15 18:55:44 -07:00
Luqman Aden
9ead7dad93 Implicitly use addr_of for output operands in asm. 2013-03-15 18:55:44 -07:00
Luqman Aden
59dcbd9f1c Initial support for output operands in asm. 2013-03-15 18:55:44 -07:00
Luqman Aden
d8ab47e7f9 Properly handle input operands for inline asm. 2013-03-15 18:55:43 -07:00
Luqman Aden
6d078db952 Actually pass inline asm operands around. 2013-03-15 18:55:43 -07:00
Luqman Aden
471d2b1765 Inline asm exprs should be RvalueStmtExpr. 2013-03-15 18:55:43 -07:00
Daniel Micay
d856215b92 add a test for the chunk function 2013-03-15 21:45:08 -04:00
bors
5a77a10488 auto merge of #5400 : thestinger/rust/misc, r=brson 2013-03-15 18:30:45 -07:00
Graydon Hoare
0942c80272 core: fix trie chunk function 2013-03-15 21:12:17 -04:00
Daniel Micay
98900d55e7 add constructor to TrieSet (was missing) 2013-03-15 21:03:29 -04:00
bors
4ad9e5c0c2 auto merge of #5396 : ILyoan/rust/fix_rt_tls, r=graydon
Add a conditional compile option for android
2013-03-15 17:18:44 -07:00
bors
6859a6d9a3 auto merge of #5391 : brson/rust/to-bytes, r=graydon
r?

I want to use this function as a method. There's probably a better way to design this but the existing `ToBytes` trait is not what I am looking for (it has a parameter to indicate the byte order).
2013-03-15 16:15:47 -07:00