From a4c133777e33754137d8a097a0c932cfc45ec8a5 Mon Sep 17 00:00:00 2001 From: Jannis Redmann Date: Wed, 29 Apr 2015 17:55:14 +0200 Subject: [PATCH 01/24] 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 Date: Wed, 29 Apr 2015 18:53:36 +0200 Subject: [PATCH 02/24] 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 4d1e48e37610f421f30e098f2ae9ef98b85b66eb Mon Sep 17 00:00:00 2001 From: Tincan Date: Thu, 7 May 2015 20:23:47 +0200 Subject: [PATCH 03/24] 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 Date: Thu, 7 May 2015 21:31:10 +0200 Subject: [PATCH 04/24] 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) -> 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) { From 96229e82985054a7b1f95732605eeeda69bf71b9 Mon Sep 17 00:00:00 2001 From: llogiq Date: Fri, 8 May 2015 13:26:45 +0200 Subject: [PATCH 05/24] fixed ICE issue #25180 --- src/librustc/middle/check_const.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 8bb83c54da8a3..195f4f4b69568 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -251,9 +251,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { b: &'v ast::Block, s: Span, fn_id: ast::NodeId) { - assert!(self.mode == Mode::Var); - self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); - visit::walk_fn(self, fk, fd, b, s); + let (old_mode, old_qualif) = (self.mode, self.qualif); + self.mode = Mode::Var; + self.qualif = ConstQualif::empty(); + self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); + visit::walk_fn(self, fk, fd, b, s); + self.mode = old_mode; + self.qualif = old_qualif; } fn visit_pat(&mut self, p: &ast::Pat) { @@ -275,7 +279,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { let node_ty = ty::node_id_to_type(self.tcx, ex.id); check_expr(self, ex, node_ty); - + // Special-case some expressions to avoid certain flags bubbling up. match ex.node { ast::ExprCall(ref callee, ref args) => { From 29daa29981e89ba7f71dcbba06166f8c54f4682d Mon Sep 17 00:00:00 2001 From: llogiq Date: Fri, 8 May 2015 13:56:14 +0200 Subject: [PATCH 06/24] formatting correction --- src/librustc/middle/check_const.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 195f4f4b69568..2322b97de1487 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -254,10 +254,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { let (old_mode, old_qualif) = (self.mode, self.qualif); self.mode = Mode::Var; self.qualif = ConstQualif::empty(); - self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); - visit::walk_fn(self, fk, fd, b, s); - self.mode = old_mode; - self.qualif = old_qualif; + self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); + visit::walk_fn(self, fk, fd, b, s); + self.mode = old_mode; + self.qualif = old_qualif; } fn visit_pat(&mut self, p: &ast::Pat) { @@ -279,7 +279,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { let node_ty = ty::node_id_to_type(self.tcx, ex.id); check_expr(self, ex, node_ty); - + // Special-case some expressions to avoid certain flags bubbling up. match ex.node { ast::ExprCall(ref callee, ref args) => { From 1434715550c372f83ab3a138d66674d5b303d429 Mon Sep 17 00:00:00 2001 From: llogiq Date: Fri, 8 May 2015 17:07:03 +0200 Subject: [PATCH 07/24] crossed the i-s and dotted the t-s ;-) Also added a run-pass test and removed the with_mode copy, thanks to eddyb --- src/librustc/middle/check_const.rs | 8 ++------ src/test/run-pass/issue-25180.rs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 src/test/run-pass/issue-25180.rs diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 2322b97de1487..d48d2abc660f6 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -251,13 +251,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { b: &'v ast::Block, s: Span, fn_id: ast::NodeId) { - let (old_mode, old_qualif) = (self.mode, self.qualif); - self.mode = Mode::Var; - self.qualif = ConstQualif::empty(); - self.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); + self.with_mode(Mode::Var, |v| v.with_euv(Some(fn_id), + |euv| euv.walk_fn(fd, b))); visit::walk_fn(self, fk, fd, b, s); - self.mode = old_mode; - self.qualif = old_qualif; } fn visit_pat(&mut self, p: &ast::Pat) { diff --git a/src/test/run-pass/issue-25180.rs b/src/test/run-pass/issue-25180.rs new file mode 100644 index 0000000000000..3955e451639fd --- /dev/null +++ b/src/test/run-pass/issue-25180.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// pretty-expanded FIXME #25180 + +const x: &'static Fn() = &|| println!("ICE here"); + +fn main() {} + From 715f7c3cd2af3d54ef79d75fe7b1e820853f08ea Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 8 May 2015 23:54:24 +0200 Subject: [PATCH 08/24] Add a precision for references --- src/doc/trpl/references-and-borrowing.md | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/doc/trpl/references-and-borrowing.md b/src/doc/trpl/references-and-borrowing.md index 21feff73342ce..06ff9bfbc55d9 100644 --- a/src/doc/trpl/references-and-borrowing.md +++ b/src/doc/trpl/references-and-borrowing.md @@ -334,3 +334,35 @@ In other words, `y` is only valid for the scope where `x` exists. As soon as `x` goes away, it becomes invalid to refer to it. As such, the error says that the borrow ‘doesn’t live long enough’ because it’s not valid for the right amount of time. + +The same problem occurs when the reference is declared _before_ the variable it refers to: + +```rust,ignore +let y: &i32; +let x = 5; +y = &x; + +println!("{}", y); +``` + +We get this error: + +error: `x` does not live long enough +y = &x; + ^ +note: reference must be valid for the block suffix following statement 0 at +2:16... + let y: &i32; + let x = 5; + y = &x; + + println!("{}", y); +} + +note: ...but borrowed value is only valid for the block suffix following +statement 1 at 3:14 + let x = 5; + y = &x; + + println!("{}", y); +} From 7a91fe845c7ee6e78f6b9f5846541fdc1785687a Mon Sep 17 00:00:00 2001 From: Sindre Johansen Date: Sat, 9 May 2015 12:59:24 +0200 Subject: [PATCH 09/24] 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 Date: Sat, 9 May 2015 13:27:23 +0200 Subject: [PATCH 10/24] 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 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. From 7a2ac0cd5ae44e84a15264888427f007f895946e Mon Sep 17 00:00:00 2001 From: Sindre Johansen Date: Sat, 9 May 2015 13:34:49 +0200 Subject: [PATCH 11/24] 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 ca5c694f439fdb86bd7314b7daaa56994e33c761 Mon Sep 17 00:00:00 2001 From: llogiq Date: Sun, 10 May 2015 04:39:51 +0200 Subject: [PATCH 12/24] Pulled walk_fn() into Var mode, extended test --- src/librustc/middle/check_const.rs | 7 ++++--- src/test/run-pass/issue-25180.rs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index d48d2abc660f6..89a93f990df63 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -251,9 +251,10 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { b: &'v ast::Block, s: Span, fn_id: ast::NodeId) { - self.with_mode(Mode::Var, |v| v.with_euv(Some(fn_id), - |euv| euv.walk_fn(fd, b))); - visit::walk_fn(self, fk, fd, b, s); + self.with_mode(Mode::Var, |v| { + v.with_euv(Some(fn_id), |euv| euv.walk_fn(fd, b)); + visit::walk_fn(v, fk, fd, b, s); + }) } fn visit_pat(&mut self, p: &ast::Pat) { diff --git a/src/test/run-pass/issue-25180.rs b/src/test/run-pass/issue-25180.rs index 3955e451639fd..d63c50192426b 100644 --- a/src/test/run-pass/issue-25180.rs +++ b/src/test/run-pass/issue-25180.rs @@ -12,5 +12,7 @@ const x: &'static Fn() = &|| println!("ICE here"); -fn main() {} +fn main() { + x() +} From f8888af412b517c55deed84f851b3dc3c93d81d0 Mon Sep 17 00:00:00 2001 From: Don Petersen Date: Sat, 9 May 2015 20:25:09 -0700 Subject: [PATCH 13/24] 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` 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 Date: Sat, 9 May 2015 22:10:34 -0700 Subject: [PATCH 14/24] 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 Date: Sun, 10 May 2015 08:02:06 +0200 Subject: [PATCH 15/24] 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 Date: Sun, 10 May 2015 11:16:32 +0200 Subject: [PATCH 16/24] 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 6e19cfacf42e2de001de4c2133a4321b5286f523 Mon Sep 17 00:00:00 2001 From: llogiq Date: Sun, 10 May 2015 11:57:52 +0200 Subject: [PATCH 17/24] more tests --- src/test/run-pass/issue-25180.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/test/run-pass/issue-25180.rs b/src/test/run-pass/issue-25180.rs index d63c50192426b..0ad5fd87e9566 100644 --- a/src/test/run-pass/issue-25180.rs +++ b/src/test/run-pass/issue-25180.rs @@ -10,9 +10,21 @@ // pretty-expanded FIXME #25180 -const x: &'static Fn() = &|| println!("ICE here"); +const empty: &'static Fn() = &|| println!("ICE here"); -fn main() { - x() +const one_argument: &'static Fn(u32) = &|y| println("{}", y); + +const plus_21: &'static Fn(u32) -> u32 = |y| y + 21; + +const multi_and_local: &'static Fn(u32, u32) -> u32 = |x, y| { + let tmp = x + y; + tmp * 2; +}; + +pub fn main() { + empty(); + one_argument(42); + assert!(plus_21(21) == 42); + assert!(multi_and_local(1, 2) == 6); } From a18ce4d47979260001e9be0a92f887e3abd4eb88 Mon Sep 17 00:00:00 2001 From: llogiq Date: Sun, 10 May 2015 12:30:06 +0200 Subject: [PATCH 18/24] fixed errors in test code --- src/test/run-pass/issue-25180.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/test/run-pass/issue-25180.rs b/src/test/run-pass/issue-25180.rs index 0ad5fd87e9566..9d2d51264e6fa 100644 --- a/src/test/run-pass/issue-25180.rs +++ b/src/test/run-pass/issue-25180.rs @@ -10,21 +10,21 @@ // pretty-expanded FIXME #25180 -const empty: &'static Fn() = &|| println!("ICE here"); +const EMPTY: &'static Fn() = &|| println!("ICE here"); -const one_argument: &'static Fn(u32) = &|y| println("{}", y); +const ONE_ARGUMENT: &'static Fn(u32) = &|y| println!("{}", y); -const plus_21: &'static Fn(u32) -> u32 = |y| y + 21; +const PLUS_21: &'static (Fn(u32) -> u32) = &|y| y + 21; -const multi_and_local: &'static Fn(u32, u32) -> u32 = |x, y| { +const MULTI_AND_LOCAL: &'static (Fn(u32, u32) -> u32) = &|x, y| { let tmp = x + y; - tmp * 2; + tmp * 2 }; pub fn main() { - empty(); - one_argument(42); - assert!(plus_21(21) == 42); - assert!(multi_and_local(1, 2) == 6); + EMPTY(); + ONE_ARGUMENT(42); + assert!(PLUS_21(21) == 42); + assert!(MULTI_AND_LOCAL(1, 2) == 6); } From a168dbad15e108fce02a996fc8f72803460b7a55 Mon Sep 17 00:00:00 2001 From: Jan Bujak Date: Sun, 10 May 2015 14:06:41 +0200 Subject: [PATCH 19/24] Add #[inline] to AsRef::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 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 } From 5613502a4f3476e5db2c68bdf203104556796630 Mon Sep 17 00:00:00 2001 From: Nick Platt Date: Sat, 9 May 2015 23:18:28 -0400 Subject: [PATCH 20/24] 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 Date: Sat, 9 May 2015 23:20:14 -0400 Subject: [PATCH 21/24] 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, From 25543f38e437f959298238790a3737ff44ab5baf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 10 May 2015 21:05:04 +0200 Subject: [PATCH 22/24] Add missing backticks --- src/doc/trpl/references-and-borrowing.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/trpl/references-and-borrowing.md b/src/doc/trpl/references-and-borrowing.md index 06ff9bfbc55d9..82533becef342 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; ^ @@ -347,6 +348,7 @@ println!("{}", y); We get this error: +```text error: `x` does not live long enough y = &x; ^ @@ -366,3 +368,4 @@ statement 1 at 3:14 println!("{}", y); } +``` \ No newline at end of file From 0c390d2f8e1cc2f29d9c1088387d375a929356a5 Mon Sep 17 00:00:00 2001 From: Alexander Polakov Date: Sun, 10 May 2015 22:37:06 +0300 Subject: [PATCH 23/24] point supposed to be immutable in this example --- src/doc/trpl/mutability.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/mutability.md b/src/doc/trpl/mutability.md index 435407a8a967d..3e910aff9eafc 100644 --- a/src/doc/trpl/mutability.md +++ b/src/doc/trpl/mutability.md @@ -169,7 +169,7 @@ struct Point { y: Cell, } -let mut point = Point { x: 5, y: Cell::new(6) }; +let point = Point { x: 5, y: Cell::new(6) }; point.y.set(7); From 685f557729e3bb2691a81ac10074bddf4f61a0b6 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 10 May 2015 16:32:18 -0400 Subject: [PATCH 24/24] Update docs to stop referencing `BufReadExt` --- src/libstd/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 9089b417fcb99..e7b2b01d09f35 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -844,7 +844,7 @@ impl fmt::Display for CharsError { /// An iterator over the contents of an instance of `BufRead` split on a /// particular byte. /// -/// See `BufReadExt::split` for more information. +/// See `BufRead::split` for more information. #[stable(feature = "rust1", since = "1.0.0")] pub struct Split { buf: B, @@ -873,7 +873,7 @@ impl Iterator for Split { /// An iterator over the lines of an instance of `BufRead` split on a newline /// byte. /// -/// See `BufReadExt::lines` for more information. +/// See `BufRead::lines` for more information. #[stable(feature = "rust1", since = "1.0.0")] pub struct Lines { buf: B,