]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agodisabling socking timing tests because openbsd/bitrig get/set are not congruent due...
Dave Huseby [Tue, 9 Jun 2015 16:36:17 +0000 (09:36 -0700)]
disabling socking timing tests because openbsd/bitrig get/set are not congruent due to rounding errors

9 years agoAuto merge of #25777 - shepmaster:cstring-return-to-c, r=alexcrichton
bors [Wed, 10 Jun 2015 22:37:38 +0000 (22:37 +0000)]
Auto merge of #25777 - shepmaster:cstring-return-to-c, r=alexcrichton

As far as I was able to determine, it's currently *impossible* to allocate a C NUL-terminated string in Rust and then return it to C (transferring ownership), without leaking memory. There is support for passing the string to C (borrowing).

To complicate matters, it's not possible for the C code to just call `free` on the allocated string, due to the different allocators in use.

`CString` has no way to recreate itself from a pointer. This commit adds one. This is complicated a bit because Rust `Vec`s want the pointer, size, and capacity.

To deal with that, another method to shrink and "leak" the `CString` to a `char *` is also provided.

We can then use `strlen` to determine the length of the string, which must match the capacity.

**TODO**

- [x] Improve documentation
- [x] Add stability markers
- [x] Convert to `Box<[u8]>`

### Example code

With this example code:

```rust
#![feature(libc)]
#![feature(cstr_to_str)]
#![feature(c_str_memory)]

extern crate libc;

use std::ffi::{CStr,CString};

#[no_mangle]
pub extern fn reverse(s: *const libc::c_char) -> *const libc::c_char {
    let s = unsafe { CStr::from_ptr(s) };
    let s2 = s.to_str().unwrap();
    let s3: String = s2.chars().rev().collect();
    let s4 = CString::new(s3).unwrap();
    s4.into_ptr()
}

#[no_mangle]
pub extern fn cleanup(s: *const libc::c_char) {
    unsafe { CString::from_ptr(s) };
}
```

Compiled using `rustc --crate-type dylib str.rs`, I was able to link against it from C (`gcc -L. -l str str.c -o str`):

```c
#include <stdio.h>

extern char *reverse(char *);
extern void cleanup(char *);

int main() {
  char *s = reverse("Hello, world!");
  printf("%s\n", s);
  cleanup(s);
}
```

As well as dynamically link via Ruby:

```ruby
require 'fiddle'
require 'fiddle/import'

module LibSum
  extend Fiddle::Importer

  dlload './libstr.dylib'
  extern 'char* reverse(char *)'
  extern 'void cleanup(char *)'
end

s = LibSum.reverse("hello, world!")
puts s
LibSum.cleanup(s)
```

9 years agoAuto merge of #24689 - SimonSapin:formatter-write-char, r=alexcrichton
bors [Wed, 10 Jun 2015 21:02:08 +0000 (21:02 +0000)]
Auto merge of #24689 - SimonSapin:formatter-write-char, r=alexcrichton

This is the logical next step after #24661, but I’m less sure about this one.

r? @alexcrichton

9 years agoHave std::fmt::Formatter implement std::fmt::Write.
Simon Sapin [Wed, 10 Jun 2015 19:41:34 +0000 (21:41 +0200)]
Have std::fmt::Formatter implement std::fmt::Write.

9 years agoAuto merge of #26182 - Manishearth:rollup, r=Manishearth
bors [Wed, 10 Jun 2015 18:41:42 +0000 (18:41 +0000)]
Auto merge of #26182 - Manishearth:rollup, r=Manishearth

- Successful merges: #26142, #26143, #26145, #26146, #26164, #26174
- Failed merges:

9 years agoAdd a write_char method to std::fmt::Formatter.
Simon Sapin [Wed, 22 Apr 2015 12:18:02 +0000 (14:18 +0200)]
Add a write_char method to std::fmt::Formatter.

This is the logical next step after #24661, but I’m less sure about this one.

9 years agoRollup merge of #26174 - mcast:trpl-assignment-empty-tuple, r=steveklabnik
Manish Goregaokar [Wed, 10 Jun 2015 16:37:10 +0000 (22:07 +0530)]
Rollup merge of #26174 - mcast:trpl-assignment-empty-tuple, r=steveklabnik

Doc patch for #26120.  Extra words here, because "value" is repeated.

I haven't read about whether/how it should go to stable (sorry), but I think it would help newcomers.

Thanks,

9 years agoRollup merge of #26164 - tafia:early-dedup, r=Gankro
Manish Goregaokar [Wed, 10 Jun 2015 16:37:10 +0000 (22:07 +0530)]
Rollup merge of #26164 - tafia:early-dedup, r=Gankro

No need to dedup if there is only 1 element in the vec, can early return

9 years agoRollup merge of #26146 - steveklabnik:remove_unsafe_pointer, r=Gankro
Manish Goregaokar [Wed, 10 Jun 2015 16:37:10 +0000 (22:07 +0530)]
Rollup merge of #26146 - steveklabnik:remove_unsafe_pointer, r=Gankro

Using two terms for one thing is confusing, these are called 'raw pointers' today.

