Skip to content

Rollup of 13 pull requests #24481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Apr 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9c6f4b6
rustc: Add long diagnostics for E0297
ruuda Apr 14, 2015
ab1723b
rustc: Add long diagnostics for E0301
ruuda Apr 14, 2015
48a376d
rustc: Add long diagnostics for E0302
ruuda Apr 14, 2015
c45eacd
rustc: Add long diagnostics for E0162
ruuda Apr 14, 2015
433f0e8
std: Set overlap/noinherit flags on windows sockets
alexcrichton Apr 8, 2015
33dca5e
rustc: Add long diagnostics for E0165
ruuda Apr 14, 2015
6fc1381
disabling a test for bitrig and openbsd
Apr 14, 2015
5e07329
std: Remove final usage of fds from Windows
alexcrichton Apr 14, 2015
cbe9a1a
Remove Incorrect Link from std::ptr::null Docs
killercup Apr 14, 2015
4f3d400
Remove superfluous `the` from `custom_attribute` feature gate message
fhahn Apr 14, 2015
f37365e
Fix the span for tuple expressions
nrc Apr 14, 2015
c773442
Auto merge of #24431 - ruud-v-a:explain, r=alexcrichton
bors Apr 15, 2015
af1c39c
Auto merge of #24211 - alexcrichton:windows-wsa-flag-overlapped, r=at…
bors Apr 15, 2015
cf43761
rustc: fix a typo in letter to rustc
richo Apr 15, 2015
a691f1e
Auto merge of #24426 - alexcrichton:windows-pipes, r=aturon
bors Apr 15, 2015
9a5a47e
Fix some typos.
Ms2ger Mar 25, 2015
14f2dce
Add tests for "ident only path should have been covered"-ICE
bytwise Apr 15, 2015
e7e7c0f
Fix link in intoiterator docs
steveklabnik Apr 15, 2015
ce27d02
Auto merge of #24436 - fhahn:fix-small-typo, r=steveklabnik
bors Apr 15, 2015
09236bc
Fix link formatting error
brettcannon Apr 15, 2015
40c7350
Fix link to stack/heap page
brettcannon Apr 15, 2015
86ec457
doc: Fix link to rustbyexample.com
andrewseidl Apr 15, 2015
2b86f1f
Describe the Iterator enumerate() method more clearly.
Apr 15, 2015
9ce73d4
Grammar fix
brettcannon Apr 15, 2015
031619f
Rollup merge of #24425 - dhuseby:bitrig_fixing_tests_3, r=alexcrichton
steveklabnik Apr 15, 2015
7115603
Rollup merge of #24435 - killercup:patch-9, r=steveklabnik
steveklabnik Apr 15, 2015
63d524d
Rollup merge of #24438 - nrc:tuple-span, r=sfackler
steveklabnik Apr 15, 2015
68a9e6a
Rollup merge of #24440 - nham:improve_enumerate_doc, r=alexcrichton
steveklabnik Apr 15, 2015
b5378f4
Rollup merge of #24449 - richo:typo, r=alexcrichton
steveklabnik Apr 15, 2015
79e5c00
Rollup merge of #24457 - Ms2ger:more-typos, r=alexcrichton
steveklabnik Apr 15, 2015
111404f
Rollup merge of #24460 - bytewiseand:master, r=alexcrichton
steveklabnik Apr 15, 2015
df54719
Rollup merge of #24465 - steveklabnik:intoiteratordocfix, r=alexcrichton
steveklabnik Apr 15, 2015
f4647ac
Rollup merge of #24467 - brettcannon:patch-1, r=alexcrichton
steveklabnik Apr 15, 2015
68648fe
Rollup merge of #24468 - brettcannon:patch-2, r=alexcrichton
steveklabnik Apr 15, 2015
ff7c991
Rollup merge of #24471 - andrewseidl:master, r=alexcrichton
steveklabnik Apr 15, 2015
438011d
Rollup merge of #24476 - brettcannon:patch-3, r=steveklabnik
steveklabnik Apr 15, 2015
7644ef8
Rollup merge of #24480 - achanda:move_test, r=alexcrichton
steveklabnik Apr 15, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ideas behind Rust.
donated to the Rust project. As the name implies, it teaches you Rust through a
series of small examples.

[rbe]: rustbyexample.com
[rbe]: http://rustbyexample.com/

