Skip to content

Commit fc365d5

Browse files
committed
make Cell & SyncUnsafeCell lang items instead of diagnostic items
1 parent a44d4f0 commit fc365d5

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

compiler/rustc_hir/src/lang_items.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@ language_item_table! {
225225
Index, sym::index, index_trait, Target::Trait, GenericRequirement::Exact(1);
226226
IndexMut, sym::index_mut, index_mut_trait, Target::Trait, GenericRequirement::Exact(1);
227227

228+
229+
Cell, sym::cell, cell_type, Target::Struct, GenericRequirement::None;
228230
UnsafeCell, sym::unsafe_cell, unsafe_cell_type, Target::Struct, GenericRequirement::None;
231+
SyncUnsafeCell, sym::sync_unsafe_cell, sync_unsafe_cell_type, Target::Struct, GenericRequirement::None;
229232
VaList, sym::va_list, va_list, Target::Struct, GenericRequirement::None;
230233

231234
Deref, sym::deref, deref_trait, Target::Trait, GenericRequirement::Exact(0);

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,10 +1261,13 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
12611261
ty::Adt(def, args) => {
12621262
if matches!(
12631263
tcx.as_lang_item(def.did()),
1264-
Some(LangItem::UnsafeCell | LangItem::ManuallyDrop | LangItem::MaybeUninit)
1265-
) || matches!(
1266-
tcx.get_diagnostic_name(def.did()),
1267-
Some(sym::Cell | sym::SyncUnsafeCell)
1264+
Some(
1265+
LangItem::Cell
1266+
| LangItem::UnsafeCell
1267+
| LangItem::SyncUnsafeCell
1268+
| LangItem::ManuallyDrop
1269+
| LangItem::MaybeUninit
1270+
)
12681271
) {
12691272
// These are the types from `std` that guarantee that
12701273
// they have the same layout as `T`.

compiler/rustc_span/src/symbol.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ symbols! {
170170
CallOnceFuture,
171171
CallRefFuture,
172172
Capture,
173-
Cell,
174173
Center,
175174
Cleanup,
176175
Clone,
@@ -322,7 +321,6 @@ symbols! {
322321
SubdiagMessage,
323322
Subdiagnostic,
324323
Sync,
325-
SyncUnsafeCell,
326324
T,
327325
Target,
328326
ToOwned,
@@ -531,6 +529,7 @@ symbols! {
531529
ceilf16,
532530
ceilf32,
533531
ceilf64,
532+
cell,
534533
cfg,
535534
cfg_accessible,
536535
cfg_attr,
@@ -1861,6 +1860,7 @@ symbols! {
18611860
surface_async_drop_in_place,
18621861
sym,
18631862
sync,
1863+
sync_unsafe_cell,
18641864
synthetic,
18651865
t32,
18661866
target,

library/core/src/cell.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ pub use once::OnceCell;
304304
/// ```
305305
///
306306
/// See the [module-level documentation](self) for more.
307-
#[cfg_attr(not(test), rustc_diagnostic_item = "Cell")]
307+
#[cfg_attr(not(bootstrap), lang = "cell")]
308308
#[stable(feature = "rust1", since = "1.0.0")]
309309
#[repr(transparent)]
310310
pub struct Cell<T: ?Sized> {
@@ -2296,7 +2296,7 @@ impl<T> UnsafeCell<*mut T> {
22962296
/// making this type just as unsafe to use.
22972297
///
22982298
/// See [`UnsafeCell`] for details.
2299-
#[cfg_attr(not(test), rustc_diagnostic_item = "SyncUnsafeCell")]
2299+
#[cfg_attr(not(bootstrap), lang = "sync_unsafe_cell")]
23002300
#[unstable(feature = "sync_unsafe_cell", issue = "95439")]
23012301
#[repr(transparent)]
23022302
pub struct SyncUnsafeCell<T: ?Sized> {

0 commit comments

Comments
 (0)