diff --git a/.mailmap b/.mailmap index c1a605bd94c..0f06604fa53 100644 --- a/.mailmap +++ b/.mailmap @@ -10,11 +10,14 @@ Abhishek Chanda Abhishek Chanda Aydin Kim aydin.kim Alex Lyon +Alex Newman Alex HotShot Newman Alex Rønne Petersen Andreas Gal +Andrew Kuchev <0coming.soon@gmail.com> Andrew <0coming.soon@gmail.com> Andrew Poelstra Anton Löfgren -Ariel Ben-Yehuda arielb1 +Ariel Ben-Yehuda arielb1 +Ariel Ben-Yehuda Ariel Ben-Yehuda Austin Seipp Ben Alpert Benjamin Jackman @@ -76,6 +79,7 @@ Kang Seonghoon Keegan McAllister Kyeongwoon Lee Lee Wondong +Lee Jeffery Lee Jeffery Lennart Kudling Lindsey Kuper Lindsey Kuper @@ -121,8 +125,10 @@ startling Steven Fackler Steven Stewart-Gallus Tamir Duberstein Tamir Duberstein +Ticki Ticki <@> Tim Chevalier Torsten Weber +Ulrik Sverdrup Ulrik Sverdrup Vadim Petrochenkov petrochenkov William Ting Xuefeng Wu Xuefeng Wu XuefengWu diff --git a/AUTHORS.txt b/AUTHORS.txt index 60e1a34aecb..310a91b2d16 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -10,6 +10,7 @@ Aaron Turon Aaron Weiss Abhishek Chanda Adam Bozanich +Adam Heins Adam Jacob Adam Roben Adam Szkoda @@ -17,6 +18,7 @@ Adenilson Cavalcanti Adolfo Ochagavía Adrien Brault Adrien Tétar +Agoston Szepessy Ahmed Charles Aidan Cully Aidan Hobson Sayers @@ -44,6 +46,7 @@ Alexei Sholik Alex Gaynor Alexis Beingessner Alex Lyon +Alex Newman Alex Quach Alex Rønne Petersen Alex Stokes @@ -73,15 +76,19 @@ Andrew Foote Andrew Gallant Andrew Hobden Andrew Kensler +Andrew Kuchev <0coming.soon@gmail.com> Andrew Paseltiner Andrew Poelstra Andrew Seidl Andrew Straw Andrew Wagner Andrzej Janik +Andy Caldwell +Andy Grover Angus Lees Anthony Juckel Anton Löfgren +Antti Keränen Aram Visser Arcterus Areski Belaid @@ -93,6 +100,7 @@ Armin Ronacher Arpad Borsos Artem Arthur Liao +arthurprs arturo Ashok Gautham Augusto Hack @@ -134,6 +142,7 @@ Bill Wendling Birunthan Mohanathas Björn Steinbrink blake2-ppc +Blake Loring bluss bluss Boris Egorov @@ -158,6 +167,7 @@ Brian J. Burg Brian Koropoff Brian Leibig Brian Quinlan +Brody Holden Bruno de Oliveira Abinader Bryan Dunsmore Byron Williams @@ -189,7 +199,9 @@ Chris Pressey Chris Sainty Chris Shea Chris Thorn +Christian Persson Christian Stadelmann +Christian Weinz Christoph Burgdorf Christopher Bergqvist Christopher Chambers @@ -228,6 +240,7 @@ Dan Albert Dan Burkert Dan Callahan Dan Connolly +Daniel Albert Daniel Brooks Daniel Fagnan Daniel Farina @@ -278,6 +291,7 @@ Derek Chiang Derek Guenther Derek Harland dgoon +diaphore Diego Giagio Diego Ongaro Diggory Blake @@ -285,6 +299,7 @@ Diggory Hardy Dimitri Krassovski Dirk Gadsden Dirkjan Bussink +Dirkjan Ochtman Dirk Leifeld Div Shekhar diwic @@ -319,6 +334,7 @@ Ehsanul Hoque Elantsev Serj Eli Friedman eliovir +Eljay Elliott Slaughter Elly Fong-Jones elszben @@ -343,6 +359,8 @@ Erik Michaels-Ober Erik Price Erik Rose Erwan +Esption +eternaleye Etienne Millon Eunchong Yu Eunji Jeong @@ -371,6 +389,7 @@ fort Francisco Souza frankamp Franklin Chen +Frank McSherry Franziska Hinkelmann free-Runner FuGangqiang @@ -392,6 +411,7 @@ Geoff Hill Geoffrey Thomas Geoffroy Couprie Geoffry Song +Georg Brandl George Papanikolaou Georges Dubus Germano Gabbianelli @@ -478,6 +498,7 @@ Jan Andersson Jan Bujak Jan-Erik Rediger Jan Kobler +Jan Likar Jan Niklas Hasse Jannis Harder Jannis Redmann @@ -486,6 +507,7 @@ Jarod Liu Jashank Jeremy Jason Fager Jason Orendorff +Jason Schein Jason Thompson Jason Toffaletti Jason Yeo @@ -499,6 +521,7 @@ J.C. Moyer Jeaye Jed Davis Jed Estep +Jeehoon Kang Jeff Balogh Jeff Belgum Jeff Muizelaar @@ -515,6 +538,8 @@ Jesse Luehrs Jesse Ray Jesse Ruderman Jessy Diamond Exum +Jesús Espino +jethrogb Jexell Jihyeok Seo Jihyun Yu @@ -556,6 +581,7 @@ joliv Jonas Hietala Jonathan Bailey Jonathan Boyett +Jonathan Hansford Jonathan Reem Jonathan S Jonathan Sternberg @@ -571,6 +597,7 @@ Jorge Aparicio Jorge Israel Peña Joris Rehm Jormundir +Jose Narvaez Joseph Crail Joseph Martin Joseph Rushton Wakeling @@ -595,6 +622,7 @@ Justin Noah juxiliary jxv Jyun-Yan You +Kagami Sascha Rosylight Kang Seonghoon Kasey Carrothers Keegan McAllister @@ -613,13 +641,17 @@ Kevin Rauwolf Kevin Walter Kevin Yap kgv +Kieran Hunt Kiet Tran Kim Røen kjpgit klutzy KokaKiwi korenchkin +Kornel Lesiński Kostas Karachalios +Kristof Söderström +krumelmonster Krzysztof Drewniak Kubilay Kocak kulakowski @@ -635,6 +667,7 @@ Leah Hanson Lee Aronson Lee Jeffery Lee Wondong +Leif Arne Storset LemmingAvalanche Lennart Kudling Leo Correa @@ -664,6 +697,7 @@ madmalik Magnus Auvinen Mahmut Bulut maikklein +Makoto Kato Makoto Nakashima Manish Goregaokar Manuel Hoffmann @@ -675,6 +709,7 @@ Margaret Meyerhofer Marijn Haverbeke Marin Atanasov Nikolov Mário Feroldi +Mark Buer Mark Lacey <641@rudkx.com> Mark Mossberg Mark Rowe @@ -699,6 +734,7 @@ Matt Brubeck Matt Carberry Matt Coffin Matt Cox +Matt Friedman Matthew Astley Matthew Auld Matthew Iselin @@ -753,6 +789,7 @@ Mickaël Delahaye Mickaël Raybaud-Roig Mickaël Salaün Mick Koch +midinastasurazz Mihnea Dobrescu-Balaur Mike Boutin Mike Dilger @@ -762,6 +799,7 @@ Mike Robinson Mike Sampson Mikhail Zabaluev Mikko Perttunen +mitaa mitchmindtree Mohammed Attia moonglum @@ -795,6 +833,7 @@ Nick Howell Nick Platt Nick Sarten Nicolas Silva +Nicolette Verlinden Niels Egberts Niels langager Ellegaard Nif Ward @@ -814,7 +853,6 @@ Oak OGINO Masanori OlegTsyba Oliver Schneider -Oliver Schneider Olivier Saut olivren Olle Jonsson @@ -849,6 +887,7 @@ Paul Quint Paul Stansifer Paul Woolcock Pavel Panchekha +Pavel Pravosud Pawel Olzacki Pedro Larroy Peer Aramillo Irizar @@ -885,6 +924,7 @@ Q.P.Liu qwitwa Rafael Ávila de Espíndola Rahul Horé +Ralf Jung Ralph Bodenner Ralph Giles Ramkumar Ramachandra @@ -940,6 +980,7 @@ Russell McClellan Ruud van Asseldonk Ryan Levick Ryan Mulligan +Ryan Pendleton Ryan Prichard Ryan Riginding Ryan Scheel @@ -1024,6 +1065,7 @@ Subhash Bhushan sumito3478 Swaroop C H Sylvestre Ledru +Taliesin Beynon Tamir Duberstein Tamir Duberstein Taras Shpot @@ -1045,6 +1087,7 @@ Thomas Jespersen Thomas Karpiniec Tiago Nobrega Tibor Benke +Ticki Till Hoeppner Tim Brooks Tim Chevalier @@ -1086,7 +1129,7 @@ Tyler Bindon Tyler Thrailkill tynopex Ty Overby -Ulrik Sverdrup +Ulrik Sverdrup Ulysse Carion User Jyyou Utkarsh Kukreti @@ -1102,6 +1145,7 @@ Vijay Korapaty Viktor Dahl ville-h Vincent Belliard +Vincent Bernat Vinzent Steinberg Virgile Andreani visualfc @@ -1109,6 +1153,7 @@ Vitali Haravy Vivek Galatage Vladimir Matveev Vladimir Pouzanov +Vladimir Rutsky Vladimir Smola Vojtech Kral Volker Mische @@ -1125,6 +1170,7 @@ Wilfred Hughes Will Andrews Will Engler Will Hipschman +William Throwe William Ting Willson Mock Will diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md index 753a5a32e8a..878947e10ad 100644 --- a/src/doc/trpl/ffi.md +++ b/src/doc/trpl/ffi.md @@ -555,3 +555,56 @@ pub extern fn oh_no() -> i32 { # fn main() {} ``` +# Representing opaque structs + +Sometimes, a C library wants to provide a pointer to something, but not let you +know the internal details of the thing it wants. The simplest way is to use a +`void *` argument: + +```c +void foo(void *arg); +void bar(void *arg); +``` + +We can represent this in Rust with the `c_void` type: + +```rust +# #![feature(libc)] +extern crate libc; + +extern "C" { + pub fn foo(arg: *mut libc::c_void); + pub fn bar(arg: *mut libc::c_void); +} +# fn main() {} +``` + +This is a perfectly valid way of handling the situation. However, we can do a bit +better. To solve this, some C libraries will instead create a `struct`, where +the details and memory layout of the struct are private. This gives some amount +of type safety. These structures are called ‘opaque’. Here’s an example, in C: + +```c +struct Foo; /* Foo is a structure, but its contents are not part of the public interface */ +struct Bar; +void foo(struct Foo *arg); +void bar(struct Bar *arg); +``` + +To do this in Rust, let’s create our own opaque types with `enum`: + +```rust +pub enum Foo {} +pub enum Bar {} + +extern "C" { + pub fn foo(arg: *mut Foo); + pub fn bar(arg: *mut Bar); +} +# fn main() {} +``` + +By using an `enum` with no variants, we create an opaque type that we can’t +instantiate, as it has no variants. But because our `Foo` and `Bar` types are +different, we’ll get type safety between the two of them, so we cannot +accidentally pass a pointer to `Foo` to `bar()`. diff --git a/src/doc/trpl/strings.md b/src/doc/trpl/strings.md index 7d5c43ea14c..aa1944a0993 100644 --- a/src/doc/trpl/strings.md +++ b/src/doc/trpl/strings.md @@ -115,7 +115,7 @@ You can get something similar to an index like this: let dog = hachiko.chars().nth(1); // kinda like hachiko[1] ``` -This emphasizes that we have to go through the whole list of `chars`. +This emphasizes that we have to walk from the beginning of the list of `chars`. ## Slicing diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2968d634544..3382095b456 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -148,8 +148,7 @@ pub trait Iterator { last } - /// Loops through `n` iterations, returning the `n`th element of the - /// iterator. + /// Skips the `n` first elements of the iterator and returns the next one. /// /// # Examples /// diff --git a/src/librustc_back/target/i686_pc_windows_msvc.rs b/src/librustc_back/target/i686_pc_windows_msvc.rs index f2ae799bd24..d8c1c79b47f 100644 --- a/src/librustc_back/target/i686_pc_windows_msvc.rs +++ b/src/librustc_back/target/i686_pc_windows_msvc.rs @@ -12,7 +12,7 @@ use target::Target; pub fn target() -> Target { let mut base = super::windows_msvc_base::opts(); - base.cpu = "i686".to_string(); + base.cpu = "pentium4".to_string(); Target { llvm_target: "i686-pc-windows-msvc".to_string(), diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 343faf7e477..bd4e4fc3110 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1803,6 +1803,43 @@ information see the [opt-in builtin traits RFC](https://github.com/rust-lang/ rfcs/blob/master/text/0019-opt-in-builtin-traits.md). "##, +E0193: r##" +`where` clauses must use generic type parameters: it does not make sense to use +them otherwise. An example causing this error: + +``` +trait Foo { + fn bar(&self); +} + +#[derive(Copy,Clone)] +struct Wrapper { + Wrapped: T +} + +impl Foo for Wrapper where Wrapper: Clone { + fn bar(&self) { } +} +``` + +This use of a `where` clause is strange - a more common usage would look +something like the following: + +``` +impl Foo for Wrapper where Wrapper: Clone { + fn bar(&self) { } +} +``` + +Here, we're saying that the implementation exists on Wrapper only when the +wrapped type `T` implements `Clone`. The `where` clause is important because +some types will not implement `Clone`, and thus will not get this method. + +In our erroneous example, however, we're referencing a single concrete type. +Since we know for certain that Wrapper implements Clone, there's no reason +to also specify it in a `where` clause. +"##, + E0195: r##" Your method's lifetime parameters do not match the trait declaration. Erroneous code example: @@ -2558,8 +2595,6 @@ register_diagnostics! { E0188, // can not cast a immutable reference to a mutable pointer E0189, // deprecated: can only cast a boxed pointer to a boxed object E0190, // deprecated: can only cast a &-pointer to an &-object - E0193, // cannot bound type where clause bounds may only be attached to types - // involving type parameters E0194, E0196, // cannot determine a type for this closure E0203, // type parameter has more than one relaxed default bound, diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index a903452d540..6995ed07e99 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -748,10 +748,10 @@ impl AsInner for DirEntry { fn as_inner(&self) -> &fs_imp::DirEntry { &self.0 } } -/// Removes a file from the underlying filesystem. +/// Removes a file from the filesystem. /// -/// Note that, just because an unlink call was successful, it is not -/// guaranteed that a file is immediately deleted (e.g. depending on +/// Note that there is no +/// guarantee that the file is immediately deleted (e.g. depending on /// platform, other open file descriptors may prevent immediate removal). /// /// # Errors diff --git a/src/libstd/path.rs b/src/libstd/path.rs index c3a887cbcb8..5b456b580e5 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -965,7 +965,7 @@ impl PathBuf { /// /// * if `path` has a root but no prefix (e.g. `\windows`), it /// replaces everything except for the prefix (if any) of `self`. - /// * if `path` has a prefix but no root, it replaces `self. + /// * if `path` has a prefix but no root, it replaces `self`. #[stable(feature = "rust1", since = "1.0.0")] pub fn push>(&mut self, path: P) { let path = path.as_ref(); diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index 8a8cf9e7c53..694d873d0d2 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -84,9 +84,13 @@ pub fn error_string(errnum: i32) -> String { } let b = buf.iter().position(|&b| b == 0).unwrap_or(buf.len()); - let msg = String::from_utf16(&buf[..b]); - match msg { - Ok(msg) => msg, + match String::from_utf16(&buf[..b]) { + Ok(mut msg) => { + // Trim trailing CRLF inserted by FormatMessageW + let len = msg.trim_right().len(); + msg.truncate(len); + msg + }, Err(..) => format!("OS Error {} (FormatMessageW() returned \ invalid UTF-16)", errnum), }