Skip to content

Commit abe02ce

Browse files
committed
Auto merge of #56518 - pietroalbini:stable-additions, r=pietroalbini
[stable] Add a few critical fixes to the 1.31.0 release This PR cherry-picks the following PRs to stable: * #56467: Bump stack size to 32MB * #56486: Propagate all closure requirements to the caller * #56519: update edition guide The changes will be included in the final 1.31.0 binary (to avoid a point release). To deploy the build to dev-static the old manifest needs to be removed from the bucket after the PR is merged. cc @rust-lang/core @rust-lang/release @rust-lang/compiler r? @alexcrichton
2 parents bdb3f53 + 6d54f6d commit abe02ce

File tree

8 files changed

+54
-9
lines changed

8 files changed

+54
-9
lines changed

src/bootstrap/builder.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ impl<'a> Builder<'a> {
443443
doc::RustdocBook,
444444
doc::RustByExample,
445445
doc::RustcBook,
446-
doc::CargoBook
446+
doc::CargoBook,
447+
doc::EditionGuide,
447448
),
448449
Kind::Dist => describe!(
449450
dist::Docs,

src/doc/edition-guide

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync::
9191
let config = ThreadPoolBuilder::new()
9292
.num_threads(Session::query_threads_from_opts(&opts))
9393
.deadlock_handler(|| unsafe { ty::query::handle_deadlock() })
94-
.stack_size(16 * 1024 * 1024);
94+
.stack_size(::STACK_SIZE);
9595

9696
let with_pool = move |pool: &ThreadPool| {
9797
pool.install(move || f(opts))

src/librustc_driver/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,11 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec<as
14601460
}
14611461
}
14621462

1463+
// Temporarily have stack size set to 32MB to deal with various crates with long method
1464+
// chains or deep syntax trees.
1465+
// FIXME(oli-obk): get https://github.com/rust-lang/rust/pull/55617 the finish line
1466+
const STACK_SIZE: usize = 32 * 1024 * 1024; // 32MB
1467+
14631468
/// Runs `f` in a suitable thread for running `rustc`; returns a `Result` with either the return
14641469
/// value of `f` or -- if a panic occurs -- the panic value.
14651470
///
@@ -1469,9 +1474,6 @@ pub fn in_named_rustc_thread<F, R>(name: String, f: F) -> Result<R, Box<dyn Any
14691474
where F: FnOnce() -> R + Send + 'static,
14701475
R: Send + 'static,
14711476
{
1472-
// Temporarily have stack size set to 16MB to deal with nom-using crates failing
1473-
const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB
1474-
14751477
#[cfg(all(unix, not(target_os = "haiku")))]
14761478
let spawn_thread = unsafe {
14771479
// Fetch the current resource limits

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11961196
blame_span: blame_span_category.1,
11971197
category: blame_span_category.0,
11981198
});
1199-
return;
1199+
continue;
12001200
}
12011201
}
12021202

src/librustc_typeck/check/wfcheck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
343343
fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId, ty_span: Span) {
344344
debug!("check_item_type: {:?}", item_id);
345345

346-
for_id(tcx, item_id, ty_span).with_fcx(|fcx, _this| {
347-
let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item_id));
346+
for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| {
347+
let ty = gcx.type_of(gcx.hir.local_def_id(item_id));
348348
let item_ty = fcx.normalize_associated_types_in(ty_span, &ty);
349349

350350
fcx.register_wf_obligation(item_ty, ty_span, ObligationCauseCode::MiscObligation);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Test that we propagate *all* requirements to the caller, not just the first
2+
// one.
3+
4+
#![feature(nll)]
5+
6+
fn once<S, T, U, F: FnOnce(S, T) -> U>(f: F, s: S, t: T) -> U {
7+
f(s, t)
8+
}
9+
10+
pub fn dangle() -> &'static [i32] {
11+
let other_local_arr = [0, 2, 4];
12+
let local_arr = other_local_arr;
13+
let mut out: &mut &'static [i32] = &mut (&[1] as _);
14+
once(|mut z: &[i32], mut out_val: &mut &[i32]| {
15+
// We unfortunately point to the first use in the closure in the error
16+
// message
17+
z = &local_arr; //~ ERROR
18+
*out_val = &local_arr;
19+
}, &[] as &[_], &mut *out);
20+
*out
21+
}
22+
23+
fn main() {
24+
println!("{:?}", dangle());
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0597]: `local_arr` does not live long enough
2+
--> $DIR/propagate-multiple-requirements.rs:17:14
3+
|
4+
LL | let mut out: &mut &'static [i32] = &mut (&[1] as _);
5+
| ------------------- type annotation requires that `local_arr` is borrowed for `'static`
6+
LL | once(|mut z: &[i32], mut out_val: &mut &[i32]| {
7+
| ----------------------------------------- value captured here
8+
...
9+
LL | z = &local_arr; //~ ERROR
10+
| ^^^^^^^^^ borrowed value does not live long enough
11+
...
12+
LL | }
13+
| - `local_arr` dropped here while still borrowed
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0597`.

0 commit comments

Comments
 (0)