From a4c133777e33754137d8a097a0c932cfc45ec8a5 Mon Sep 17 00:00:00 2001 From: Jannis Redmann <mail@jannisr.de> Date: Wed, 29 Apr 2015 17:55:14 +0200 Subject: [PATCH 01/21] link to .editorconfig for Rust files I've written a small [EditorConfig](http://editorconfig.org) file for Rust development. --- src/etc/CONFIGS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index 036a2f7d4365b..def5ab05fe2f1 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -2,6 +2,7 @@ Here are some links to repos with configs which ease the use of rust: +* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/)) * [rust.vim](https://github.com/rust-lang/rust.vim) * [emacs rust-mode](https://github.com/rust-lang/rust-mode) * [gedit-config](https://github.com/rust-lang/gedit-config) From 6f3641de83b2b3a5c52557b424489bc9fc350571 Mon Sep 17 00:00:00 2001 From: Jannis Redmann <mail@jannisr.de> Date: Wed, 29 Apr 2015 18:53:36 +0200 Subject: [PATCH 02/21] distinction between official and community plugins --- src/etc/CONFIGS.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index def5ab05fe2f1..74837a06faecd 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -1,11 +1,16 @@ # Configs -Here are some links to repos with configs which ease the use of rust: +These are some links to repos with configs which ease the use of rust. + +## Officially Maintained Configs -* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/)) * [rust.vim](https://github.com/rust-lang/rust.vim) * [emacs rust-mode](https://github.com/rust-lang/rust-mode) * [gedit-config](https://github.com/rust-lang/gedit-config) * [kate-config](https://github.com/rust-lang/kate-config) * [nano-config](https://github.com/rust-lang/nano-config) * [zsh-config](https://github.com/rust-lang/zsh-config) + +## Community-maintained Configs + +* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/)) From 7ec81722250efc7798d9163574e01eec5cde85ca Mon Sep 17 00:00:00 2001 From: Carol Nichols <carol.nichols@gmail.com> Date: Sat, 2 May 2015 16:25:49 -0400 Subject: [PATCH 03/21] Update old uses of ~ in comments and debugging statements --- src/librustc/middle/expr_use_visitor.rs | 2 +- src/librustc/middle/traits/coherence.rs | 2 +- src/librustc/middle/traits/select.rs | 6 +++--- src/librustc/util/ppaux.rs | 2 +- src/librustc_borrowck/borrowck/check_loans.rs | 2 +- src/librustc_privacy/lib.rs | 2 +- src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/save/span_utils.rs | 6 +++--- src/librustc_trans/trans/attributes.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/variance.rs | 4 ++-- src/librustdoc/clean/mod.rs | 2 +- src/libsyntax/ext/deriving/generic/mod.rs | 4 ++-- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/print/pp.rs | 18 +++++++++--------- src/libtest/lib.rs | 4 ++-- src/test/compile-fail/kindck-copy.rs | 2 +- src/test/debuginfo/issue11600.rs | 2 +- src/test/run-pass/const-bound.rs | 2 +- src/test/run-pass/issue-3556.rs | 4 ---- 20 files changed, 35 insertions(+), 39 deletions(-) diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index d740d24e23672..359ea02c1d74f 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -1125,7 +1125,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { // that case we can adjust the length of the // original vec accordingly, but we'd have to // make trans do the right thing, and it would - // only work for `~` vectors. It seems simpler + // only work for `Vec`s. It seems simpler // to just require that people call // `vec.pop()` or `vec.unshift()`. let slice_bk = ty::BorrowKind::from_mutbl(slice_mutbl); diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index d9f8a88fddca3..222da6d7c3e5e 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -323,7 +323,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, def_id.krate == ast::LOCAL_CRATE } - ty::ty_uniq(_) => { // treat ~T like Box<T> + ty::ty_uniq(_) => { // Box<T> let krate = tcx.lang_items.owned_box().map(|d| d.krate); krate == Some(ast::LOCAL_CRATE) } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 49371eae2652d..9a5e7219aaa8c 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -2441,10 +2441,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { /// `match_impl()`. For example, if `impl_def_id` is declared /// as: /// - /// impl<T:Copy> Foo for ~T { ... } + /// impl<T:Copy> Foo for Box<T> { ... } /// - /// and `obligation_self_ty` is `int`, we'd back an `Err(_)` - /// result. But if `obligation_self_ty` were `~int`, we'd get + /// and `obligation_self_ty` is `int`, we'd get back an `Err(_)` + /// result. But if `obligation_self_ty` were `Box<int>`, we'd get /// back `Ok(T=int)`. fn match_inherent_impl(&mut self, impl_def_id: ast::DefId, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index aa89c1943a2e3..32ec70c487887 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -637,7 +637,7 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice<T> { } } -// This is necessary to handle types like Option<~[T]>, for which +// This is necessary to handle types like Option<Vec<T>>, for which // autoderef cannot convert the &[T] handler impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec<T> { fn repr(&self, tcx: &ctxt<'tcx>) -> String { diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 9776538de3fed..839b39a8ca003 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -732,7 +732,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { /// let p: Point; /// p.x = 22; // ok, even though `p` is uninitialized /// - /// let p: ~Point; + /// let p: Box<Point>; /// (*p).x = 22; // not ok, p is uninitialized, can't deref /// ``` fn check_if_assigned_path_is_moved(&self, diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 128e29ee76e7d..9a8bbc5ea0bc0 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -1314,7 +1314,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { // `impl [... for] Private` is never visible. let self_contains_private; // impl [... for] Public<...>, but not `impl [... for] - // ~[Public]` or `(Public,)` etc. + // Vec<Public>` or `(Public,)` etc. let self_is_public_path; // check the properties of the Self type: diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 92c9549b37727..49e336c670078 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -288,7 +288,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI, // when using unix's linker. Perhaps one day when we just use a linker from LLVM // we won't need to do this name mangling. The problem with name mangling is // that it seriously limits the available characters. For example we can't - // have things like &T or ~[T] in symbol names when one would theoretically + // have things like &T or Vec<T> in symbol names when one would theoretically // want them for things like impls of traits on that type. // // To be able to work on all platforms and get *some* reasonable output, we diff --git a/src/librustc_trans/save/span_utils.rs b/src/librustc_trans/save/span_utils.rs index 84a7678959d3e..504663571f533 100644 --- a/src/librustc_trans/save/span_utils.rs +++ b/src/librustc_trans/save/span_utils.rs @@ -230,8 +230,8 @@ impl<'a> SpanUtils<'a> { // Reparse span and return an owned vector of sub spans of the first limit // identifier tokens in the given nesting level. // example with Foo<Bar<T,V>, Bar<T,V>> - // Nesting = 0: all idents outside of brackets: ~[Foo] - // Nesting = 1: idents within one level of brackets: ~[Bar, Bar] + // Nesting = 0: all idents outside of brackets: Vec<Foo> + // Nesting = 1: idents within one level of brackets: Vec<Bar, Bar> pub fn spans_with_brackets(&self, span: Span, nesting: isize, limit: isize) -> Vec<Span> { let mut result: Vec<Span> = vec!(); @@ -352,7 +352,7 @@ impl<'a> SpanUtils<'a> { return vec!(); } // Type params are nested within one level of brackets: - // i.e. we want ~[A, B] from Foo<A, B<T,U>> + // i.e. we want Vec<A, B> from Foo<A, B<T,U>> self.spans_with_brackets(span, 1, number) } diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/trans/attributes.rs index b44ccec0127bd..8086f88deeee9 100644 --- a/src/librustc_trans/trans/attributes.rs +++ b/src/librustc_trans/trans/attributes.rs @@ -196,7 +196,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx // The `noalias` attribute on the return value is useful to a // function ptr caller. match ret_ty.sty { - // `~` pointer return values never alias because ownership + // `Box` pointer return values never alias because ownership // is transferred ty::ty_uniq(it) if common::type_is_sized(ccx.tcx(), it) => { attrs.ret(llvm::Attribute::NoAliasAttribute); @@ -239,7 +239,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx attrs.arg(idx, llvm::Attribute::ZExtAttribute); } - // `~` pointer parameters never alias because ownership is transferred + // `Box` pointer parameters never alias because ownership is transferred ty::ty_uniq(inner) => { let llsz = machine::llsize_of_real(ccx, type_of::type_of(ccx, inner)); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index c05c1c6b08523..3769e9fa0f36a 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2458,7 +2458,7 @@ fn check_expr_with_lvalue_pref<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, expr: &'tcx ast:: } // determine the `self` type, using fresh variables for all variables -// declared on the impl declaration e.g., `impl<A,B> for ~[(A,B)]` +// declared on the impl declaration e.g., `impl<A,B> for Vec<(A,B)>` // would return ($0, $1) where $0 and $1 are freshly instantiated type // variables. pub fn impl_self_ty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index 9e8c23734e3c8..7c062d354d395 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -178,8 +178,8 @@ //! further that for whatever reason I specifically supply the value of //! `String` for the type parameter `T`: //! -//! let mut vector = ~["string", ...]; -//! convertAll::<int, String>(v); +//! let mut vector = vec!["string", ...]; +//! convertAll::<int, String>(vector); //! //! Is this legal? To put another way, can we apply the `impl` for //! `Object` to the type `String`? The answer is yes, but to see why diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1e6e9a7562a7c..8f78841ef792a 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -897,7 +897,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> { } } -// maybe use a Generic enum and use ~[Generic]? +// maybe use a Generic enum and use Vec<Generic>? #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)] pub struct Generics { pub lifetimes: Vec<Lifetime>, diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 339e535cdcd9f..eb6d0c0285f75 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -896,8 +896,8 @@ impl<'a> MethodDef<'a> { nonself_args: &[P<Expr>]) -> P<Expr> { - let mut raw_fields = Vec::new(); // ~[[fields of self], - // [fields of next Self arg], [etc]] + let mut raw_fields = Vec::new(); // Vec<[fields of self], + // [fields of next Self arg], [etc]> let mut patterns = Vec::new(); for i in 0..self_args.len() { let struct_path= cx.path(DUMMY_SP, vec!( type_ident )); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 4ea2d4e5c686c..b471e06492d44 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1691,7 +1691,7 @@ mod tests { // induced by visit. Each of these arrays contains a list of indexes, // interpreted as the varrefs in the varref traversal that this binding // should match. So, for instance, in a program with two bindings and - // three varrefs, the array ~[~[1,2],~[0]] would indicate that the first + // three varrefs, the array [[1, 2], [0]] would indicate that the first // binding should match the second two varrefs, and the second binding // should match the first varref. // diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 15aaf9cf390fd..ed9937c53f4af 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -312,7 +312,7 @@ impl<'a> Printer<'a> { self.token[self.right] = t; } pub fn pretty_print(&mut self, token: Token) -> io::Result<()> { - debug!("pp ~[{},{}]", self.left, self.right); + debug!("pp Vec<{},{}>", self.left, self.right); match token { Token::Eof => { if !self.scan_stack_empty { @@ -329,7 +329,7 @@ impl<'a> Printer<'a> { self.left = 0; self.right = 0; } else { self.advance_right(); } - debug!("pp Begin({})/buffer ~[{},{}]", + debug!("pp Begin({})/buffer Vec<{},{}>", b.offset, self.left, self.right); self.token[self.right] = token; self.size[self.right] = -self.right_total; @@ -339,10 +339,10 @@ impl<'a> Printer<'a> { } Token::End => { if self.scan_stack_empty { - debug!("pp End/print ~[{},{}]", self.left, self.right); + debug!("pp End/print Vec<{},{}>", self.left, self.right); self.print(token, 0) } else { - debug!("pp End/buffer ~[{},{}]", self.left, self.right); + debug!("pp End/buffer Vec<{},{}>", self.left, self.right); self.advance_right(); self.token[self.right] = token; self.size[self.right] = -1; @@ -358,7 +358,7 @@ impl<'a> Printer<'a> { self.left = 0; self.right = 0; } else { self.advance_right(); } - debug!("pp Break({})/buffer ~[{},{}]", + debug!("pp Break({})/buffer Vec<{},{}>", b.offset, self.left, self.right); self.check_stack(0); let right = self.right; @@ -370,11 +370,11 @@ impl<'a> Printer<'a> { } Token::String(s, len) => { if self.scan_stack_empty { - debug!("pp String('{}')/print ~[{},{}]", + debug!("pp String('{}')/print Vec<{},{}>", s, self.left, self.right); self.print(Token::String(s, len), len) } else { - debug!("pp String('{}')/buffer ~[{},{}]", + debug!("pp String('{}')/buffer Vec<{},{}>", s, self.left, self.right); self.advance_right(); self.token[self.right] = Token::String(s, len); @@ -386,7 +386,7 @@ impl<'a> Printer<'a> { } } pub fn check_stream(&mut self) -> io::Result<()> { - debug!("check_stream ~[{}, {}] with left_total={}, right_total={}", + debug!("check_stream Vec<{}, {}> with left_total={}, right_total={}", self.left, self.right, self.left_total, self.right_total); if self.right_total - self.left_total > self.space { debug!("scan window is {}, longer than space on line ({})", @@ -446,7 +446,7 @@ impl<'a> Printer<'a> { assert!((self.right != self.left)); } pub fn advance_left(&mut self) -> io::Result<()> { - debug!("advance_left ~[{},{}], sizeof({})={}", self.left, self.right, + debug!("advance_left Vec<{},{}>, sizeof({})={}", self.left, self.right, self.left, self.size[self.left]); let mut left_size = self.size[self.left]; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 9cbfe283cbddc..31eb9b7fa2768 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -259,8 +259,8 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn> ) { // This will panic (intentionally) when fed any dynamic tests, because // it is copying the static values out into a dynamic vector and cannot // copy dynamic values. It is doing this because from this point on -// a ~[TestDescAndFn] is used in order to effect ownership-transfer -// semantics into parallel test runners, which in turn requires a ~[] +// a Vec<TestDescAndFn> is used in order to effect ownership-transfer +// semantics into parallel test runners, which in turn requires a Vec<> // rather than a &[]. pub fn test_main_static(args: env::Args, tests: &[TestDescAndFn]) { let args = args.collect::<Vec<_>>(); diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index d43ddff6b9500..95ab2bbab14a3 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -37,7 +37,7 @@ fn test<'a,T,U:Copy>(_: &'a isize) { assert_copy::<&'static mut isize>(); //~ ERROR `core::marker::Copy` is not implemented assert_copy::<&'a mut isize>(); //~ ERROR `core::marker::Copy` is not implemented - // ~ pointers are not ok + // owned pointers are not ok assert_copy::<Box<isize>>(); //~ ERROR `core::marker::Copy` is not implemented assert_copy::<String>(); //~ ERROR `core::marker::Copy` is not implemented assert_copy::<Vec<isize> >(); //~ ERROR `core::marker::Copy` is not implemented diff --git a/src/test/debuginfo/issue11600.rs b/src/test/debuginfo/issue11600.rs index e93704cac34c2..b79cba7aa6971 100644 --- a/src/test/debuginfo/issue11600.rs +++ b/src/test/debuginfo/issue11600.rs @@ -25,6 +25,6 @@ fn main() { // compile-flags:-g // gdb-command:list // gdb-check:1[...]fn main() { -// gdb-check:2[...]let args : ~[String] = ::std::os::args(); +// gdb-check:2[...]let args : Vec<String> = ::std::os::args(); // gdb-check:3[...]::std::io::println(args[0]); // gdb-check:4[...]} diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 5c2985ffa777d..72a23b998e5a1 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -20,7 +20,7 @@ struct F { field: isize } pub fn main() { /*foo(1); foo("hi".to_string()); - foo(~[1, 2, 3]); + foo(vec![1, 2, 3]); foo(F{field: 42}); foo((1, 2)); foo(@1);*/ diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index 0efa85e232bae..e6b577ada0c86 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -32,10 +32,6 @@ fn check_strs(actual: &str, expected: &str) -> bool pub fn main() { -// assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")")); -// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())), -// "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - let t = Token::Text("foo".to_string()); let u = Token::Section(vec!["alpha".to_string()], true, From 232b2022b515fdba7e06354c635998cbc0d76114 Mon Sep 17 00:00:00 2001 From: Carol Nichols <carol.nichols@gmail.com> Date: Sat, 2 May 2015 16:26:45 -0400 Subject: [PATCH 04/21] Update debuginfo metadata to use Box instead of ~ Also remove comments that reference the unique_type_id HEAP_VEC_BOX metadata, which was removed in 3e62637 and the unique_type_id GC_BOX metadata, which was removed in 8a91d33. --- .../trans/debuginfo/metadata.rs | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 9ff69e7f9dd29..29c22c8c9f712 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -142,26 +142,24 @@ impl<'tcx> TypeMap<'tcx> { fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>, type_: Ty<'tcx>) -> UniqueTypeId { - // basic type -> {:name of the type:} - // tuple -> {tuple_(:param-uid:)*} - // struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> } - // enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> } - // enum variant -> {variant_:variant-name:_:enum-uid:} - // reference (&) -> {& :pointee-uid:} - // mut reference (&mut) -> {&mut :pointee-uid:} - // ptr (*) -> {* :pointee-uid:} - // mut ptr (*mut) -> {*mut :pointee-uid:} - // unique ptr (~) -> {~ :pointee-uid:} - // @-ptr (@) -> {@ :pointee-uid:} - // sized vec ([T; x]) -> {[:size:] :element-uid:} - // unsized vec ([T]) -> {[] :element-uid:} - // trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> } - // closure -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \ + // basic type -> {:name of the type:} + // tuple -> {tuple_(:param-uid:)*} + // struct -> {struct_:svh: / :node-id:_<(:param-uid:),*> } + // enum -> {enum_:svh: / :node-id:_<(:param-uid:),*> } + // enum variant -> {variant_:variant-name:_:enum-uid:} + // reference (&) -> {& :pointee-uid:} + // mut reference (&mut) -> {&mut :pointee-uid:} + // ptr (*) -> {* :pointee-uid:} + // mut ptr (*mut) -> {*mut :pointee-uid:} + // unique ptr (Box) -> {Box :pointee-uid:} + // @-ptr (@) -> {@ :pointee-uid:} + // sized vec ([T; x]) -> {[:size:] :element-uid:} + // unsized vec ([T]) -> {[] :element-uid:} + // trait (T) -> {trait_:svh: / :node-id:_<(:param-uid:),*> } + // closure -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \ // :return-type-uid: : (:bounds:)*} - // function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \ + // function -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \ // :return-type-uid:} - // unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>} - // gc box -> {GC_BOX<:pointee-uid:>} match self.type_to_unique_id.get(&type_).cloned() { Some(unique_type_id) => return unique_type_id, @@ -202,7 +200,7 @@ impl<'tcx> TypeMap<'tcx> { } }, ty::ty_uniq(inner_type) => { - unique_type_id.push('~'); + unique_type_id.push_str("Box "); let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type); let inner_type_id = self.get_unique_type_id_as_string(inner_type_id); unique_type_id.push_str(&inner_type_id[..]); From d3667746d417228f551a91886b7215c9e3038056 Mon Sep 17 00:00:00 2001 From: Carol Nichols <carol.nichols@gmail.com> Date: Sat, 2 May 2015 16:28:53 -0400 Subject: [PATCH 05/21] Update tests to not use old ~ syntax --- src/test/debuginfo/issue11600.rs | 2 +- src/test/run-pass/issue-4241.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/debuginfo/issue11600.rs b/src/test/debuginfo/issue11600.rs index b79cba7aa6971..dea2a0c5a23f8 100644 --- a/src/test/debuginfo/issue11600.rs +++ b/src/test/debuginfo/issue11600.rs @@ -13,7 +13,7 @@ // ignore-test fn main() { - let args : ~[String] = ::std::os::args(); + let args : Vec<String> = ::std::os::args(); ::std::io::println(args[0]); } diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index c9b684fd65694..ab75c2064a403 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -22,8 +22,8 @@ use std::io::{ReaderUtil,WriterUtil}; enum Result { Nil, Int(isize), - Data(~[u8]), - List(~[Result]), + Data(Vec<u8>), + List(Vec<Result>), Error(String), Status(String) } @@ -35,7 +35,7 @@ fn parse_data(len: usize, io: @io::Reader) -> Result { assert_eq!(bytes.len(), len); Data(bytes) } else { - Data(~[]) + Data(vec![]) }; assert_eq!(io.read_char(), '\r'); assert_eq!(io.read_char(), '\n'); @@ -43,7 +43,7 @@ fn parse_data(len: usize, io: @io::Reader) -> Result { } fn parse_list(len: usize, io: @io::Reader) -> Result { - let mut list: ~[Result] = ~[]; + let mut list: Vec<Result> = vec![]; for _ in 0..len { let v = match io.read_char() { '$' => parse_bulk(io), @@ -72,7 +72,7 @@ fn parse_multi(io: @io::Reader) -> Result { match from_str::<isize>(chop(io.read_line())) { None => panic!(), Some(-1) => Nil, - Some(0) => List(~[]), + Some(0) => List(vec![]), Some(len) if len >= 0 => parse_list(len as usize, io), Some(_) => panic!() } @@ -96,7 +96,7 @@ fn parse_response(io: @io::Reader) -> Result { } } -fn cmd_to_string(cmd: ~[String]) -> String { +fn cmd_to_string(cmd: Vec<String>) -> String { let mut res = "*".to_string(); res.push_str(cmd.len().to_string()); res.push_str("\r\n"); @@ -107,7 +107,7 @@ fn cmd_to_string(cmd: ~[String]) -> String { res } -fn query(cmd: ~[String], sb: TcpSocketBuf) -> Result { +fn query(cmd: Vec<String>, sb: TcpSocketBuf) -> Result { let cmd = cmd_to_string(cmd); //println!("{}", cmd); sb.write_str(cmd); @@ -115,7 +115,7 @@ fn query(cmd: ~[String], sb: TcpSocketBuf) -> Result { res } -fn query2(cmd: ~[String]) -> Result { +fn query2(cmd: Vec<String>) -> Result { let _cmd = cmd_to_string(cmd); io::with_str_reader("$3\r\nXXX\r\n".to_string())(|sb| { let res = parse_response(@sb as @io::Reader); From 55e7f9b7d680d8085765c7c659351d3efe09ffb8 Mon Sep 17 00:00:00 2001 From: Carol Nichols <carol.nichols@gmail.com> Date: Mon, 4 May 2015 21:33:51 -0400 Subject: [PATCH 06/21] Changing Vec to Box<[T]> --- src/librustc/middle/expr_use_visitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 359ea02c1d74f..0458bd70346c1 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -1125,7 +1125,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { // that case we can adjust the length of the // original vec accordingly, but we'd have to // make trans do the right thing, and it would - // only work for `Vec`s. It seems simpler + // only work for `Box<[T]>`s. It seems simpler // to just require that people call // `vec.pop()` or `vec.unshift()`. let slice_bk = ty::BorrowKind::from_mutbl(slice_mutbl); From 77acf7b4ee533bf0d84ee5097dfb6676e2f4360e Mon Sep 17 00:00:00 2001 From: Carol Nichols <carol.nichols@gmail.com> Date: Mon, 4 May 2015 21:43:11 -0400 Subject: [PATCH 07/21] Use the lowercase version of the box syntax --- src/librustc_trans/trans/debuginfo/metadata.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 29c22c8c9f712..bd04bd7a75460 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -151,7 +151,7 @@ impl<'tcx> TypeMap<'tcx> { // mut reference (&mut) -> {&mut :pointee-uid:} // ptr (*) -> {* :pointee-uid:} // mut ptr (*mut) -> {*mut :pointee-uid:} - // unique ptr (Box) -> {Box :pointee-uid:} + // unique ptr (box) -> {box :pointee-uid:} // @-ptr (@) -> {@ :pointee-uid:} // sized vec ([T; x]) -> {[:size:] :element-uid:} // unsized vec ([T]) -> {[] :element-uid:} @@ -200,7 +200,7 @@ impl<'tcx> TypeMap<'tcx> { } }, ty::ty_uniq(inner_type) => { - unique_type_id.push_str("Box "); + unique_type_id.push_str("box "); let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type); let inner_type_id = self.get_unique_type_id_as_string(inner_type_id); unique_type_id.push_str(&inner_type_id[..]); From abc0017f3b2308c3bff2a975d4e33b53c2f52bdb Mon Sep 17 00:00:00 2001 From: Carol Nichols <carol.nichols@gmail.com> Date: Mon, 4 May 2015 21:44:22 -0400 Subject: [PATCH 08/21] Remove an obsolete example in a comment --- src/librustc_trans/back/link.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 49e336c670078..e97f8d9be1274 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -288,7 +288,7 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(path: PI, // when using unix's linker. Perhaps one day when we just use a linker from LLVM // we won't need to do this name mangling. The problem with name mangling is // that it seriously limits the available characters. For example we can't - // have things like &T or Vec<T> in symbol names when one would theoretically + // have things like &T in symbol names when one would theoretically // want them for things like impls of traits on that type. // // To be able to work on all platforms and get *some* reasonable output, we From 4d1e48e37610f421f30e098f2ae9ef98b85b66eb Mon Sep 17 00:00:00 2001 From: Tincan <tincann@users.noreply.github.com> Date: Thu, 7 May 2015 20:23:47 +0200 Subject: [PATCH 09/21] Typo in ownership.md --- src/doc/trpl/ownership.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index 3003156f875aa..a70f03739f773 100644 --- a/src/doc/trpl/ownership.md +++ b/src/doc/trpl/ownership.md @@ -3,7 +3,7 @@ This guide is one of three presenting Rust’s ownership system. This is one of Rust’s most unique and compelling features, with which Rust developers should become quite acquainted. Ownership is how Rust achieves its largest goal, -memory safety. The there are a few distinct concepts, each with its own +memory safety. There are a few distinct concepts, each with its own chapter: * ownership, which you’re reading now. From ae1b2f4bf3a5d9cee9227528b6df24decc20b977 Mon Sep 17 00:00:00 2001 From: Tincan <tincann@users.noreply.github.com> Date: Thu, 7 May 2015 21:31:10 +0200 Subject: [PATCH 10/21] Another typo --- src/doc/trpl/ownership.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index a70f03739f773..d994c1772755b 100644 --- a/src/doc/trpl/ownership.md +++ b/src/doc/trpl/ownership.md @@ -173,7 +173,7 @@ fn foo(v: Vec<i32>) -> Vec<i32> { } ``` -This would get very tedius. It gets worse the more things we want to take ownership of: +This would get very tedious. It gets worse the more things we want to take ownership of: ```rust fn foo(v1: Vec<i32>, v2: Vec<i32>) -> (Vec<i32>, Vec<i32>, i32) { From 7a91fe845c7ee6e78f6b9f5846541fdc1785687a Mon Sep 17 00:00:00 2001 From: Sindre Johansen <sindre@sindrejohansen.no> Date: Sat, 9 May 2015 12:59:24 +0200 Subject: [PATCH 11/21] Fixed a typo. Removed an extra s --- src/doc/trpl/primitive-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index e017e222c7417..f0f57c3ab5858 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -176,7 +176,7 @@ Slices have type `&[T]`. We’ll talk about that `T` when we cover [generics]: generics.html -You can find more documentation for `slices`s [in the standard library +You can find more documentation for `slices` [in the standard library documentation][slice]. [slice]: ../std/primitive.slice.html From 1e9ce0d50564b872d12457da59911838eb21b760 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup <root@localhost> Date: Sat, 9 May 2015 13:27:23 +0200 Subject: [PATCH 12/21] std: Add example for HashMap::entry() --- src/libstd/collections/hash/map.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index eedda3cf4371a..ae75de2086b77 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -916,6 +916,24 @@ impl<K, V, S> HashMap<K, V, S> } /// Gets the given key's corresponding entry in the map for in-place manipulation. + /// + /// # Examples + /// + /// ``` + /// use std::collections::HashMap; + /// + /// let mut letters = HashMap::new(); + /// + /// for ch in "a short treatise on fungi".chars() { + /// let counter = letters.entry(ch).or_insert(0); + /// *counter += 1; + /// } + /// + /// assert_eq!(letters[&'s'], 2); + /// assert_eq!(letters[&'t'], 3); + /// assert_eq!(letters[&'u'], 1); + /// assert_eq!(letters.get(&'y'), None); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn entry(&mut self, key: K) -> Entry<K, V> { // Gotta resize now. From 7a2ac0cd5ae44e84a15264888427f007f895946e Mon Sep 17 00:00:00 2001 From: Sindre Johansen <sindre@sindrejohansen.no> Date: Sat, 9 May 2015 13:34:49 +0200 Subject: [PATCH 13/21] Added start of last text block The start of the last text block in references was missing, I added it. --- src/doc/trpl/references-and-borrowing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/trpl/references-and-borrowing.md b/src/doc/trpl/references-and-borrowing.md index 8bb3f94760bc9..f428107ffc0ca 100644 --- a/src/doc/trpl/references-and-borrowing.md +++ b/src/doc/trpl/references-and-borrowing.md @@ -312,6 +312,7 @@ println!("{}", y); We get this error: +```text error: `x` does not live long enough y = &x; ^ From f8888af412b517c55deed84f851b3dc3c93d81d0 Mon Sep 17 00:00:00 2001 From: Don Petersen <don@donpetersen.net> Date: Sat, 9 May 2015 20:25:09 -0700 Subject: [PATCH 14/21] Add omitted word to mutability docs. --- src/doc/trpl/mutability.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/trpl/mutability.md b/src/doc/trpl/mutability.md index 435407a8a967d..9b386acdca214 100644 --- a/src/doc/trpl/mutability.md +++ b/src/doc/trpl/mutability.md @@ -78,8 +78,8 @@ When we call `clone()`, the `Arc<T>` needs to update the reference count. Yet we’ve not used any `mut`s here, `x` is an immutable binding, and we didn’t take `&mut 5` or anything. So what gives? -To this, we have to go back to the core of Rust’s guiding philosophy, memory -safety, and the mechanism by which Rust guarantees it, the +To understand this, we have to go back to the core of Rust’s guiding +philosophy, memory safety, and the mechanism by which Rust guarantees it, the [ownership][ownership] system, and more specifically, [borrowing][borrowing]: > You may have one or the other of these two kinds of borrows, but not both at From ae1b64ff7376859b3582441cd41218b5445da148 Mon Sep 17 00:00:00 2001 From: Don Petersen <don@donpetersen.net> Date: Sat, 9 May 2015 22:10:34 -0700 Subject: [PATCH 15/21] Fix typo in Match document. --- src/doc/trpl/match.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/match.md b/src/doc/trpl/match.md index 2c0c8ea73c03c..86b9445338966 100644 --- a/src/doc/trpl/match.md +++ b/src/doc/trpl/match.md @@ -50,7 +50,7 @@ side of a `let` binding or directly where an expression is used: ```rust let x = 5; -let numer = match x { +let number = match x { 1 => "one", 2 => "two", 3 => "three", From 2cc4d822dfada7395b67d83368a5bee44b50a5e2 Mon Sep 17 00:00:00 2001 From: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Date: Sun, 10 May 2015 08:02:06 +0200 Subject: [PATCH 16/21] Fix small typos in documentation --- src/doc/trpl/guessing-game.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index 57479a21e47a8..fc3927380fadb 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -711,7 +711,7 @@ variety of numbers, we need to give Rust a hint as to the exact type of number we want. Hence, `let guess: u32`. The colon (`:`) after `guess` tells Rust we’re going to annotate its type. `u32` is an unsigned, thirty-two bit integer. Rust has [a number of built-in number types][number], but we’ve -chosen `u32`. It’s a good default choice for a small positive numer. +chosen `u32`. It’s a good default choice for a small positive number. [parse]: ../std/primitive.str.html#method.parse [number]: primitive-types.html#numeric-types @@ -920,7 +920,7 @@ failure. Each contains more information: the successful parsed integer, or an error type. In this case, we `match` on `Ok(num)`, which sets the inner value of the `Ok` to the name `num`, and then we just return it on the right-hand side. In the `Err` case, we don’t care what kind of error it is, so we just -use `_` intead of a name. This ignores the error, and `continue` causes us +use `_` instead of a name. This ignores the error, and `continue` causes us to go to the next iteration of the `loop`. Now we should be good! Let’s try: From 8ad1c90db0670c763fec0f1d5cfc0303bc28fb77 Mon Sep 17 00:00:00 2001 From: Sindre Johansen <sindre@sindrejohansen.no> Date: Sun, 10 May 2015 11:16:32 +0200 Subject: [PATCH 17/21] Removed the backticks on slices --- src/doc/trpl/primitive-types.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index f0f57c3ab5858..bb2bf028700d2 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -176,7 +176,7 @@ Slices have type `&[T]`. We’ll talk about that `T` when we cover [generics]: generics.html -You can find more documentation for `slices` [in the standard library +You can find more documentation for slices [in the standard library documentation][slice]. [slice]: ../std/primitive.slice.html From dcdc50dd35eb792192ca4b1595b7cf3f34318a39 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe <tshepang@gmail.com> Date: Sun, 10 May 2015 13:32:31 +0200 Subject: [PATCH 18/21] doc: unwrap is discouraged, so use Some --- src/libcore/iter.rs | 84 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index e4d2ab198630a..838480c88895c 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -137,7 +137,7 @@ pub trait Iterator { /// /// ``` /// let a = [1, 2, 3, 4, 5]; - /// assert_eq!(a.iter().last().unwrap(), &5); + /// assert_eq!(a.iter().last(), Some(&5)); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -155,7 +155,7 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert_eq!(it.nth(2).unwrap(), &3); + /// assert_eq!(it.nth(2), Some(&3)); /// assert_eq!(it.nth(2), None); /// ``` #[inline] @@ -178,8 +178,8 @@ pub trait Iterator { /// let a = [0]; /// let b = [1]; /// let mut it = a.iter().chain(b.iter()); - /// assert_eq!(it.next().unwrap(), &0); - /// assert_eq!(it.next().unwrap(), &1); + /// assert_eq!(it.next(), Some(&0)); + /// assert_eq!(it.next(), Some(&1)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -201,7 +201,7 @@ pub trait Iterator { /// let a = [0]; /// let b = [1]; /// let mut it = a.iter().zip(b.iter()); - /// assert_eq!(it.next().unwrap(), (&0, &1)); + /// assert_eq!(it.next(), Some((&0, &1))); /// assert!(it.next().is_none()); /// ``` /// @@ -234,8 +234,8 @@ pub trait Iterator { /// ``` /// let a = [1, 2]; /// let mut it = a.iter().map(|&x| 2 * x); - /// assert_eq!(it.next().unwrap(), 2); - /// assert_eq!(it.next().unwrap(), 4); + /// assert_eq!(it.next(), Some(2)); + /// assert_eq!(it.next(), Some(4)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -255,7 +255,7 @@ pub trait Iterator { /// ``` /// let a = [1, 2]; /// let mut it = a.iter().filter(|&x| *x > 1); - /// assert_eq!(it.next().unwrap(), &2); + /// assert_eq!(it.next(), Some(&2)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -275,7 +275,7 @@ pub trait Iterator { /// ``` /// let a = [1, 2]; /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None}); - /// assert_eq!(it.next().unwrap(), 4); + /// assert_eq!(it.next(), Some(4)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -310,8 +310,8 @@ pub trait Iterator { /// ``` /// let a = [100, 200]; /// let mut it = a.iter().enumerate(); - /// assert_eq!(it.next().unwrap(), (0, &100)); - /// assert_eq!(it.next().unwrap(), (1, &200)); + /// assert_eq!(it.next(), Some((0, &100))); + /// assert_eq!(it.next(), Some((1, &200))); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -329,12 +329,12 @@ pub trait Iterator { /// # #![feature(core)] /// let xs = [100, 200, 300]; /// let mut it = xs.iter().cloned().peekable(); - /// assert_eq!(*it.peek().unwrap(), 100); - /// assert_eq!(it.next().unwrap(), 100); - /// assert_eq!(it.next().unwrap(), 200); - /// assert_eq!(*it.peek().unwrap(), 300); - /// assert_eq!(*it.peek().unwrap(), 300); - /// assert_eq!(it.next().unwrap(), 300); + /// assert_eq!(*it.peek(), Some(100)); + /// assert_eq!(it.next(), Some(100)); + /// assert_eq!(it.next(), Some(200)); + /// assert_eq!(*it.peek(), Some(300)); + /// assert_eq!(*it.peek(), Some(300)); + /// assert_eq!(it.next(), Some(300)); /// assert!(it.peek().is_none()); /// assert!(it.next().is_none()); /// ``` @@ -353,9 +353,9 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().skip_while(|&a| *a < 3); - /// assert_eq!(it.next().unwrap(), &3); - /// assert_eq!(it.next().unwrap(), &4); - /// assert_eq!(it.next().unwrap(), &5); + /// assert_eq!(it.next(), Some(&3)); + /// assert_eq!(it.next(), Some(&4)); + /// assert_eq!(it.next(), Some(&5)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -375,8 +375,8 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().take_while(|&a| *a < 3); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.next().unwrap(), &2); + /// assert_eq!(it.next(), Some(&1)); + /// assert_eq!(it.next(), Some(&2)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -395,8 +395,8 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().skip(3); - /// assert_eq!(it.next().unwrap(), &4); - /// assert_eq!(it.next().unwrap(), &5); + /// assert_eq!(it.next(), Some(&4)); + /// assert_eq!(it.next(), Some(&5)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -413,9 +413,9 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().take(3); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.next().unwrap(), &2); - /// assert_eq!(it.next().unwrap(), &3); + /// assert_eq!(it.next(), Some(&1)); + /// assert_eq!(it.next(), Some(&2)); + /// assert_eq!(it.next(), Some(&3)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -437,11 +437,11 @@ pub trait Iterator { /// *fac = *fac * x; /// Some(*fac) /// }); - /// assert_eq!(it.next().unwrap(), 1); - /// assert_eq!(it.next().unwrap(), 2); - /// assert_eq!(it.next().unwrap(), 6); - /// assert_eq!(it.next().unwrap(), 24); - /// assert_eq!(it.next().unwrap(), 120); + /// assert_eq!(it.next(), Some(1)); + /// assert_eq!(it.next(), Some(2)); + /// assert_eq!(it.next(), Some(6)); + /// assert_eq!(it.next(), Some(24)); + /// assert_eq!(it.next(), Some(120)); /// assert!(it.next().is_none()); /// ``` #[inline] @@ -680,7 +680,7 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3); + /// assert_eq!(it.find(|&x| *x == 3), Some(&3)); /// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]); #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -715,7 +715,7 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert_eq!(it.position(|x| *x == 3).unwrap(), 2); + /// assert_eq!(it.position(|x| *x == 3), Some(2)); /// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]); #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -743,7 +743,7 @@ pub trait Iterator { /// ``` /// let a = [1, 2, 2, 4, 5]; /// let mut it = a.iter(); - /// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2); + /// assert_eq!(it.rposition(|x| *x == 2), Some(2)); /// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]); #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -773,7 +773,7 @@ pub trait Iterator { /// /// ``` /// let a = [1, 2, 3, 4, 5]; - /// assert_eq!(a.iter().max().unwrap(), &5); + /// assert_eq!(a.iter().max(), Some(&5)); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -796,7 +796,7 @@ pub trait Iterator { /// /// ``` /// let a = [1, 2, 3, 4, 5]; - /// assert_eq!(a.iter().min().unwrap(), &1); + /// assert_eq!(a.iter().min(), Some(&1)); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -900,7 +900,7 @@ pub trait Iterator { /// # #![feature(core)] /// /// let a = [-3_i32, 0, 1, 5, -10]; - /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10); + /// assert_eq!(*a.iter().max_by(|x| x.abs()), Some(-10)); /// ``` #[inline] #[unstable(feature = "core", @@ -929,7 +929,7 @@ pub trait Iterator { /// # #![feature(core)] /// /// let a = [-3_i32, 0, 1, 5, -10]; - /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0); + /// assert_eq!(*a.iter().min_by(|x| x.abs()), Some(0)); /// ``` #[inline] #[unstable(feature = "core", @@ -1025,9 +1025,9 @@ pub trait Iterator { /// ``` /// let a = [1, 2]; /// let mut it = a.iter().cycle(); - /// assert_eq!(it.next().unwrap(), &1); - /// assert_eq!(it.next().unwrap(), &2); - /// assert_eq!(it.next().unwrap(), &1); + /// assert_eq!(it.next(), Some(&1)); + /// assert_eq!(it.next(), Some(&2)); + /// assert_eq!(it.next(), Some(&1)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] From a168dbad15e108fce02a996fc8f72803460b7a55 Mon Sep 17 00:00:00 2001 From: Jan Bujak <j@exia.io> Date: Sun, 10 May 2015 14:06:41 +0200 Subject: [PATCH 19/21] Add #[inline] to AsRef<str>::as_ref for String and str. --- src/libcollections/string.rs | 1 + src/libcore/convert.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 3c668f7fe9bc6..bb5345917e713 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1052,6 +1052,7 @@ impl<T: fmt::Display + ?Sized> ToString for T { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<str> for String { + #[inline] fn as_ref(&self) -> &str { self } diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index d3de77a9241e3..da6ac6bd752bf 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -173,6 +173,7 @@ impl<T> AsMut<[T]> for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<str> for str { + #[inline] fn as_ref(&self) -> &str { self } From 5613502a4f3476e5db2c68bdf203104556796630 Mon Sep 17 00:00:00 2001 From: Nick Platt <platt.nicholas@gmail.com> Date: Sat, 9 May 2015 23:18:28 -0400 Subject: [PATCH 20/21] Add long diagnostic for E0067 --- src/librustc_typeck/diagnostics.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 0e6386618f17b..2cc1b23e03ec3 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -46,6 +46,23 @@ enum variant, one of the fields was not provided. Each field should be specified exactly once. "##, +E0067: r##" +The left-hand side of an assignment operator must be an lvalue expression. An +lvalue expression represents a memory location and includes item paths (ie, +namespaced variables), dereferences, indexing expressions, and field references. + +``` +use std::collections::LinkedList; + +// Good +let mut list = LinkedList::new(); + + +// Bad: assignment to non-lvalue expression +LinkedList::new() += 1; +``` +"##, + E0081: r##" Enum discriminants are used to differentiate enum variants stored in memory. This error indicates that the same value was used for two or more variants, @@ -149,7 +166,6 @@ register_diagnostics! { E0060, E0061, E0066, - E0067, E0068, E0069, E0070, From ffc0d0448917c1f225a3500bf3a1dc6fc40029d7 Mon Sep 17 00:00:00 2001 From: Nick Platt <platt.nicholas@gmail.com> Date: Sat, 9 May 2015 23:20:14 -0400 Subject: [PATCH 21/21] Add long diagnostic for E0131, E0132 --- src/librustc_typeck/diagnostics.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 2cc1b23e03ec3..026ba3d08b42b 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -136,6 +136,20 @@ construct an instance of the following type using only safe code: ``` enum Empty {} ``` +"##, + +E0131: r##" +It is not possible to define `main` with type parameters, or even with function +parameters. When `main` is present, it must take no arguments and return `()`. +"##, + +E0132: r##" +It is not possible to declare type parameters on a function that has the `start` +attribute. Such a function must have the following type signature: + +``` +fn(isize, *const *const u8) -> isize +``` "## } @@ -205,8 +219,6 @@ register_diagnostics! { E0128, E0129, E0130, - E0131, - E0132, E0141, E0159, E0163,