Use def_path_str for def id arg in UnsupportedOpInfo

This commit is contained in:
Michael Goulet 2025-03-20 03:21:58 +00:00
parent 2947be7af8
commit e6004ccb50
6 changed files with 12 additions and 11 deletions

View File

@ -93,7 +93,7 @@ const_eval_expected_inbounds_pointer =
} }
const_eval_extern_static = const_eval_extern_static =
cannot access extern static ({$did}) cannot access extern static `{$did}`
const_eval_extern_type_field = `extern type` field does not have a known offset const_eval_extern_type_field = `extern type` field does not have a known offset
const_eval_fn_ptr_call = const_eval_fn_ptr_call =
@ -381,7 +381,7 @@ const_eval_thread_local_access =
thread-local statics cannot be accessed at compile-time thread-local statics cannot be accessed at compile-time
const_eval_thread_local_static = const_eval_thread_local_static =
cannot access thread local static ({$did}) cannot access thread local static `{$did}`
const_eval_too_generic = const_eval_too_generic =
encountered overly generic constant encountered overly generic constant
const_eval_too_many_caller_args = const_eval_too_many_caller_args =

View File

@ -898,6 +898,7 @@ impl ReportErrorExt for UnsupportedOpInfo {
UnsupportedOpInfo::ExternStatic(_) => const_eval_extern_static, UnsupportedOpInfo::ExternStatic(_) => const_eval_extern_static,
} }
} }
fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) { fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
use UnsupportedOpInfo::*; use UnsupportedOpInfo::*;
@ -917,9 +918,9 @@ impl ReportErrorExt for UnsupportedOpInfo {
OverwritePartialPointer(ptr) | ReadPartialPointer(ptr) => { OverwritePartialPointer(ptr) | ReadPartialPointer(ptr) => {
diag.arg("ptr", ptr); diag.arg("ptr", ptr);
} }
ThreadLocalStatic(did) | ExternStatic(did) => { ThreadLocalStatic(did) | ExternStatic(did) => rustc_middle::ty::tls::with(|tcx| {
diag.arg("did", format!("{did:?}")); diag.arg("did", tcx.def_path_str(did));
} }),
} }
} }
} }

View File

@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer
--> $DIR/extern-static.rs:11:25 --> $DIR/extern-static.rs:11:25
| |
LL | unsafe { let _val = DATA; } LL | unsafe { let _val = DATA; }
| ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) | ^^^^ cannot access extern static `DATA`
error[E0080]: could not evaluate static initializer error[E0080]: could not evaluate static initializer
--> $DIR/extern-static.rs:16:14 --> $DIR/extern-static.rs:16:14
| |
LL | unsafe { DATA = 0; } LL | unsafe { DATA = 0; }
| ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) | ^^^^^^^^ cannot access extern static `DATA`
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View File

@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer
--> $DIR/tls.rs:11:25 --> $DIR/tls.rs:11:25
| |
LL | unsafe { let _val = A; } LL | unsafe { let _val = A; }
| ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) | ^ cannot access thread local static `A`
error[E0080]: could not evaluate static initializer error[E0080]: could not evaluate static initializer
--> $DIR/tls.rs:20:26 --> $DIR/tls.rs:20:26
| |
LL | unsafe { let _val = &A; } LL | unsafe { let _val = &A; }
| ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) | ^ cannot access thread local static `A`
warning: skipping const checks warning: skipping const checks
| |

View File

@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
--> $DIR/issue-28324.rs:5:23 --> $DIR/issue-28324.rs:5:23
| |
LL | pub static BAZ: u32 = *&error_message_count; LL | pub static BAZ: u32 = *&error_message_count;
| ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static (DefId(0:4 ~ issue_28324[8ec4]::{extern#0}::error_message_count)) | ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static `error_message_count`
error[E0133]: use of extern static is unsafe and requires unsafe function or block error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-28324.rs:5:25 --> $DIR/issue-28324.rs:5:25

View File

@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer
--> $DIR/issue-14227.rs:4:21 --> $DIR/issue-14227.rs:4:21
| |
LL | static CRASH: u32 = symbol; LL | static CRASH: u32 = symbol;
| ^^^^^^ cannot access extern static (DefId(0:4 ~ issue_14227[1133]::{extern#0}::symbol)) | ^^^^^^ cannot access extern static `symbol`
error[E0133]: use of extern static is unsafe and requires unsafe function or block error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-14227.rs:4:21 --> $DIR/issue-14227.rs:4:21