Commit Graph

43541 Commits

Author SHA1 Message Date
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
Manish Goregaokar
7d9427e6cd Rollup merge of #26146 - steveklabnik:remove_unsafe_pointer, r=Gankro
Using two terms for one thing is confusing, these are called 'raw pointers' today.
2015-06-10 22:07:10 +05:30
Manish Goregaokar
ef089ff70d Rollup merge of #26145 - steveklabnik:gh25853, r=brson
Fixes #25853
2015-06-10 22:07:10 +05:30
Manish Goregaokar
32e96aa165 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
2015-06-10 22:07:09 +05:30
Manish Goregaokar
c84aff92b9 Rollup merge of #26142 - steveklabnik:gh25850, r=Gankro
Fixes #25850
2015-06-10 22:07:09 +05:30
Steven Allen
44007f2701 Rust is now post-1.0
closes #26178
2015-06-10 12:25:01 -04:00
Johannes Oertel
5c9f069ece Improve examples for atomic types.
Swap arguments of `assert_eq!` calls, insert additional assertions
here and there.
Closes #26169.
2015-06-10 18:19:16 +02:00
Matthew Astley
aaf1983a56 mend bad Markdown 2015-06-10 16:16:03 +01:00
bors
d8a9570154 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.
2015-06-10 11:38:04 +00:00
bors
8025bc964c Auto merge of #26153 - dotdash:issue26127, r=luqmana
Fixes #26127
2015-06-10 10:05:39 +00:00
Matthew Astley
1ece005838 trpl: why (assignment == empty tuple) #26120 2015-06-10 11:02:31 +01:00
Nick Hamann
aace3675b7 Revise E0133 description.
Tweaks some of the wording so it reads better.
2015-06-10 02:18:53 -05:00
Nick Hamann
c8b088eb38 Add explanation for E0116 and update the error message.
Also updates the reference on this point.
2015-06-10 02:18:14 -05:00
Ulrik Sverdrup
1112a05b8f collections: Remove redundant slicing for str
This is a remnant from a previous implementation of the str methods.
Using `self` is fine now.
2015-06-10 09:15:07 +02:00
Ulrik Sverdrup
d43bf53948 Add str::split_at
Implement RFC rust-lang/rfcs#1123

Add str method str::split_at(mid: usize) -> (&str, &str).
2015-06-10 09:15:07 +02:00
bors
6c5834d81b 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!
2015-06-10 06:59:31 +00:00
bors
e954031ea2 Auto merge of #26130 - steveklabnik:gh25986, r=alexcrichton
This can be confusing when whitespace is the separator

Fixes #25986
2015-06-10 05:28:03 +00:00
bors
172cd83490 Auto merge of #26058 - Kimundi:issue15609, r=nikomatsakis
Closes #15609
2015-06-10 03:15:16 +00:00
Johann Tuffe
cb31373dc2 early return if 1 element
No need to dedup if there is only 1 element in the vec, can early return
2015-06-10 10:51:48 +08:00
bors
5ea3ed0fd0 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
2015-06-10 01:44:59 +00:00
Alex Crichton
56a5ff284a std: Tweak process raising/lowering implementations
* 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`.
2015-06-09 17:48:10 -07:00
Alex Crichton
ec68c4a835 std: Stabilize a number of new fs features
This commit stabilizes the following APIs, slating them all to be cherry-picked
into the 1.1 release.

* fs::FileType (and transitively the derived trait implementations)
* fs::Metadata::file_type
* fs::FileType::is_dir
* fs::FileType::is_file
* fs::FileType::is_symlink
* fs::DirEntry::metadata
* fs::DirEntry::file_type
* fs::DirEntry::file_name
* fs::set_permissions
* fs::symlink_metadata
* os::raw::{self, *}
* os::{android, bitrig, linux, ...}::raw::{self, *}
* os::{android, bitrig, linux, ...}::fs::MetadataExt
* os::{android, bitrig, linux, ...}::fs::MetadataExt::as_raw_stat
* os::unix::fs::PermissionsExt
* os::unix::fs::PermissionsExt::mode
* os::unix::fs::PermissionsExt::set_mode
* os::unix::fs::PermissionsExt::from_mode
* os::unix::fs::OpenOptionsExt
* os::unix::fs::OpenOptionsExt::mode
* os::unix::fs::DirEntryExt
* os::unix::fs::DirEntryExt::ino
* os::windows::fs::MetadataExt
* os::windows::fs::MetadataExt::file_attributes
* os::windows::fs::MetadataExt::creation_time
* os::windows::fs::MetadataExt::last_access_time
* os::windows::fs::MetadataExt::last_write_time
* os::windows::fs::MetadataExt::file_size

The `os::unix::fs::Metadata` structure was also removed entirely, moving all of
its associated methods into the `os::unix::fs::MetadataExt` trait instead. The
methods are all marked as `#[stable]` still.

As some minor cleanup, some deprecated and unstable fs apis were also removed:

* File::path
* Metadata::accessed
* Metadata::modified

Features that were explicitly left unstable include:

* fs::WalkDir - the semantics of this were not considered in the recent fs
  expansion RFC.
* fs::DirBuilder - it's still not 100% clear if the naming is right here and if
  the set of functionality exposed is appropriate.
* fs::canonicalize - the implementation on Windows here is specifically in
  question as it always returns a verbatim path. Additionally the Unix
  implementation is susceptible to buffer overflows on long paths unfortunately.
* fs::PathExt - as this is just a convenience trait, it is not stabilized at
  this time.
* fs::set_file_times - this funciton is still waiting on a time abstraction.
2015-06-09 17:44:13 -07:00
marcell
e87c62fb12 Modify String::push to reallocate more conservatively in case of the character's UTF-8 representation is bigger than 1 byte 2015-06-10 02:04:37 +02:00
Alex Crichton
9d6ffbdaa8 Revert "Added AsRef implementations for Arc and Rc"
This reverts commit 7f3ae0aa26.
2015-06-09 16:47:45 -07:00
Eduard Burtescu
76eaed44d9 syntax: move ast_map to librustc. 2015-06-10 02:40:45 +03:00
bors
2228ce10c6 Auto merge of #25836 - steveklabnik:gh25305, r=alexcrichton
Fixes #25794
2015-06-09 23:11:25 +00:00
Björn Steinbrink
96bc00f30e Use the correct type of undef value for ignored return values in trans_named_tuple_constructor
Fixes #26127
2015-06-10 00:07:47 +02:00
marcell
c5d0e2a073 Add missing #[inline] to methods related to char. 2015-06-09 23:58:00 +02:00
bors
ac67354392 Auto merge of #26150 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #26111, #26125, #26129, #26131, #26132, #26133, #26134, #26136, #26140, #26144
- Failed merges:
2015-06-09 21:36:03 +00:00
Steve Klabnik
6b6b380fd1 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?
2015-06-09 17:24:45 -04:00