Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4a7bd52

Browse files
committed
Auto merge of rust-lang#134878 - Zalathar:rollup-ebqmxw7, r=Zalathar
Rollup of 4 pull requests Successful merges: - rust-lang#122565 (Try to write the panic message with a single `write_all` call) - rust-lang#133460 (Use `check-run-results` for `run-fail` test stderr) - rust-lang#134627 (Avoid ICE in borrowck) - rust-lang#134799 (nits: Cleanups in `librustdoc::clean`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 480eec0 + 68d06b4 commit 4a7bd52

File tree

451 files changed

+1083
-254
lines changed

Some content is hidden

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

451 files changed

+1083
-254
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,8 +1950,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
19501950
target_test: impl Fn(RegionVid) -> bool,
19511951
) -> (BlameConstraint<'tcx>, Vec<ExtraConstraintInfo>) {
19521952
// Find all paths
1953-
let (path, target_region) =
1954-
self.find_constraint_paths_between_regions(from_region, target_test).unwrap();
1953+
let (path, target_region) = self
1954+
.find_constraint_paths_between_regions(from_region, target_test)
1955+
.or_else(|| {
1956+
self.find_constraint_paths_between_regions(from_region, |r| {
1957+
self.cannot_name_placeholder(from_region, r)
1958+
})
1959+
})
1960+
.unwrap();
19551961
debug!(
19561962
"path={:#?}",
19571963
path.iter()

library/std/src/panicking.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,23 @@ fn default_hook(info: &PanicHookInfo<'_>) {
266266
// Use a lock to prevent mixed output in multithreading context.
267267
// Some platforms also require it when printing a backtrace, like `SymFromAddr` on Windows.
268268
let mut lock = backtrace::lock();
269-
let _ = writeln!(err, "thread '{name}' panicked at {location}:\n{msg}");
269+
// Try to write the panic message to a buffer first to prevent other concurrent outputs
270+
// interleaving with it.
271+
let mut buffer = [0u8; 512];
272+
let mut cursor = crate::io::Cursor::new(&mut buffer[..]);
273+
274+
let write_msg = |dst: &mut dyn crate::io::Write| {
275+
// We add a newline to ensure the panic message appears at the start of a line.
276+
writeln!(dst, "\nthread '{name}' panicked at {location}:\n{msg}")
277+
};
278+
279+
if write_msg(&mut cursor).is_ok() {
280+
let pos = cursor.position() as usize;
281+
let _ = err.write_all(&buffer[0..pos]);
282+
} else {
283+
// The message did not fit into the buffer, write it directly instead.
284+
let _ = write_msg(err);
285+
};
270286

271287
static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
272288

src/librustdoc/clean/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn clean_poly_trait_ref_with_constraints<'tcx>(
268268
)
269269
}
270270

271-
fn clean_lifetime(lifetime: &hir::Lifetime, cx: &mut DocContext<'_>) -> Lifetime {
271+
fn clean_lifetime(lifetime: &hir::Lifetime, cx: &DocContext<'_>) -> Lifetime {
272272
if let Some(
273273
rbv::ResolvedArg::EarlyBound(did)
274274
| rbv::ResolvedArg::LateBound(_, _, did)
@@ -362,9 +362,9 @@ pub(crate) fn clean_predicate<'tcx>(
362362
let bound_predicate = predicate.kind();
363363
match bound_predicate.skip_binder() {
364364
ty::ClauseKind::Trait(pred) => clean_poly_trait_predicate(bound_predicate.rebind(pred), cx),
365-
ty::ClauseKind::RegionOutlives(pred) => clean_region_outlives_predicate(pred),
365+
ty::ClauseKind::RegionOutlives(pred) => Some(clean_region_outlives_predicate(pred)),
366366
ty::ClauseKind::TypeOutlives(pred) => {
367-
clean_type_outlives_predicate(bound_predicate.rebind(pred), cx)
367+
Some(clean_type_outlives_predicate(bound_predicate.rebind(pred), cx))
368368
}
369369
ty::ClauseKind::Projection(pred) => {
370370
Some(clean_projection_predicate(bound_predicate.rebind(pred), cx))
@@ -396,32 +396,30 @@ fn clean_poly_trait_predicate<'tcx>(
396396
})
397397
}
398398

399-
fn clean_region_outlives_predicate(
400-
pred: ty::RegionOutlivesPredicate<'_>,
401-
) -> Option<WherePredicate> {
399+
fn clean_region_outlives_predicate(pred: ty::RegionOutlivesPredicate<'_>) -> WherePredicate {
402400
let ty::OutlivesPredicate(a, b) = pred;
403401

404-
Some(WherePredicate::RegionPredicate {
402+
WherePredicate::RegionPredicate {
405403
lifetime: clean_middle_region(a).expect("failed to clean lifetime"),
406404
bounds: vec![GenericBound::Outlives(
407405
clean_middle_region(b).expect("failed to clean bounds"),
408406
)],
409-
})
407+
}
410408
}
411409

412410
fn clean_type_outlives_predicate<'tcx>(
413411
pred: ty::Binder<'tcx, ty::TypeOutlivesPredicate<'tcx>>,
414412
cx: &mut DocContext<'tcx>,
415-
) -> Option<WherePredicate> {
413+
) -> WherePredicate {
416414
let ty::OutlivesPredicate(ty, lt) = pred.skip_binder();
417415

418-
Some(WherePredicate::BoundPredicate {
416+
WherePredicate::BoundPredicate {
419417
ty: clean_middle_ty(pred.rebind(ty), cx, None, None),
420418
bounds: vec![GenericBound::Outlives(
421419
clean_middle_region(lt).expect("failed to clean lifetimes"),
422420
)],
423421
bound_params: Vec::new(),
424-
})
422+
}
425423
}
426424

427425
fn clean_middle_term<'tcx>(
@@ -1860,7 +1858,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
18601858

18611859
/// Returns `None` if the type could not be normalized
18621860
fn normalize<'tcx>(
1863-
cx: &mut DocContext<'tcx>,
1861+
cx: &DocContext<'tcx>,
18641862
ty: ty::Binder<'tcx, Ty<'tcx>>,
18651863
) -> Option<ty::Binder<'tcx, Ty<'tcx>>> {
18661864
// HACK: low-churn fix for #79459 while we wait for a trait normalization fix

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind1.rs:LL:CC:
23
explicit panic
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
12
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
23
explicit panic
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
45
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
6+
57
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
68
panic in a function that cannot unwind
79
stack backtrace:

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
12
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
23
explicit panic
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
45
note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect
6+
57
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
68
panic in a function that cannot unwind
79
stack backtrace:

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC:
23
explicit panic
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
thread 'main' panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC:
23
explicit panic
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/tools/miri/tests/fail/intrinsics/uninit_uninhabited_type.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
23
aborted execution: attempted to instantiate uninhabited type `!`
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/tools/miri/tests/fail/intrinsics/zero_fn_ptr.stderr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
23
aborted execution: attempted to zero-initialize type `fn()`, which is invalid
34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

0 commit comments

Comments
 (0)