Skip to content

Commit e1cc0a0

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 274246 b: refs/heads/stable c: e0fd9c3 h: refs/heads/master
1 parent db85e52 commit e1cc0a0

Some content is hidden

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

56 files changed

+505
-1437
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: b46bd2fb292dbd5bca8c147074a5528b3906328e
32+
refs/heads/stable: e0fd9c3b00a4d2818a1add4840263d936f8748cd
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/getting-started.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ pub mod middle {
108108
pub mod free_region;
109109
pub mod intrinsicck;
110110
pub mod infer;
111-
pub mod implicator;
112111
pub mod lang_items;
113112
pub mod liveness;
114113
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)