Skip to content

Commit afbdb38

Browse files
committed
---
yaml --- r: 274247 b: refs/heads/stable c: ced313c h: refs/heads/master i: 274245: db85e52 274243: 090a21b 274239: dca8a68
1 parent e1cc0a0 commit afbdb38

Some content is hidden

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

53 files changed

+934
-504
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: e0fd9c3b00a4d2818a1add4840263d936f8748cd
32+
refs/heads/stable: ced313cf19990b0e82ea9d9255da9349202ad8a2
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*)
1054+
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7* | 3.8* | 3.9*)
10551055
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
10561056
;;
10571057
(*)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,15 +511,17 @@ 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 finally ready for release, you can use `cargo build
516+
When your project is 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-
Running this command also causes Cargo to create a new file called
522+
### What Is That `Cargo.lock`?
523+
524+
Running `cargo build` also causes Cargo to create a new file called
523525
*Cargo.lock*, which looks like this:
524526

525527
```toml

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

Lines changed: 11 additions & 58 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, abi};
31+
use syntax::ast;
3232
use rustc_front::hir::Expr;
3333
use rustc_front::hir;
3434
use rustc_front::intravisit::FnKind;
@@ -1090,19 +1090,16 @@ 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 (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-
}
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");
11061103
assert_eq!(decl.inputs.len(), args.len());
11071104

11081105
let mut call_args = NodeMap();
@@ -1117,7 +1114,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
11171114
let old = call_args.insert(arg.pat.id, arg_val);
11181115
assert!(old.is_none());
11191116
}
1120-
let result = block.expr.as_ref().unwrap();
11211117
debug!("const call({:?})", call_args);
11221118
try!(eval_const_expr_partial(tcx, &**result, ty_hint, Some(&call_args)))
11231119
},
@@ -1389,46 +1385,3 @@ pub fn compare_lit_exprs<'tcx>(tcx: &ty::ctxt<'tcx>,
13891385
};
13901386
compare_const_vals(&a, &b)
13911387
}
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: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -267,24 +267,28 @@ 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 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),
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));
275287
}
276-
};
277-
if s.is_empty() {
278-
say("crate name must not be empty");
279-
}
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));
284288
}
285-
match sess {
286-
Some(sess) => sess.abort_if_errors(),
287-
None => {}
289+
290+
if err_count > 0 {
291+
sess.unwrap().abort_if_errors();
288292
}
289293
}
290294

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,7 @@ 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-
println!("{}", String::from_utf8(v).unwrap());
531-
""
530+
String::from_utf8(v).unwrap()
532531
});
533532
}
534533

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ 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();
243242
items
244243
}
245244

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

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

branches/stable/src/librustc_driver/driver.rs

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ pub fn compile_input(sess: Session,
6969
let state = $make_state;
7070
(control.$point.callback)(state);
7171

72-
$tsess.abort_if_errors();
7372
if control.$point.stop == Compilation::Stop {
73+
$tsess.abort_if_errors();
7474
return;
7575
}
7676
})}
@@ -470,7 +470,11 @@ pub fn phase_2_configure_and_expand(sess: &Session,
470470

471471
let mut feature_gated_cfgs = vec![];
472472
krate = time(time_passes, "configuration 1", || {
473-
syntax::config::strip_unconfigured_items(sess.diagnostic(), krate, &mut feature_gated_cfgs)
473+
sess.abort_if_new_errors(|| {
474+
syntax::config::strip_unconfigured_items(sess.diagnostic(),
475+
krate,
476+
&mut feature_gated_cfgs)
477+
})
474478
});
475479

476480
*sess.crate_types.borrow_mut() = collect_crate_types(sess, &krate.attrs);
@@ -481,13 +485,15 @@ pub fn phase_2_configure_and_expand(sess: &Session,
481485
});
482486

483487
time(time_passes, "gated macro checking", || {
484-
let features = syntax::feature_gate::check_crate_macros(sess.codemap(),
485-
&sess.parse_sess.span_diagnostic,
486-
&krate);
487-
488-
// these need to be set "early" so that expansion sees `quote` if enabled.
489-
*sess.features.borrow_mut() = features;
490-
sess.abort_if_errors();
488+
sess.abort_if_new_errors(|| {
489+
let features =
490+
syntax::feature_gate::check_crate_macros(sess.codemap(),
491+
&sess.parse_sess.span_diagnostic,
492+
&krate);
493+
494+
// these need to be set "early" so that expansion sees `quote` if enabled.
495+
*sess.features.borrow_mut() = features;
496+
});
491497
});
492498

493499

@@ -525,7 +531,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
525531
let Registry { syntax_exts, early_lint_passes, late_lint_passes, lint_groups,
526532
llvm_passes, attributes, .. } = registry;
527533

