about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-05 11:01:42 +0000
committerbors <bors@rust-lang.org>2015-09-05 11:01:42 +0000
commit5c2cfdfb79d3be18ee50f5b5a60205d040c8396a (patch)
tree8cd038cf48b57efb6c5995c2bcf55db69897d168
parent6b36e921f4198f5afc1656db2d153f4f74a1fabe (diff)
parent1bf060ffb31ef6dc79543b4c10b975cd802020d0 (diff)
downloadrust-5c2cfdfb79d3be18ee50f5b5a60205d040c8396a.tar.gz
rust-5c2cfdfb79d3be18ee50f5b5a60205d040c8396a.zip
Auto merge of #28258 - Manishearth:rollup, r=Manishearth
- Successful merges: #28225, #28231, #28234, #28253
- Failed merges: 
-rw-r--r--src/doc/trpl/method-syntax.md16
-rw-r--r--src/librustc/diagnostics.rs20
-rw-r--r--src/librustc/middle/check_match.rs3
-rw-r--r--src/librustc_typeck/diagnostics.rs19
-rw-r--r--src/libstd/prelude/mod.rs4
5 files changed, 47 insertions, 15 deletions
diff --git a/src/doc/trpl/method-syntax.md b/src/doc/trpl/method-syntax.md
index 1afa622db7d..a2bdd66b0c2 100644
--- a/src/doc/trpl/method-syntax.md
+++ b/src/doc/trpl/method-syntax.md
@@ -7,7 +7,7 @@ can be awkward. Consider this code:
 baz(bar(foo));
 ```
 
-We would read this left-to right, and so we see ‘baz bar foo’. But this isn’t the
+We would read this left-to-right, and so we see ‘baz bar foo’. But this isn’t the
 order that the functions would get called in, that’s inside-out: ‘foo bar baz’.
 Wouldn’t it be nice if we could do this instead?
 
@@ -45,17 +45,17 @@ This will print `12.566371`.
 
 
 
-We’ve made a struct that represents a circle. We then write an `impl` block,
+We’ve made a `struct` that represents a circle. We then write an `impl` block,
 and inside it, define a method, `area`.
 
-Methods take a  special first parameter, of which there are three variants:
+Methods take a special first parameter, of which there are three variants:
 `self`, `&self`, and `&mut self`. You can think of this first parameter as
 being the `foo` in `foo.bar()`. The three variants correspond to the three
 kinds of things `foo` could be: `self` if it’s just a value on the stack,
 `&self` if it’s a reference, and `&mut self` if it’s a mutable reference.
 Because we took the `&self` parameter to `area`, we can use it just like any
 other parameter. Because we know it’s a `Circle`, we can access the `radius`
-just like we would with any other struct. 
+just like we would with any other `struct`. 
 
 We should default to using `&self`, as you should prefer borrowing over taking
 ownership, as well as taking immutable references over mutable ones. Here’s an
@@ -120,12 +120,12 @@ Check the return type:
 ```rust
 # struct Circle;
 # impl Circle {
