From 9c6f4b6d1d57ef53886034b91f46e09f892a2851 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Tue, 14 Apr 2015 18:27:41 +0200 Subject: [PATCH 01/20] rustc: Add long diagnostics for E0297 --- src/librustc/diagnostics.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index b15304d6dc50c..63d10a8375195 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -112,6 +112,33 @@ reference when using guards or refactor the entire expression, perhaps by putting the condition inside the body of the arm. "##, +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 { + ... + } +} +"##, + 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 @@ -194,7 +221,6 @@ 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 From ab1723b6704f31390a55a160955240aef817c8b3 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Tue, 14 Apr 2015 19:31:42 +0200 Subject: [PATCH 02/20] rustc: Add long diagnostics for E0301 --- src/librustc/diagnostics.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 63d10a8375195..3495f8eb160f4 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -139,6 +139,20 @@ for item in xs { } "##, +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`. +} +"##, + 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 @@ -224,7 +238,6 @@ register_diagnostics! { 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 From 48a376da18b27c787818eec18ad26ba96ebdff67 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Tue, 14 Apr 2015 19:39:58 +0200 Subject: [PATCH 03/20] rustc: Add long diagnostics for E0302 --- src/librustc/diagnostics.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 3495f8eb160f4..7f77c0fceea1f 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -153,6 +153,20 @@ match Some(()) { } "##, +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 @@ -238,7 +252,6 @@ register_diagnostics! { E0298, // mismatched types between arms E0299, // mismatched types between arms E0300, // unexpanded macro - E0302, // cannot assign in a pattern guard E0304, // expected signed integer constant E0305, // expected constant E0306, // expected positive integer for repeat count From c45eacdbc688708ccd4dd09c8bcfb513e5e5fead Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Tue, 14 Apr 2015 20:00:17 +0200 Subject: [PATCH 04/20] rustc: Add long diagnostics for E0162 --- src/librustc/diagnostics.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 7f77c0fceea1f..d4a1dd2666071 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -112,6 +112,25 @@ 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); +"##, + 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 @@ -220,7 +239,6 @@ register_diagnostics! { E0152, E0158, E0161, - E0162, E0165, E0170, E0261, // use of undeclared lifetime name From 433f0e8d1fbd25693172f71e5a577bb9625b45b0 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 8 Apr 2015 15:43:37 -0700 Subject: [PATCH 05/20] std: Set overlap/noinherit flags on windows sockets This commit modifies the socket creation functions on windows to always specify the `WSA_FLAG_OVERLAPPED` and `WSA_FLAG_NO_HANDLE_INHERIT` flags by default. The overlapped flag enables IOCP APIs on Windows to be used with the socket at no cost, enabling better interoperation with external libraries. The no handle inherit flag mirrors the upcoming change to Unix to set CLOEXEC by default for all handles. Closes #24206 --- src/libstd/sys/windows/c.rs | 2 ++ src/libstd/sys/windows/net.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 4804f6504419c..2d3c25826983f 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -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; diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs index 12a8ef99d764a..f47c785bd263c 100644 --- a/src/libstd/sys/windows/net.rs +++ b/src/libstd/sys/windows/net.rs @@ -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)), } @@ -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)), } From 33dca5e3ad376e7bd1fd618d5bbd0ed3a27840f8 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Tue, 14 Apr 2015 20:11:04 +0200 Subject: [PATCH 06/20] rustc: Add long diagnostics for E0165 --- src/librustc/diagnostics.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index d4a1dd2666071..938a74382e20e 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -131,6 +131,26 @@ 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 @@ -239,7 +259,6 @@ register_diagnostics! { E0152, E0158, E0161, - E0165, E0170, E0261, // use of undeclared lifetime name E0262, // illegal lifetime parameter name From 6fc138136d8d6cf9f8478efa501e3a173e5c0277 Mon Sep 17 00:00:00 2001 From: Dave Huseby Date: Tue, 14 Apr 2015 11:18:12 -0700 Subject: [PATCH 07/20] disabling a test for bitrig and openbsd --- src/doc/trpl/no-stdlib.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/no-stdlib.md b/src/doc/trpl/no-stdlib.md index 094c82a08cc9d..67db919c59f45 100644 --- a/src/doc/trpl/no-stdlib.md +++ b/src/doc/trpl/no-stdlib.md @@ -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] From 5e073293064a227ebf454053c8aa35d7d8bdcf52 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 14 Apr 2015 11:17:47 -0700 Subject: [PATCH 08/20] std: Remove final usage of fds from Windows This commit removes the last remnants of file descriptors from the Windows implementation of `std::sys` by using `CreatePipe` to create anonymous pipes instead of the `pipe` shim provided in msvcrt. --- src/libstd/sys/windows/c.rs | 4 ++ src/libstd/sys/windows/handle.rs | 59 ++++++++++++---------------- src/libstd/sys/windows/pipe2.rs | 63 ++++++++---------------------- src/libstd/sys/windows/process2.rs | 2 +- 4 files changed, 46 insertions(+), 82 deletions(-) diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index c8f6aca7bd32e..a23379e6b3b2a 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -463,6 +463,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")] diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs index 0089dcad455df..c3a30aae9e0e8 100644 --- a/src/libstd/sys/windows/handle.rs +++ b/src/libstd/sys/windows/handle.rs @@ -36,11 +36,34 @@ impl Handle { } pub fn read(&self, buf: &mut [u8]) -> io::Result { - 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 { - 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) } } @@ -49,35 +72,3 @@ impl Drop for Handle { unsafe { let _ = libc::CloseHandle(self.0); } } } - - -pub fn read(h: HANDLE, buf: &mut [u8]) -> io::Result { - 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 { - 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) -} diff --git a/src/libstd/sys/windows/pipe2.rs b/src/libstd/sys/windows/pipe2.rs index ed41c95978289..b441d8beedbc0 100644 --- a/src/libstd/sys/windows/pipe2.rs +++ b/src/libstd/sys/windows/pipe2.rs @@ -10,70 +10,39 @@ use prelude::v1::*; -use sys::handle; use io; -use libc::{self, c_int, HANDLE}; +use libc; +use sys::cvt; +use sys::c; +use sys::handle::Handle; //////////////////////////////////////////////////////////////////////////////// // Anonymous pipes //////////////////////////////////////////////////////////////////////////////// pub struct AnonPipe { - fd: c_int + inner: Handle, } pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> { - // Windows pipes work subtly differently than unix pipes, and their - // inheritance has to be handled in a different way that I do not - // fully understand. Here we explicitly make the pipe non-inheritable, - // which means to pass it to a subprocess they need to be duplicated - // first, as in std::run. - let mut fds = [0; 2]; - unsafe { - match libc::pipe(fds.as_mut_ptr(), 1024 as ::libc::c_uint, - (libc::O_BINARY | libc::O_NOINHERIT) as c_int) { - 0 => { - assert!(fds[0] != -1 && fds[0] != 0); - assert!(fds[1] != -1 && fds[1] != 0); - - Ok((AnonPipe::from_fd(fds[0]), AnonPipe::from_fd(fds[1]))) - } - _ => Err(io::Error::last_os_error()), - } - } + let mut reader = libc::INVALID_HANDLE_VALUE; + let mut writer = libc::INVALID_HANDLE_VALUE; + try!(cvt(unsafe { + c::CreatePipe(&mut reader, &mut writer, 0 as *mut _, 0) + })); + let reader = Handle::new(reader); + let writer = Handle::new(writer); + Ok((AnonPipe { inner: reader }, AnonPipe { inner: writer })) } impl AnonPipe { - pub fn from_fd(fd: libc::c_int) -> AnonPipe { - AnonPipe { fd: fd } - } - - pub fn raw(&self) -> HANDLE { - unsafe { libc::get_osfhandle(self.fd) as libc::HANDLE } - } + pub fn handle(&self) -> &Handle { &self.inner } pub fn read(&self, buf: &mut [u8]) -> io::Result { - handle::read(self.raw(), buf) + self.inner.read(buf) } pub fn write(&self, buf: &[u8]) -> io::Result { - handle::write(self.raw(), buf) - } -} - -impl Drop for AnonPipe { - fn drop(&mut self) { - // closing stdio file handles makes no sense, so never do it. Also, note - // that errors are ignored when closing a file descriptor. The reason - // for this is that if an error occurs we don't actually know if the - // file descriptor was closed or not, and if we retried (for something - // like EINTR), we might close another valid file descriptor (opened - // after we closed ours. - if self.fd > libc::STDERR_FILENO { - let n = unsafe { libc::close(self.fd) }; - if n != 0 { - println!("error {} when closing file descriptor {}", n, self.fd); - } - } + self.inner.write(buf) } } diff --git a/src/libstd/sys/windows/process2.rs b/src/libstd/sys/windows/process2.rs index 7495392192170..fdb47eb8c8084 100644 --- a/src/libstd/sys/windows/process2.rs +++ b/src/libstd/sys/windows/process2.rs @@ -199,7 +199,7 @@ impl Process { } } Stdio::Piped(ref pipe) => { - let orig = pipe.raw(); + let orig = pipe.handle().raw(); if DuplicateHandle(cur_proc, orig, cur_proc, slot, 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE { return Err(Error::last_os_error()) From cbe9a1a6f49dad61dac0613920631eb63a004823 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Tue, 14 Apr 2015 23:22:37 +0200 Subject: [PATCH 09/20] Remove Incorrect Link from std::ptr::null Docs The link works on the std::ptr docs page, but not the primitive.ptr.html page. Instead of leaving it half-broken, it is removed. --- src/libcore/ptr.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index a622ef78a21a4..fdd96e64e4a5f 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -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 //! From 4f3d400b3d117d2c9088c7b9d0a7c0a16c908ca6 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 14 Apr 2015 23:24:03 +0200 Subject: [PATCH 10/20] Remove superfluous `the` from `custom_attribute` feature gate message --- src/libsyntax/feature_gate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 689b4595d39a6..0d51816dbdbec 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -399,7 +399,7 @@ impl<'a> Context<'a> { } else { self.gate_feature("custom_attribute", attr.span, &format!("The attribute `{}` is currently \ - unknown to the the compiler and \ + unknown to the compiler and \ may have meaning \ added to it in the future", name)); From f37365ea929e77142ac77b482804683c1a86b20d Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 15 Apr 2015 11:20:17 +1200 Subject: [PATCH 11/20] Fix the span for tuple expressions --- src/libsyntax/parse/parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a3dd77b8197dc..7cc21105102ac 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1972,7 +1972,7 @@ impl<'a> Parser<'a> { } try!(self.bump()); - hi = self.span.hi; + hi = self.last_span.hi; return if es.len() == 1 && !trailing_comma { Ok(self.mk_expr(lo, hi, ExprParen(es.into_iter().nth(0).unwrap()))) } else { From cf43761de448c859cfe487125b9a6923a5eb9b66 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Wed, 15 Apr 2015 00:07:25 -0700 Subject: [PATCH 12/20] rustc: fix a typo in letter to rustc --- src/librustc/metadata/loader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index 7b63e38b58598..4a77f80d3b846 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -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`. //! From 9a5a47eddc0df36d2d3321552eed7fbb8b05bb3e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 25 Mar 2015 18:02:11 +0100 Subject: [PATCH 13/20] Fix some typos. --- src/liballoc/arc.rs | 2 +- src/libstd/ffi/c_str.rs | 2 +- src/libstd/fs.rs | 4 ++-- src/libstd/io/mod.rs | 2 +- src/libstd/net/tcp.rs | 2 +- src/test/run-pass/method-two-trait-defer-resolution-2.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index ff176d815916b..0cfdcd2413fd9 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -274,7 +274,7 @@ pub fn get_mut(this: &mut Arc) -> Option<&mut T> { // reference to the inner data. let inner = unsafe { &mut **this._ptr }; Some(&mut inner.data) - }else { + } else { None } } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index c1c05da4ee4b5..04513e9d048be 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -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) -> CString { v.push(0); diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 6e902a4739623..d30d44a04d336 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -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 \ diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index f3ba5cd7854d9..93c6deac6e59a 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -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 diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index 209a0032fb441..e48d0e6008b87 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -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 { diff --git a/src/test/run-pass/method-two-trait-defer-resolution-2.rs b/src/test/run-pass/method-two-trait-defer-resolution-2.rs index e1b64f250d8e1..cf9bc9bb56a89 100644 --- a/src/test/run-pass/method-two-trait-defer-resolution-2.rs +++ b/src/test/run-pass/method-two-trait-defer-resolution-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that when we write `x.foo()`, we do nothave to know the +// Test that when we write `x.foo()`, we do not have to know the // complete type of `x` in order to type-check the method call. In // this case, we know that `x: Vec<_1>`, but we don't know what type // `_1` is (because the call to `push` comes later). To pick between From 14f2dce5329fb56c2f6fc63b3b1fa6992b303998 Mon Sep 17 00:00:00 2001 From: Andreas Martens Date: Wed, 15 Apr 2015 11:32:12 +0200 Subject: [PATCH 14/20] Add tests for "ident only path should have been covered"-ICE --- src/test/parse-fail/issue-24197.rs | 13 +++++++++++++ src/test/parse-fail/issue-24375.rs | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/parse-fail/issue-24197.rs create mode 100644 src/test/parse-fail/issue-24375.rs diff --git a/src/test/parse-fail/issue-24197.rs b/src/test/parse-fail/issue-24197.rs new file mode 100644 index 0000000000000..37d6218261234 --- /dev/null +++ b/src/test/parse-fail/issue-24197.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` +} diff --git a/src/test/parse-fail/issue-24375.rs b/src/test/parse-fail/issue-24375.rs new file mode 100644 index 0000000000000..8723423325c19 --- /dev/null +++ b/src/test/parse-fail/issue-24375.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static tmp : [&'static str; 2] = ["hello", "he"]; + +fn main() { + let z = "hello"; + match z { + tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` + _ => {} + } +} From e7e7c0fc85341bf1b861d6a3d6ca2ec1ad1de76c Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 15 Apr 2015 11:43:43 -0400 Subject: [PATCH 15/20] Fix link in intoiterator docs --- src/libcore/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 4a0706906ee9c..d546d69c9993a 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1129,7 +1129,7 @@ pub trait FromIterator { /// 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 From 09236bcb07adbf2fd6518c612f131121e5e919a9 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 15 Apr 2015 12:51:34 -0400 Subject: [PATCH 16/20] Fix link formatting error Had a newline in middle of a link, causing the link text to be shown with `[]`. --- src/doc/trpl/installing-rust.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/trpl/installing-rust.md b/src/doc/trpl/installing-rust.md index e4054a097989d..09b4495ffe990 100644 --- a/src/doc/trpl/installing-rust.md +++ b/src/doc/trpl/installing-rust.md @@ -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 From 40c7350407a652c4bf13fd5abc2789a2a5242a70 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 15 Apr 2015 12:57:22 -0400 Subject: [PATCH 17/20] Fix link to stack/heap page Link spanned a line and was mising the actual link target. --- src/doc/trpl/hello-world.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/trpl/hello-world.md b/src/doc/trpl/hello-world.md index 6c320d27ba654..e58bac656d0c5 100644 --- a/src/doc/trpl/hello-world.md +++ b/src/doc/trpl/hello-world.md @@ -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 From 86ec4571d5269e35a8c1014d1ad040aa12126119 Mon Sep 17 00:00:00 2001 From: Andrew Seidl Date: Wed, 15 Apr 2015 12:58:00 -0500 Subject: [PATCH 18/20] doc: Fix link to rustbyexample.com --- src/doc/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/index.md b/src/doc/index.md index 124a82aa7dc80..5a437e959b7fb 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -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 From 2b86f1f428ace09dbf79c0bf75a7dd06fb6441e2 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Tue, 14 Apr 2015 20:11:37 -0500 Subject: [PATCH 19/20] Describe the Iterator enumerate() method more clearly. --- src/libcore/iter.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index c756d3cb9c28c..eed8edb7a528b 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -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 From 9ce73d40d44fead1d490e4ea03c2a812f3ab9847 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 15 Apr 2015 15:56:01 -0400 Subject: [PATCH 20/20] Grammar fix "as an library" -> "as a library" --- src/doc/trpl/ffi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md index 23f6e17b860b2..2c5e6b2e5fc7c 100644 --- a/src/doc/trpl/ffi.md +++ b/src/doc/trpl/ffi.md @@ -166,7 +166,7 @@ pub fn uncompress(src: &[u8]) -> Option> { } ``` -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