528-
{
534+
sess.abort_if_new_errors(|| {
529535
let mut ls = sess.lint_store.borrow_mut();
530536
for pass in early_lint_passes {
531537
ls.register_early_pass(Some(sess), true, pass);
@@ -540,17 +546,14 @@ pub fn phase_2_configure_and_expand(sess: &Session,
540546

541547
*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
542548
*sess.plugin_attributes.borrow_mut() = attributes.clone();
543-
}
549+
});
544550

545551
// Lint plugins are registered; now we can process command line flags.
546552
if sess.opts.describe_lints {
547553
super::describe_lints(&*sess.lint_store.borrow(), true);
548554
return None;
549555
}
550-
sess.lint_store.borrow_mut().process_command_line(sess);
551-
552-
// Abort if there are errors from lint processing or a plugin registrar.
553-
sess.abort_if_errors();
556+
sess.abort_if_new_errors(|| sess.lint_store.borrow_mut().process_command_line(sess));
554557

555558
krate = time(time_passes, "expansion", || {
556559
// Windows dlls do not have rpaths, so they don't know how to find their
@@ -594,29 +597,36 @@ pub fn phase_2_configure_and_expand(sess: &Session,
594597
// much as possible (e.g. help the programmer avoid platform
595598
// specific differences)
596599
time(time_passes, "complete gated feature checking 1", || {
597-
let features = syntax::feature_gate::check_crate(sess.codemap(),
598-
&sess.parse_sess.span_diagnostic,
599-
&krate,
600-
&attributes,
601-
sess.opts.unstable_features);
602-
*sess.features.borrow_mut() = features;
603-
sess.abort_if_errors();
600+
sess.abort_if_new_errors(|| {
601+
let features = syntax::feature_gate::check_crate(sess.codemap(),
602+
&sess.parse_sess.span_diagnostic,
603+
&krate,
604+
&attributes,
605+
sess.opts.unstable_features);
606+
*sess.features.borrow_mut() = features;
607+
});
604608
});
605609

606610
// JBC: make CFG processing part of expansion to avoid this problem:
607611

608612
// strip again, in case expansion added anything with a #[cfg].
609-
krate = time(time_passes, "configuration 2", || {
610-
syntax::config::strip_unconfigured_items(sess.diagnostic(), krate, &mut feature_gated_cfgs)
611-
});
613+
krate = sess.abort_if_new_errors(|| {
614+
let krate = time(time_passes, "configuration 2", || {
615+
syntax::config::strip_unconfigured_items(sess.diagnostic(),
616+
krate,
617+
&mut feature_gated_cfgs)
618+
});
612619

613-
time(time_passes, "gated configuration checking", || {
614-
let features = sess.features.borrow();
615-
feature_gated_cfgs.sort();
616-
feature_gated_cfgs.dedup();
617-
for cfg in &feature_gated_cfgs {
618-
cfg.check_and_emit(sess.diagnostic(), &features, sess.codemap());
619-
}
620+
time(time_passes, "gated configuration checking", || {
621+
let features = sess.features.borrow();
622+
feature_gated_cfgs.sort();
623+
feature_gated_cfgs.dedup();
624+
for cfg in &feature_gated_cfgs {
625+
cfg.check_and_emit(sess.diagnostic(), &features, sess.codemap());
626+
}
627+
});
628+
629+
krate
620630
});
621631

622632
krate = time(time_passes, "maybe building test harness", || {
@@ -639,13 +649,14 @@ pub fn phase_2_configure_and_expand(sess: &Session,
639649
// later, to make sure we've got everything (e.g. configuration
640650
// can insert new attributes via `cfg_attr`)
641651
time(time_passes, "complete gated feature checking 2", || {
642-
let features = syntax::feature_gate::check_crate(sess.codemap(),
643-
&sess.parse_sess.span_diagnostic,
644-
&krate,
645-
&attributes,
646-
sess.opts.unstable_features);
647-
*sess.features.borrow_mut() = features;
648-
sess.abort_if_errors();
652+
sess.abort_if_new_errors(|| {
653+
let features = syntax::feature_gate::check_crate(sess.codemap(),
654+
&sess.parse_sess.span_diagnostic,
655+
&krate,
656+
&attributes,
657+
sess.opts.unstable_features);
658+
*sess.features.borrow_mut() = features;
659+
});
649660
});
650661

651662
time(time_passes,
@@ -711,9 +722,11 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
711722
"external crate/lib resolution",
712723
|| LocalCrateReader::new(sess, cstore, &hir_map).read_crates(krate));
713724

714-
let lang_items = time(time_passes,
715-
"language item collection",
716-
|| middle::lang_items::collect_language_items(&sess, &hir_map));
725+
let lang_items = time(time_passes, "language item collection", || {
726+
sess.abort_if_new_errors(|| {
727+
middle::lang_items::collect_language_items(&sess, &hir_map)
728+
})
729+
});
717730

718731
let resolve::CrateMap {
719732
def_map,

0 commit comments

Comments
 (0)