Skip to content

Commit 7566ed8

Browse files
committed
tweak wording
1 parent fe178cc commit 7566ed8

File tree

11 files changed

+111
-110
lines changed

11 files changed

+111
-110
lines changed

src/tools/miri/src/borrow_tracker/tree_borrows/diagnostics.rs

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl HistoryData {
7070
let this = format!("the {tag_name} tag {tag:?}");
7171
let msg_initial_state = format!(", in the initial state {}", created.1);
7272
let msg_creation = format!(
73-
"{this} was created here{maybe_msg_initial_state}.",
73+
"{this} was created here{maybe_msg_initial_state}",
7474
maybe_msg_initial_state = if show_initial_state { &msg_initial_state } else { "" },
7575
);
7676

@@ -79,8 +79,8 @@ impl HistoryData {
7979
{
8080
// NOTE: `offset` is explicitly absent from the error message, it has no significance
8181
// to the user. The meaningful one is `access_range`.
82-
self.events.push((Some(span.data()), format!("{this} then transitioned {transition} due to a {rel} {access_kind} at offsets {access_range:?}.", rel = if is_foreign { "foreign" } else { "child" })));
83-
self.events.push((None, format!("this corresponds to {}.", transition.summary())));
82+
self.events.push((Some(span.data()), format!("{this} then transitioned {transition} due to a {rel} {access_kind} at offsets {access_range:?}", rel = if is_foreign { "foreign" } else { "child" })));
83+
self.events.push((None, format!("this corresponds to {}", transition.summary())));
8484
}
8585
}
8686
}
@@ -266,50 +266,49 @@ impl TbError<'_> {
266266
let accessed = self.accessed_info;
267267
let conflicting = self.conflicting_info;
268268
let accessed_is_conflicting = accessed.tag == conflicting.tag;
269-
let (pre_error, title, relation, problem, conflicting_tag_name) = match self.error_kind {
269+
let (pre_error, title, details, conflicting_tag_name) = match self.error_kind {
270270
ChildAccessForbidden(perm) => {
271271
let conflicting_tag_name =
272272
if accessed_is_conflicting { "accessed" } else { "conflicting" };
273-
(
274-
perm,
275-
format!("{kind} through {accessed} is forbidden."),
276-
(!accessed_is_conflicting).then_some(format!(
277-
"the accessed tag {accessed} is a child of the conflicting tag {conflicting}."
278-
)),
279-
format!(
280-
"the {conflicting_tag_name} tag {conflicting} has state {perm} which forbids child {kind}es."
281-
),
282-
conflicting_tag_name,
283-
)
273+
let title = format!("{kind} through {accessed} is forbidden");
274+
let mut details = Vec::new();
275+
if !accessed_is_conflicting {
276+
details.push(format!(
277+
"the accessed tag {accessed} is a child of the conflicting tag {conflicting}"
278+
));
279+
}
280+
details.push(format!(
281+
"the {conflicting_tag_name} tag {conflicting} has state {perm} which forbids child {kind}es"
282+
));
283+
(perm, title, details, conflicting_tag_name)
284284
}
285285
ProtectedTransition(transition) => {
286286
let conflicting_tag_name = "protected";
287-
(
288-
transition.started(),
289-
format!("{kind} through {accessed} is forbidden."),
290-
Some(format!(
291-
"the accessed tag {accessed} is a foreign tag for the {conflicting_tag_name} tag {conflicting}."
292-
)),
287+
let title = format!("{kind} through {accessed} is forbidden");
288+
let details = vec![
289+
format!(
290+
"the accessed tag {accessed} is foreign to the {conflicting_tag_name} tag {conflicting} (i.e., it is not a child)"
291+
),
292+
format!(
293+
"the access would cause the {conflicting_tag_name} tag {conflicting} to transition {transition}"
294+
),
293295
format!(
294-
"the access would cause the {conflicting_tag_name} tag {conflicting} to transition {transition}. This is {loss}, which is not allowed for protected tags.",
296+
"this is {loss}, which is not allowed for protected tags",
295297
loss = transition.summary(),
296298
),
297-
conflicting_tag_name,
298-
)
299+
];
300+
(transition.started(), title, details, conflicting_tag_name)
299301
}
300302
ProtectedDealloc => {
301303
let conflicting_tag_name = "strongly protected";
302-
(
303-
started_as,
304-
format!("deallocation through {accessed} is forbidden."),
305-
Some(format!(
306-
"the allocation of the accessed tag {accessed} also contains the {conflicting_tag_name} tag {conflicting}."
307-
)),
304+
let title = format!("deallocation through {accessed} is forbidden");
305+
let details = vec![
308306
format!(
309-
"the {conflicting_tag_name} tag {conflicting} disallows deallocations."
307+
"the allocation of the accessed tag {accessed} also contains the {conflicting_tag_name} tag {conflicting}"
310308
),
311-
conflicting_tag_name,
312-
)
309+
format!("the {conflicting_tag_name} tag {conflicting} disallows deallocations"),
310+
];
311+
(started_as, title, details, conflicting_tag_name)
313312
}
314313
};
315314
let pre_transition = PermTransition::from(started_as, pre_error).unwrap();
@@ -322,7 +321,7 @@ impl TbError<'_> {
322321
conflicting_tag_name,
323322
true,
324323
);
325-
err_machine_stop!(TerminationInfo::TreeBorrowsUb { title, relation, problem, history })
324+
err_machine_stop!(TerminationInfo::TreeBorrowsUb { title, details, history })
326325
}
327326
}
328327

