Commit Graph

31007 Commits

Author SHA1 Message Date
Adolfo Ochagavía
75a0062d88 Add string::raw::from_buf 2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
684479ab91 Fix travis errors 2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
0fe894e49b Deprecated String::from_raw_parts
Replaced by `string::raw::from_parts`

[breaking-change]
2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
6e509d3462 Deprecated str::raw::from_buf_len
Replaced by `string::raw::from_buf_len`

[breaking-change]
2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
feeae27a56 Deprecated str::raw::from_byte
Use `string:raw::from_utf8` instead

[breaking-change]
2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
9ec19373af Deprecated str::raw::from_utf8_owned
Replaced by `string::raw::from_utf8`

[breaking-change]
2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
eacc5d779f Deprecated str::raw::from_c_str
Use `string::raw::from_buf` instead

[breaking-change]
2014-07-24 07:25:43 -07:00
Adolfo Ochagavía
ba707fb3a0 Remove OwnedStr trait
This trait was only implemented by `String`. It provided the methods
`into_bytes` and `append`, both of which **are already implemented as normal
methods** of `String` (not as trait methods). This change improves the
consistency of strings.

This shouldn't break any code, except if somebody has implemented
`OwnedStr` for a user-defined type.
2014-07-24 07:25:43 -07:00
Jonas Hietala
c4ce4c8f9b Cleanup HashMap documentation.
Link to mentioned methods. Use `# Failure` tags to describe failure.
Make `pop_equiv`, `find_equiv` and `get_copy` standalone.
2014-07-24 16:25:19 +02:00
bors
6203f8ac7b auto merge of #15922 : poiru/rust/remove-whitespace-mk-backslash, r=brson
The alignment of the line continuation backslashes is rather inconsistent. These commits solve that by removing the extra whitespace and adding a space where there previously was none. An alternative solution would be to fix the alignment.
2014-07-24 13:51:17 +00:00
Jonas Hietala
6bbe92e6ef Cleanup LruCache doc. 2014-07-24 14:40:57 +02:00
bors
482c776d5a auto merge of #15856 : treeman/rust/doc-priorityqueue, r=huonw
Add examples to methods.
2014-07-24 11:46:15 +00:00
Jonas Hietala
3c45fe9e1d Documentation examples for LruCache. 2014-07-24 12:51:42 +02:00
bors
e70ee120bf auto merge of #15921 : dotdash/rust/match_lifetimes, r=pcwalton
The allocas used in match expression currently don't get good lifetime
markers, in fact they only get lifetime start markers, because their
lifetimes don't match to cleanup scopes.

While the bindings themselves are bog standard and just need a matching
pair of start and end markers, they might need them twice, once for a
guard clause and once for the match body.

The __llmatch alloca OTOH needs a single lifetime start marker, but
when there's a guard clause, it needs two end markers, because its
lifetime ends either when the guard doesn't match or after the match
body.

With these intrinsics in place, LLVM can now, for example, optimize
code like this:

````rust
enum E {
  A1(int),
  A2(int),
  A3(int),
  A4(int),
}

pub fn variants(x: E) {
  match x {
    A1(m) => bar(&m),
    A2(m) => bar(&m),
    A3(m) => bar(&m),
    A4(m) => bar(&m),
  }
}
````

To a single call to bar, using only a single stack slot. It still fails
to eliminate some of checks.

````gas
.Ltmp5:
	.cfi_def_cfa_offset 16
	movb	(%rdi), %al
	testb	%al, %al
	je	.LBB3_5
	movzbl	%al, %eax
	cmpl	$1, %eax
	je	.LBB3_5
	cmpl	$2, %eax
.LBB3_5:
	movq	8(%rdi), %rax
	movq	%rax, (%rsp)
	leaq	(%rsp), %rdi
	callq	_ZN3bar20hcb7a0d8be8e17e37daaE@PLT
	popq	%rax
	retq
````

Refs #15665
2014-07-24 09:51:16 +00:00
Jonas Hietala
571692c0ab Document PriorityQueue. 2014-07-24 11:41:23 +02:00
Jonas Hietala
87ef2f390b Move contructors to the top of PriorityQueue. 2014-07-24 11:40:22 +02:00
Jonas Hietala
7028b3fda9 Remove explicit rust code specifier. Unhide use HashMap. 2014-07-24 10:35:04 +02:00
Jonas Hietala
0d61c6b128 Fill in example code for HashMap.
Add an example showing how to use the map with a custom type. Fill in
examples for methods in the hashmap file without ones.

