Commit Graph

874 Commits

Author SHA1 Message Date
Patrick Walton
1e91595520 librustc: Remove fail_unless! 2013-03-29 16:39:08 -07:00
bors
a17a9d41f6 auto merge of #5624 : thestinger/rust/tutorial, r=pcwalton 2013-03-29 13:30:46 -07:00
Daniel Micay
0189ef3600 tutorial: add an example of freezing a managed box 2013-03-29 15:45:10 -04:00
Daniel Micay
f78af18127 tutorial: improve the managed boxes section 2013-03-29 15:45:10 -04:00
Daniel Micay
85ed840e23 tutorial: improve the owned boxes section 2013-03-29 15:45:07 -04:00
Daniel Micay
777ad8b204 tutorial: use "owned box" consistently 2013-03-29 14:16:52 -04:00
bors
706ed6dd53 auto merge of #5583 : jbclements/rust/docfix-for-block-comment-grammar, r=jbclements
... by adding Kleene '+' in two places, and changing a "non-slash" into "non_slash_or_star".

Closes #1588
2013-03-29 09:39:43 -07:00
bors
5da9e12778 auto merge of #5570 : alexcrichton/rust/fix-unused-imports, r=sanxiyn
Before it wouldn't warn about unused imports in the list if something in the list was used. These commits fix that case, add a test, and remove all unused imports in lists of imports throughout the compiler.
2013-03-29 05:57:44 -07:00
Alex Crichton
be57d745d2 Removing unused imports 2013-03-28 23:56:46 -04:00
Daniel Micay
d4509f270b tutorial: only Owned types can have a Drop impl 2013-03-28 18:41:55 -04:00
Daniel Micay
467502216e tutorial: cleaner libc use statements 2013-03-28 17:53:29 -04:00
John Clements
dcb8fa8f35 added defn of non_slash_or_star 2013-03-28 10:23:20 -07:00
John Clements
81d30ade61 fix another subtle bug in comment regex 2013-03-28 10:19:08 -07:00
John Clements
48cb50af13 fixes stated grammar for block comments, by adding Kleene '+' in two places.
Closes #1588
2013-03-27 10:17:37 -07:00
Patrick Walton
b07b36bbf3 test: Fix tests 2013-03-26 22:45:22 -07:00
Patrick Walton
8b56a8380b librustc: Modify all code to use new lifetime binder syntax 2013-03-26 21:30:17 -07:00
Alex Crichton
31f6e64324 doc: Remove mentions of oldmap::HashMap 2013-03-26 19:20:02 -04:00
bors
7f5d7e1c2e auto merge of #5549 : brson/rust/rustdoc, r=brson
r?
2013-03-26 09:52:14 -07:00
Brian Anderson
4d745c288a rustdoc: Tweak list style 2013-03-26 09:31:44 -07:00
Felix S. Klock II
e1dccf9a73 Updated to reflect alpha-rename of constant/static items section. 2013-03-26 14:36:01 +01:00
Felix S. Klock II
5b10f4e117 Miscellaneous documentation additions.
Added notes explaining how [expr, ..expr] form is used, targeted at
individuals like me who thought it was more general and handled
dynamic repeat expressions.  (I left a TODO for this section in a
comment, but perhaps that is bad form for the manual...)

Added example of `do` syntax with a function of arity > 1; yes, one
should be able to derive this from the text above it, but it is still
a useful detail to compare and contrast against the arity == 1 case.

Added example of using for expression over a uint range, since someone
who is most used to write `for(int i; i < lim; i++) { ... }` will
likely want to know how to translate that form (regardless of whether
it happens to be good style or not for their use-case).

Added note about the semi-strange meaning of "fixed size" of vectors
in the vector type section.
2013-03-26 14:18:48 +01:00
bors
d469212d9d auto merge of #5507 : graydon/rust/fixups2, r=graydon
Just some editing-to-reflect-reality on release notes and manual.
2013-03-25 16:36:58 -07:00
Graydon Hoare
b481829306 docs: update to avoid mention of const. 2013-03-25 15:53:02 -07:00
bors
df171e4b68 auto merge of #5505 : catamorphism/rust/macro-tutorial, r=graydon
r? @jbclements
2013-03-25 15:13:09 -07:00
Patrick Walton
28efc234f4 libcore: Fix obsolete syntax in extfmt 2013-03-22 23:09:15 -07:00
Tim Chevalier
3633ba240f Copyedit macro tutorial 2013-03-22 16:11:27 -07:00
Tim Chevalier
ab2a397ae7 docs: Copyedit my randomly assigned sections of the manual 2013-03-22 14:45:16 -07:00
Luca Bruno
f9bb7b7768 Tutorial: make struct section more coherent
In struct section of tutorial, make everything more coherent and
clear by always using "struct Point". Also, do not prematurely
introduce pointers and arrays. Fixes #5240