# Community & Getting Help

Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn uncompress(src: &[u8]) -> Option<Vec<u8>> {
}
```

For reference, the examples used here are also available as an [library on
For reference, the examples used here are also available as a [library on
GitHub](https://github.com/thestinger/rust-snappy).

# Destructors
Expand Down
8 changes: 4 additions & 4 deletions src/doc/trpl/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ We’ll get to the details eventually, you’ll just have to trust us for now.

Next, `"Hello, world!"` is a ‘string’. Strings are a surprisingly complicated
topic in a systems programming language, and this is a ‘statically allocated’
string. If you want to read further about allocation, check out [the stack and
the heap], but you don’t need to right now if you don’t want to. We pass this
string as an argument to `println!`, which prints the string to the screen.
Easy enough!
string. If you want to read further about allocation, check out
[the stack and the heap][allocation], but you don’t need to right now if you
don’t want to. We pass this string as an argument to `println!`, which prints the
string to the screen. Easy enough!

[allocation]: the-stack-and-the-heap.html

Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/installing-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ If not, there are a number of places where you can get help. The easiest is
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
(a silly nickname we call ourselves), and we can help you out. Other great
resources include [the user’s forum][users], and [Stack Overflow][stack
overflow].
resources include [the user’s forum][users], and
[Stack Overflow][stack overflow].

[irc]: irc://irc.mozilla.org/#rust
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust
Expand Down
2 changes: 1 addition & 1 deletion src/doc/trpl/no-stdlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ necessary functionality for writing idiomatic and effective Rust code.
As an example, here is a program that will calculate the dot product of two
vectors provided from C, using idiomatic Rust practices.

```
```ignore
#![feature(lang_items, start, no_std, core, libc)]
#![no_std]

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T> {
// reference to the inner data.
let inner = unsafe { &mut **this._ptr };
Some(&mut inner.data)
}else {
} else {
None
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ pub trait Iterator {
FilterMap { iter: self, f: f }
}

/// Creates an iterator that yields a pair of the value returned by this
/// iterator plus the current index of iteration.
/// Creates an iterator that yields pairs `(i, val)` where `i` is the
/// current index of iteration and `val` is the value returned by the
/// iterator.
///
/// `enumerate` keeps its count as a `usize`. If you want to count by a
/// different sized integer, the `zip` function provides similar
Expand Down Expand Up @@ -1129,7 +1130,7 @@ pub trait FromIterator<A> {
/// Conversion into an `Iterator`
///
/// Implementing this trait allows you to use your type with Rust's `for` loop. See
/// the [module level documentation](../index.html) for more details.
/// the [module level documentation](index.html) for more details.
#[stable(feature = "rust1", since = "1.0.0")]
pub trait IntoIterator {
/// The type of the elements being iterated
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
//! Working with unsafe pointers in Rust is uncommon,
//! typically limited to a few patterns.
//!
//! Use the [`null` function](fn.null.html) to create null pointers, and
//! the `is_null` method of the `*const T` type to check for null.
//! The `*const T` type also defines the `offset` method, for pointer math.
//! Use the `null` function to create null pointers, and the `is_null` method
//! of the `*const T` type to check for null. The `*const T` type also defines
//! the `offset` method, for pointer math.
//!
//! # Common ways to create unsafe pointers
//!
Expand Down
99 changes: 94 additions & 5 deletions src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,100 @@ reference when using guards or refactor the entire expression, perhaps by
putting the condition inside the body of the arm.
"##,

E0162: r##"
An if-let pattern attempts to match the pattern, and enters the body if the
match was succesful. If the match is irrefutable (when it cannot fail to match),
use a regular `let`-binding instead. For instance:

struct Irrefutable(i32);
let irr = Irrefutable(0);

// This fails to compile because the match is irrefutable.
if let Irrefutable(x) = irr {
// This body will always be executed.
foo(x);
}

// Try this instead:
let Irrefutable(x) = irr;
foo(x);
"##,

E0165: r##"
A while-let pattern attempts to match the pattern, and enters the body if the
match was succesful. If the match is irrefutable (when it cannot fail to match),
use a regular `let`-binding inside a `loop` instead. For instance:

struct Irrefutable(i32);
let irr = Irrefutable(0);

// This fails to compile because the match is irrefutable.
while let Irrefutable(x) = irr {
...
}

// Try this instead:
loop {
let Irrefutable(x) = irr;
...
}
"##,

E0297: r##"
Patterns used to bind names must be irrefutable. That is, they must guarantee
that a name will be extracted in all cases. Instead of pattern matching the
loop variable, consider using a `match` or `if let` inside the loop body. For
instance:

// This fails because `None` is not covered.
for Some(x) in xs {
...
}

// Match inside the loop instead:
for item in xs {
match item {
Some(x) => ...
None => ...
}
}

// Or use `if let`:
for item in xs {
if let Some(x) = item {
...
}
}
"##,

E0301: r##"
Mutable borrows are not allowed in pattern guards, because matching cannot have
side effects. Side effects could alter the matched object or the environment
on which the match depends in such a way, that the match would not be
exhaustive. For instance, the following would not match any arm if mutable
borrows were allowed:

match Some(()) {
None => { },
option if option.take().is_none() => { /* impossible, option is `Some` */ },
Some(_) => { } // When the previous match failed, the option became `None`.
}
"##,

E0302: r##"
Assignments are not allowed in pattern guards, because matching cannot have
side effects. Side effects could alter the matched object or the environment
on which the match depends in such a way, that the match would not be
exhaustive. For instance, the following would not match any arm if assignments
were allowed:

match Some(()) {
None => { },
option if { option = None; false } { },
Some(_) => { } // When the previous match failed, the option became `None`.
}
"##,

E0303: r##"
In certain cases it is possible for sub-bindings to violate memory safety.
Updates to the borrow checker in a future version of Rust may remove this
Expand Down Expand Up @@ -165,8 +259,6 @@ register_diagnostics! {
E0152,
E0158,
E0161,
E0162,
E0165,
E0170,
E0261, // use of undeclared lifetime name
E0262, // illegal lifetime parameter name
Expand Down Expand Up @@ -194,12 +286,9 @@ register_diagnostics! {
E0284, // cannot resolve type
E0285, // overflow evaluation builtin bounds
E0296, // malformed recursion limit attribute
E0297, // refutable pattern in for loop binding
E0298, // mismatched types between arms
E0299, // mismatched types between arms
E0300, // unexpanded macro
E0301, // cannot mutable borrow in a pattern guard
E0302, // cannot assign in a pattern guard
E0304, // expected signed integer constant
E0305, // expected constant
E0306, // expected positive integer for repeat count
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
//! > Dear rustc,
//! >
//! > When you are attempting to load the immediate dependency `crate-name`, I
//! > would like you too assume that the library is located at
//! > would like you to assume that the library is located at
//! > `path/to/the/crate.rlib`, and look nowhere else. Also, please do not
//! > assume that the path I specified has the name `crate-name`.
//!
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl CString {
///
/// This method is equivalent to `new` except that no runtime assertion
/// is made that `v` contains no 0 bytes, and it requires an actual
/// byte vector, not anyhting that can be converted to one with Into.
/// byte vector, not anything that can be converted to one with Into.
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
v.push(0);
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,8 @@ impl PathExt for Path {
/// Changes the timestamps for a file's last modification and access time.
///
/// The file at the path specified will have its last access time set to
/// `atime` and its modification time set to `mtime`. The times specified should
/// be in milliseconds.
/// `accessed` and its modification time set to `modified`. The times specified
/// should be in milliseconds.
#[unstable(feature = "fs_time",
reason = "the argument type of u64 is not quite appropriate for \
this function and may change if the standard library \
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub trait Read {
///
/// If the return value of this method is `Ok(n)`, then it must be
/// guaranteed that `0 <= n <= buf.len()`. A nonzero `n` value indicates
/// that the buffer `buf` has ben filled in with `n` bytes of data from this
/// that the buffer `buf` has been filled in with `n` bytes of data from this
/// source. If `n` is `0`, then it can indicate one of two scenarios:
///
/// 1. This reader has reached its "end of file" and will likely no longer
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl TcpListener {
/// Returns an iterator over the connections being received on this
/// listener.
///
/// The returned iterator will never returned `None` and will also not yield
/// The returned iterator will never return `None` and will also not yield
/// the peer's `SocketAddr` structure.
#[stable(feature = "rust1", since = "1.0.0")]
pub fn incoming(&self) -> Incoming {
Expand Down
6 changes: 6 additions & 0 deletions src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub const WSA_WAIT_TIMEOUT: libc::DWORD = libc::consts::os::extra::WAIT_TIMEOUT;
pub const WSA_WAIT_EVENT_0: libc::DWORD = libc::consts::os::extra::WAIT_OBJECT_0;
pub const WSA_WAIT_FAILED: libc::DWORD = libc::consts::os::extra::WAIT_FAILED;
pub const WSAESHUTDOWN: libc::c_int = 10058;
pub const WSA_FLAG_OVERLAPPED: libc::DWORD = 0x01;
pub const WSA_FLAG_NO_HANDLE_INHERIT: libc::DWORD = 0x80;

pub const ERROR_NO_MORE_FILES: libc::DWORD = 18;
pub const TOKEN_READ: libc::DWORD = 0x20008;
Expand Down Expand Up @@ -463,6 +465,10 @@ extern "system" {
nOutBufferSize: libc::DWORD,
lpBytesReturned: libc::LPDWORD,
lpOverlapped: libc::LPOVERLAPPED) -> libc::BOOL;
pub fn CreatePipe(hReadPipe: libc::LPHANDLE,
hWritePipe: libc::LPHANDLE,
lpPipeAttributes: libc::LPSECURITY_ATTRIBUTES,
nSize: libc::DWORD) -> libc::BOOL;
}

#[link(name = "userenv")]
Expand Down
59 changes: 25 additions & 34 deletions src/libstd/sys/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,34 @@ impl Handle {
}

pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
read(self.0, buf)
let mut read = 0;
let res = cvt(unsafe {
libc::ReadFile(self.0, buf.as_ptr() as libc::LPVOID,
buf.len() as libc::DWORD, &mut read,
ptr::null_mut())
});

match res {
Ok(_) => Ok(read as usize),

// The special treatment of BrokenPipe is to deal with Windows
// pipe semantics, which yields this error when *reading* from
// a pipe after the other end has closed; we interpret that as
// EOF on the pipe.
Err(ref e) if e.kind() == ErrorKind::BrokenPipe => Ok(0),

Err(e) => Err(e)
}
}

pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
write(self.0, buf)
let mut amt = 0;
try!(cvt(unsafe {
libc::WriteFile(self.0, buf.as_ptr() as libc::LPVOID,
buf.len() as libc::DWORD, &mut amt,
ptr::null_mut())
}));
Ok(amt as usize)
}
}

Expand All @@ -49,35 +72,3 @@ impl Drop for Handle {
unsafe { let _ = libc::CloseHandle(self.0); }
}
}


pub fn read(h: HANDLE, buf: &mut [u8]) -> io::Result<usize> {
let mut read = 0;
let res = cvt(unsafe {
libc::ReadFile(h, buf.as_ptr() as libc::LPVOID,
buf.len() as libc::DWORD, &mut read,
ptr::null_mut())
});

match res {
Ok(_) => Ok(read as usize),

// The special treatment of BrokenPipe is to deal with Windows
// pipe semantics, which yields this error when *reading* from
// a pipe after the other end has closed; we interpret that as
// EOF on the pipe.
Err(ref e) if e.kind() == ErrorKind::BrokenPipe => Ok(0),

Err(e) => Err(e)
}
}

pub fn write(h: HANDLE, buf: &[u8]) -> io::Result<usize> {
let mut amt = 0;
try!(cvt(unsafe {
libc::WriteFile(h, buf.as_ptr() as libc::LPVOID,
buf.len() as libc::DWORD, &mut amt,
ptr::null_mut())
}));
Ok(amt as usize)
}
10 changes: 8 additions & 2 deletions src/libstd/sys/windows/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ impl Socket {
SocketAddr::V4(..) => libc::AF_INET,
SocketAddr::V6(..) => libc::AF_INET6,
};
match unsafe { libc::socket(fam, ty, 0) } {
let socket = unsafe {
c::WSASocketW(fam, ty, 0, 0 as *mut _, 0,
c::WSA_FLAG_OVERLAPPED | c::WSA_FLAG_NO_HANDLE_INHERIT)
};
match socket {
INVALID_SOCKET => Err(last_error()),
n => Ok(Socket(n)),
}
Expand All @@ -103,7 +107,9 @@ impl Socket {
match c::WSASocketW(info.iAddressFamily,
info.iSocketType,
info.iProtocol,
&mut info, 0, 0) {
&mut info, 0,
c::WSA_FLAG_OVERLAPPED |
c::WSA_FLAG_NO_HANDLE_INHERIT) {
INVALID_SOCKET => Err(last_error()),
n => Ok(Socket(n)),
}
Expand Down
Loading