Skip to content

Commit 090a21b

Browse files
committed
---
yaml --- r: 274243 b: refs/heads/stable c: 276fae1 h: refs/heads/master i: 274241: 263e6d0 274239: dca8a68
1 parent 55c25b0 commit 090a21b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+892
-854
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: faf6d1e87391b25196b35909c3c95e5d873cacf0
32+
refs/heads/stable: 276fae11ea999e946a48b2150e59438eb8a5e442
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/COPYRIGHT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ terms.
77
Longer version:
88

99
The Rust Project is copyright 2016, The Rust Project
10-
Developers.
10+
Developers (given in the file AUTHORS.txt).
1111

1212
Licensed under the Apache License, Version 2.0
1313
<LICENSE-APACHE or

branches/stable/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ then
10511051
esac
10521052
else
10531053
case $CFG_CLANG_VERSION in
1054-
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8* | 3.9*)
1054+
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8*)
10551055
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
10561056
;;
10571057
(*)

branches/stable/src/doc/book/bibliography.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@ Language](http://www.cs.indiana.edu/~eholk/papers/hips2013.pdf). Early GPU work
8080
Rust](http://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip
8181
Munksgaard's master's thesis. Research for Servo.
8282
* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](http://amitlevy.com/papers/tock-plos2015.pdf)
83-
* [You can't spell trust without Rust](https://raw.githubusercontent.com/Gankro/thesis/master/thesis.pdf). Alexis Beingessner's master's thesis.

branches/stable/src/doc/book/getting-started.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ If we're on Linux or a Mac, all we need to do is open a terminal and type this:
111111
$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
112112
```
113113

114-
This will download a script, and start the installation. If it all goes well,
114+
This will download a script, and stat the installation. If it all goes well,
115115
you’ll see this appear:
116116

117117
```text
@@ -511,17 +511,15 @@ programming languages. For complex projects composed of multiple crates, it’s
511511
much easier to let Cargo coordinate the build. Using Cargo, you can run `cargo
512512
build`, and it should work the right way.
513513

514-
### Building for Release
514+
## Building for Release
515515

516-
When your project is ready for release, you can use `cargo build
516+
When your project is finally ready for release, you can use `cargo build
517517
--release` to compile your project with optimizations. These optimizations make
518518
your Rust code run faster, but turning them on makes your program take longer
519519
to compile. This is why there are two different profiles, one for development,
520520
and one for building the final program you’ll give to a user.
521521

522-
### What Is That `Cargo.lock`?
523-
524-
Running `cargo build` also causes Cargo to create a new file called
522+
Running this command also causes Cargo to create a new file called
525523
*Cargo.lock*, which looks like this:
526524

527525
```toml

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,6 @@ let guess: u32 = match guess.trim().parse() {
908908
```
909909
910910
This is how you generally move from ‘crash on error’ to ‘actually handle the
911-
error’, by switching from `expect()` to a `match` statement. The `Result`
912911
returned by `parse()` is an `enum` like `Ordering`, but in this case, each
913912
variant has some data associated with it: `Ok` is a success, and `Err` is a
914913
failure. Each contains more information: the successfully parsed integer, or an

branches/stable/src/doc/book/no-stdlib.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ The compiler currently makes a few assumptions about symbols which are available
7777
in the executable to call. Normally these functions are provided by the standard
7878
library, but without it you must define your own.
7979

80-
The first of these two functions, `eh_personality`, is used by the failure
81-
mechanisms of the compiler. This is often mapped to GCC's personality function
82-
(see the [libstd implementation][unwind] for more information), but crates
83-
which do not trigger a panic can be assured that this function is never
84-
called. The second function, `panic_fmt`, is also used by the failure
85-
mechanisms of the compiler.
86-
87-
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/unwind/gcc.rs
80+
The first of these two functions, `eh_personality`, is used by the
81+
failure mechanisms of the compiler. This is often mapped to GCC's
82+
personality function (see the
83+
[libstd implementation](../std/rt/unwind/index.html) for more
84+
information), but crates which do not trigger a panic can be assured
85+
that this function is never called. The second function, `panic_fmt`, is
86+
also used by the failure mechanisms of the compiler.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ copying. For example, you might want to reference only one line of a file read
164164
into memory. By nature, a slice is not created directly, but from an existing
165165
variable binding. Slices have a defined length, can be mutable or immutable.
166166

167-
Internally, slices are represented as a pointer to the beginning of the data
168-
and a length.
169-
170167
## Slicing syntax
171168

172169
You can use a combo of `&` and `[]` to create a slice from various things. The

branches/stable/src/doc/book/traits.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -277,22 +277,16 @@ This will compile without error.
277277
This means that even if someone does something bad like add methods to `i32`,
278278
it won’t affect you, unless you `use` that trait.
279279

280-
There’s one more restriction on implementing traits: either the trait
281-
or the type you’re implementing it for must be defined by you. Or more
282-
precisely, one of them must be defined in the same crate as the `impl`
283-
you're writing. For more on Rust's module and package system, see the
284-
chapter on [crates and modules][cm].
285-
286-
So, we could implement the `HasArea` type for `i32`, because we defined
287-
`HasArea` in our code. But if we tried to implement `ToString`, a trait
288-
provided by Rust, for `i32`, we could not, because neither the trait nor
289-
the type are defined in our crate.
280+
There’s one more restriction on implementing traits: either the trait, or the
281+
type you’re writing the `impl` for, must be defined by you. So, we could
282+
implement the `HasArea` type for `i32`, because `HasArea` is in our code. But
283+
if we tried to implement `ToString`, a trait provided by Rust, for `i32`, we could
284+
not, because neither the trait nor the type are in our code.
290285

291286
One last thing about traits: generic functions with a trait bound use
292287
‘monomorphization’ (mono: one, morph: form), so they are statically dispatched.
293288
What’s that mean? Check out the chapter on [trait objects][to] for more details.
294289

295-
[cm]: crates-and-modules.html
296290
[to]: trait-objects.html
297291

298292
# Multiple trait bounds

branches/stable/src/doc/version_info.html.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div id="versioninfo">
2-
<img src="https://www.rust-lang.org/logos/rust-logo-32x32-blk.png" width="32" height="32" alt="Rust logo"><br>
2+
<img src="https://www.rust-lang.org/logos/rust-logo-32x32-blk.png" width="32" height="32" alt><br>
33
<span class="white-sticker"><a href="https://www.rust-lang.org">Rust</a> VERSION</span><br>
44
<a href="https://github.com/rust-lang/rust/commit/STAMP"
55
class="hash white-sticker">SHORT_HASH</a>

branches/stable/src/libcollections/btree/map.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,17 +1194,17 @@ unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
11941194
}
11951195

11961196
impl<K, V> BTreeMap<K, V> {
1197-
/// Gets an iterator over the entries of the map, sorted by key.
1197+
/// Gets an iterator over the entries of the map.
11981198
///
11991199
/// # Examples
12001200
///
12011201
/// ```
12021202
/// use std::collections::BTreeMap;
12031203
///
12041204
/// let mut map = BTreeMap::new();
1205-
/// map.insert(3, "c");
1206-
/// map.insert(2, "b");
12071205
/// map.insert(1, "a");
1206+
/// map.insert(2, "b");
1207+
/// map.insert(3, "c");
12081208
///
12091209
/// for (key, value) in map.iter() {
12101210
/// println!("{}: {}", key, value);
@@ -1224,7 +1224,7 @@ impl<K, V> BTreeMap<K, V> {
12241224
}
12251225
}
12261226

1227-
/// Gets a mutable iterator over the entries of the map, sorted by key.
1227+
/// Gets a mutable iterator over the entries of the map.
12281228
///
12291229
/// # Examples
12301230
///
@@ -1257,16 +1257,16 @@ impl<K, V> BTreeMap<K, V> {
12571257
}
12581258
}
12591259

1260-
/// Gets an iterator over the keys of the map, in sorted order.
1260+
/// Gets an iterator over the keys of the map.
12611261
///
12621262
/// # Examples
12631263
///
12641264
/// ```
12651265
/// use std::collections::BTreeMap;
12661266
///
12671267
/// let mut a = BTreeMap::new();
1268-
/// a.insert(2, "b");
12691268
/// a.insert(1, "a");
1269+
/// a.insert(2, "b");
12701270
///
12711271
/// let keys: Vec<_> = a.keys().cloned().collect();
12721272
/// assert_eq!(keys, [1, 2]);
@@ -1276,19 +1276,19 @@ impl<K, V> BTreeMap<K, V> {
12761276
Keys { inner: self.iter() }
12771277
}
12781278

1279-
/// Gets an iterator over the values of the map, in order by key.
1279+
/// Gets an iterator over the values of the map.
12801280
///
12811281
/// # Examples
12821282
///
12831283
/// ```
12841284
/// use std::collections::BTreeMap;
12851285
///
12861286
/// let mut a = BTreeMap::new();
1287-
/// a.insert(1, "hello");
1288-
/// a.insert(2, "goodbye");
1287+
/// a.insert(1, "a");
1288+
/// a.insert(2, "b");
12891289
///
12901290
/// let values: Vec<&str> = a.values().cloned().collect();
1291-
/// assert_eq!(values, ["hello", "goodbye"]);
1291+
/// assert_eq!(values, ["a", "b"]);
12921292
/// ```
12931293
#[stable(feature = "rust1", since = "1.0.0")]
12941294
pub fn values<'a>(&'a self) -> Values<'a, K, V> {

