Skip to content

Commit 76126be

Browse files
committed
Auto merge of #153741 - JonathanBrouwer:rollup-xwr7mEB, r=JonathanBrouwer
Rollup of 12 pull requests Successful merges: - rust-lang/rust#152569 (Stop using rustc_layout_scalar_valid_range_* in rustc) - rust-lang/rust#153421 (Fix ICE in fn_delegation when child segment resolves to a trait) - rust-lang/rust#153571 (Avoid ICE when an EII declaration conflicts with a constructor) - rust-lang/rust#153581 (Simplify `type_of_opaque`.) - rust-lang/rust#153611 (interpret: go back to regular string interpolation for error messages) - rust-lang/rust#153635 (Unify same-span labels in move error diagnostics) - rust-lang/rust#153660 (mir-opt: Drop invalid debuginfos after SingleUseConsts.) - rust-lang/rust#153685 (Introduce `for_each_query_vtable!` to move more code out of query macros) - rust-lang/rust#153722 (miri-test-libstd: use --tests and update some comments) - rust-lang/rust#153671 (Make Enzyme has dependent on LLVM hash) - rust-lang/rust#153710 (remove `.ftl` checks from tidy) - rust-lang/rust#153720 (doc/rustc: clarify how to contact arm-maintainers)
2 parents 1645a27 + e860133 commit 76126be

4 files changed

Lines changed: 29 additions & 46 deletions

File tree

