diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index 50767b603c46c..12dd087f20c09 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -713,7 +713,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 @@ -922,7 +922,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: 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", 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` 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 diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index fba5226ca2ed9..971bb7cd700db 100644 --- a/src/doc/trpl/ownership.md +++ b/src/doc/trpl/ownership.md @@ -174,7 +174,7 @@ fn foo(v: Vec) -> Vec { } ``` -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, v2: Vec) -> (Vec, Vec, i32) { diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index e017e222c7417..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`s [in the standard library +You can find more documentation for slices [in the standard library documentation][slice]. [slice]: ../std/primitive.slice.html 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; ^ diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index 036a2f7d4365b..74837a06faecd 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -1,6 +1,8 @@ # 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 * [rust.vim](https://github.com/rust-lang/rust.vim) * [emacs rust-mode](https://github.com/rust-lang/rust-mode) @@ -8,3 +10,7 @@ Here are some links to repos with configs which ease the use of rust: * [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/)) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 52d72501b4a9b..28e476742911b 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1052,6 +1052,7 @@ impl ToString for T { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef 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 AsMut<[T]> for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl AsRef for str { + #[inline] fn as_ref(&self) -> &str { self } 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::>(), [&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::>(), [&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::>(), [&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] diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index d740d24e23672..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 `~` vectors. 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); 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 + ty::ty_uniq(_) => { // Box 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 Foo for ~T { ... } + /// impl Foo for Box { ... } /// - /// 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`, 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 { } } -// This is necessary to handle types like Option<~[T]>, for which +// This is necessary to handle types like Option>, for which // autoderef cannot convert the &[T] handler impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec { 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; /// (*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` 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 a11b0f69faadf..38ad909dd012e 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -289,7 +289,7 @@ pub fn mangle>(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 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> - // 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 + // Nesting = 1: idents within one level of brackets: Vec pub fn spans_with_brackets(&self, span: Span, nesting: isize, limit: isize) -> Vec { let mut result: Vec = 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> + // i.e. we want Vec from Foo> self.spans_with_brackets(span, 1, number) } diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/trans/attributes.rs index b32181426a33e..132947e34d795 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::NoAlias); @@ -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::ZExt); } - // `~` 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_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 9ff69e7f9dd29..bd04bd7a75460 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 -> { :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 -> { :store-sigil: |(:param-uid:),* <,_...>| -> \ // :return-type-uid: : (:bounds:)*} - // function -> { fn( (:param-uid:)* <,_...> ) -> \ + // function -> { 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[..]); 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 for ~[(A,B)]` +// declared on the impl declaration e.g., `impl 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/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 0e6386618f17b..026ba3d08b42b 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, @@ -119,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 +``` "## } @@ -149,7 +180,6 @@ register_diagnostics! { E0060, E0061, E0066, - E0067, E0068, E0069, E0070, @@ -189,8 +219,6 @@ register_diagnostics! { E0128, E0129, E0130, - E0131, - E0132, E0141, E0159, E0163, 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::(v); +//! let mut vector = vec!["string", ...]; +//! convertAll::(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 444e5dea89a46..4c2357f8a8f0d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -897,7 +897,7 @@ impl<'tcx> Clean for ty::ProjectionTy<'tcx> { } } -// maybe use a Generic enum and use ~[Generic]? +// maybe use a Generic enum and use Vec? #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Debug)] pub struct Generics { pub lifetimes: Vec, diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 9b824f11b9268..48f65a5abfd45 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -916,6 +916,24 @@ impl HashMap } /// 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 { // Gotta resize now. diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index e36631210d4da..f7511f9753aa1 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]) -> P { - 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 c3f1b9748155f..05499959b7585 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1692,7 +1692,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 4d0b746c60c75..00ef8760985be 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -259,8 +259,8 @@ pub fn test_main(args: &[String], tests: Vec ) { // 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 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::>(); 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::>(); //~ ERROR `core::marker::Copy` is not implemented assert_copy::(); //~ ERROR `core::marker::Copy` is not implemented assert_copy:: >(); //~ ERROR `core::marker::Copy` is not implemented diff --git a/src/test/debuginfo/issue11600.rs b/src/test/debuginfo/issue11600.rs index e93704cac34c2..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 = ::std::os::args(); ::std::io::println(args[0]); } @@ -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 = ::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, 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), + List(Vec), 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 = 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::(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 { 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, 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) -> 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);