9 years agoRollup merge of #26145 - steveklabnik:gh25853, r=brson
Manish Goregaokar [Wed, 10 Jun 2015 16:37:10 +0000 (22:07 +0530)]
Rollup merge of #26145 - steveklabnik:gh25853, r=brson

Fixes #25853

9 years agoRollup merge of #26143 - steveklabnik:gh25851, r=alexcrichton
Manish Goregaokar [Wed, 10 Jun 2015 16:37:09 +0000 (22:07 +0530)]
Rollup merge of #26143 - steveklabnik:gh25851, r=alexcrichton

Still some references left to this old term, I've updated them to say boxes.

Related to #25851

9 years agoRollup merge of #26142 - steveklabnik:gh25850, r=Gankro
Manish Goregaokar [Wed, 10 Jun 2015 16:37:09 +0000 (22:07 +0530)]
Rollup merge of #26142 - steveklabnik:gh25850, r=Gankro

Fixes #25850

9 years agomend bad Markdown
Matthew Astley [Wed, 10 Jun 2015 15:15:24 +0000 (16:15 +0100)]
mend bad Markdown

9 years agoAuto merge of #26141 - eddyb:ast_map, r=nikomatsakis
bors [Wed, 10 Jun 2015 11:38:04 +0000 (11:38 +0000)]
Auto merge of #26141 - eddyb:ast_map, r=nikomatsakis

