Commit Graph

43467 Commits

Author SHA1 Message Date
bors
4cc87c8acb Auto merge of #26245 - mbrubeck:extern, r=steveklabnik
r? @steveklabnik
2015-06-12 15:15:11 +00:00
Matt Brubeck
334ce91443 [reference] Fix typo in extern fn section 2015-06-12 08:08:48 -07:00
bors
a2f2a64763 Auto merge of #26238 - Manishearth:rollup, r=Manishearth
- Successful merges: #24495, #26229, #26231
- Failed merges:
2015-06-12 06:25:49 +00:00
Manish Goregaokar
a9ea380523 Rollup merge of #26231 - reem:patch-2, r=Gankro
r? @steveklabnik
2015-06-12 11:55:37 +05:30
Manish Goregaokar
8f841b24ca Rollup merge of #26229 - Stebalien:versionless-book, r=steveklabnik
They're forever doomed to be out-of-date. Also, don't assume the user is
installing a particular version.

r? @steveklabnik
2015-06-12 11:55:37 +05:30
Manish Goregaokar
18f70e3498 Rollup merge of #24495 - nathanl:nathanl-explain-bin-flag, r=steveklabnik
Explain the --bin flag in terms of the difference
between shipping binary and library code

I'm not sure if my explanation is even quite correct, but as a newbie coming from Ruby, this is my best guess. (In Rubyland, libraries always ship with the source code because there's no other form you can ship. :) )
2015-06-12 11:55:37 +05:30
bors
69db64f304 Auto merge of #26224 - mcast:doc-travis2buildbot, r=steveklabnik
Suggesting this because I was confused by what is now visible from the Travis CI / buildbot split.

Found the hint  in bors comments on d911936d
Couldn't find anything on https://internals.rust-lang.org/
2015-06-12 04:38:02 +00:00
bors
0da58cc361 Auto merge of #26226 - alexcrichton:fix-msvc-dist, r=brson
Right now the distribution tarball for MSVC only includes the *.dll files for
the supporting libraries, but not the corresponding *.lib files which allow
actually linking to the dll. This means that the current MSVC nightlies cannot
produce dynamically linked binaries as the *.lib files are not available to link
against.

This commit modifies the `LIB_GLOB` used to copy the files around to include the
`lib` variant of the `dll`.
2015-06-12 01:36:55 +00:00
bors
7648776503 Auto merge of #26225 - arielb1:raw-self, r=eddyb
This can't be made to work with the current setup.

Technically a [breaking-change], but a simple bug fix.

Fixes #26194.
2015-06-12 00:00:27 +00:00
Jonathan Reem
3c6dcea985 Add Terminal.com to the list of companies using rust in production. 2015-06-11 16:07:34 -07:00
bors
400e955d8b Auto merge of #26199 - swgillespie:issue-26092, r=alexcrichton
`driver::build_output_filenames` calls `file_stem` on a PathBuf obtained from the output file compiler flag. It's possible to pass the empty string to this compiler flag. When file_stem is called on an empty Path, it returns None, which is unwrapped and the compiler panics.

This change modifies the `unwrap` to an `unwrap_or` so that the empty string is passed through the compilation pipeline until it reaches `trans:🔙:write_output_file`, which will emit an appropriate error.

Instead of panicking, the error that is emitted now is:

```
$ rustc -o "" thing.rs
error: could not write output to : No such file or directory
```

The `:` is a little strange, but it /is/ reporting the filename (the empty string) correctly, I suppose. Both gcc and clang hand the output file to ld, which emits a similar error message when faced with the empty string as an output file:

```
$ clang -o "" thing.c
ld: can't open output file for writing: , errno=2 for architecture x86_64
```

This PR also adds a test for this, in `run-make`. This fixes issue #26092.
2015-06-11 21:35:10 +00:00
Steven Allen
e2e292cc00 Don't link to specific versions of rust in the book.
They're forever doomed to be out-of-date. Also, don't assume the user is
installing a particular version.
2015-06-11 17:33:18 -04:00
Alex Crichton
6fee2690cf mk: Tweak the LIB_GLOB for MSVC
Right now the distribution tarball for MSVC only includes the *.dll files for
the supporting libraries, but not the corresponding *.lib files which allow
actually linking to the dll. This means that the current MSVC nightlies cannot
produce dynamically linked binaries as the *.lib files are not available to link
against.