Also move pop_equiv next to related public methods, to not create a
duplicate trait implementation in the docs.
2014-07-24 10:32:14 +02:00
bors
02464196ea auto merge of #15909 : colemickens/rust/patch-3, r=alexcrichton
Tested this on the playground, the range specifies range(0u, 3), so it should be okay to remove this cast.
2014-07-24 07:51:18 +00:00
bors
9e2bb9d67b auto merge of #15862 : jakub-/rust/issue-15774, r=alexcrichton
Fixed #15774.
2014-07-24 05:01:22 +00:00
bors
221c28a088 auto merge of #15781 : alexcrichton/rust/issue-15758, r=bblum
Semaphores are not currently designed to handle this case correctly, leading to
very strange behavior. Semaphores as written are intended to count *resources*
and it's not possible to have a negative number of resources.

This alters the behavior and documentation to note that the task will be failed
if the initial count is 0.

Closes #15758
2014-07-24 02:16:13 +00:00
bors
2224edcfe1 auto merge of #15407 : sneves/rust/master, r=aturon
At the moment, writing generic functions for integer types that involve shifting is rather verbose. For example, a function at shifts an integer left by 1 currently requires 

    use std::num::One;
    fn f<T: Int>(x : T) -> T {
        x << One::one()
    }

If the shift amount is not 1, it's even worse:

    use std::num::FromPrimitive;
    fn f<T: Int + FromPrimitive>(x: T) -> T {
        x << FromPrimitive::from_int(2).unwrap()
    }

This patch allows the much simpler implementation

    fn f<T: Int>(x: T) -> T { 
        x << 2
    }

It accomplishes this by changing the built-in integer types (and the `Int` trait) to implement `Shl<uint, T>` instead of `Shl<T, T>` as it currently is defined. Note that the internal implementations of `shl` already cast the right-hand side to `uint`. `BigInt` also implements `Shl<uint, BigInt>`, so this increases consistency.

All of the above applies similarly to right shifts, i.e., `Shr<uint, T>`.
2014-07-24 00:26:14 +00:00
bors
fb72c4767f auto merge of #15611 : brson/rust/pushpop, r=alexcrichton
This fixes naming conventions for `push`/`pop` from either end of a structure by partially implementing @erickt's suggestion from https://github.com/rust-lang/rust/issues/10852#issuecomment-30823343, namely:

* push/pop from the 'back' are called `push` and `pop`.
* push/pop from the 'front' are called `push_front` and `pop_front`.
* `push`/`pop` are declared on the `MutableSeq` trait.
* Implement `MutableSeq` for `Vec`, `DList`, and `RingBuf`.
* Add `MutableSeq` to the prelude.

I did not make any further refactorings because there is some more extensive thought that needs to be put into the collections traits. This is an easy first step that should close https://github.com/rust-lang/rust/issues/10852.

I left the `push_back` and `pop_back` methods on `DList` and `RingBuf` deprecated. Because `MutableSeq` is in the prelude it shouldn't break many, but it is a breaking change.
2014-07-23 21:41:14 +00:00
Brian Anderson
71a75cc2ce Just land already 2014-07-23 13:20:17 -07:00
Brian Anderson
27e70c5d49 Remove stray llvmdeps.rs 2014-07-23 13:20:17 -07:00
Brian Anderson
63d1137d68 collections: Tweak docs for push 2014-07-23 13:20:17 -07:00
Brian Anderson
054b1ff989 Remove kludgy imports from vec! macro 2014-07-23 13:20:17 -07:00
Brian Anderson
9db1d35687 collections: Deprecate shift/unshift
Use insert/remove instead.
2014-07-23 13:20:16 -07:00
Brian Anderson
94e42c2d89 collections: Make push_back/pop_back default methods 2014-07-23 13:20:16 -07:00
Brian Anderson
2d79bfa415 vim: Add MutableSeq 2014-07-23 13:20:16 -07:00
Brian Anderson
7c61bb7213 collections: Move push/pop docs to MutableSeq 2014-07-23 13:20:16 -07:00
Brian Anderson
5599b69b6d Convert some push_back users to push 2014-07-23 13:20:16 -07:00
Brian Anderson
79a980558b collections: Deprecate push_back/pop_back 2014-07-23 13:20:16 -07:00
Brian Anderson
d36a8f3f9c collections: Move push/pop to MutableSeq
Implement for Vec, DList, RingBuf. Add MutableSeq to the prelude.

Since the collections traits are in the prelude most consumers of
these methods will continue to work without change.