branches/stable/src/librustc/middle/const_eval.rs

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use util::num::ToPrimitive;
2828
use util::nodemap::NodeMap;
2929

3030
use graphviz::IntoCow;
31-
use syntax::ast;
31+
use syntax::{ast, abi};
3232
use rustc_front::hir::Expr;
3333
use rustc_front::hir;
3434
use rustc_front::intravisit::FnKind;
@@ -1090,16 +1090,19 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
10901090
hir::ExprCall(ref callee, ref args) => {
10911091
let sub_ty_hint = ty_hint.erase_hint();
10921092
let callee_val = try!(eval_const_expr_partial(tcx, callee, sub_ty_hint, fn_args));
1093-
let did = match callee_val {
1094-
Function(did) => did,
1095-
callee => signal!(e, CallOn(callee)),
1096-
};
1097-
let (decl, result) = if let Some(fn_like) = lookup_const_fn_by_id(tcx, did) {
1098-
(fn_like.decl(), &fn_like.body().expr)
1099-
} else {
1100-
signal!(e, NonConstPath)
1101-
};
1102-
let result = result.as_ref().expect("const fn has no result expression");
1093+
let (decl, block, constness) = try!(get_fn_def(tcx, e, callee_val));
1094+
match (ty_hint, constness) {
1095+
(ExprTypeChecked, _) => {
1096+
// no need to check for constness... either check_const
1097+
// already forbids this or we const eval over whatever
1098+
// we want
1099+
},
1100+
(_, hir::Constness::Const) => {
1101+
// we don't know much about the function, so we force it to be a const fn
1102+
// so compilation will fail later in case the const fn's body is not const
1103+
},
1104+
_ => signal!(e, NonConstPath),
1105+
}
11031106
assert_eq!(decl.inputs.len(), args.len());
11041107

11051108
let mut call_args = NodeMap();
@@ -1114,6 +1117,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
11141117
let old = call_args.insert(arg.pat.id, arg_val);
11151118
assert!(old.is_none());
11161119
}
1120+
let result = block.expr.as_ref().unwrap();
11171121
debug!("const call({:?})", call_args);
11181122
try!(eval_const_expr_partial(tcx, &**result, ty_hint, Some(&call_args)))
11191123
},
@@ -1385,3 +1389,46 @@ pub fn compare_lit_exprs<'tcx>(tcx: &ty::ctxt<'tcx>,
13851389
};
13861390
compare_const_vals(&a, &b)
13871391
}
1392+
1393+
1394+
// returns Err if callee is not `Function`
1395+
// `e` is only used for error reporting/spans
1396+
fn get_fn_def<'a>(tcx: &'a ty::ctxt,
1397+
e: &hir::Expr,
1398+
callee: ConstVal)
1399+
-> Result<(&'a hir::FnDecl, &'a hir::Block, hir::Constness), ConstEvalErr> {
1400+
let did = match callee {
1401+
Function(did) => did,
1402+
callee => signal!(e, CallOn(callee)),
1403+
};
1404+
debug!("fn call: {:?}", tcx.map.get_if_local(did));
1405+
match tcx.map.get_if_local(did) {
1406+
None => signal!(e, UnimplementedConstVal("calling non-local const fn")), // non-local
1407+
Some(ast_map::NodeItem(it)) => match it.node {
1408+
hir::ItemFn(
1409+
ref decl,
1410+
hir::Unsafety::Normal,
1411+
constness,
1412+
abi::Abi::Rust,
1413+
_, // ducktype generics? types are funky in const_eval
1414+
ref block,
1415+
) => Ok((&**decl, &**block, constness)),
1416+
_ => signal!(e, NonConstPath),
1417+
},
1418+
Some(ast_map::NodeImplItem(it)) => match it.node {
1419+
hir::ImplItemKind::Method(
1420+
hir::MethodSig {
1421+
ref decl,
1422+
unsafety: hir::Unsafety::Normal,
1423+
constness,
1424+
abi: abi::Abi::Rust,
1425+
.. // ducktype generics? types are funky in const_eval
1426+
},
1427+
ref block,
1428+
) => Ok((decl, block, constness)),
1429+
_ => signal!(e, NonConstPath),
1430+
},
1431+
Some(ast_map::NodeTraitItem(..)) => signal!(e, NonConstPath),
1432+
Some(_) => signal!(e, UnimplementedConstVal("calling struct, tuple or variant")),
1433+
}
1434+
}