This commit modifies the `LIB_GLOB` used to copy the files around to include the
`lib` variant of the `dll`.
2015-06-11 14:15:36 -07:00
Ariel Ben-Yehuda
3be18f0edc Prevent raw pointers from being used as an explicit self
This can't be made to work with the current setup.

Fixes #26194.
2015-06-11 23:45:27 +03:00
Matthew Astley
512b105b15 point to buildbot
Since 7b6ecc00
2015-06-11 19:57:16 +01:00
bors
b5b3a99f84 Auto merge of #26190 - Veedrac:no-iter, r=alexcrichton
Pull request for #26188.
2015-06-11 18:10:08 +00:00
bors
deff2f50a9 Auto merge of #26212 - Manishearth:rollup, r=Manishearth
- Successful merges: #26181, #26184, #26189, #26191, #26195, #26202
- Failed merges:
2015-06-11 16:33:53 +00:00
bors
c85f307369 Auto merge of #26197 - dhuseby:fixing_morestack_breakage, r=brson
Revision 021e483 broke the BSD builds.  This fixes it for Bitrig and probably the others.
2015-06-11 14:57:13 +00:00
Nathan Long
a47d7a752e Explain the --bin flag more clearly 2015-06-11 09:20:14 -04:00
bors
acfcb15e09 Auto merge of #26184 - aepsil0n:error-desc-funcargs, r=alexcrichton
These errors all relate to type checking, specifically the number of function arguments, and occur in librustc_typeck::check::check_argument_types.

Resolves part of #24407.
2015-06-11 13:17:19 +00:00
Joshua Landau
d7f5fa4636 Conver reborrows to .iter() calls where appropriate 2015-06-11 13:56:07 +01:00
bors
7e9a8e322a Auto merge of #26177 - jooert:fix26169, r=alexcrichton
Closes #26169.

r? @steveklabnik
2015-06-11 11:41:24 +00:00
bors
fc9e424550 Auto merge of #26172 - nham:add_E0116, r=alexcrichton
Also improves the wording of the E0133 description.

cc #24407
2015-06-11 10:06:38 +00:00
bors
f6341a878e Auto merge of #26159 - alexcrichton:tweak-process-lowering-raising, r=brson
* Slate these features to be stable in 1.2 instead of 1.1 (not being backported)
* Have the `FromRawFd` implementations follow the contract of the `FromRawFd`
  trait by taking ownership of the primitive specified.
* Refactor the implementations slightly to remove the `unreachable!` blocks as
  well as separating the stdio representation of `std::process` from
  `std::sys::process`.

cc #25494
2015-06-11 08:22:39 +00:00
Manish Goregaokar
e50675d549 Rollup merge of #26202 - nham:revise_E0072, r=alexcrichton
Converts the size calculation in the explanation from a fenced code block to an indented one. I think it looks better when not rendered, and is the same rendered.
2015-06-11 12:50:54 +05:30
Manish Goregaokar
cf3e79d558 Rollup merge of #26195 - tshepang:patch-1, r=alexcrichton 2015-06-11 12:50:53 +05:30
Manish Goregaokar
95407cc627 Rollup merge of #26191 - jimblandy:master, r=steveklabnik
In the discussion of returning closures, it seems like the example code got simplified, but only the later copies got fixed. The final working code has `factory` returning `|x| x + num`, but the earlier code has `|x| vec.push(x)`.

The first form seemed to have more distracting characteristics, and the code wasn't right anyway, so I changed them to all use the second form, and updated the error messages.

r? @steveklabnik
2015-06-11 12:50:53 +05:30
Manish Goregaokar
ea4949d449 Rollup merge of #26189 - bluss:iter-once-clone, r=Gankro
core: impl Clone for option::IntoIter and iter::Once
2015-06-11 12:50:53 +05:30
Manish Goregaokar
cf685cb8f8 Rollup merge of #26184 - aepsil0n:error-desc-funcargs, r=alexcrichton
These errors all relate to type checking, specifically the number of function arguments, and occur in librustc_typeck::check::check_argument_types.

