Skip to content

Commit 92122e4

Browse files
committed
---
yaml --- r: 273435 b: refs/heads/beta c: e3f2dfd h: refs/heads/master i: 273433: b9a92a3 273431: c20aba5
1 parent ab84c18 commit 92122e4

File tree

30 files changed

+398
-110
lines changed

30 files changed

+398
-110
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 782c0cf4a2fb57492012f6093ad7b70be72f654d
26+
refs/heads/beta: e3f2dfdececa8053e652eb0fb286db9aef0f82e6
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ build.
7777
7878
Download [MinGW from
7979
here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
80-
`threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
80+
`version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
8181
add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
8282
installing from pacman should be just fine.
8383

branches/beta/src/compiletest/errors.rs

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,54 @@
99
// except according to those terms.
1010
use self::WhichLine::*;
1111

12+
use std::fmt;
1213
use std::fs::File;
1314
use std::io::BufReader;
1415
use std::io::prelude::*;
1516
use std::path::Path;
17+
use std::str::FromStr;
18+
19+
#[derive(Clone, Debug, PartialEq)]
20+
pub enum ErrorKind {
21+
Help,
22+
Error,
23+
Note,
24+
Suggestion,
25+
Warning,
26+
}
27+
28+
impl FromStr for ErrorKind {
29+
type Err = ();
30+
fn from_str(s: &str) -> Result<Self, Self::Err> {
31+
match &s.trim_right_matches(':') as &str {
32+
"HELP" => Ok(ErrorKind::Help),
33+
"ERROR" => Ok(ErrorKind::Error),
34+
"NOTE" => Ok(ErrorKind::Note),
35+
"SUGGESTION" => Ok(ErrorKind::Suggestion),
36+
"WARN" => Ok(ErrorKind::Warning),
37+
"WARNING" => Ok(ErrorKind::Warning),
38+
_ => Err(()),
39+
}
40+
}
41+
}
42+
43+
impl fmt::Display for ErrorKind {
44+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
45+
match *self {
46+
ErrorKind::Help => write!(f, "help"),
47+
ErrorKind::Error => write!(f, "error"),
48+
ErrorKind::Note => write!(f, "note"),
49+
ErrorKind::Suggestion => write!(f, "suggestion"),
50+
ErrorKind::Warning => write!(f, "warning"),
51+
}
52+
}
53+
}
1654

1755
pub struct ExpectedError {
1856
pub line_num: usize,
19-
pub kind: String,
57+
/// What kind of message we expect (e.g. warning, error, suggestion).
58+
/// `None` if not specified or unknown message kind.
59+
pub kind: Option<ErrorKind>,
2060
pub msg: String,
2161
}
2262

@@ -81,11 +121,11 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
81121
(false, line[start + tag.len()..].chars().take_while(|c| *c == '^').count())
82122
};
83123
let kind_start = start + tag.len() + adjusts + (follow as usize);
84-
let letters = line[kind_start..].chars();
85-
let kind = letters.skip_while(|c| c.is_whitespace())
86-
.take_while(|c| !c.is_whitespace())
87-
.flat_map(|c| c.to_lowercase())
88-
.collect::<String>();
124+
let kind = line[kind_start..].split_whitespace()
125+
.next()
126+
.expect("Encountered unexpected empty comment")
127+
.parse::<ErrorKind>()
128+
.ok();
89129
let letters = line[kind_start..].chars();
90130
let msg = letters.skip_while(|c| c.is_whitespace())
91131
.skip_while(|c| !c.is_whitespace())

branches/beta/src/compiletest/runtest.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use common::Config;
1212
use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
1313
use common::{Codegen, DebugInfoLldb, DebugInfoGdb, Rustdoc, CodegenUnits};
14-
use errors;
14+
use errors::{self, ErrorKind};
1515
use header::TestProps;
1616
use header;
1717
use procsrv;
@@ -1033,8 +1033,8 @@ fn check_expected_errors(revision: Option<&str>,
10331033
expected_errors.iter()
10341034
.fold((false, false),
10351035
|(acc_help, acc_note), ee|
1036-
(acc_help || ee.kind == "help:" || ee.kind == "help",
1037-
acc_note || ee.kind == "note:" || ee.kind == "note"));
1036+
(acc_help || ee.kind == Some(ErrorKind::Help),
1037+
acc_note || ee.kind == Some(ErrorKind::Note)));
10381038