[breaking-change]
2014-07-23 13:20:10 -07:00
Jakub Wieczorek
ad30579ef8 Parser: Global single-segment paths should be represented as PatEnum
Fixed #15774.
2014-07-23 22:15:11 +02:00
bors
b3a732a3ea auto merge of #15928 : brson/rust/dist, r=alexcrichton,alexcrichton
The first commit reverts a similar fix that only solves the `make install` case. This adds the `--enable-dist-host-only` flag to configure to preserve the old behavior, which the nightly bots rely on. The bots will need to be updated soon after this lands (or they will ~double in size).

Closes https://github.com/rust-lang/rust/issues/15711
2014-07-23 19:56:15 +00:00
Brian Anderson
e34e86d151 mk: Have the various flavors of 'dist' install all targets by default
Closes #15711
2014-07-23 12:04:29 -07:00
Brian Anderson
04914fddfb configure: Add --enable-dist-host-only flag
This preserves the current behavior of `make dist` where we only
distribute bins for the host architecture. The bots need this.
2014-07-23 12:04:27 -07:00
bors
c080d26d32 auto merge of #15902 : nham/rust/hash_triemap, r=alexcrichton
cc #15294
2014-07-23 18:11:15 +00:00
Birunthan Mohanathas
6511053d1c mk: Add space before line continuation backslash 2014-07-23 08:44:11 -07:00
Birunthan Mohanathas
c5433c3a0f mk: Remove extra whitespace before line continuation backslashes 2014-07-23 08:41:55 -07:00
Björn Steinbrink
0d6f257657 Improve usage of lifetime intrinsics in match expressions
The allocas used in match expression currently don't get good lifetime
markers, in fact they only get lifetime start markers, because their
lifetimes don't match to cleanup scopes.

While the bindings themselves are bog standard and just need a matching
pair of start and end markers, they might need them twice, once for a
guard clause and once for the match body.

The __llmatch alloca OTOH needs a single lifetime start marker, but
when there's a guard clause, it needs two end markers, because its
lifetime ends either when the guard doesn't match or after the match
body.

With these intrinsics in place, LLVM can now, for example, optimize
code like this:

````rust
enum E {
  A1(int),
  A2(int),
  A3(int),
  A4(int),
}

pub fn variants(x: E) {
  match x {
    A1(m) => bar(&m),
    A2(m) => bar(&m),
    A3(m) => bar(&m),
    A4(m) => bar(&m),
  }
}
````

To a single call to bar, using only a single stack slot. It still fails
to eliminate some of checks.

````gas
.Ltmp5:
	.cfi_def_cfa_offset 16
	movb	(%rdi), %al
	testb	%al, %al
	je	.LBB3_5
	movzbl	%al, %eax
	cmpl	$1, %eax
	je	.LBB3_5
	cmpl	$2, %eax
.LBB3_5:
	movq	8(%rdi), %rax
	movq	%rax, (%rsp)
	leaq	(%rsp), %rdi
	callq	_ZN3bar20hcb7a0d8be8e17e37daaE@PLT
	popq	%rax
	retq
````
2014-07-23 17:39:13 +02:00
bors
826b835813 auto merge of #15749 : vhbit/rust/treemap-doc-fixes, r=alexcrichton
1. Removed obsolete comment regarding recursive/iteration implementations of tree_find_with/tree_find_mut_with
2. Replaced easy breakable find_with example with simpler one (which only removes redundant allocation during search)
2014-07-23 14:06:08 +00:00
bors
b10dcbe53a auto merge of #15910 : sfackler/rust/nogc, r=cmr 2014-07-23 10:06:09 +00:00
bors
b13d6ea6c2 auto merge of #15900 : tbu-/rust/pr_numcleanup, r=kballard
This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.
2014-07-23 08:16:10 +00:00
Valerii Hiora
4a00d4e676 TreeMap examples fixes
1. Removed obsolete comment regarding recursive/iteration implementations of tree_find_with/tree_find_mut_with
2. Replaced easy breakable find_with example with simpler one (which only removes redundant allocation during search)
2014-07-23 10:58:46 +03:00
bors
83a8a56473 auto merge of #15899 : aochagavia/rust/guide, r=kballard
The removed code caused confusion because it is not clear that the type of `y` is actually `()`
2014-07-23 06:31:11 +00:00
Steven Fackler
3e62ad3fb9 Remove ancient GC cfg flags 2014-07-22 23:20:09 -07:00
Cole Mickens
6bb22a9d6d Remove unnecessary cast from intro 2014-07-22 23:10:18 -07:00
bors
c4209d17a0 auto merge of #15897 : Gankro/rust/it-docs, r=kballard
I found these things to be ambiguous, or at least worth stating explicitly to reduce the amount a user/developer needs to think about the API.
2014-07-23 04:46:09 +00:00