Resolves part of #24407.
2015-06-11 12:50:53 +05:30
Manish Goregaokar
bdebe94433 Rollup merge of #26181 - Stebalien:fix-26178, r=steveklabnik
The list of in-production users is probably incomplete. It's based on a [post](https://www.reddit.com/r/rust/comments/2x567m/who_is_using_rust_or_what_projects_that_are/cox7eby) by /u/mozilla_kmc

closes #26178
2015-06-11 12:50:52 +05:30
bors
cf0edd0ad9 Auto merge of #26155 - dhuseby:fixing_bitrig_net_tests, r=alexcrichton
… congruent due to rounding errors

@semarie this affected both openbsd and bitrig.  it seems the correct solution is to switch to fixed point arithmetic in the timeout code, the same as freebsd.
2015-06-11 06:46:25 +00:00
bors
37cf025f1c Auto merge of #26154 - pmarcelll:master, r=Gankro
Various methods in both libcore/char.rs and librustc_unicode/char.rs were previously marked with #[inline], now every method is marked in char's impl blocks.
Partially fixes #26124.
EDIT: I'm not familiar with pull reqests (yet), apparently Github added my second commit to thit PR...
Fixes #26124
2015-06-11 05:05:20 +00:00
bors
2fbbd54afe Auto merge of #26122 - bluss:borrow-box, r=alexcrichton
Implement Borrow<T> and BorrowMut<T> for Box<T: ?Sized>
2015-06-11 03:25:45 +00:00
Nick Hamann
a297651607 Revise the E0072 explanation. 2015-06-10 21:36:32 -05:00
swgillespie
91effb374c fix #26092 by returning an empty OS string when the output file path has no file_stem 2015-06-10 18:18:04 -07:00
bors
fbb13543fc Auto merge of #25839 - bluss:str-split-at-impl, r=alexcrichton
Implement RFC rust-lang/rfcs#1123

Add str method str::split_at(mid: usize) -> (&str, &str).

Also a minor cleanup in the collections::str module. Remove redundant slicing of self.
2015-06-11 00:22:27 +00:00
bors
01ab4f761c 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)
```
2015-06-10 22:37:38 +00:00
Tshepang Lekhonkhobe
fa0de66dfe doc: typo fix 2015-06-11 00:19:45 +02:00
bors
db0c1cb13c 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
2015-06-10 21:02:08 +00:00
Jim Blandy
7d298d1ace Fix examples for returning closures. 2015-06-10 13:17:49 -07:00
Joshua Landau
ca7418b846 Removed many pointless calls to *iter() and iter_mut() 2015-06-10 21:14:03 +01:00
Simon Sapin
63da18b269 Have std::fmt::Formatter implement std::fmt::Write. 2015-06-10 22:06:18 +02:00
Ulrik Sverdrup
c00b859c9d core: impl Clone for option::IntoIter and iter::Once 2015-06-10 20:58:09 +02:00
bors
ae8a3c92a7 Auto merge of #26182 - Manishearth:rollup, r=Manishearth
- Successful merges: #26142, #26143, #26145, #26146, #26164, #26174
- Failed merges:
2015-06-10 18:41:42 +00:00
Simon Sapin
15b028c585 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.
2015-06-10 20:34:22 +02:00
Eduard Bopp
4753fad99f Add error explanation for E0057, E0059–E0061
These errors all relate to type checking, specifically the number of function
arguments, and occur in librustc_typeck::check::check_argument_types.
2015-06-10 20:28:51 +02:00
Dave Huseby
5b2edcdd6e fixes __morestack symbol problem on BSDs 2015-06-10 11:24:13 -07:00
Dave Huseby
4a2d4d3eb9 disabling socking timing tests because openbsd/bitrig get/set are not congruent due to rounding errors 2015-06-10 11:23:47 -07:00
Manish Goregaokar
c8519c9793 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,
2015-06-10 22:07:10 +05:30
Manish Goregaokar
bd7a6ec8ec 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
2015-06-10 22:07:10 +05:30