Skip to content

Commit 01fd384

Browse files
committed
Correct comments concerning updated dangling pointer lint
1 parent 24cc924 commit 01fd384

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

compiler/rustc_lint/src/dangling.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ declare_lint! {
4343
}
4444

4545
/// FIXME: false negatives (i.e. the lint is not emitted when it should be)
46-
/// 1. Method calls that are not checked for:
47-
/// - [`temporary_unsafe_cell.get()`][`core::cell::UnsafeCell::get()`]
48-
/// - [`temporary_sync_unsafe_cell.get()`][`core::cell::SyncUnsafeCell::get()`]
49-
/// 2. Ways to get a temporary that are not recognized:
46+
/// 1. Ways to get a temporary that are not recognized:
5047
/// - `owning_temporary.field`
5148
/// - `owning_temporary[index]`
52-
/// 3. No checks for ref-to-ptr conversions:
49+
/// 2. No checks for ref-to-ptr conversions:
5350
/// - `&raw [mut] temporary`
5451
/// - `&temporary as *(const|mut) _`
5552
/// - `ptr::from_ref(&temporary)` and friends
@@ -200,8 +197,8 @@ fn is_temporary_rvalue(expr: &Expr<'_>) -> bool {
200197
}
201198
}
202199

203-
// Array, Vec, String, CString, MaybeUninit, Cell, Box<[_]>, Box<str>, Box<CStr>,
204-
// or any of the above in arbitrary many nested Box'es.
200+
// Array, Vec, String, CString, MaybeUninit, Cell, Box<[_]>, Box<str>, Box<CStr>, UnsafeCell,
201+
// SyncUnsafeCell, or any of the above in arbitrary many nested Box'es.
205202
fn owns_allocation(tcx: TyCtxt<'_>, ty: Ty<'_>) -> bool {
206203
if ty.is_array() {
207204
true
@@ -217,7 +214,7 @@ fn owns_allocation(tcx: TyCtxt<'_>, ty: Ty<'_>) -> bool {
217214
}
218215
}
219216
tcx.get_diagnostic_name(def.did()).is_some_and(|name| {
220-
matches!(name, sym::cstring_type | sym::Vec | sym::Cell | sym::sync_unsafe_cell)
217+
matches!(name, sym::cstring_type | sym::Vec | sym::Cell | sym::SyncUnsafeCell)
221218
})
222219
} else {
223220
false

compiler/rustc_span/src/symbol.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ symbols! {
316316
SubdiagMessage,
317317
Subdiagnostic,
318318
Sync,
319+
SyncUnsafeCell,
319320
T,
320321
Target,
321322
ToOwned,
@@ -1929,7 +1930,6 @@ symbols! {
19291930
surface_async_drop_in_place,
19301931
sym,
19311932
sync,
1932-
sync_unsafe_cell,
19331933
synthetic,
19341934
t32,
19351935
target,

library/core/src/cell.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<UnsafeCell<U>> for UnsafeCell<T>
22732273
/// See [`UnsafeCell`] for details.
22742274
#[unstable(feature = "sync_unsafe_cell", issue = "95439")]
22752275
#[repr(transparent)]
2276-
#[rustc_diagnostic_item = "sync_unsafe_cell"]
2276+
#[rustc_diagnostic_item = "SyncUnsafeCell"]
22772277
#[rustc_pub_transparent]
22782278
pub struct SyncUnsafeCell<T: ?Sized> {
22792279
value: UnsafeCell<T>,

0 commit comments

Comments
 (0)