Signed-off-by: Luca Bruno <lucab@debian.org>
2013-03-21 21:33:29 +01:00
Daniel Micay
9967dc81fe rewrite the tutorial section on boxes 2013-03-19 16:27:08 -04: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
58f248d923 test: Fix tests. rs=tests 2013-03-13 20:08:35 -07:00
Patrick Walton
8fa66e8e07 librustc: Remove implicit self from the language, except for old-style drop blocks. 2013-03-13 20:07:10 -07:00
Patrick Walton
b1c699815d librustc: Don't accept as Trait anymore; fix all occurrences of it. 2013-03-13 20:07:09 -07:00
Brian Anderson
82f190355b Remove uses of log 2013-03-11 23:19:42 -07:00
Patrick Walton
08c840205e librustc: Lint the old drop destructor notation off 2013-03-11 09:36:00 -07:00
Patrick Walton
1fcb0443cf doc: Remove documentation on newtype enums. 2013-03-11 09:35:59 -07:00
Patrick Walton
d7e74b5e91 librustc: Convert all uses of assert over to fail_unless! 2013-03-07 22:37:57 -08:00
Niko Matsakis
3168fe06ff Add manual &self/ and &static/ and /&self declarations that
are currently inferred.  New rules are coming that will require
them to be explicit.  All add some explicit self declarations.
2013-03-06 15:12:57 -05:00
Patrick Walton
30bb09c0e7 test: Remove fn@, fn~, and fn& from the test suite. rs=defun 2013-03-02 18:47:47 -08:00
Patrick Walton
a3f728238b librustc: Forbid chained imports and fix the logic for one-level renaming imports 2013-03-02 16:49:30 -08:00
bors
5aca7d6aef auto merge of #5137 : yjh0502/rust/empty_struct, r=nikomatsakis
The fix is straight-forward, but there are several changes
while fixing the issue.

1) disallow `mut` keyword when making a new struct

In code base, there are following code,

```rust
struct Foo { mut a: int };
let a = Foo { mut a: 1 };
```

This is because of structural record, which is
deprecated corrently (see issue #3089) In structural
record, `mut` keyword should be allowd to control
mutability. But without structural record, we don't
need to allow `mut` keyword while constructing struct.

2) disallow structural records in parser level
This is related to 1). With structural records, there
is an ambiguity between empty block and empty struct
To solve the problem, I change parser to stop parsing
structural records. I think this is not a problem,
because structural records are not compiled already.

Misc. issues

There is an ambiguity between empty struct vs. empty match stmt.
with following code,

```rust
match x{} {}
```

Two interpretation is possible, which is listed blow

```rust
match (x{}) {} //  matching with newly-constructed empty struct
(match x{}) {}  //  matching with empty enum(or struct) x
                //  and then empty block
```

It seems that there is no such code in rust code base, but
there is one test which uses empty match statement:
https://github.com/mozilla/rust/blob/incoming/src/test/run-pass/issue-3037.rs

All other cases could be distinguished with look-ahead,
but this can't be. One possible solution is wrapping with
parentheses when matching with an uninhabited type.

```rust
enum what { }
fn match_with_empty(x: what) -> ~str {
    match (x) { //use parentheses to remove the ambiguity
    }
}
```
2013-03-02 04:21:38 -08:00
bors
10faa521ae auto merge of #5188 : ben0x539/rust/doc-call-generic-fn, r=catamorphism
I have seen a few people confused on how to explicitly instantiate generic functions, since the syntax differs from C++'s and C#'s, which is probably where most people asking questions about generic functions are coming from. The only use of the `::<T>` syntax in the reference right now is in the section on paths, which is possibly not where someone trying to find out about generic functions is going to start looking. The tutorial doesn't mention it at all, but I think it's all right to make the reference a tiny bit more redundant and avoid stuffing the tutorial with syntax details.

----

The "Generic functions" subsection mentions that generic functions are instantiated based on context, so let's also mention right away (with a link to the #paths section) that an explicit form is available.

This also adds an example that explicitly instantiates a generic function to the function call expression section.
2013-03-02 01:00:41 -08:00
Jihyun Yu
95bc9ea26d Remove REC, change related tests/docs 2013-03-02 12:57:05 +09:00
Benjamin Herr
382143abd8 doc/rust.md: Demonstrate the f::<T>() syntax more often
The "Generic functions" subsection mentions that generic functions are
instantiated based on context, so let's also mention right away (with a
link to the #paths section) that an explicit form is available.

This also adds an example to the function call expression section that
explicitly instantiates a generic function.
2013-03-02 01:07:01 +01:00
Benjamin Herr
332c046029 docs/rust.md: Mention unit-like structs along with other struct types 2013-03-02 00:25:44 +01:00
Patrick Walton
2859c1ac6d librustc: Enforce cross-crate method privacy 2013-02-28 11:32:26 -08:00
bors
292e946163 auto merge of #5106 : pnkfelix/rust/fix-docs, r=graydon
...s.  I freely admit I have not run a "make check" on this (trivial) change.
2013-02-27 19:03:41 -08:00
Patrick Walton
8d7e6ef772 libsyntax: Forbid ~mut and ~const. rs=demuting 2013-02-27 09:40:15 -08:00
Alex Crichton
df481473da Fix unused imports in the tutorials 2013-02-26 17:52:16 -05:00
bors
0e6d895ed8 auto merge of #5119 : Kimundi/rust/incoming, r=catamorphism
Removed deprecated `str()` functions in int-template.rs and uint-template.rs
2013-02-26 10:54:39 -08:00