Skip to content

Rename the "unsafe" lang item to "unsafe_cell" #22262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
@@ -649,7 +649,8 @@ impl<'b, T> DerefMut for RefMut<'b, T> {
///
/// **NOTE:** `UnsafeCell<T>`'s fields are public to allow static initializers. It is not
/// recommended to access its fields directly, `get` should be used instead.
#[lang="unsafe"]
#[cfg_attr(stage0, lang="unsafe")] // NOTE: remove after next snapshot
#[cfg_attr(not(stage0), lang="unsafe_cell")]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct UnsafeCell<T> {
/// Wrapped value
2 changes: 1 addition & 1 deletion src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ lets_do_this! {
RangeToStructLangItem, "range_to", range_to_struct;
RangeFullStructLangItem, "range_full", range_full_struct;

UnsafeTypeLangItem, "unsafe", unsafe_type;
UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type;

DerefTraitLangItem, "deref", deref_trait;
DerefMutTraitLangItem, "deref_mut", deref_mut_trait;
2 changes: 1 addition & 1 deletion src/librustc/middle/traits/select.rs
Original file line number Diff line number Diff line change
@@ -1654,7 +1654,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::BoundSync => {
if
Some(def_id) == tcx.lang_items.managed_bound() ||
Some(def_id) == tcx.lang_items.unsafe_type()
Some(def_id) == tcx.lang_items.unsafe_cell_type()
{
return Err(Unimplemented)
}
2 changes: 1 addition & 1 deletion src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
@@ -3577,7 +3577,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
-> TypeContents {
if Some(did) == cx.lang_items.managed_bound() {
tc | TC::Managed
} else if Some(did) == cx.lang_items.unsafe_type() {
} else if Some(did) == cx.lang_items.unsafe_cell_type() {
tc | TC::InteriorUnsafe
} else {
tc
8 changes: 4 additions & 4 deletions src/librustc_typeck/variance.rs
Original file line number Diff line number Diff line change
@@ -412,7 +412,7 @@ struct ConstraintContext<'a, 'tcx: 'a> {
invariant_lang_items: [Option<ast::DefId>; 2],
covariant_lang_items: [Option<ast::DefId>; 2],
contravariant_lang_items: [Option<ast::DefId>; 2],
unsafe_lang_item: Option<ast::DefId>,
unsafe_cell_lang_item: Option<ast::DefId>,

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

let unsafe_lang_item = terms_cx.tcx.lang_items.unsafe_type();
let unsafe_cell_lang_item = terms_cx.tcx.lang_items.unsafe_cell_type();

let covariant = terms_cx.arena.alloc(ConstantTerm(ty::Covariant));
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>,
invariant_lang_items: invariant_lang_items,
covariant_lang_items: covariant_lang_items,
contravariant_lang_items: contravariant_lang_items,
unsafe_lang_item: unsafe_lang_item,
unsafe_cell_lang_item: unsafe_cell_lang_item,

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