src/tools/miri/src/diagnostics.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ pub enum TerminationInfo {
2525
},
2626
TreeBorrowsUb {
2727
title: String,
28-
relation: Option<String>,
29-
problem: String,
28+
details: Vec<String>,
3029
history: tree_diagnostics::HistoryData,
3130
},
3231
Int2PtrWithStrictProvenance,
@@ -222,13 +221,13 @@ pub fn report_error<'tcx, 'mir>(
222221
}
223222
helps
224223
},
225-
TreeBorrowsUb { title: _, relation, problem, history } => {
226-
let mut helps = Vec::new();
227-
if let Some(relation) = relation {
228-
helps.push((None, relation.clone()));
224+
TreeBorrowsUb { title: _, details, history } => {
225+
let mut helps = vec![
226+
(None, format!("this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental"))
227+
];
228+
for m in details {
229+
helps.push((None, m.clone()));
229230
}
230-
helps.push((None, problem.clone()));
231-
helps.push((None, format!("this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental")));
232231
for event in history.events.clone() {
233232
helps.push(event);
234233
}

src/tools/miri/tests/fail/tree-borrows/alternate-read-write.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
error: Undefined Behavior: write access through <TAG> is forbidden.
1+
error: Undefined Behavior: write access through <TAG> is forbidden
22
--> $DIR/alternate-read-write.rs:LL:CC
33
|
44
LL | *y += 1; // Failure
5-
| ^^^^^^^ write access through <TAG> is forbidden.
5+
| ^^^^^^^ write access through <TAG> is forbidden
66
|
7-
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>.
8-
= help: the conflicting tag <TAG> has state Frozen which forbids child write accesses.
97
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
10-
help: the accessed tag <TAG> was created here.
8+
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>
9+
= help: the conflicting tag <TAG> has state Frozen which forbids child write accesses
10+
help: the accessed tag <TAG> was created here
1111
--> $DIR/alternate-read-write.rs:LL:CC
1212
|
1313
LL | let y = unsafe { &mut *(x as *mut u8) };
1414
| ^^^^^^^^^^^^^^^^^^^^
15-
help: the conflicting tag <TAG> was created here, in the initial state Reserved.
15+
help: the conflicting tag <TAG> was created here, in the initial state Reserved
1616
--> $DIR/alternate-read-write.rs:LL:CC
1717
|
1818
LL | let y = unsafe { &mut *(x as *mut u8) };
1919
| ^^^^^^^^^^^^^^^^^^^^
20-
help: the conflicting tag <TAG> then transitioned from Reserved to Active due to a child write access at offsets [0x0..0x1].
20+
help: the conflicting tag <TAG> then transitioned from Reserved to Active due to a child write access at offsets [0x0..0x1]
2121
--> $DIR/alternate-read-write.rs:LL:CC
2222
|
2323
LL | *y += 1; // Success
2424
| ^^^^^^^
25-
= help: this corresponds to an activation.
26-
help: the conflicting tag <TAG> then transitioned from Active to Frozen due to a foreign read access at offsets [0x0..0x1].
25+
= help: this corresponds to an activation
26+
help: the conflicting tag <TAG> then transitioned from Active to Frozen due to a foreign read access at offsets [0x0..0x1]
2727
--> $DIR/alternate-read-write.rs:LL:CC
2828
|
2929
LL | let _val = *x;
3030
| ^^
31-
= help: this corresponds to a loss of write permissions.
31+
= help: this corresponds to a loss of write permissions
3232
= note: BACKTRACE (of the first span):
3333
= note: inside `main` at $DIR/alternate-read-write.rs:LL:CC
3434

src/tools/miri/tests/fail/tree-borrows/error-range.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
error: Undefined Behavior: read access through <TAG> is forbidden.
1+
error: Undefined Behavior: read access through <TAG> is forbidden
22
--> $DIR/error-range.rs:LL:CC
33
|
44
LL | rmut[5] += 1;
5-
| ^^^^^^^^^^^^ read access through <TAG> is forbidden.
5+
| ^^^^^^^^^^^^ read access through <TAG> is forbidden
66
|
7-
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>.
8-
= help: the conflicting tag <TAG> has state Disabled which forbids child read accesses.
97
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
10-
help: the accessed tag <TAG> was created here.
8+
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>
9+
= help: the conflicting tag <TAG> has state Disabled which forbids child read accesses
10+
help: the accessed tag <TAG> was created here
1111
--> $DIR/error-range.rs:LL:CC
1212
|
1313
LL | let rmut = &mut *addr_of_mut!(data[0..6]);
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15-
help: the conflicting tag <TAG> was created here, in the initial state Reserved.
15+
help: the conflicting tag <TAG> was created here, in the initial state Reserved
1616
--> $DIR/error-range.rs:LL:CC
1717
|
1818
LL | let rmut = &mut *addr_of_mut!(data[0..6]);
1919
| ^^^^
20-
help: the conflicting tag <TAG> then transitioned from Reserved to Active due to a child write access at offsets [0x5..0x6].
20+
help: the conflicting tag <TAG> then transitioned from Reserved to Active due to a child write access at offsets [0x5..0x6]
2121
--> $DIR/error-range.rs:LL:CC
2222
|
2323
LL | rmut[5] += 1;
2424
| ^^^^^^^^^^^^
25-
= help: this corresponds to an activation.
26-
help: the conflicting tag <TAG> then transitioned from Active to Frozen due to a foreign read access at offsets [0x5..0x6].
25+
= help: this corresponds to an activation
26+
help: the conflicting tag <TAG> then transitioned from Active to Frozen due to a foreign read access at offsets [0x5..0x6]
2727
--> $DIR/error-range.rs:LL:CC
2828
|
2929
LL | let _v = data[5];
3030
| ^^^^^^^
31-
= help: this corresponds to a loss of write permissions.
32-
help: the conflicting tag <TAG> then transitioned from Frozen to Disabled due to a foreign write access at offsets [0x5..0x6].
31+
= help: this corresponds to a loss of write permissions
32+
help: the conflicting tag <TAG> then transitioned from Frozen to Disabled due to a foreign write access at offsets [0x5..0x6]
3333
--> $DIR/error-range.rs:LL:CC
3434
|
3535
LL | data[5] = 1;
3636
| ^^^^^^^^^^^
37-
= help: this corresponds to a loss of read permissions.
37+
= help: this corresponds to a loss of read permissions
3838
= note: BACKTRACE (of the first span):
3939
= note: inside `main` at $DIR/error-range.rs:LL:CC
4040

src/tools/miri/tests/fail/tree-borrows/fragile-data-race.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
error: Undefined Behavior: write access through <TAG> is forbidden.
1+
error: Undefined Behavior: write access through <TAG> is forbidden
22
--> $DIR/fragile-data-race.rs:LL:CC
33
|
44
LL | unsafe { *p = 1 };
5-
| ^^^^^^ write access through <TAG> is forbidden.
5+
| ^^^^^^ write access through <TAG> is forbidden
66
|
7-
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>.
8-
= help: the conflicting tag <TAG> has state Frozen which forbids child write accesses.
97
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
10-
help: the accessed tag <TAG> was created here.
8+
= help: the accessed tag <TAG> is a child of the conflicting tag <TAG>
9+
= help: the conflicting tag <TAG> has state Frozen which forbids child write accesses
10+
help: the accessed tag <TAG> was created here
1111
--> $DIR/fragile-data-race.rs:LL:CC
1212
|
1313
LL | fn thread_1(x: &mut u8) -> SendPtr {
1414
| ^
15-
help: the conflicting tag <TAG> was created here, in the initial state Reserved.
15+
help: the conflicting tag <TAG> was created here, in the initial state Reserved
1616
--> RUSTLIB/std/src/panic.rs:LL:CC
1717
|
1818
LL | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
1919
| ^
20-
help: the conflicting tag <TAG> then transitioned from Reserved to Frozen due to a foreign read access at offsets [0x0..0x1].
20+
help: the conflicting tag <TAG> then transitioned from Reserved to Frozen due to a foreign read access at offsets [0x0..0x1]
2121
--> RUSTLIB/core/src/ptr/mod.rs:LL:CC
2222
|
2323
LL | crate::intrinsics::read_via_copy(src)
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
25-
= help: this corresponds to a loss of write permissions.
25+
= help: this corresponds to a loss of write permissions
2626
= note: BACKTRACE (of the first span):
2727
= note: inside `main` at $DIR/fragile-data-race.rs:LL:CC
2828

src/tools/miri/tests/fail/tree-borrows/outside-range.stderr

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
error: Undefined Behavior: write access through <TAG> is forbidden.
1+
error: Undefined Behavior: write access through <TAG> is forbidden
22
--> $DIR/outside-range.rs:LL:CC
33
|
44
LL | *y.add(3) = 42;
5-
| ^^^^^^^^^^^^^^ write access through <TAG> is forbidden.
5+
| ^^^^^^^^^^^^^^ write access through <TAG> is forbidden
66
|
7-
= help: the accessed tag <TAG> is a foreign tag for the protected tag <TAG>.
8-
= help: the access would cause the protected tag <TAG> to transition from Reserved to Disabled. This is a loss of read and write permissions, which is not allowed for protected tags.
97
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
10-
help: the accessed tag <TAG> was created here.
8+
= help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
9+
= help: the access would cause the protected tag <TAG> to transition from Reserved to Disabled
10+
= help: this is a loss of read and write permissions, which is not allowed for protected tags
11+
help: the accessed tag <TAG> was created here
1112
--> $DIR/outside-range.rs:LL:CC
1213
|
1314
LL | let raw = data.as_mut_ptr();
1415
| ^^^^^^^^^^^^^^^^^
15-
help: the protected tag <TAG> was created here, in the initial state Reserved.
16+
help: the protected tag <TAG> was created here, in the initial state Reserved
1617
--> $DIR/outside-range.rs:LL:CC
1718
|
1819
LL | unsafe fn stuff(x: &mut u8, y: *mut u8) {

src/tools/miri/tests/fail/tree-borrows/read-to-local.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
error: Undefined Behavior: write access through <TAG> is forbidden.
1+
error: Undefined Behavior: write access through <TAG> is forbidden
22
--> $DIR/read-to-local.rs:LL:CC
33
|
44
LL | *ptr = 0;
5-
| ^^^^^^^^ write access through <TAG> is forbidden.
5+
| ^^^^^^^^ write access through <TAG> is forbidden
66
|
7-
= help: the accessed tag <TAG> has state Frozen which forbids child write accesses.
87
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
9-
help: the accessed tag <TAG> was created here, in the initial state Reserved.
8+
= help: the accessed tag <TAG> has state Frozen which forbids child write accesses
9+
help: the accessed tag <TAG> was created here, in the initial state Reserved
1010
--> $DIR/read-to-local.rs:LL:CC
1111
|
1212
LL | let mref = &mut root;
1313
| ^^^^^^^^^
14-
help: the accessed tag <TAG> then transitioned from Reserved to Active due to a child write access at offsets [0x0..0x1].
14+
help: the accessed tag <TAG> then transitioned from Reserved to Active due to a child write access at offsets [0x0..0x1]
1515
--> $DIR/read-to-local.rs:LL:CC
1616
|
1717
LL | *ptr = 0; // Write
1818
| ^^^^^^^^
19-
= help: this corresponds to an activation.
20-
help: the accessed tag <TAG> then transitioned from Active to Frozen due to a foreign read access at offsets [0x0..0x1].
19+
= help: this corresponds to an activation
20+
help: the accessed tag <TAG> then transitioned from Active to Frozen due to a foreign read access at offsets [0x0..0x1]
2121
--> $DIR/read-to-local.rs:LL:CC
2222
|
2323
LL | assert_eq!(root, 0); // Parent Read
2424
| ^^^^^^^^^^^^^^^^^^^
25-
= help: this corresponds to a loss of write permissions.
25+
= help: this corresponds to a loss of write permissions
2626
= note: BACKTRACE (of the first span):
2727
= note: inside `main` at $DIR/read-to-local.rs:LL:CC
2828
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)