Skip to content

Commit c672773

Browse files
committedApr 23, 2024
Auto merge of rust-lang#124277 - matthiaskrgr:rollup-zdb93i4, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#123680 (Deny gen keyword in `edition_2024_compat` lints) - rust-lang#124057 (Fix ICE when ADT tail has type error) - rust-lang#124168 (Use `DefiningOpaqueTypes::Yes` in rustdoc, where the `InferCtxt` is guaranteed to have no opaque types it can define) - rust-lang#124197 (Move duplicated code in functions in `tests/rustdoc-gui/notable-trait.goml`) - rust-lang#124200 (Improve handling of expr->field errors) - rust-lang#124220 (Miri: detect wrong vtables in wide pointers) - rust-lang#124266 (remove an unused type from the reentrant lock tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a77f76e + 819b4d5 commit c672773

Some content is hidden

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

51 files changed

+674
-254
lines changed
 

‎compiler/rustc_const_eval/messages.ftl

+3-9
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ const_eval_double_storage_live =
8282
const_eval_dyn_call_not_a_method =
8383
`dyn` call trying to call something that is not a method
8484
85-
const_eval_dyn_call_vtable_mismatch =
86-
`dyn` call on a pointer whose vtable does not match its type
87-
88-
const_eval_dyn_star_call_vtable_mismatch =
89-
`dyn*` call on a pointer whose vtable does not match its type
90-
9185
const_eval_error = {$error_kind ->
9286
[static] could not evaluate static initializer
9387
[const] evaluation of constant value failed
@@ -192,6 +186,8 @@ const_eval_invalid_uninit_bytes_unknown =
192186
const_eval_invalid_vtable_pointer =
193187
using {$pointer} as vtable pointer but it does not point to a vtable
194188
189+
const_eval_invalid_vtable_trait =
190+
using vtable for trait `{$vtable_trait}` but trait `{$expected_trait}` was expected
195191
196192
const_eval_live_drop =
197193
destructor of `{$dropped_ty}` cannot be evaluated at compile-time
@@ -401,9 +397,6 @@ const_eval_unterminated_c_string =
401397
const_eval_unwind_past_top =
402398
unwinding past the topmost frame of the stack
403399
404-
const_eval_upcast_mismatch =
405-
upcast on a pointer whose vtable does not match its type
406-
407400
## The `front_matter`s here refer to either `const_eval_front_matter_invalid_value` or `const_eval_front_matter_invalid_value_with_path`.
408401
## (We'd love to sort this differently to make that more clear but tidy won't let us...)
409402
const_eval_validation_box_to_static = {$front_matter}: encountered a box pointing to a static variable in a constant
@@ -450,6 +443,7 @@ const_eval_validation_invalid_fn_ptr = {$front_matter}: encountered {$value}, bu
450443
const_eval_validation_invalid_ref_meta = {$front_matter}: encountered invalid reference metadata: total size is bigger than largest supported object
451444
const_eval_validation_invalid_ref_slice_meta = {$front_matter}: encountered invalid reference metadata: slice is bigger than largest supported object
452445
const_eval_validation_invalid_vtable_ptr = {$front_matter}: encountered {$value}, but expected a vtable pointer
446+
const_eval_validation_invalid_vtable_trait = {$front_matter}: wrong trait in wide pointer vtable: expected `{$ref_trait}`, but encountered `{$vtable_trait}`
453447
const_eval_validation_mutable_ref_to_immutable = {$front_matter}: encountered mutable reference or box pointing to read-only memory
454448
const_eval_validation_never_val = {$front_matter}: encountered a value of the never type `!`
455449
const_eval_validation_null_box = {$front_matter}: encountered a null box

‎compiler/rustc_const_eval/src/errors.rs

+17
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
498498
InvalidTag(_) => const_eval_invalid_tag,
499499
InvalidFunctionPointer(_) => const_eval_invalid_function_pointer,
500500
InvalidVTablePointer(_) => const_eval_invalid_vtable_pointer,
501+
InvalidVTableTrait { .. } => const_eval_invalid_vtable_trait,
501502
InvalidStr(_) => const_eval_invalid_str,
502503
InvalidUninitBytes(None) => const_eval_invalid_uninit_bytes_unknown,
503504
InvalidUninitBytes(Some(_)) => const_eval_invalid_uninit_bytes,
@@ -537,13 +538,21 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
537538
| DeadLocal
538539
| UninhabitedEnumVariantWritten(_)
539540
| UninhabitedEnumVariantRead(_) => {}
541+
540542
BoundsCheckFailed { len, index } => {
541543
diag.arg("len", len);
542544
diag.arg("index", index);
543545
}
544546
UnterminatedCString(ptr) | InvalidFunctionPointer(ptr) | InvalidVTablePointer(ptr) => {
545547
diag.arg("pointer", ptr);
546548
}
549+
InvalidVTableTrait { expected_trait, vtable_trait } => {
550+
diag.arg("expected_trait", expected_trait.to_string());
551+
diag.arg(
552+
"vtable_trait",
553+
vtable_trait.map(|t| t.to_string()).unwrap_or_else(|| format!("<trivial>")),
554+
);
555+
}
547556
PointerUseAfterFree(alloc_id, msg) => {
548557
diag.arg("alloc_id", alloc_id)
549558
.arg("bad_pointer_message", bad_pointer_message(msg, dcx));
@@ -634,6 +643,7 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
634643
UninhabitedEnumVariant => const_eval_validation_uninhabited_enum_variant,
635644
Uninit { .. } => const_eval_validation_uninit,
636645
InvalidVTablePtr { .. } => const_eval_validation_invalid_vtable_ptr,
646+
InvalidMetaWrongTrait { .. } => const_eval_validation_invalid_vtable_trait,
637647
InvalidMetaSliceTooLarge { ptr_kind: PointerKind::Box } => {
638648
const_eval_validation_invalid_box_slice_meta
639649
}
@@ -773,6 +783,13 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
773783
DanglingPtrNoProvenance { pointer, .. } => {
774784
err.arg("pointer", pointer);
775785
}
786+
InvalidMetaWrongTrait { expected_trait: ref_trait, vtable_trait } => {
787+
err.arg("ref_trait", ref_trait.to_string());
788+
err.arg(
789+
"vtable_trait",
790+
vtable_trait.map(|t| t.to_string()).unwrap_or_else(|| format!("<trivial>")),
791+
);
792+
}
776793
NullPtr { .. }
777794
| PtrToStatic { .. }
778795
| ConstRefToMutable

0 commit comments

Comments
 (0)