Skip to content

Commit 8e49334

Browse files
committed
---
yaml --- r: 274255 b: refs/heads/stable c: 6c56260 h: refs/heads/master i: 274253: e28a197 274251: d72167c 274247: afbdb38 274239: dca8a68
1 parent d9a6996 commit 8e49334

Some content is hidden

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

60 files changed

+1026
-943
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: 24931a32e8e2935d6872f581281a908d88095b68
32+
refs/heads/stable: 6c56260b302d5b21ff780fc60aede25b40e3df76
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

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/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates.
15121512

15131513
We're not going to spend a lot of time on setting up a project with
15141514
Cargo because it is already covered well in [the Cargo
1515-
section](getting-started.html#hello-cargo) and [Cargo's documentation][14].
1515+
section](../book/hello-cargo.html) and [Cargo's documentation][14].
15161516

15171517
To get started from scratch, run `cargo new --bin city-pop` and make sure your
15181518
`Cargo.toml` looks something like this:

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ variable. If it isn't, run the installer again, select "Change" on the "Change,
167167
repair, or remove installation" page and ensure "Add to PATH" is installed on
168168
the local hard drive.
169169

170+
Rust does not do its own linking, and so you’ll need to have a linker
171+
installed. Doing so will depend on your specific system, consult its
172+
documentation for more details.
173+
170174
If not, there are a number of places where we can get help. The easiest is
171175
[the #rust IRC channel on irc.mozilla.org][irc], which we can access through
172176
[Mibbit][mibbit]. Click that link, and we'll be chatting with other Rustaceans
@@ -511,17 +515,15 @@ programming languages. For complex projects composed of multiple crates, it’s
511515
much easier to let Cargo coordinate the build. Using Cargo, you can run `cargo
512516
build`, and it should work the right way.
513517

514-
### Building for Release
518+
## Building for Release
515519

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

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

527529
```toml
@@ -604,11 +606,11 @@ This chapter covered the basics that will serve you well through the rest of
604606
this book, and the rest of your time with Rust. Now that you’ve got the tools
605607
down, we'll cover more about the Rust language itself.
606608

607-
You have two options: Dive into a project with ‘[Tutorial: Guessing Game][guessinggame]’, or
609+
You have two options: Dive into a project with ‘[Learn Rust][learnrust]’, or
608610
start from the bottom and work your way up with ‘[Syntax and
609611
Semantics][syntax]’. More experienced systems programmers will probably prefer
610-
Tutorial: Guessing Game’, while those from dynamic backgrounds may enjoy either. Different
612+
Learn Rust’, while those from dynamic backgrounds may enjoy either. Different
611613
people learn differently! Choose whatever’s right for you.
612614

613-
[guessinggame]: guessing-game.html
615+
[learnrust]: learn-rust.html
614616
[syntax]: syntax-and-semantics.html
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
% Learn Rust
2+
3+
Welcome! This chapter has a few tutorials that teach you Rust through building
4+
projects. You’ll get a high-level overview, but we’ll skim over the details.
5+
6+
If you’d prefer a more ‘from the ground up’-style experience, check
7+
out [Syntax and Semantics][ss].
8+
9+
[ss]: syntax-and-semantics.html

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ for x in 0..10 {
195195
You may also encounter situations where you have nested loops and need to
196196
specify which one your `break` or `continue` statement is for. Like most
197197
other languages, by default a `break` or `continue` will apply to innermost
198-
loop. In a situation where you would like to `break` or `continue` for one
198+
loop. In a situation where you would like to a `break` or `continue` for one
199199
of the outer loops, you can use labels to specify which loop the `break` or
200200
`continue` statement applies to. This will only print when both `x` and `y` are
201201
odd:

branches/stable/src/libcore/cell.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,7 @@ impl<T: ?Sized> RefCell<T> {
414414
///
415415
/// let c = RefCell::new(5);
416416
///
417-
/// *c.borrow_mut() = 7;
418-
///
419-
/// assert_eq!(*c.borrow(), 7);
417+
/// let borrowed_five = c.borrow_mut();
420418
/// ```
421419
///
422420
/// An example of panic:

branches/stable/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub mod middle {
108108
pub mod free_region;
109109
pub mod intrinsicck;
110110
pub mod infer;
111+
pub mod implicator;
111112
pub mod lang_items;
112113
pub mod liveness;
113114
pub mod mem_categorization;

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

0 commit comments

Comments
 (0)