10391039
// Scan and extract our error/warning messages,
10401040
// which look like:
@@ -1052,15 +1052,15 @@ fn check_expected_errors(revision: Option<&str>,
10521052
let mut prev = 0;
10531053
for (i, ee) in expected_errors.iter().enumerate() {
10541054
if !found_flags[i] {
1055-
debug!("prefix={} ee.kind={} ee.msg={} line={}",
1055+
debug!("prefix={} ee.kind={:?} ee.msg={} line={}",
10561056
prefixes[i],
10571057
ee.kind,
10581058
ee.msg,
10591059
line);
10601060
// Suggestions have no line number in their output, so take on the line number of
10611061
// the previous expected error
1062-
if ee.kind == "suggestion" {
1063-
assert!(expected_errors[prev].kind == "help",
1062+
if ee.kind == Some(ErrorKind::Suggestion) {
1063+
assert!(expected_errors[prev].kind == Some(ErrorKind::Help),
10641064
"SUGGESTIONs must be preceded by a HELP");
10651065
if line.contains(&ee.msg) {
10661066
found_flags[i] = true;
@@ -1070,7 +1070,7 @@ fn check_expected_errors(revision: Option<&str>,
10701070
}
10711071
if
10721072
(prefix_matches(line, &prefixes[i]) || continuation(line)) &&
1073-
line.contains(&ee.kind) &&
1073+
(ee.kind.is_none() || line.contains(&ee.kind.as_ref().unwrap().to_string())) &&
10741074
line.contains(&ee.msg)
10751075
{
10761076
found_flags[i] = true;
@@ -1096,7 +1096,10 @@ fn check_expected_errors(revision: Option<&str>,
10961096
if !flag {
10971097
let ee = &expected_errors[i];
10981098
error(revision, &format!("expected {} on line {} not found: {}",
1099-
ee.kind, ee.line_num, ee.msg));
1099+
ee.kind.as_ref()
1100+
.map_or("message".into(),
1101+
|k| k.to_string()),
1102+
ee.line_num, ee.msg));
11001103
not_found += 1;
11011104
}
11021105
}

branches/beta/src/doc/book/error-handling.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,6 +2019,16 @@ impl Error for CliError {
20192019
CliError::NotFound => "not found",
20202020
}
20212021
}
2022+
2023+
fn cause(&self) -> Option<&error::Error> {
2024+
match *self {
2025+
CliError::Io(ref err) => Some(err),
2026+
CliError::Parse(ref err) => Some(err),
2027+
// Our custom error doesn't have an underlying cause, but we could
2028+
// modify it so that it does.
2029+
CliError::NotFound() => None,
2030+
}
2031+
}
20222032
}
20232033
```
20242034

branches/beta/src/doc/book/match.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ give us an error:
3636
error: non-exhaustive patterns: `_` not covered
3737
```
3838

39-
Rust is telling us that we forgot a value. The compiler infers from `x` that it
40-
can have any positive 32bit value; for example 1 to 2,147,483,647. The `_` acts
39+
Rust is telling us that we forgot some value. The compiler infers from `x` that it
40+
can have any 32bit integer value; for example -2,147,483,648 to 2,147,483,647. The `_` acts
4141
as a 'catch-all', and will catch all possible values that *aren't* specified in
42-
an arm of `match`. As you can see with the previous example, we provide `match`
42+
an arm of `match`. As you can see in the previous example, we provide `match`
4343
arms for integers 1-5, if `x` is 6 or any other value, then it is caught by `_`.
4444

4545
`match` is also an expression, which means we can use it on the right-hand

branches/beta/src/doc/book/primitive-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ of these ones, as well, but these are the most primitive.
77

88
# Booleans
99

10-
Rust has a built in boolean type, named `bool`. It has two values, `true` and `false`:
10+
Rust has a built-in boolean type, named `bool`. It has two values, `true` and `false`:
1111

1212
```rust
1313
let x = true;
@@ -89,13 +89,13 @@ Unsigned types use a `u` for their category, and signed types use `i`. The `i`
8989
is for ‘integer’. So `u8` is an eight-bit unsigned number, and `i8` is an
9090
eight-bit signed number.
9191

92-
## Fixed size types
92+
## Fixed-size types
9393

94-
Fixed size types have a specific number of bits in their representation. Valid
94+
Fixed-size types have a specific number of bits in their representation. Valid
9595
bit sizes are `8`, `16`, `32`, and `64`. So, `u32` is an unsigned, 32-bit integer,
9696
and `i64` is a signed, 64-bit integer.
9797

98-
## Variable sized types
98+
## Variable-size types
9999

100100
Rust also provides types whose size depends on the size of a pointer of the
101101
underlying machine. These types have ‘size’ as the category, and come in signed

branches/beta/src/doc/book/references-and-borrowing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn main() {
212212

213213
In other words, the mutable borrow is held through the rest of our example. What
214214
we want is for the mutable borrow by `y` to end so that the resource can be
215-
returned to the owner, `x`. `x` can then provide a mutable borrow to `println!`.
215+
returned to the owner, `x`. `x` can then provide a immutable borrow to `println!`.
216216
In Rust, borrowing is tied to the scope that the borrow is valid for. And our
217217
scopes look like this:
218218

branches/beta/src/libcore/cmp.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
//! by the compiler to implement comparison operators. Rust programs may
1515
//! implement `PartialOrd` to overload the `<`, `<=`, `>`, and `>=` operators,
1616
//! and may implement `PartialEq` to overload the `==` and `!=` operators.
17+
//!
18+
//! # Examples
19+
//!
20+
//! ```
21+
//! let x: u32 = 0;
22+
//! let y: u32 = 1;
23+
//!
24+
//! // these two lines are equivalent
25+
//! assert_eq!(x < y, true);
26+
//! assert_eq!(x.lt(&y), true);
27+
//!
28+
//! // these two lines are also equivalent
29+
//! assert_eq!(x == y, false);
30+
//! assert_eq!(x.eq(&y), false);
31+
//! ```
1732
1833
#![stable(feature = "rust1", since = "1.0.0")]
1934

@@ -44,6 +59,16 @@ use option::Option::{self, Some};
4459
/// only if `a != b`.
4560
///
4661
/// This trait can be used with `#[derive]`.
62+
///
63+
/// # Examples
64+
///
65+
/// ```
66+
/// let x: u32 = 0;
67+
/// let y: u32 = 1;
68+
///
69+
/// assert_eq!(x == y, false);
70+
/// assert_eq!(x.eq(&y), false);
71+
/// ```
4772
#[lang = "eq"]
4873
#[stable(feature = "rust1", since = "1.0.0")]
4974
pub trait PartialEq<Rhs: ?Sized = Self> {
@@ -226,6 +251,16 @@ impl PartialOrd for Ordering {
226251
///
227252
/// This trait can be used with `#[derive]`. When `derive`d, it will produce an ordering
228253
/// based on the top-to-bottom declaration order of the struct's members.
254+
///
255+
/// # Examples
256+
///
257+
/// ```
258+
/// let x : u32 = 0;
259+
/// let y : u32 = 1;
260+
///
261+
/// assert_eq!(x < y, true);
262+
/// assert_eq!(x.lt(&y), true);
263+
/// ```
229264
#[lang = "ord"]
230265
#[stable(feature = "rust1", since = "1.0.0")]
231266
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {

branches/beta/src/librustc/diagnostics.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,23 @@ each method; it is not possible to annotate the entire impl with an `#[inline]`
19621962
attribute.
19631963
"##,
19641964

1965+
E0522: r##"
1966+
The lang attribute is intended for marking special items that are built-in to
1967+
Rust itself. This includes special traits (like `Copy` and `Sized`) that affect
1968+
how the compiler behaves, as well as special functions that may be automatically
1969+
invoked (such as the handler for out-of-bounds accesses when indexing a slice).
1970+
Erroneous code example:
1971+
1972+
```compile_fail
1973+
#![feature(lang_items)]
1974+
1975+
#[lang = "cookie"]
1976+
fn cookie() -> ! { // error: definition of an unknown language item: `cookie`
1977+
loop {}
1978+
}
1979+
```
1980+
"##,
1981+
19651982
}
19661983

19671984

branches/beta/src/librustc/middle/infer/bivariate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> {
7777
if a == b { return Ok(a); }
7878

7979
let infcx = self.fields.infcx;
80-
let a = infcx.type_variables.borrow().replace_if_possible(a);
81-
let b = infcx.type_variables.borrow().replace_if_possible(b);
80+
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
81+
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
8282
match (&a.sty, &b.sty) {
8383
(&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => {
8484
infcx.type_variables.borrow_mut().relate_vars(a_id, BiTo, b_id);

branches/beta/src/librustc/middle/infer/combine.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
210210
None => break,
211211
Some(e) => e,
212212
};
213+
// Get the actual variable that b_vid has been inferred to
214+
let (b_vid, b_ty) = {
215+
let mut variables = self.infcx.type_variables.borrow_mut();
216+
let b_vid = variables.root_var(b_vid);
217+
(b_vid, variables.probe_root(b_vid))
218+
};
213219

214220
debug!("instantiate(a_ty={:?} dir={:?} b_vid={:?})",
215221
a_ty,
@@ -219,7 +225,6 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
219225
// Check whether `vid` has been instantiated yet. If not,
220226
// make a generalized form of `ty` and instantiate with
221227
// that.
222-
let b_ty = self.infcx.type_variables.borrow().probe(b_vid);
223228
let b_ty = match b_ty {
224229
Some(t) => t, // ...already instantiated.
225230
None => { // ...not yet instantiated:
@@ -307,12 +312,17 @@ impl<'cx, 'tcx> ty::fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> {
307312
// where `$1` has already been instantiated with `Box<$0>`)
308313
match t.sty {
309314
ty::TyInfer(ty::TyVar(vid)) => {
315+
let mut variables = self.infcx.type_variables.borrow_mut();
316+
let vid = variables.root_var(vid);
310317
if vid == self.for_vid {
311318
self.cycle_detected = true;
312319
self.tcx().types.err
313320
} else {
314-
match self.infcx.type_variables.borrow().probe(vid) {
315-
Some(u) => self.fold_ty(u),
321+
match variables.probe_root(vid) {
322+
Some(u) => {
323+
drop(variables);
324+
self.fold_ty(u)
325+
}
316326
None => t,
317327
}
318328
}

branches/beta/src/librustc/middle/infer/equate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> {
5050
if a == b { return Ok(a); }
5151

5252
let infcx = self.fields.infcx;
53-
let a = infcx.type_variables.borrow().replace_if_possible(a);
54-
let b = infcx.type_variables.borrow().replace_if_possible(b);
53+
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
54+
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
5555
match (&a.sty, &b.sty) {
5656
(&ty::TyInfer(TyVar(a_id)), &ty::TyInfer(TyVar(b_id))) => {
5757
infcx.type_variables.borrow_mut().relate_vars(a_id, EqTo, b_id);

branches/beta/src/librustc/middle/infer/freshen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
111111

112112
match t.sty {
113113
ty::TyInfer(ty::TyVar(v)) => {
114+
let opt_ty = self.infcx.type_variables.borrow_mut().probe(v);
114115
self.freshen(
115-
self.infcx.type_variables.borrow().probe(v),
116+
opt_ty,
116117
ty::TyVar(v),
117118
ty::FreshTy)
118119
}

branches/beta/src/librustc/middle/infer/higher_ranked/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> {
434434
self.region_vars.vars_created_since_snapshot(&snapshot.region_vars_snapshot);
435435

436436
let escaping_types =
437-
self.type_variables.borrow().types_escaping_snapshot(&snapshot.type_snapshot);
437+
self.type_variables.borrow_mut().types_escaping_snapshot(&snapshot.type_snapshot);
438438

439439
let mut escaping_region_vars = FnvHashSet();
440440
for ty in &escaping_types {

branches/beta/src/librustc/middle/infer/lattice.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ pub fn super_lattice_tys<'a,'tcx,L:LatticeDir<'a,'tcx>>(this: &mut L,
6060
}
6161

6262
let infcx = this.infcx();
63-
let a = infcx.type_variables.borrow().replace_if_possible(a);
64-
let b = infcx.type_variables.borrow().replace_if_possible(b);
63+
let a = infcx.type_variables.borrow_mut().replace_if_possible(a);
64+
let b = infcx.type_variables.borrow_mut().replace_if_possible(b);
6565
match (&a.sty, &b.sty) {
6666
(&ty::TyInfer(TyVar(..)), &ty::TyInfer(TyVar(..)))
6767
if infcx.type_var_diverges(a) && infcx.type_var_diverges(b) => {

0 commit comments

Comments
 (0)