-fn grow(&self) -> Circle {
+fn grow(&self, increment: f64) -> Circle {
 # Circle } }
 ```
 
 We just say we’re returning a `Circle`. With this method, we can grow a new
-circle to any arbitrary size.
+`Circle` to any arbitrary size.
 
 # Associated functions
 
@@ -161,7 +161,7 @@ methods’.
 
 # Builder Pattern
 
-Let’s say that we want our users to be able to create Circles, but we will
+Let’s say that we want our users to be able to create `Circle`s, but we will
 allow them to only set the properties they care about. Otherwise, the `x`
 and `y` attributes will be `0.0`, and the `radius` will be `1.0`. Rust doesn’t
 have method overloading, named arguments, or variable arguments. We employ
@@ -224,7 +224,7 @@ fn main() {
 }
 ```
 
-What we’ve done here is make another struct, `CircleBuilder`. We’ve defined our
+What we’ve done here is make another `struct`, `CircleBuilder`. We’ve defined our
 builder methods on it. We’ve also defined our `area()` method on `Circle`. We
 also made one more method on `CircleBuilder`: `finalize()`. This method creates
 our final `Circle` from the builder. Now, we’ve used the type system to enforce
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 696b38219f4..91845e916d4 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -44,7 +44,7 @@ E0002: r##"
 This error indicates that an empty match expression is invalid because the type
 it is matching on is non-empty (there exist values of this type). In safe code
 it is impossible to create an instance of an empty type, so empty match
-expressions are almost never desired.  This error is typically fixed by adding
+expressions are almost never desired. This error is typically fixed by adding
 one or more cases to the match expression.
 
 An example of an empty type is `enum Empty { }`. So, the following will work:
@@ -218,7 +218,14 @@ match x {
 E0010: r##"
 The value of statics and constants must be known at compile time, and they live
 for the entire lifetime of a program. Creating a boxed value allocates memory on
-the heap at runtime, and therefore cannot be done at compile time.
+the heap at runtime, and therefore cannot be done at compile time. Erroneous
+code example:
+
+```
+#![feature(box_syntax)]
+
+const CON : Box<i32> = box 0;
+```
 "##,
 
 E0011: r##"
@@ -335,7 +342,6 @@ is not allowed.
 
 If you really want global mutable state, try using `static mut` or a global
 `UnsafeCell`.
-
 "##,
 
 E0018: r##"
@@ -399,7 +405,13 @@ fn main() {
 
 E0020: r##"
 This error indicates that an attempt was made to divide by zero (or take the
-remainder of a zero divisor) in a static or constant expression.
+remainder of a zero divisor) in a static or constant expression. Erroneous
+code example:
+
+```
+const X: i32 = 42 / 0;
+// error: attempted to divide by zero in a constant expression
+```
 "##,
 
 E0022: r##"
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index 40025aa0b7b..8d592c92629 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -218,6 +218,9 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
                     span_err!(cx.tcx.sess, ex.span, E0002,
                               "non-exhaustive patterns: type {} is non-empty",
                               pat_ty);
+                    span_help!(cx.tcx.sess, ex.span,
+                        "Please ensure that all possible cases are being handled; \
+                         possibly adding wildcards or more match arms.");
                 }
                 // If the type *is* empty, it's vacuously exhaustive
                 return;
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index dfce7a9c315..8a2f8b1cf4b 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -2475,6 +2475,24 @@ struct Bar<S, T> { x: Foo<S, T> }
 ```
 "##,
 
+//NB: not currently reachable
+E0247: r##"
+This error indicates an attempt to use a module name where a type is expected.
+For example:
+
+```
+mod MyMod {
+    mod MySubMod { }
+}
+
+fn do_something(x: MyMod::MySubMod) { }
+```
+
+In this example, we're attempting to take a parameter of type `MyMod::MySubMod`
+in the do_something function. This is not legal: `MyMod::MySubMod` is a module
+name, not a type.
+"##,
+
 E0248: r##"
 This error indicates an attempt to use a value where a type is expected. For
 example:
@@ -3291,7 +3309,6 @@ register_diagnostics! {
     E0242, // internal error looking up a definition
     E0245, // not a trait
 //  E0246, // invalid recursive type
-    E0247, // found module name used as a type
 //  E0319, // trait impls for defaulted traits allowed just for structs/enums
     E0320, // recursive overflow during dropck
     E0321, // extended coherence rules for defaulted traits violated
diff --git a/src/libstd/prelude/mod.rs b/src/libstd/prelude/mod.rs
index 4597db41e90..82578172802 100644
--- a/src/libstd/prelude/mod.rs
+++ b/src/libstd/prelude/mod.rs
@@ -103,8 +103,8 @@
 //!   `Some` and `None`.
 //! * `std::result::Result::`{
 //!     [`self`](../result/enum.Result.html),
-//!     [`Some`](../result/enum.Result.html),
-//!     [`None`](../result/enum.Result.html)
+//!     [`Ok`](../result/enum.Result.html),
+//!     [`Err`](../result/enum.Result.html)
 //!   }.
 //!   The ubiquitous `Result` type and its two [variants][book-enums],
 //!   `Ok` and `Err`.