src/borrow_tracker/stacked_borrows/diagnostics.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@ impl Creation {
3737
let tag = self.retag.new_tag;
3838
if let Some(perm) = self.retag.permission {
3939
(
40-
format!(
41-
"{tag:?} was created by a {:?} retag at offsets {:?}",
42-
perm, self.retag.range,
43-
),
40+
format!("{tag:?} was created by a {perm:?} retag at offsets {}", self.retag.range),
4441
self.span.data(),
4542
)
4643
} else {
4744
assert!(self.retag.range.size == Size::ZERO);
4845
(
4946
format!(
50-
"{tag:?} would have been created here, but this is a zero-size retag ({:?}) so the tag in question does not exist anywhere",
47+
"{tag:?} would have been created here, but this is a zero-size retag ({}) so the tag in question does not exist anywhere",
5148
self.retag.range,
5249
),
5350
self.span.data(),
@@ -79,12 +76,12 @@ impl Invalidation {
7976
// For a FnEntry retag, our Span points at the caller.
8077
// See `DiagnosticCx::log_invalidation`.
8178
format!(
82-
"{:?} was later invalidated at offsets {:?} by a {} inside this call",
79+
"{:?} was later invalidated at offsets {} by a {} inside this call",
8380
self.tag, self.range, self.cause
8481
)
8582
} else {
8683
format!(
87-
"{:?} was later invalidated at offsets {:?} by a {}",
84+
"{:?} was later invalidated at offsets {} by a {}",
8885
self.tag, self.range, self.cause
8986
)
9087
};
@@ -343,7 +340,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
343340
if self.history.root.0.tag() == tag {
344341
Some((
345342
format!(
346-
"{tag:?} was created here, as the root tag for {:?}",
343+
"{tag:?} was created here, as the root tag for {}",
347344
self.history.id
348345
),
349346
self.history.root.1.data(),
@@ -383,7 +380,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
383380
let perm =
384381
op.permission.expect("`start_grant` must be called before calling `grant_error`");
385382
let action = format!(
386-
"trying to retag from {:?} for {:?} permission at {:?}[{:#x}]",
383+
"trying to retag from {:?} for {:?} permission at {}[{:#x}]",
387384
op.orig_tag,
388385
perm,
389386
self.history.id,
@@ -410,7 +407,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
410407
Operation::Dealloc(_) => return self.dealloc_error(stack),
411408
};
412409
let action = format!(
413-
"attempting a {access} using {tag:?} at {alloc_id:?}[{offset:#x}]",
410+
"attempting a {access} using {tag:?} at {alloc_id}[{offset:#x}]",
414411
access = op.kind,
415412
tag = op.tag,
416413
alloc_id = self.history.id,
@@ -455,7 +452,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
455452
};
456453
err_sb_ub(
457454
format!(
458-
"attempting deallocation using {tag:?} at {alloc_id:?}{cause}",
455+
"attempting deallocation using {tag:?} at {alloc_id}{cause}",
459456
tag = op.tag,
460457
alloc_id = self.history.id,
461458
cause = error_cause(stack, op.tag),
@@ -488,7 +485,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
488485
}
489486

490487
fn operation_summary(operation: &str, alloc_id: AllocId, alloc_range: AllocRange) -> String {
491-
format!("this error occurs as part of {operation} at {alloc_id:?}{alloc_range:?}")
488+
format!("this error occurs as part of {operation} at {alloc_id}{alloc_range}")
492489
}
493490

494491
fn error_cause(stack: &Stack, prov_extra: ProvenanceExtra) -> &'static str {

src/borrow_tracker/tree_borrows/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl HistoryData {
157157
// to the user. The meaningful one is `access_range`.
158158
let access = access_cause.print_as_access(is_foreign);
159159
let access_range_text = match access_range {
160-
Some(r) => format!("at offsets {r:?}"),
160+
Some(r) => format!("at offsets {r}"),
161161
None => format!("on every location previously accessed by this tag"),
162162
};
163163
self.events.push((
@@ -339,7 +339,7 @@ impl TbError<'_> {
339339
// all tags through which an access would cause UB.
340340
let accessed_is_conflicting = accessed.map(|a| a.tag) == Some(conflicting.tag);
341341
let title = format!(
342-
"{cause} through {accessed_str} at {alloc_id:?}[{error_offset:#x}] is forbidden",
342+
"{cause} through {accessed_str} at {alloc_id}[{error_offset:#x}] is forbidden",
343343
alloc_id = self.access_info.alloc_id
344344
);
345345
let (title, details, conflicting_tag_name) = match self.error_kind {

src/diagnostics.rs

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::sync::Mutex;
44

55
use rustc_abi::{Align, Size};
66
use rustc_data_structures::fx::{FxBuildHasher, FxHashSet};
7-
use rustc_errors::{Diag, DiagMessage, Level};
7+
use rustc_errors::{Diag, Level};
88
use rustc_span::{DUMMY_SP, Span, SpanData, Symbol};
99

1010
use crate::borrow_tracker::stacked_borrows::diagnostics::TagHistory;
@@ -106,16 +106,7 @@ impl fmt::Debug for TerminationInfo {
106106
}
107107
}
108108

109-
impl MachineStopType for TerminationInfo {
110-
fn diagnostic_message(&self) -> DiagMessage {
111-
self.to_string().into()
112-
}
113-
fn add_args(
114-
self: Box<Self>,
115-
_: &mut dyn FnMut(std::borrow::Cow<'static, str>, rustc_errors::DiagArgValue),
116-
) {
117-
}
118-
}
109+
impl MachineStopType for TerminationInfo {}
119110

120111
/// Miri specific diagnostics
121112
pub enum NonHaltingDiagnostic {
@@ -354,16 +345,14 @@ pub fn report_result<'tcx>(
354345
(title, helps)
355346
} else {
356347
let title = match res.kind() {
357-
UndefinedBehavior(ValidationError(validation_err))
358-
if matches!(
359-
validation_err.kind,
360-
ValidationErrorKind::PointerAsInt { .. } | ValidationErrorKind::PartialPointer
361-
) =>
362-
{
348+
UndefinedBehavior(UndefinedBehaviorInfo::ValidationError {
349+
ptr_bytes_warning: true,
350+
..
351+
}) => {
363352
ecx.handle_ice(); // print interpreter backtrace (this is outside the eval `catch_unwind`)
364353
bug!(
365354
"This validation error should be impossible in Miri: {}",
366-
format_interp_error(ecx.tcx.dcx(), res)
355+
format_interp_error(res)
367356
);
368357
}
369358
UndefinedBehavior(_) => "Undefined Behavior",
@@ -380,10 +369,7 @@ pub fn report_result<'tcx>(
380369
) => "post-monomorphization error",
381370
_ => {
382371
ecx.handle_ice(); // print interpreter backtrace (this is outside the eval `catch_unwind`)
383-
bug!(
384-
"This error should be impossible in Miri: {}",
385-
format_interp_error(ecx.tcx.dcx(), res)
386-
);
372+
bug!("This error should be impossible in Miri: {}", format_interp_error(res));
387373
}
388374
};
389375
#[rustfmt::skip]
@@ -411,10 +397,10 @@ pub fn report_result<'tcx>(
411397
match info {
412398
PointerUseAfterFree(alloc_id, _) | PointerOutOfBounds { alloc_id, .. } => {
413399
if let Some(span) = ecx.machine.allocated_span(*alloc_id) {
414-
helps.push(note_span!(span, "{:?} was allocated here:", alloc_id));
400+
helps.push(note_span!(span, "{alloc_id} was allocated here:"));
415401
}
416402
if let Some(span) = ecx.machine.deallocated_span(*alloc_id) {
417-
helps.push(note_span!(span, "{:?} was deallocated here:", alloc_id));
403+
helps.push(note_span!(span, "{alloc_id} was deallocated here:"));
418404
}
419405
}
420406
AbiMismatchArgument { .. } | AbiMismatchReturn { .. } => {
@@ -447,7 +433,7 @@ pub fn report_result<'tcx>(
447433
UndefinedBehavior(InvalidUninitBytes(Some((alloc_id, access)))) => {
448434
writeln!(
449435
extra,
450-
"Uninitialized memory occurred at {alloc_id:?}{range:?}, in this allocation:",
436+
"Uninitialized memory occurred at {alloc_id}{range}, in this allocation:",
451437
range = access.bad,
452438
)
453439
.unwrap();
@@ -460,7 +446,7 @@ pub fn report_result<'tcx>(
460446
if let Some(title) = title {
461447
write!(primary_msg, "{title}: ").unwrap();
462448
}
463-
write!(primary_msg, "{}", format_interp_error(ecx.tcx.dcx(), res)).unwrap();
449+
write!(primary_msg, "{}", format_interp_error(res)).unwrap();
464450

465451
if labels.is_empty() {
466452
labels.push(format!(
@@ -510,7 +496,7 @@ pub fn report_leaks<'tcx>(
510496
let mut any_pruned = false;
511497
for (id, kind, alloc) in leaks {
512498
let mut title = format!(
513-
"memory leaked: {id:?} ({}, size: {:?}, align: {:?})",
499+
"memory leaked: {id:?} ({}, size: {}, align: {})",
514500
kind,
515501
alloc.size().bytes(),
516502
alloc.align.bytes()
@@ -665,17 +651,17 @@ impl<'tcx> MiriMachine<'tcx> {
665651
format!("created {tag:?} with {perm} derived from unknown tag"),
666652
CreatedPointerTag(tag, Some(perm), Some((alloc_id, range, orig_tag))) =>
667653
format!(
668-
"created tag {tag:?} with {perm} at {alloc_id:?}{range:?} derived from {orig_tag:?}"
654+
"created tag {tag:?} with {perm} at {alloc_id}{range} derived from {orig_tag:?}"
669655
),
670656
PoppedPointerTag(item, cause) => format!("popped tracked tag for item {item:?}{cause}"),
671657
TrackingAlloc(id, size, align) =>
672658
format!(
673-
"now tracking allocation {id:?} of {size} bytes (alignment {align} bytes)",
659+
"now tracking allocation {id} of {size} bytes (alignment {align} bytes)",
674660
size = size.bytes(),
675661
align = align.bytes(),
676662
),
677663
AccessedAlloc(id, range, access_kind) =>
678-
format!("{access_kind} at {id:?}[{}..{}]", range.start.bytes(), range.end().bytes()),
664+
format!("{access_kind} at {id}{range}"),
679665
FreedAlloc(id) => format!("freed allocation {id:?}"),
680666
RejectedIsolatedOp(op) => format!("{op} was made to return an error due to isolation"),
681667
ProgressReport { .. } =>

tests/pass/alloc-access-tracking.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ note: now tracking allocation ALLOC of 123 bytes (alignment ALIGN bytes)
44
LL | utils::miri_track_alloc(ptr);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tracking was triggered here
66

7-
note: write access at ALLOC[0..1]
7+
note: write access at ALLOC[0x0..0x1]
88
--> tests/pass/alloc-access-tracking.rs:LL:CC
99
|
1010
LL | *ptr = 42; // Crucially, only a write is printed here, no read!
1111
| ^^^^^^^^^ tracking was triggered here
1212

13-
note: read access at ALLOC[0..1]
13+
note: read access at ALLOC[0x0..0x1]
1414
--> tests/pass/alloc-access-tracking.rs:LL:CC
1515
|
1616
LL | assert_eq!(*ptr, 42);

0 commit comments

Comments
 (0)