Commit Graph

43478 Commits

Author SHA1 Message Date
bors
bca2ea6c4a Auto merge of #26247 - steveklabnik:remove_4120, r=alexcrichton
This test originated from an ICE in Rust 0.4:
373504a7ac (diff-214656000770dff71c8165d051c3f027)

it was ignored one day later:
1fa2b9980f (diff-214656000770dff71c8165d051c3f027)

and then never enabled again. I think we're safe without it.
2015-06-13 01:23:26 +00:00
bors
c6b1483377 Auto merge of #26160 - alexcrichton:revert-rc-as-ref, r=aturon
This is a revert of PR #26008 which caused the unintended breakage reported in #26096. We may want to add these implementations in the long run, but for now this revert allows us to take some more time to evaluate the impact of such a change (e.g. run it through crater).

Closes #26096
2015-06-12 23:05:06 +00:00
bors
50ab23ddbd Auto merge of #25844 - alexcrichton:stabilize-fs-features, r=aturon
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-12 21:31:37 +00:00
bors
85b5338e34 Auto merge of #26232 - eefriedman:rename-sty, r=nrc
Use camel-case naming, and use names which actually make sense in modern Rust.
2015-06-12 19:57:27 +00:00
bors
1671b9baec Auto merge of #26221 - sanxiyn:wf-span, r=arielb1
When checking field types of struct or enum definitions, use spans for field types instead of the entire item.
2015-06-12 18:25:55 +00:00
Eli Friedman
3c69db4c3c Cleanup: rename middle::ty::sty and its variants.
Use camel-case naming, and use names which actually make sense in modern Rust.
2015-06-12 11:07:16 -07:00
Steve Klabnik
cae1d67406 Remove ignore'd test for old ICE
This test originated from an ICE in Rust 0.4:
373504a7ac (diff-214656000770dff71c8165d051c3f027)

it was ignored one day later:
1fa2b9980f (diff-214656000770dff71c8165d051c3f027)

and then never enabled again. I think we're safe without it.
2015-06-12 12:44:25 -04:00
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
Seo Sanghyeon
793d9fcb52 Add tests for tuple-like structs and dictionary-like enum variants 2015-06-12 21:09:17 +09:00
Seo Sanghyeon
16d5c83d5f Use more precise span when checking type definitions 2015-06-12 20:28:09 +09: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