From ddeda4541fd52d2195f4bfa58408bdf0e3fb3445 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Mon, 3 Dec 2018 17:38:04 +0100 Subject: [PATCH 1/4] Bump stack size to 32MB --- src/librustc_driver/driver.rs | 2 +- src/librustc_driver/lib.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7ad012409b53a..07803d0659823 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -91,7 +91,7 @@ pub fn spawn_thread_pool R + sync::Send, R: sync:: let config = ThreadPoolBuilder::new() .num_threads(Session::query_threads_from_opts(&opts)) .deadlock_handler(|| unsafe { ty::query::handle_deadlock() }) - .stack_size(16 * 1024 * 1024); + .stack_size(::STACK_SIZE); let with_pool = move |pool: &ThreadPool| { pool.install(move || f(opts)) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 276b7290c2ef0..9a0d461444c27 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1460,6 +1460,11 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec(name: String, f: F) -> Result R + Send + 'static, R: Send + 'static, { - // Temporarily have stack size set to 16MB to deal with nom-using crates failing - const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB - #[cfg(all(unix, not(target_os = "haiku")))] let spawn_thread = unsafe { // Fetch the current resource limits From 6b4e2971d74318491c168ae52960274e8f18fcd1 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 3 Dec 2018 23:17:02 +0000 Subject: [PATCH 2/4] Propagate all closure requirements to the caller --- .../borrow_check/nll/region_infer/mod.rs | 2 +- .../propagate-multiple-requirements.rs | 25 +++++++++++++++++++ .../propagate-multiple-requirements.stderr | 17 +++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs create mode 100644 src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index 50fd4afcd7eca..82e0b3495da61 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -1196,7 +1196,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { blame_span: blame_span_category.1, category: blame_span_category.0, }); - return; + continue; } } diff --git a/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs b/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs new file mode 100644 index 0000000000000..dbc659b4aeef9 --- /dev/null +++ b/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs @@ -0,0 +1,25 @@ +// Test that we propagate *all* requirements to the caller, not just the first +// one. + +#![feature(nll)] + +fn once U>(f: F, s: S, t: T) -> U { + f(s, t) +} + +pub fn dangle() -> &'static [i32] { + let other_local_arr = [0, 2, 4]; + let local_arr = other_local_arr; + let mut out: &mut &'static [i32] = &mut (&[1] as _); + once(|mut z: &[i32], mut out_val: &mut &[i32]| { + // We unfortunately point to the first use in the closure in the error + // message + z = &local_arr; //~ ERROR + *out_val = &local_arr; + }, &[] as &[_], &mut *out); + *out +} + +fn main() { + println!("{:?}", dangle()); +} diff --git a/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr b/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr new file mode 100644 index 0000000000000..2ad4577869a55 --- /dev/null +++ b/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr @@ -0,0 +1,17 @@ +error[E0597]: `local_arr` does not live long enough + --> $DIR/propagate-multiple-requirements.rs:17:14 + | +LL | let mut out: &mut &'static [i32] = &mut (&[1] as _); + | ------------------- type annotation requires that `local_arr` is borrowed for `'static` +LL | once(|mut z: &[i32], mut out_val: &mut &[i32]| { + | ----------------------------------------- value captured here +... +LL | z = &local_arr; //~ ERROR + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `local_arr` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. From f41b48a10e0c5c934f284bc29852ba44ef7e3fbf Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Tue, 4 Dec 2018 19:14:13 +0000 Subject: [PATCH 3/4] Call methods on the right tcx There are two `TyCtxt`s, one global, one local. Methods must be called on the right one, as they differ by invariant lifetimes. --- src/librustc_typeck/check/wfcheck.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 9990d2ee2b676..75207f18ab103 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -343,8 +343,8 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) { fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId, ty_span: Span) { debug!("check_item_type: {:?}", item_id); - for_id(tcx, item_id, ty_span).with_fcx(|fcx, _this| { - let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item_id)); + for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| { + let ty = gcx.type_of(gcx.hir.local_def_id(item_id)); let item_ty = fcx.normalize_associated_types_in(ty_span, &ty); fcx.register_wf_obligation(item_ty, ty_span, ObligationCauseCode::MiscObligation); From 6d54f6d6b1181e6fa7c5934ea3b4d6bfd1775512 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 4 Dec 2018 16:47:46 -0500 Subject: [PATCH 4/4] build the edition guide and update it so that links are correct --- src/bootstrap/builder.rs | 3 ++- src/doc/edition-guide | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index ab2c7c2325c99..02e9ca9250005 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -443,7 +443,8 @@ impl<'a> Builder<'a> { doc::RustdocBook, doc::RustByExample, doc::RustcBook, - doc::CargoBook + doc::CargoBook, + doc::EditionGuide, ), Kind::Dist => describe!( dist::Docs, diff --git a/src/doc/edition-guide b/src/doc/edition-guide index ad895867b6751..419edb885ec1a 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit ad895867b675199a7f597ce7045a56875a7e516a +Subproject commit 419edb885ec1a98c0747b3907003d79e3e6b93a9