Skip to content

Commit bb53df1

Browse files
committed
diagnostics: do not repeat the entire message in the span label
1 parent f0d0882 commit bb53df1

File tree

544 files changed

+581
-578
lines changed

Some content is hidden

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

544 files changed

+581
-578
lines changed

src/tools/miri/src/diagnostics.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,17 @@ pub fn report_error<'tcx>(
426426
_ => {}
427427
}
428428

429-
msg.insert(0, format_interp_error(ecx.tcx.dcx(), e));
429+
let mut primary_msg = String::new();
430+
if let Some(title) = title {
431+
write!(primary_msg, "{title}: ").unwrap();
432+
}
433+
write!(primary_msg, "{}", format_interp_error(ecx.tcx.dcx(), e)).unwrap();
434+
435+
msg.insert(0, format!("{} occurred here", title.unwrap_or("error")));
430436

431437
report_msg(
432438
DiagLevel::Error,
433-
if let Some(title) = title { format!("{title}: {}", msg[0]) } else { msg[0].clone() },
439+
primary_msg,
434440
msg,
435441
vec![],
436442
helps,

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: using uninitialized data, but this operation requires
22
--> tests/fail-dep/concurrency/libc_pthread_cond_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_cond_destroy(cond.as_mut_ptr());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_move.init.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: `pthread_cond_t` can't be moved after first use
22
--> tests/fail-dep/concurrency/libc_pthread_cond_move.rs:LL:CC
33
|
44
LL | libc::pthread_cond_destroy(cond2.as_mut_ptr());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `pthread_cond_t` can't be moved after first use
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_cond_move.static_initializer.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: `pthread_cond_t` can't be moved after first use
22
--> tests/fail-dep/concurrency/libc_pthread_cond_move.rs:LL:CC
33
|
44
LL | libc::pthread_cond_destroy(&mut cond2 as *mut _);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `pthread_cond_t` can't be moved after first use
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: using uninitialized data, but this operation requires
22
--> tests/fail-dep/concurrency/libc_pthread_condattr_double_destroy.rs:LL:CC
33
|
44
LL | libc::pthread_condattr_destroy(attr.as_mut_ptr());
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_few_args.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
error: Undefined Behavior: calling a function with more arguments than it expected
22
|
3-
= note: calling a function with more arguments than it expected
3+
= note: Undefined Behavior occurred here
44
= note: (no span available)
55
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
66
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_create_too_many_args.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
error: Undefined Behavior: calling a function with fewer arguments than it requires
22
|
3-
= note: calling a function with fewer arguments than it requires
3+
= note: Undefined Behavior occurred here
44
= note: (no span available)
55
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
66
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_detached.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to join a detached thread
22
--> tests/fail-dep/concurrency/libc_pthread_join_detached.rs:LL:CC
33
|
44
LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached thread
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_joined.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to join an already joined thread
22
--> tests/fail-dep/concurrency/libc_pthread_join_joined.rs:LL:CC
33
|
44
LL | assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join an already joined thread
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

src/tools/miri/tests/fail-dep/concurrency/libc_pthread_join_main.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: Undefined Behavior: trying to join a detached thread
22
--> tests/fail-dep/concurrency/libc_pthread_join_main.rs:LL:CC
33
|
44
LL | assert_eq!(libc::pthread_join(thread_id, ptr::null_mut()), 0);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trying to join a detached thread
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

0 commit comments

Comments
 (0)