branches/stable/src/librustc/middle/cstore.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -267,28 +267,24 @@ impl InlinedItem {
267267

268268
// FIXME: find a better place for this?
269269
pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
270-
let mut err_count = 0;
271-
{
272-
let mut say = |s: &str| {
273-
match (sp, sess) {
274-
(_, None) => panic!("{}", s),
275-
(Some(sp), Some(sess)) => sess.span_err(sp, s),
276-
(None, Some(sess)) => sess.err(s),
277-
}
278-
err_count += 1;
279-
};
280-
if s.is_empty() {
281-
say("crate name must not be empty");
282-
}
283-
for c in s.chars() {
284-
if c.is_alphanumeric() { continue }
285-
if c == '_' { continue }
286-
say(&format!("invalid character `{}` in crate name: `{}`", c, s));
270+
let say = |s: &str| {
271+
match (sp, sess) {
272+
(_, None) => panic!("{}", s),
273+
(Some(sp), Some(sess)) => sess.span_err(sp, s),
274+
(None, Some(sess)) => sess.err(s),
287275
}
276+
};
277+
if s.is_empty() {
278+
say("crate name must not be empty");
288279
}
289-
290-
if err_count > 0 {
291-
sess.unwrap().abort_if_errors();
280+
for c in s.chars() {
281+
if c.is_alphanumeric() { continue }
282+
if c == '_' { continue }
283+
say(&format!("invalid character `{}` in crate name: `{}`", c, s));
284+
}
285+
match sess {
286+
Some(sess) => sess.abort_if_errors(),
287+
None => {}
292288
}
293289
}
294290

branches/stable/src/librustc/middle/dataflow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ impl<'a, 'tcx, O:DataFlowOperator+Clone+'static> DataFlowContext<'a, 'tcx, O> {
527527
debug!("{}", {
528528
let mut v = Vec::new();
529529
self.pretty_print_to(box &mut v, blk).unwrap();
530-
String::from_utf8(v).unwrap()
530+
println!("{}", String::from_utf8(v).unwrap());
531+
""
531532
});
532533
}
533534

branches/stable/src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ pub fn collect_language_items(session: &Session,
239239
collector.collect(krate);
240240
let LanguageItemCollector { mut items, .. } = collector;
241241
weak_lang_items::check_crate(krate, session, &mut items);
242+
session.abort_if_errors();
242243
items
243244
}
244245

branches/stable/src/librustc/session/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,14 @@ impl Session {
176176
pub fn abort_if_errors(&self) {
177177
self.diagnostic().abort_if_errors();
178178
}
179-
pub fn abort_if_new_errors<F, T>(&self, f: F) -> T
180-
where F: FnOnce() -> T
179+
pub fn abort_if_new_errors<F>(&self, mut f: F)
180+
where F: FnMut()
181181
{
182182
let count = self.err_count();
183-
let result = f();
183+
f();
184184
if self.err_count() > count {
185185
self.abort_if_errors();
186186
}
187-
result
188187
}
189188
pub fn span_warn(&self, sp: Span, msg: &str) {
190189
self.diagnostic().span_warn(sp, msg)

branches/stable/src/librustc_borrowck/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn main() {
124124
let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));
125125
let y = x.clone();
126126
x.borrow_mut().s = 6;
127-
println!("{}", x.borrow().s);
127+
println!("{}", x.borrow.s);
128128
}
129129
```
130130

0 commit comments

Comments
 (0)