Gets libsyntax one step closer to running on stable (see #24518).
Closes #24757, erickt's previous attempt at this.

9 years agoAuto merge of #26153 - dotdash:issue26127, r=luqmana
bors [Wed, 10 Jun 2015 10:05:39 +0000 (10:05 +0000)]
Auto merge of #26153 - dotdash:issue26127, r=luqmana

Fixes #26127

9 years agotrpl: why (assignment == empty tuple) #26120
Matthew Astley [Wed, 10 Jun 2015 09:59:36 +0000 (10:59 +0100)]
trpl: why (assignment == empty tuple) #26120

9 years agoAuto merge of #26137 - steveklabnik:gh25623, r=alexcrichton
bors [Wed, 10 Jun 2015 06:59:31 +0000 (06:59 +0000)]
Auto merge of #26137 - steveklabnik:gh25623, r=alexcrichton

Fixes #25623

I am bad with BNF, so I may have messed this up, but that's what review is for!

9 years agoAuto merge of #26130 - steveklabnik:gh25986, r=alexcrichton
bors [Wed, 10 Jun 2015 05:28:03 +0000 (05:28 +0000)]
Auto merge of #26130 - steveklabnik:gh25986, r=alexcrichton

This can be confusing when whitespace is the separator

Fixes #25986

9 years agoAuto merge of #26058 - Kimundi:issue15609, r=nikomatsakis
bors [Wed, 10 Jun 2015 03:15:16 +0000 (03:15 +0000)]
Auto merge of #26058 - Kimundi:issue15609, r=nikomatsakis

Closes #15609

9 years agoearly return if 1 element
Johann Tuffe [Wed, 10 Jun 2015 02:51:48 +0000 (10:51 +0800)]
early return if 1 element

No need to dedup if there is only 1 element in the vec, can early return

9 years agoAuto merge of #26055 - arielb1:smart-fold, r=nikomatsakis
bors [Wed, 10 Jun 2015 01:44:59 +0000 (01:44 +0000)]
Auto merge of #26055 - arielb1:smart-fold, r=nikomatsakis

Before:
581.72user 4.75system 7:42.74elapsed 126%CPU (0avgtext+0avgdata 1176224maxresident)k
llvm took 359.183

After:
550.63user 5.09system 7:20.28elapsed 126%CPU (0avgtext+0avgdata 1165516maxresident)k
llvm took 354.801

9 years agosyntax: move ast_map to librustc.
Eduard Burtescu [Tue, 9 Jun 2015 23:40:45 +0000 (02:40 +0300)]
syntax: move ast_map to librustc.

9 years agoAuto merge of #25836 - steveklabnik:gh25305, r=alexcrichton
bors [Tue, 9 Jun 2015 23:11:25 +0000 (23:11 +0000)]
Auto merge of #25836 - steveklabnik:gh25305, r=alexcrichton

Fixes #25794

9 years agoUse the correct type of undef value for ignored return values in trans_named_tuple_co...
Björn Steinbrink [Tue, 9 Jun 2015 22:07:47 +0000 (00:07 +0200)]
Use the correct type of undef value for ignored return values in trans_named_tuple_constructor

Fixes #26127

9 years agoAuto merge of #26150 - steveklabnik:rollup, r=steveklabnik
bors [Tue, 9 Jun 2015 21:36:03 +0000 (21:36 +0000)]
Auto merge of #26150 - steveklabnik:rollup, r=steveklabnik

- Successful merges: #26111, #26125, #26129, #26131, #26132, #26133, #26134, #26136, #26140, #26144
- Failed merges:

9 years agoRollup merge of #26144 - steveklabnik:static_doc_fix, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:45 +0000 (17:24 -0400)]
Rollup merge of #26144 - steveklabnik:static_doc_fix, r=alexcrichton

Fixes #25851

I am 99% sure this is true for all `static`s and not just `static mut`, yes?

9 years agoRollup merge of #26140 - steveklabnik:gh25803, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:45 +0000 (17:24 -0400)]
Rollup merge of #26140 - steveklabnik:gh25803, r=alexcrichton

As this example got changed, we stopped showing how to return self as
the first example, so this text is outdated.

Fixes #25803

9 years agoRollup merge of #26136 - steveklabnik:gh25597, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:44 +0000 (17:24 -0400)]
Rollup merge of #26136 - steveklabnik:gh25597, r=alexcrichton

Fixes #25597

9 years agoRollup merge of #26134 - steveklabnik:gh25586, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:44 +0000 (17:24 -0400)]
Rollup merge of #26134 - steveklabnik:gh25586, r=alexcrichton

After talking with @graydon on #rust-internals, this is hopefully clarifying.

Fixes #25586

@mkpankov, what do you think?

9 years agoRollup merge of #26133 - steveklabnik:gh25573, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:44 +0000 (17:24 -0400)]
Rollup merge of #26133 - steveklabnik:gh25573, r=alexcrichton

This obscures more than it helps.

Fixes #25573

9 years agoRollup merge of #26132 - astraw:fix-demangle-comment, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:44 +0000 (17:24 -0400)]
Rollup merge of #26132 - astraw:fix-demangle-comment, r=alexcrichton

Hi, I think the second example fails rule 3 described immediately above. This PR fixes that.

9 years agoRollup merge of #26131 - astraw:fix-trait-comment, r=alexcrichton
Steve Klabnik [Tue, 9 Jun 2015 21:24:43 +0000 (17:24 -0400)]
Rollup merge of #26131 - astraw:fix-trait-comment, r=alexcrichton

Hi, I think the comments are wrong in the example and this PR offers my suggested fix.

9 years agoRollup merge of #26129 - steveklabnik:gh26012, r=brson
Steve Klabnik [Tue, 9 Jun 2015 21:24:43 +0000 (17:24 -0400)]
Rollup merge of #26129 - steveklabnik:gh26012, r=brson

Fixes #26012

9 years agoRollup merge of #26125 - nsimplex:master, r=steveklabnik
Steve Klabnik [Tue, 9 Jun 2015 21:24:43 +0000 (17:24 -0400)]
Rollup merge of #26125 - nsimplex:master, r=steveklabnik

The text claimed 'any borrow must last for a _smaller_ scope than the
owner', however the accurate way of describing the comparison is
inclusive (i.e., 'less than or equal to' vs. 'less than').

9 years agoRollup merge of #26111 - tshepang:consistency, r=brson
Steve Klabnik [Tue, 9 Jun 2015 21:24:42 +0000 (17:24 -0400)]
Rollup merge of #26111 - tshepang:consistency, r=brson

9 years agoExise 'unsafe pointer' in favor of 'raw pointer'
Steve Klabnik [Tue, 9 Jun 2015 20:49:24 +0000 (16:49 -0400)]
Exise 'unsafe pointer' in favor of 'raw pointer'

Using two terms for one thing is confusing, these are called 'raw pointers' today.

9 years agomake note of slicing syntax in TRPL: strings
Steve Klabnik [Tue, 9 Jun 2015 20:37:47 +0000 (16:37 -0400)]
make note of slicing syntax in TRPL: strings

Fixes #25853

9 years agoMake note about static and dtors
Steve Klabnik [Tue, 9 Jun 2015 20:30:39 +0000 (16:30 -0400)]
Make note about static and dtors

Fixes #25851

9 years agoExise 'owned pointer' from the codebase
Steve Klabnik [Tue, 9 Jun 2015 20:26:21 +0000 (16:26 -0400)]
Exise 'owned pointer' from the codebase

Still some references left to this old term, I've updated them to say boxes.

Related to #25851

9 years agoMention that enum constructors are functions
Steve Klabnik [Tue, 9 Jun 2015 20:12:43 +0000 (16:12 -0400)]
Mention that enum constructors are functions

Fixes #25850

9 years agoAuto merge of #26039 - SimonSapin:case-mapping, r=alexcrichton
bors [Tue, 9 Jun 2015 20:00:32 +0000 (20:00 +0000)]
Auto merge of #26039 - SimonSapin:case-mapping, r=alexcrichton

* Add “complex” mappings to `char::to_lowercase` and `char::to_uppercase`, making them yield sometimes more than on `char`: #25800. `str::to_lowercase` and `str::to_uppercase` are affected as well.
* Add `char::to_titlecase`, since it’s the same algorithm (just different data). However this does **not** add `str::to_titlecase`, as that would require UAX#29 Unicode Text Segmentation which we decided not to include in of `std`: https://github.com/rust-lang/rfcs/pull/1054 I made `char::to_titlecase` immediately `#[stable]`, since it’s so similar to `char::to_uppercase` that’s already stable. Let me know if it should be `#[unstable]` for a while.
* Add a special case for upper-case Sigma in word-final position in `str::to_lowercase`: #26035. This is the only language-independent conditional mapping currently in `SpecialCasing.txt`.
* Stabilize `str::to_lowercase` and `str::to_uppercase`. The `&self -> String` on `str` signature seems straightforward enough, and the only relevant issue I’ve found is #24536 about naming. But `char` already has stable methods with the same name, and deprecating them for a rename doesn’t seem worth it.

r? @alexcrichton

9 years agoFix some copyediting in TRPL: method-syntax
Steve Klabnik [Tue, 9 Jun 2015 19:49:54 +0000 (15:49 -0400)]
Fix some copyediting in TRPL: method-syntax

As this example got changed, we stopped showing how to return self as
the first example, so this text is outdated.

Fixes #25803

9 years agoRemove numbers all together from not_found.html
Steve Klabnik [Tue, 9 Jun 2015 19:47:48 +0000 (15:47 -0400)]
Remove numbers all together from not_found.html

9 years agoExplain interaction with if and | in patterns
Steve Klabnik [Tue, 9 Jun 2015 18:32:10 +0000 (14:32 -0400)]
Explain interaction with if and | in patterns

Fixes #26012

9 years agoFix up macro grammar
Steve Klabnik [Tue, 9 Jun 2015 19:26:51 +0000 (15:26 -0400)]
Fix up macro grammar

Fixes #25623

9 years agoExpand a bit on clone() in Dining Philosophers
Steve Klabnik [Tue, 9 Jun 2015 19:24:44 +0000 (15:24 -0400)]
Expand a bit on clone() in Dining Philosophers

Fixes #25597

9 years agoClarify confusing sentence in TRPL: FFI
Steve Klabnik [Tue, 9 Jun 2015 19:17:25 +0000 (15:17 -0400)]
Clarify confusing sentence in TRPL: FFI

After talking with @graydon on #rust-internals, this is hopefully clarifying.

Fixes #25586

9 years agoremove stuff about #define
Steve Klabnik [Tue, 9 Jun 2015 18:59:25 +0000 (14:59 -0400)]
remove stuff about #define

This obscures more than it helps.

Fixes #25573

9 years agofix comments in example about types
Andrew Straw [Tue, 9 Jun 2015 18:49:52 +0000 (20:49 +0200)]
fix comments in example about types

9 years agofix example in comments about demangling
Andrew Straw [Tue, 9 Jun 2015 18:47:51 +0000 (20:47 +0200)]
fix example in comments about demangling

9 years agoDocument str::split behavior with contiguous separators
Steve Klabnik [Tue, 9 Jun 2015 18:42:55 +0000 (14:42 -0400)]
Document str::split behavior with contiguous separators

This can be confusing when whitespace is the separator

Fixes #25986

9 years agoAuto merge of #25995 - alexcrichton:msvc-md, r=brson
bors [Tue, 9 Jun 2015 18:26:26 +0000 (18:26 +0000)]
Auto merge of #25995 - alexcrichton:msvc-md, r=brson

On MSVC there are two ways that the CRT can be linked, either statically or
dynamically. Each object file produced by the compiler is compiled against
msvcrt (a dll) or libcmt (a static library). When the linker is dealing with
more than one object file, it requires that all object files link to the same
CRT, or else the linker will spit out some errors.

For now, compile code with `-MD` as it seems to appear more often in C libraries
so we'll stick with the same trend.

9 years agoSemantic accuracy in borrow scope rules.
simplex [Tue, 9 Jun 2015 16:08:16 +0000 (13:08 -0300)]
Semantic accuracy in borrow scope rules.

The text claimed 'any borrow must last for a _smaller_ scope than the
owner', however the accurate way of describing the comparison is
inclusive (i.e., 'less than or equal to' vs. 'less than').

9 years agoMade ref pattern bindings correctly pick Deref or DerefMut
Marvin Löbel [Sat, 6 Jun 2015 18:10:23 +0000 (20:10 +0200)]
Made ref pattern bindings correctly pick Deref or DerefMut

Added LvaluePreference::from_mutbl

Closes #15609

9 years agoMove collectionstest::char into coretest::char
Simon Sapin [Tue, 9 Jun 2015 09:38:11 +0000 (11:38 +0200)]
Move collectionstest::char into coretest::char

9 years agoFix coretest::char::test_to_uppercase for complex mapping
Simon Sapin [Tue, 9 Jun 2015 09:37:08 +0000 (11:37 +0200)]
Fix coretest::char::test_to_uppercase for complex mapping

9 years agoAuto merge of #26102 - retep998:openoptionsext, r=alexcrichton
bors [Tue, 9 Jun 2015 10:55:04 +0000 (10:55 +0000)]
Auto merge of #26102 - retep998:openoptionsext, r=alexcrichton

r? @alexcrichton

9 years agoAuto merge of #26068 - bluss:bench-sigfigs, r=huonw
bors [Tue, 9 Jun 2015 09:12:09 +0000 (09:12 +0000)]
Auto merge of #26068 - bluss:bench-sigfigs, r=huonw

test: Display benchmark results with thousands separators

Example display:

```
running 9 tests
test a ... bench:           0 ns/iter (+/- 0)
test b ... bench:          52 ns/iter (+/- 0)
test c ... bench:          88 ns/iter (+/- 0)
test d ... bench:         618 ns/iter (+/- 111)
test e ... bench:       5,933 ns/iter (+/- 87)
test f ... bench:      59,280 ns/iter (+/- 1,052)
test g ... bench:     588,672 ns/iter (+/- 3,381)
test h ... bench:   5,894,227 ns/iter (+/- 303,489)
test i ... bench:  59,112,382 ns/iter (+/- 1,500,110)
```

Fixes #10953
Fixes #26109

9 years agoAuto merge of #26098 - russellmcc:add-ar-tool-flexible-target-spec, r=alexcrichton
bors [Tue, 9 Jun 2015 06:03:17 +0000 (06:03 +0000)]
Auto merge of #26098 - russellmcc:add-ar-tool-flexible-target-spec, r=alexcrichton

Looks like this was missed from af56e2efde5cd82564e32598889d25d798c02722.

This will help with defining cross-compile workflows for rust.

9 years agoAuto merge of #25627 - murarth:execution-engine-fix, r=nrc
bors [Tue, 9 Jun 2015 04:28:57 +0000 (04:28 +0000)]
Auto merge of #25627 - murarth:execution-engine-fix, r=nrc

* Removes `RustJITMemoryManager` from public API.
  This was really sort of an implementation detail to begin with.
* `__morestack` is linked to C++ wrapper code and this pointer
  is used when resolving the symbol for `ExecutionEngine` code.
* `__morestack_addr` is also resolved for `ExecutionEngine` code.
  This function is sometimes referenced in LLVM-generated code,
  but was not able to be resolved on Mac OS systems.
* Added Windows support to `ExecutionEngine` API.
* Added a test for basic `ExecutionEngine` functionality.

9 years agoAuto merge of #26117 - Manishearth:rollup, r=Manishearth
bors [Tue, 9 Jun 2015 01:34:24 +0000 (01:34 +0000)]
Auto merge of #26117 - Manishearth:rollup, r=Manishearth

- Successful merges: #25898, #25909, #25948, #25968, #26073, #26078, #26099, #26104, #26105, #26112, #26113
- Failed merges:

9 years agotest: Display benchmark results with thousands separators
Ulrik Sverdrup [Sun, 7 Jun 2015 17:23:56 +0000 (19:23 +0200)]
test: Display benchmark results with thousands separators

Example display:

```
running 9 tests
test a ... bench:           0 ns/iter (+/- 0)
test b ... bench:          52 ns/iter (+/- 0)
test c ... bench:          88 ns/iter (+/- 0)
test d ... bench:         618 ns/iter (+/- 111)
test e ... bench:       5,933 ns/iter (+/- 87)
test f ... bench:      59,280 ns/iter (+/- 1,052)
test g ... bench:     588,672 ns/iter (+/- 3,381)
test h ... bench:   5,894,227 ns/iter (+/- 303,489)
test i ... bench:  59,112,382 ns/iter (+/- 1,500,110)
```

Fixes #10953
Fixes #26109

9 years agoRollup merge of #26113 - tshepang:avoid-abbreviations, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:29 +0000 (05:42 +0530)]
Rollup merge of #26113 - tshepang:avoid-abbreviations, r=steveklabnik

9 years agoRollup merge of #26112 - tshepang:readability, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:28 +0000 (05:42 +0530)]
Rollup merge of #26112 - tshepang:readability, r=steveklabnik

9 years agoRollup merge of #26105 - tshepang:sentence-not-clear, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:28 +0000 (05:42 +0530)]
Rollup merge of #26105 - tshepang:sentence-not-clear, r=steveklabnik

9 years agoRollup merge of #26104 - saml:patch-1, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:28 +0000 (05:42 +0530)]
Rollup merge of #26104 - saml:patch-1, r=steveklabnik

Cargo expects `lib` to be table, not an array of tables (only single lib per project).

9 years agoRollup merge of #26099 - TheNeikos:fix-old_array_syntax_in_comments, r=alexcrichton
Manish Goregaokar [Tue, 9 Jun 2015 00:12:28 +0000 (05:42 +0530)]
Rollup merge of #26099 - TheNeikos:fix-old_array_syntax_in_comments, r=alexcrichton

As per RFC#520 the syntax for arrays has changed,
this changes the remaining comments to reflect
the new syntax.

I checked for existing occurences of this with the following command:

`ag "\[., \.\..\]"` which by now should only return a single occurence.

9 years agoRollup merge of #26078 - diwic:patch-2, r=alexcrichton
Manish Goregaokar [Tue, 9 Jun 2015 00:12:27 +0000 (05:42 +0530)]
Rollup merge of #26078 - diwic:patch-2, r=alexcrichton

It was determined that no leaks were unsafe, make the language reference clear about this.

9 years agoRollup merge of #26073 - chuckSMASH:trpl-5-4-comments, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:27 +0000 (05:42 +0530)]
Rollup merge of #26073 - chuckSMASH:trpl-5-4-comments, r=steveklabnik

For a user following the path of reading Chapter 5: Syntax & Symantics
prior to Chapter 4: Learn Rust, this will be the first time they have
encountered executable tests inside documentation comments.

The test will fail because the `add_one` function is not defined in
the context of the doctest. This might not be the optimal place to
introduce and explain the `/// #` notation but I think it is important
that this snippet pass as a test when `rustdoc --test` is run against
it.

9 years agoRollup merge of #25968 - benfleis:master, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:27 +0000 (05:42 +0530)]
Rollup merge of #25968 - benfleis:master, r=steveklabnik

to address https://github.com/rust-lang/rust/issues/25488 .

9 years agoRollup merge of #25948 - tshepang:misc-doc-improvements, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:27 +0000 (05:42 +0530)]
Rollup merge of #25948 - tshepang:misc-doc-improvements, r=steveklabnik

9 years agoRollup merge of #25909 - frankamp:patch-1, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:26 +0000 (05:42 +0530)]
Rollup merge of #25909 - frankamp:patch-1, r=steveklabnik

The doc indicates that you can replace 'before' with 'after' showing the use of try!. The two examples should be equivalent, but they are not.

In the File::create we were inducing a panic before in case of error, not propagating. It is important for newbies (like myself) to understand that try! propagates failures, while unwrap can induce a panic.

The other alternative is to make the 'before' File::create also manually handle Err like the other calls. Either way it would be consistent.

9 years agoRollup merge of #25898 - azerupi:patch-3, r=steveklabnik
Manish Goregaokar [Tue, 9 Jun 2015 00:12:26 +0000 (05:42 +0530)]
Rollup merge of #25898 - azerupi:patch-3, r=steveklabnik

As mentioned in #25893 the copy trait is not very well explained for beginners. There is no clear mention that all primitive types implement the copy trait and there are not a lot of examples.

With this change I try to make it more visible and understandable for new users.

I myself have struggled with this, see [my question on stackoverflow](http://stackoverflow.com/questions/30540419/why-are-booleans-copyable-even-though-the-documentation-doesnt-indicate-that). And I want to make it more transparent for others.

I filed issue #25893 but I thought that I could give it a shot myself to relieve some of the work from the devs :)

If it is not well written or there are some changes to be made before it can be merged, let me know.

Cheers,
Mathieu

9 years agoAuto merge of #26065 - Marwes:master, r=alexcrichton
bors [Tue, 9 Jun 2015 00:00:35 +0000 (00:00 +0000)]
Auto merge of #26065 - Marwes:master, r=alexcrichton

PR for #26052 with the new order as written below.

```
//Querying
fn len(&self) -> usize
fn is_empty(&self) -> bool
fn width(&self, is_cjk: bool) -> usize
fn is_char_boundary(&self, index: usize) -> bool

//Slicing and char retrieval
fn as_bytes(&self) -> &[u8]
fn as_ptr(&self) -> *const u8
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str
fn slice_chars(&self, begin: usize, end: usize) -> &str
fn char_range_at(&self, start: usize) -> CharRange
fn char_range_at_reverse(&self, start: usize) -> CharRange
fn char_at(&self, i: usize) -> char
fn char_at_reverse(&self, i: usize) -> char
fn slice_shift_char(&self) -> Option<(char, &str)>

//Iterators
fn chars(&self) -> Chars
fn char_indices(&self) -> CharIndices
fn bytes(&self) -> Bytes
fn split_whitespace(&self) -> SplitWhitespace
fn words(&self) -> Words
fn lines(&self) -> Lines
fn lines_any(&self) -> LinesAny
fn nfd_chars(&self) -> Decompositions
fn nfkd_chars(&self) -> Decompositions
fn nfc_chars(&self) -> Recompositions
fn nfkc_chars(&self) -> Recompositions
fn graphemes(&self, is_extended: bool) -> Graphemes
fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices
fn utf16_units(&self) -> Utf16Units

//Searching
fn contains<'a, P>(&'a self, pat: P) -> bool where P: Pattern<'a>
fn starts_with<'a, P>(&'a self, pat: P) -> bool where P: Pattern<'a>
fn ends_with<'a, P>(&'a self, pat: P) -> bool where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn find<'a, P>(&'a self, pat: P) -> Option<usize> where P: Pattern<'a>
fn rfind<'a, P>(&'a self, pat: P) -> Option<usize> where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn split<'a, P>(&'a self, pat: P) -> Split<'a, P> where P: Pattern<'a>
fn rsplit<'a, P>(&'a self, pat: P) -> RSplit<'a, P> where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn split_terminator<'a, P>(&'a self, pat: P) -> SplitTerminator<'a, P> where P: Pattern<'a>
fn rsplit_terminator<'a, P>(&'a self, pat: P) -> RSplitTerminator<'a, P> where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn splitn<'a, P>(&'a self, count: usize, pat: P) -> SplitN<'a, P> where P: Pattern<'a>
fn rsplitn<'a, P>(&'a self, count: usize, pat: P) -> RSplitN<'a, P> where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn matches<'a, P>(&'a self, pat: P) -> Matches<'a, P> where P: Pattern<'a>
fn rmatches<'a, P>(&'a self, pat: P) -> RMatches<'a, P> where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn match_indices<'a, P>(&'a self, pat: P) -> MatchIndices<'a, P> where P: Pattern<'a>
fn rmatch_indices<'a, P>(&'a self, pat: P) -> RMatchIndices<'a, P> where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>
fn subslice_offset(&self, inner: &str) -> usize

//Trim
fn trim(&self) -> &str
fn trim_left(&self) -> &str
fn trim_right(&self) -> &str
fn trim_matches<'a, P>(&'a self, pat: P) -> &'a str where P: Pattern<'a>, P::Searcher: DoubleEndedSearcher<'a>
fn trim_left_matches<'a, P>(&'a self, pat: P) -> &'a str where P: Pattern<'a>
fn trim_right_matches<'a, P>(&'a self, pat: P) -> &'a str where P: Pattern<'a>, P::Searcher: ReverseSearcher<'a>

//Conversion
fn parse<F>(&self) -> Result<F, F::Err> where F: FromStr
fn replace(&self, from: &str, to: &str) -> String
fn to_lowercase(&self) -> String
fn to_uppercase(&self) -> String
fn escape_default(&self) -> String
fn escape_unicode(&self) -> String
```

9 years agoChanges to LLVM `ExecutionEngine` wrapper
Murarth [Tue, 19 May 2015 23:00:59 +0000 (16:00 -0700)]
Changes to LLVM `ExecutionEngine` wrapper

* Removes `RustJITMemoryManager` from public API.
  This was really sort of an implementation detail to begin with.
* `__morestack` is linked to C++ wrapper code and this pointer
  is used when resolving the symbol for `ExecutionEngine` code.
* `__morestack_addr` is also resolved for `ExecutionEngine` code.
  This function is sometimes referenced in LLVM-generated code,
  but was not able to be resolved on Mac OS systems.
* Added Windows support to `ExecutionEngine` API.
* Added a test for basic `ExecutionEngine` functionality.

9 years agoAuto merge of #26079 - eefriedman:emit-closure, r=nrc
bors [Mon, 8 Jun 2015 22:26:16 +0000 (22:26 +0000)]
Auto merge of #26079 - eefriedman:emit-closure, r=nrc

This isn't a very clean fix, but I'm not sure what a better fix would look
like.

Fixes #24779.

9 years agoreference: that looks better without those abbreviations
Tshepang Lekhonkhobe [Mon, 8 Jun 2015 22:20:51 +0000 (00:20 +0200)]
reference: that looks better without those abbreviations

9 years agoreference: improve readability
Tshepang Lekhonkhobe [Mon, 8 Jun 2015 22:16:23 +0000 (00:16 +0200)]
reference: improve readability

9 years agoreference: get consistent by removing unneeded whitespace
Tshepang Lekhonkhobe [Mon, 8 Jun 2015 22:00:20 +0000 (00:00 +0200)]
reference: get consistent by removing unneeded whitespace

9 years agobook: remove a sentence that is not clear
Tshepang Lekhonkhobe [Mon, 8 Jun 2015 19:58:48 +0000 (21:58 +0200)]
book: remove a sentence that is not clear

9 years agoAuto merge of #26077 - SimonSapin:patch-6, r=alexcrichton
bors [Mon, 8 Jun 2015 20:52:33 +0000 (20:52 +0000)]
Auto merge of #26077 - SimonSapin:patch-6, r=alexcrichton

With the latter is provided by the `From` conversion trait, the former is now completely redundant. Their code is identical. Let’s deprecate now and plan to remove in the next cycle. (It’s `#[unstable]`.)

r? @alexcrichton
CC @nagisa

9 years agoReordered the methods on str to improve doc sorting
Markus Westerlind [Mon, 8 Jun 2015 20:18:13 +0000 (22:18 +0200)]
Reordered the methods on str to improve doc sorting

9 years agoFixing typo, [[lib]] to [lib]
saml [Mon, 8 Jun 2015 19:42:33 +0000 (15:42 -0400)]
Fixing typo, [[lib]] to [lib]

Cargo expects `lib` to be table, not an array of tables (only single lib per project).

9 years agoAuto merge of #26060 - funkill:fix_rustbook, r=alexcrichton
bors [Mon, 8 Jun 2015 19:18:31 +0000 (19:18 +0000)]
Auto merge of #26060 - funkill:fix_rustbook, r=alexcrichton

Case:
Russian translate of trpl use this structure:
```bash
rust_book_ru $ tree
.
├── README.md
├── src
│   ├── academic-research.md
...
└── SUMMARY.md
```
Links in table of content generated relative to the root dir, for example if i'm on the page `http://kgv.github.io/rust_book_ru/src/academic-research.html` link to README.html will be `http://kgv.github.io/rust_book_ru/src/README.html`, not `http://kgv.github.io/rust_book_ru/README.html`.
Now we use old version of rustbook.
Sorry for my english

9 years agoOpenOptionsExt on Windows: i32 -> u32
Peter Atashian [Mon, 8 Jun 2015 18:04:22 +0000 (14:04 -0400)]
OpenOptionsExt on Windows: i32 -> u32
Since all those flags are u32 anyway, avoid unnecessary conversions
[breaking change]

Signed-off-by: Peter Atashian <retep998@gmail.com>
9 years agoAddress a review comment and fix a bootstrapping issue
Simon Sapin [Mon, 8 Jun 2015 17:43:04 +0000 (19:43 +0200)]
Address a review comment and fix a bootstrapping issue

9 years agoAuto merge of #26044 - nagisa:canonicalize-metadata-loader, r=alexcrichton
bors [Mon, 8 Jun 2015 17:44:30 +0000 (17:44 +0000)]
Auto merge of #26044 - nagisa:canonicalize-metadata-loader, r=alexcrichton

This might fail when --extern library is a symlink to an invalid location. Instead just pretend it
doesn’t exist at all.

Fixes #26006

9 years agoTranslate "ignored" closure expressions.
Eli Friedman [Sun, 7 Jun 2015 21:32:37 +0000 (14:32 -0700)]
Translate "ignored" closure expressions.

This isn't a very clean fix, but I'm not sure what a better fix would look
like.

Fixes #24779.

9 years agoAuto merge of #25989 - jooert:implement_rfc839, r=Gankro
bors [Mon, 8 Jun 2015 16:09:56 +0000 (16:09 +0000)]
Auto merge of #25989 - jooert:implement_rfc839, r=Gankro

I had to use `impl<'a, V: Copy> Extend<(usize, &'a V)> for VecMap<V>` instead of `impl<'a, V: Copy> Extend<(&'a usize, &'a V)> for VecMap<V>` as that's what is needed for doing

```rust
let mut a = VecMap::new();
let b = VecMap::new();
b.insert(1, "foo");

a.extend(&b)
```

I can squash the commits after review.

r? @Gankro

9 years agoUpdated with requested changes
Mathieu David [Mon, 8 Jun 2015 16:01:40 +0000 (18:01 +0200)]
Updated with requested changes

9 years agoFixed old occurences of the removed array syntax
Marcel Müller [Mon, 8 Jun 2015 15:58:08 +0000 (17:58 +0200)]
Fixed old occurences of the removed array syntax

As per RFC#520 the syntax for arrays has changed,
this changes the remaining comments to reflect
the new syntax.

9 years agoReplace usage of String::from_str with String:from
Simon Sapin [Mon, 8 Jun 2015 14:55:35 +0000 (16:55 +0200)]
Replace usage of String::from_str with String:from

9 years agoAuto merge of #26091 - chellmuth:pub-struct-field-span, r=nrc
bors [Mon, 8 Jun 2015 14:35:27 +0000 (14:35 +0000)]
Auto merge of #26091 - chellmuth:pub-struct-field-span, r=nrc

Issue: #26083

Re-submitting https://github.com/rust-lang/rust/pull/26084

r? @nrc

9 years agoAdd ability to change `ar` tool from target specification json
Russell McClellan [Mon, 8 Jun 2015 13:01:32 +0000 (09:01 -0400)]
Add ability to change `ar` tool from target specification json

9 years agoAuto merge of #26088 - tamird:llvm35-fixes, r=alexcrichton
bors [Mon, 8 Jun 2015 11:55:04 +0000 (11:55 +0000)]
Auto merge of #26088 - tamird:llvm35-fixes, r=alexcrichton

rebase of #25739, closes #25739. r? @alexcrichton

9 years agoImplement RFC 839
Johannes Oertel [Wed, 3 Jun 2015 10:38:42 +0000 (12:38 +0200)]
Implement RFC 839

Closes #25976.

9 years agoAuto merge of #26029 - GuillaumeGomez:const_check, r=Manishearth
bors [Mon, 8 Jun 2015 09:54:32 +0000 (09:54 +0000)]
Auto merge of #26029 - GuillaumeGomez:const_check, r=Manishearth

Part of #24407.

9 years agoSkip useless recursion in freshening and late-bound-region substitutio
Ariel Ben-Yehuda [Fri, 5 Jun 2015 23:06:14 +0000 (02:06 +0300)]
Skip useless recursion in freshening and late-bound-region substitutio

Before:
581.72user 4.75system 7:42.74elapsed 126%CPU (0avgtext+0avgdata 1176224maxresident)k
llvm took 359.183

After:
550.63user 5.09system 7:20.28elapsed 126%CPU (0avgtext+0avgdata 1165516maxresident)k
llvm took 354.801

9 years agoAdd error explanation for E0014
Guillaume Gomez [Fri, 5 Jun 2015 10:40:18 +0000 (12:40 +0200)]
Add error explanation for E0014

9 years agoAuto merge of #25823 - oli-obk:static_to_const_lint, r=alexcrichton
bors [Mon, 8 Jun 2015 04:54:59 +0000 (04:54 +0000)]
Auto merge of #25823 - oli-obk:static_to_const_lint, r=alexcrichton

r? @eddyb