Skip to content

Commit 55fa3f7

Browse files
authored
Rollup merge of #138732 - compiler-errors:did, r=jieyouxu
Use `def_path_str` for def id arg in `UnsupportedOpInfo` We could alternatively just omit the def path from the label, but I think it's fine to keep around Fixes #138730
2 parents 0d37f36 + e6004cc commit 55fa3f7

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

compiler/rustc_const_eval/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ const_eval_expected_inbounds_pointer =
9393
}
9494
9595
const_eval_extern_static =
96-
cannot access extern static ({$did})
96+
cannot access extern static `{$did}`
9797
const_eval_extern_type_field = `extern type` field does not have a known offset
9898
9999
const_eval_fn_ptr_call =
@@ -381,7 +381,7 @@ const_eval_thread_local_access =
381381
thread-local statics cannot be accessed at compile-time
382382
383383
const_eval_thread_local_static =
384-
cannot access thread local static ({$did})
384+
cannot access thread local static `{$did}`
385385
const_eval_too_generic =
386386
encountered overly generic constant
387387
const_eval_too_many_caller_args =

compiler/rustc_const_eval/src/errors.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ impl ReportErrorExt for UnsupportedOpInfo {
898898
UnsupportedOpInfo::ExternStatic(_) => const_eval_extern_static,
899899
}
900900
}
901+
901902
fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
902903
use UnsupportedOpInfo::*;
903904

@@ -917,9 +918,9 @@ impl ReportErrorExt for UnsupportedOpInfo {
917918
OverwritePartialPointer(ptr) | ReadPartialPointer(ptr) => {
918919
diag.arg("ptr", ptr);
919920
}
920-
ThreadLocalStatic(did) | ExternStatic(did) => {
921-
diag.arg("did", format!("{did:?}"));
922-
}
921+
ThreadLocalStatic(did) | ExternStatic(did) => rustc_middle::ty::tls::with(|tcx| {
922+
diag.arg("did", tcx.def_path_str(did));
923+
}),
923924
}
924925
}
925926
}

tests/ui/consts/miri_unleashed/extern-static.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer
22
--> $DIR/extern-static.rs:11:25
33
|
44
LL | unsafe { let _val = DATA; }
5-
| ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA))
5+
| ^^^^ cannot access extern static `DATA`
66

77
error[E0080]: could not evaluate static initializer
88
--> $DIR/extern-static.rs:16:14
99
|
1010
LL | unsafe { DATA = 0; }
11-
| ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA))
11+
| ^^^^^^^^ cannot access extern static `DATA`
1212

1313
error: aborting due to 2 previous errors
1414

tests/ui/consts/miri_unleashed/tls.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer
22
--> $DIR/tls.rs:11:25
33
|
44
LL | unsafe { let _val = A; }
5-
| ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A))
5+
| ^ cannot access thread local static `A`
66

77
error[E0080]: could not evaluate static initializer
88
--> $DIR/tls.rs:20:26
99
|
1010
LL | unsafe { let _val = &A; }
11-
| ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A))
11+
| ^ cannot access thread local static `A`
1212

1313
warning: skipping const checks
1414
|

tests/ui/extern/issue-28324.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
22
--> $DIR/issue-28324.rs:5:23
33
|
44
LL | pub static BAZ: u32 = *&error_message_count;
5-
| ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static (DefId(0:4 ~ issue_28324[8ec4]::{extern#0}::error_message_count))
5+
| ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static `error_message_count`
66

77
error[E0133]: use of extern static is unsafe and requires unsafe function or block
88
--> $DIR/issue-28324.rs:5:25

tests/ui/statics/issue-14227.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
22
--> $DIR/issue-14227.rs:4:21
33
|
44
LL | static CRASH: u32 = symbol;
5-
| ^^^^^^ cannot access extern static (DefId(0:4 ~ issue_14227[1133]::{extern#0}::symbol))
5+
| ^^^^^^ cannot access extern static `symbol`
66

77
error[E0133]: use of extern static is unsafe and requires unsafe function or block
88
--> $DIR/issue-14227.rs:4:21

0 commit comments

Comments
 (0)