Skip to content

Commit 8ebbf58

Browse files
committed
Rollup merge of rust-lang#22262 - lfairy:unsafe-cell-lang-item, r=alexcrichton
`Unsafe` was renamed to `UnsafeCell` a while ago, but the corresponding lang item kept the old name. This patch fixes the inconsistency. r? @eddyb
2 parents da1a1f5 + aef5551 commit 8ebbf58

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

src/libcore/cell.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ impl<'b, T> DerefMut for RefMut<'b, T> {
649649
///
650650
/// **NOTE:** `UnsafeCell<T>`'s fields are public to allow static initializers. It is not
651651
/// recommended to access its fields directly, `get` should be used instead.
652-
#[lang="unsafe"]
652+
#[cfg_attr(stage0, lang="unsafe")] // NOTE: remove after next snapshot
653+
#[cfg_attr(not(stage0), lang="unsafe_cell")]
653654
#[stable(feature = "rust1", since = "1.0.0")]
654655
pub struct UnsafeCell<T> {
655656
/// Wrapped value

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ lets_do_this! {
271271
RangeToStructLangItem, "range_to", range_to_struct;
272272
RangeFullStructLangItem, "range_full", range_full_struct;
273273

274-
UnsafeTypeLangItem, "unsafe", unsafe_type;
274+
UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type;
275275

276276
DerefTraitLangItem, "deref", deref_trait;
277277
DerefMutTraitLangItem, "deref_mut", deref_mut_trait;

src/librustc/middle/traits/select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16541654
ty::BoundSync => {
16551655
if
16561656
Some(def_id) == tcx.lang_items.managed_bound() ||
1657-
Some(def_id) == tcx.lang_items.unsafe_type()
1657+
Some(def_id) == tcx.lang_items.unsafe_cell_type()
16581658
{
16591659
return Err(Unimplemented)
16601660
}

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3577,7 +3577,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
35773577
-> TypeContents {
35783578
if Some(did) == cx.lang_items.managed_bound() {
35793579
tc | TC::Managed
3580-
} else if Some(did) == cx.lang_items.unsafe_type() {
3580+
} else if Some(did) == cx.lang_items.unsafe_cell_type() {
35813581
tc | TC::InteriorUnsafe
35823582
} else {
35833583
tc

src/librustc_typeck/variance.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ struct ConstraintContext<'a, 'tcx: 'a> {
412412
invariant_lang_items: [Option<ast::DefId>; 2],
413413
covariant_lang_items: [Option<ast::DefId>; 2],
414414
contravariant_lang_items: [Option<ast::DefId>; 2],
415-
unsafe_lang_item: Option<ast::DefId>,
415+
unsafe_cell_lang_item: Option<ast::DefId>,
416416

417417
// These are pointers to common `ConstantTerm` instances
418418
covariant: VarianceTermPtr<'a>,
@@ -453,7 +453,7 @@ fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
453453
invariant_lang_items[RegionParam as uint] =
454454
terms_cx.tcx.lang_items.invariant_lifetime();
455455

456-
let unsafe_lang_item = terms_cx.tcx.lang_items.unsafe_type();
456+
let unsafe_cell_lang_item = terms_cx.tcx.lang_items.unsafe_cell_type();
457457

458458
let covariant = terms_cx.arena.alloc(ConstantTerm(ty::Covariant));
459459
let contravariant = terms_cx.arena.alloc(ConstantTerm(ty::Contravariant));
@@ -465,7 +465,7 @@ fn add_constraints_from_crate<'a, 'tcx>(terms_cx: TermsContext<'a, 'tcx>,
465465
invariant_lang_items: invariant_lang_items,
466466
covariant_lang_items: covariant_lang_items,
467467
contravariant_lang_items: contravariant_lang_items,
468-
unsafe_lang_item: unsafe_lang_item,
468+
unsafe_cell_lang_item: unsafe_cell_lang_item,
469469

470470
covariant: covariant,
471471
contravariant: contravariant,
@@ -654,7 +654,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
654654
self.covariant
655655
} else if self.contravariant_lang_items[kind as uint] == Some(item_def_id) {
656656
self.contravariant
657-
} else if kind == TypeParam && Some(item_def_id) == self.unsafe_lang_item {
657+
} else if kind == TypeParam && Some(item_def_id) == self.unsafe_cell_lang_item {
658658
self.invariant
659659
} else if param_def_id.krate == ast::LOCAL_CRATE {
660660
// Parameter on an item defined within current crate:

0 commit comments

Comments
 (0)