You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if a_offset < a_info.size && b_offset < b_info.size{
351
+
0
352
+
}else{
353
+
// Otherwise, conservatively say we don't know.
354
+
// There are some cases we could still return `0` for, e.g.
355
+
// if the pointers being equal would require their statics to overlap
356
+
// one or more bytes, but for simplicity we currently only check
357
+
// strictly in-bounds pointers.
358
+
2
359
+
}
360
+
}
361
+
}else{
362
+
// All other cases we conservatively say we don't know.
363
+
//
364
+
// For comparing statics to non-statics, as per https://doc.rust-lang.org/nightly/reference/items/static-items.html#r-items.static.storage-disjointness
365
+
// immutable statics can overlap with other kinds of allocations sometimes.
366
+
//
367
+
// FIXME: We could be more decisive for (non-zero-sized) mutable statics,
368
+
// which cannot overlap with other kinds of allocations.
369
+
//
370
+
// Functions and vtables can be duplicated and deduplicated, so we
371
+
// cannot be sure of runtime equality of pointers to the same one, or the
372
+
// runtime inequality of pointers to different ones (see e.g. #73722),
373
+
// so comparing those should return 2, whether they are the same allocation
374
+
// or not.
375
+
//
376
+
// `GlobalAlloc::TypeId` exists mostly to prevent consteval from comparing
377
+
// `TypeId`s, so comparing those should always return 2, whether they are the
378
+
// same allocation or not.
379
+
//
380
+
// FIXME: We could revisit comparing pointers into the same
381
+
// `GlobalAlloc::Memory` once https://github.com/rust-lang/rust/issues/128775
382
+
// is fixed (but they can be deduplicated, so comparing pointers into different
383
+
// ones should return 2).
384
+
2
385
+
}
289
386
}
290
-
// Other ways of comparing integers and pointers can never be known for sure.
Copy file name to clipboardExpand all lines: compiler/rustc_lint/messages.ftl
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -462,6 +462,14 @@ lint_invalid_reference_casting_note_book = for more information, visit <https://
462
462
463
463
lint_invalid_reference_casting_note_ty_has_interior_mutability = even for types with interior mutability, the only legal way to obtain a mutable pointer from a shared reference is through `UnsafeCell::get`
464
464
465
+
lint_int_to_ptr_transmutes = transmuting an integer to a pointer creates a pointer without provenance
466
+
.note = this is dangerous because dereferencing the resulting pointer is undefined behavior
467
+
.note_exposed_provenance = exposed provenance semantics can be used to create a pointer based on some previously exposed provenance
468
+
.help_transmute = for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers>
469
+
.help_exposed_provenance = for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance>
470
+
.suggestion_with_exposed_provenance = use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance
471
+
.suggestion_without_provenance_mut = if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`
472
+
465
473
lint_legacy_derive_helpers = derive helper attribute is used before it is introduced
0 commit comments