Skip to content

Commit 45439b1

Browse files
committed
---
yaml --- r: 216816 b: refs/heads/stable c: 978dc9f h: refs/heads/master v: v3
1 parent 6600962 commit 45439b1

16 files changed

+241
-158
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ refs/heads/tmp: 378a370ff2057afeb1eae86eb6e78c476866a4a6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: a5286998df566e736b32f6795bfc3803bdaf453d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: f23867aa66d61393183313f1828e6383d8365e47
32+
refs/heads/stable: 978dc9f36a7ebd5c16100ab6cf6ee5f528ccf14a
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375

branches/stable/src/doc/trpl/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ we can use the `unwrap()` method:
214214
io::stdin().read_line(&mut buffer).unwrap();
215215
```
216216

217-
`unwrap()` will `panic!` if the `Result` is `Err`. This basically says "Give
217+
`unwrap()` will `panic!` if the `Option` is `None`. This basically says "Give
218218
me the value, and if something goes wrong, just crash." This is less reliable
219219
than matching the error and attempting to recover, but is also significantly
220220
shorter. Sometimes, just crashing is appropriate.

branches/stable/src/doc/trpl/guessing-game.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ prints a [string][strings] to the screen.
131131
let mut guess = String::new();
132132
```
133133

134-
Now we’re getting interesting! There’s a lot going on in this little line. The first thing to notice is that this is a [let statement][let], which is used to create ‘variable bindings’. They take this form:
134+
Now we’re getting interesting! There’s a lot going on in this little line.
135+
The first thing to notice is that this is a [let statement][let], which is
136+
used to create ‘variable bindings’. They take this form:
135137

136138
```rust,ignore
137139
let foo = bar;
@@ -171,7 +173,7 @@ bound to: `String::new()`.
171173

172174
[string]: ../std/string/struct.String.html
173175

174-
The `::new()` syntax is uses `::` because this is an ‘associated function’ of
176+
The `::new()` syntax uses `::` because this is an ‘associated function’ of
175177
a particular type. That is to say, it’s associated with `String` itself,
176178
rather than a particular instance of a `String`. Some languages call this a
177179
‘static method’.

branches/stable/src/librustc/diagnostics.rs

Lines changed: 2 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,6 @@ fn main() {
271271
See also http://doc.rust-lang.org/book/unsafe.html
272272
"##,
273273

274-
E0137: r##"
275-
This error indicates that the compiler found multiple functions with the
276-
#[main] attribute. This is an error because there must be a unique entry point
277-
into a Rust program.
278-
"##,
279-
280274
E0152: r##"
281275
Lang items are already implemented in the standard library. Unless you are
282276
writing a free-standing application (e.g. a kernel), you do not need to provide
@@ -425,142 +419,6 @@ of a loop. Without a loop to break out of or continue in, no sensible action can
425419
be taken.
426420
"##,
427421

428-
E0271: r##"
429-
This is because of a type mismatch between the associated type of some
430-
trait (e.g. T::Bar, where T implements trait Quux { type Bar; })
431-
and another type U that is required to be equal to T::Bar, but is not.
432-
Examples follow.
433-
434-
Here is a basic example:
435-
436-
```
437-
trait Trait { type AssociatedType; }
438-
fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
439-
println!("in foo");
440-
}
441-
impl Trait for i8 { type AssociatedType = &'static str; }
442-
foo(3_i8);
443-
```
444-
445-
Here is that same example again, with some explanatory comments:
446-
447-
```
448-
trait Trait { type AssociatedType; }
449-
450-
fn foo<T>(t: T) where T: Trait<AssociatedType=u32> {
451-
// ~~~~~~~~ ~~~~~~~~~~~~~~~~~~
452-
// | |
453-
// This says `foo` can |
454-
// only be used with |
455-
// some type that |
456-
// implements `Trait`. |
457-
// |
458-
// This says not only must
459-
// `T` be an impl of `Trait`
460-
// but also that the impl
461-
// must assign the type `u32`
462-
// to the associated type.
463-
println!("in foo");
464-
}
465-
466-
impl Trait for i8 { type AssociatedType = &'static str; }
467-
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
468-
// | |
469-
// `i8` does have |
470-
// implementation |
471-
// of `Trait`... |
472-
// ... but it is an implementation
473-
// that assigns `&'static str` to
474-
// the associated type.
475-
476-
foo(3_i8);
477-
// Here, we invoke `foo` with an `i8`, which does not satisfy
478-
// the constraint `<i8 as Trait>::AssociatedType=32`, and
479-
// therefore the type-checker complains with this error code.
480-
```
481-
482-
Here is a more subtle instance of the same problem, that can
483-
arise with for-loops in Rust:
484-
485-
```
486-
let vs: Vec<i32> = vec![1, 2, 3, 4];
487-
for v in &vs {
488-
match v {
489-
1 => {}
490-
_ => {}
491-
}
492-
}
493-
```
494-
495-
The above fails because of an analogous type mismatch,
496-
though may be harder to see. Again, here are some
497-
explanatory comments for the same example:
498-
499-
```
500-
{
501-
let vs = vec![1, 2, 3, 4];
502-
503-
// `for`-loops use a protocol based on the `Iterator`
504-
// trait. Each item yielded in a `for` loop has the
505-
// type `Iterator::Item` -- that is,I `Item` is the
506-
// associated type of the concrete iterator impl.
507-
for v in &vs {
508-
// ~ ~~~
509-
// | |
510-
// | We borrow `vs`, iterating over a sequence of
511-
// | *references* of type `&Elem` (where `Elem` is
512-
// | vector's element type). Thus, the associated
513-
// | type `Item` must be a reference `&`-type ...
514-
// |
515-
// ... and `v` has the type `Iterator::Item`, as dictated by
516-
// the `for`-loop protocol ...
517-
518-
match v {
519-
1 => {}
520-
// ~
521-
// |
522-
// ... but *here*, `v` is forced to have some integral type;
523-
// only types like `u8`,`i8`,`u16`,`i16`, et cetera can
524-
// match the pattern `1` ...
525-
526-
_ => {}
527-
}
528-
529-
// ... therefore, the compiler complains, because it sees
530-
// an attempt to solve the equations
531-
// `some integral-type` = type-of-`v`
532-
// = `Iterator::Item`
533-
// = `&Elem` (i.e. `some reference type`)
534-
//
535-
// which cannot possibly all be true.
536-
537-
}
538-
}
539-
```
540-
541-
To avoid those issues, you have to make the types match correctly.
542-
So we can fix the previous examples like this:
543-
544-
```
545-
// Basic Example:
546-
trait Trait { type AssociatedType; }
547-
fn foo<T>(t: T) where T: Trait<AssociatedType = &'static str> {
548-
println!("in foo");
549-
}
550-
impl Trait for i8 { type AssociatedType = &'static str; }
551-
foo(3_i8);
552-
553-
// For-Loop Example:
554-
let vs = vec![1, 2, 3, 4];
555-
for v in &vs {
556-
match v {
557-
&1 => {}
558-
_ => {}
559-
}
560-
}
561-
```
562-
"##,
563-
564422
E0282: r##"
565423
This error indicates that type inference did not result in one unique possible
566424
type, and extra information is required. In most cases this can be provided
@@ -806,6 +664,7 @@ register_diagnostics! {
806664
E0134,
807665
E0135,
808666
E0136,
667+
E0137,
809668
E0138,
810669
E0139,
811670
E0261, // use of undeclared lifetime name
@@ -815,6 +674,7 @@ register_diagnostics! {
815674
E0266, // expected item
816675
E0269, // not all control paths return a value
817676
E0270, // computation may converge in a function marked as diverging
677+
E0271, // type mismatch resolving
818678
E0272, // rustc_on_unimplemented attribute refers to non-existent type parameter
819679
E0273, // rustc_on_unimplemented must have named format arguments
820680
E0274, // rustc_on_unimplemented must have a value

branches/stable/src/librustc_typeck/diagnostics.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ let x_is_nonzero = x as bool;
3434
```
3535
"##,
3636

37-
E0062: r##"
38-
This error indicates that during an attempt to build a struct or struct-like
39-
enum variant, one of the fields was specified more than once. Each field should
40-
be specified exactly one time.
41-
"##,
42-
43-
E0063: r##"
44-
This error indicates that during an attempt to build a struct or struct-like
45-
enum variant, one of the fields was not provided. Each field should be specified
46-
exactly once.
47-
"##,
48-
4937
E0081: r##"
5038
Enum discriminants are used to differentiate enum variants stored in memory.
5139
This error indicates that the same value was used for two or more variants,
@@ -148,6 +136,8 @@ register_diagnostics! {
148136
E0059,
149137
E0060,
150138
E0061,
139+
E0062,
140+
E0063,
151141
E0066,
152142
E0067,
153143
E0068,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="crateresolve3#0.1"]
12+
13+
#![crate_type = "lib"]
14+
15+
pub fn f() -> isize { 10 }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="crateresolve3#0.2"]
12+
13+
#![crate_type = "lib"]
14+
15+
pub fn g() -> isize { 20 }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="crateresolve5#0.1"]
12+
13+
#![crate_type = "lib"]
14+
15+
pub struct NameVal { pub name: String, pub val: isize }
16+
17+
pub fn struct_nameval() -> NameVal {
18+
NameVal { name: "crateresolve5".to_string(), val: 10 }
19+
}
20+
21+
pub enum e {
22+
e_val
23+
}
24+
25+
pub fn nominal() -> e { e_val }
26+
27+
pub fn nominal_eq(_e1: e, _e2: e) -> bool { true }
28+
29+
impl PartialEq for e {
30+
fn eq(&self, other: &e) -> bool { nominal_eq(*self, *other) }
31+
fn ne(&self, other: &e) -> bool { !nominal_eq(*self, *other) }
32+
}
33+
34+
pub fn f() -> isize { 10 }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="crateresolve5#0.2"]
12+
13+
#![crate_type = "lib"]
14+
15+
pub struct NameVal { pub name: String, pub val: isize }
16+
pub fn struct_nameval() -> NameVal {
17+
NameVal { name: "crateresolve5".to_string(), val: 10 }
18+
}
19+
20+
pub enum e {
21+
e_val
22+
}
23+
24+
impl PartialEq for e {
25+
fn eq(&self, other: &e) -> bool { !nominal_neq(*self, *other) }
26+
fn ne(&self, other: &e) -> bool { nominal_neq(*self, *other) }
27+
}
28+
29+
pub fn nominal() -> e { e_val }
30+
31+
pub fn nominal_neq(_e1: e, _e2: e) -> bool { false }
32+
33+
pub fn f() -> isize { 20 }
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:crateresolve_calories-1.rs
12+
// aux-build:crateresolve_calories-2.rs
13+
14+
// These both have the same version but differ in other metadata
15+
pub mod a {
16+
extern crate cr_1 (name = "crateresolve_calories", vers = "0.1", calories="100");
17+
pub fn f() -> isize { cr_1::f() }
18+
}
19+
20+
pub mod b {
21+
extern crate cr_2 (name = "crateresolve_calories", vers = "0.1", calories="200");
22+
pub fn f() -> isize { cr_2::f() }
23+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// default link meta for 'package_id' will be equal to filestem
12+
#![crate_name="crateresolve8#0.1"]
13+
14+
#![crate_type = "lib"]
15+
16+
pub fn f() -> isize { 20 }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="crateresolve_calories#0.1"]
12+
#![crate_type = "lib"]
13+
14+
pub fn f() -> isize { 100 }

0 commit comments

Comments
 (0)