librustc: Rename Const to Freeze

This commit is contained in:
Patrick Walton 2013-06-05 15:53:17 -07:00 committed by Corey Richardson
parent d350981c0e
commit 1eec3bba13
19 changed files with 42 additions and 42 deletions

View File

@ -112,7 +112,7 @@ impl<'self> Condvar<'self> {
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
/// Create an atomically reference counted wrapper.
pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
pub fn ARC<T:Freeze + Owned>(data: T) -> ARC<T> {
ARC { x: UnsafeAtomicRcBox::new(data) }
}
@ -120,7 +120,7 @@ pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
* Access the underlying data in an atomically reference counted
* wrapper.
*/
impl<T:Const+Owned> ARC<T> {
impl<T:Freeze+Owned> ARC<T> {
pub fn get<'a>(&'a self) -> &'a T {
unsafe { &*self.x.get_immut() }
}
@ -133,7 +133,7 @@ impl<T:Const+Owned> ARC<T> {
* object. However, one of the `arc` objects can be sent to another task,
* allowing them to share the underlying data.
*/
impl<T:Const + Owned> Clone for ARC<T> {
impl<T:Freeze + Owned> Clone for ARC<T> {
fn clone(&self) -> ARC<T> {
ARC { x: self.x.clone() }
}
@ -282,14 +282,14 @@ struct RWARC<T> {
}
/// Create a reader/writer ARC with the supplied data.
pub fn RWARC<T:Const + Owned>(user_data: T) -> RWARC<T> {
pub fn RWARC<T:Freeze + Owned>(user_data: T) -> RWARC<T> {
rw_arc_with_condvars(user_data, 1)
}
/**
* Create a reader/writer ARC with the supplied data and a specified number
* of condvars (as sync::rwlock_with_condvars).
*/
pub fn rw_arc_with_condvars<T:Const + Owned>(
pub fn rw_arc_with_condvars<T:Freeze + Owned>(
user_data: T,
num_condvars: uint) -> RWARC<T>
{
@ -299,7 +299,7 @@ pub fn rw_arc_with_condvars<T:Const + Owned>(
RWARC { x: UnsafeAtomicRcBox::new(data), }
}
impl<T:Const + Owned> RWARC<T> {
impl<T:Freeze + Owned> RWARC<T> {
/// Duplicate a rwlock-protected ARC, as arc::clone.
pub fn clone(&self) -> RWARC<T> {
RWARC {
@ -309,7 +309,7 @@ impl<T:Const + Owned> RWARC<T> {
}
impl<T:Const + Owned> RWARC<T> {
impl<T:Freeze + Owned> RWARC<T> {
/**
* Access the underlying data mutably. Locks the rwlock in write mode;
* other readers and writers will block.
@ -435,7 +435,7 @@ impl<T:Const + Owned> RWARC<T> {
// lock it. This wraps the unsafety, with the justification that the 'lock'
// field is never overwritten; only 'failed' and 'data'.
#[doc(hidden)]
fn borrow_rwlock<T:Const + Owned>(state: *const RWARCInner<T>) -> *RWlock {
fn borrow_rwlock<T:Freeze + Owned>(state: *const RWARCInner<T>) -> *RWlock {
unsafe { cast::transmute(&const (*state).lock) }
}
@ -452,7 +452,7 @@ pub struct RWReadMode<'self, T> {
token: sync::RWlockReadMode<'self>,
}
impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
impl<'self, T:Freeze + Owned> RWWriteMode<'self, T> {
/// Access the pre-downgrade RWARC in write mode.
pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
match *self {
@ -493,7 +493,7 @@ impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
}
}
impl<'self, T:Const + Owned> RWReadMode<'self, T> {
impl<'self, T:Freeze + Owned> RWReadMode<'self, T> {
/// Access the post-downgrade rwlock in read mode.
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
match *self {

View File

@ -13,10 +13,10 @@
/** Task-local reference counted smart pointers
Task-local reference counted smart pointers are an alternative to managed boxes with deterministic
destruction. They are restricted to containing types that are either `Owned` or `Const` (or both) to
destruction. They are restricted to containing types that are either `Owned` or `Freeze` (or both) to
prevent cycles.
Neither `Rc<T>` or `RcMut<T>` is ever `Owned` and `RcMut<T>` is never `Const`. If `T` is `Const`, a
Neither `Rc<T>` or `RcMut<T>` is ever `Owned` and `RcMut<T>` is never `Freeze`. If `T` is `Freeze`, a
cycle cannot be created with `Rc<T>` because there is no way to modify it after creation.
*/
@ -56,7 +56,7 @@ pub fn rc_from_owned<T: Owned>(value: T) -> Rc<T> {
}
// FIXME: #6516: should be a static method
pub fn rc_from_const<T: Const>(value: T) -> Rc<T> {
pub fn rc_from_const<T: Freeze>(value: T) -> Rc<T> {
unsafe { Rc::new(value) }
}
@ -190,7 +190,7 @@ pub fn rc_mut_from_owned<T: Owned>(value: T) -> RcMut<T> {
}
// FIXME: #6516: should be a static method
pub fn rc_mut_from_const<T: Const>(value: T) -> RcMut<T> {
pub fn rc_mut_from_const<T: Freeze>(value: T) -> RcMut<T> {
unsafe { RcMut::new(value) }
}

View File

@ -539,14 +539,14 @@ mutable borrowed pointers.
### Restrictions for loans of const aliasable pointees
Const pointers are read-only. There may be `&mut` or `&` aliases, and
Freeze pointers are read-only. There may be `&mut` or `&` aliases, and
we can not prevent *anything* but moves in that case. So the
`RESTRICTIONS` function is only defined if `ACTIONS` is the empty set.
Because moves from a `&const` or `@const` lvalue are never legal, it
is not necessary to add any restrictions at all to the final
result.
RESTRICTIONS(*LV, []) = [] // R-Deref-Const-Borrowed
RESTRICTIONS(*LV, []) = [] // R-Deref-Freeze-Borrowed
TYPE(LV) = &const Ty or @const Ty
### Restrictions for loans of mutable borrowed pointees

View File

@ -125,7 +125,7 @@ impl RestrictionsContext {
mc::cat_deref(_, _, mc::region_ptr(m_const, _)) |
mc::cat_deref(_, _, mc::gc_ptr(m_const)) => {
// R-Deref-Const-Borrowed
// R-Deref-Freeze-Borrowed
self.check_no_mutability_control(cmt, restrictions);
Safe
}

View File

@ -1165,7 +1165,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
* enum consisting of a newtyped Ty or a region) to ty's
* notion of ty param bounds, which can either be user-defined
* traits, or one of the four built-in traits (formerly known
* as kinds): Const, Copy, and Send.
* as kinds): Freeze, Copy, and Send.
*/
let mut param_bounds = ty::ParamBounds {

View File

@ -152,7 +152,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
~"Function"
}
doc::ConstTag(_) => {
~"Const"
~"Freeze"
}
doc::EnumTag(_) => {
~"Enum"
@ -786,7 +786,7 @@ mod test {
#[test]
fn should_write_const_header() {
let markdown = render(~"static a: bool = true;");
assert!(markdown.contains("## Const `a`\n\n"));
assert!(markdown.contains("## Freeze `a`\n\n"));
}
#[test]

View File

@ -22,7 +22,7 @@ by convention implementing the `Clone` trait and calling the
*/
use core::kinds::Const;
use core::kinds::Freeze;
/// A common trait for cloning an object.
pub trait Clone {
@ -113,16 +113,16 @@ impl<T: DeepClone> DeepClone for ~T {
}
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
impl<T: Const + DeepClone> DeepClone for @T {
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
impl<T: Freeze + DeepClone> DeepClone for @T {
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline]
fn deep_clone(&self) -> @T { @(**self).deep_clone() }
}
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
impl<T: Const + DeepClone> DeepClone for @mut T {
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
impl<T: Freeze + DeepClone> DeepClone for @mut T {
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline]
fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() }

View File

@ -57,13 +57,13 @@ pub trait Owned {
#[cfg(stage0)]
#[lang="const"]
pub trait Const {
pub trait Freeze {
// empty.
}
#[cfg(not(stage0))]
#[lang="freeze"]
pub trait Const {
pub trait Freeze {
// empty.
}

View File

@ -30,7 +30,7 @@ Rust's prelude has three main parts:
// Reexported core operators
pub use either::{Either, Left, Right};
pub use kinds::{Copy, Sized};
pub use kinds::{Const, Owned};
pub use kinds::{Freeze, Owned};
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
pub use ops::{BitAnd, BitOr, BitXor};
pub use ops::{Drop};

View File

@ -147,7 +147,7 @@ pub static crate_node_id: node_id = 0;
// The AST represents all type param bounds as types.
// typeck::collect::compute_bounds matches these against
// the "special" built-in traits (see middle::lang_items) and
// detects Copy, Send, Owned, and Const.
// detects Copy, Send, Owned, and Freeze.
pub enum TyParamBound {
TraitTyParamBound(@trait_ref),
RegionTyParamBound

View File

@ -563,7 +563,7 @@ pub mod keywords {
// Strict keywords
As,
Break,
Const,
Freeze,
Copy,
Do,
Else,

View File

@ -21,7 +21,7 @@ pub struct Interner<T> {
}
// when traits can extend traits, we should extend index<uint,T> to get []
impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
impl<T:Eq + IterBytes + Hash + Freeze + Copy> Interner<T> {
pub fn new() -> Interner<T> {
Interner {
map: @mut HashMap::new(),

View File

@ -20,17 +20,17 @@ struct arc_destruct<T> {
}
#[unsafe_destructor]
impl<T:Const> Drop for arc_destruct<T> {
impl<T:Freeze> Drop for arc_destruct<T> {
fn drop(&self) {}
}
fn arc_destruct<T:Const>(data: int) -> arc_destruct<T> {
fn arc_destruct<T:Freeze>(data: int) -> arc_destruct<T> {
arc_destruct {
_data: data
}
}
fn arc<T:Const>(_data: T) -> arc_destruct<T> {
fn arc<T:Freeze>(_data: T) -> arc_destruct<T> {
arc_destruct(0)
}

View File

@ -20,7 +20,7 @@ struct E {
}
impl A for E {
fn b<F:Copy + Const,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Const`
fn b<F:Copy + Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
}
fn main() {}

View File

@ -10,7 +10,7 @@
// xfail-test
// error-pattern: instantiating a type parameter with an incompatible type
struct S<T:Const> {
struct S<T:Freeze> {
s: T,
cant_nest: ()
}

View File

@ -11,9 +11,9 @@
#[mutable]
enum Foo { A }
fn bar<T: Const>(_: T) {}
fn bar<T: Freeze>(_: T) {}
fn main() {
let x = A;
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const`
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Freeze`
}

View File

@ -11,9 +11,9 @@
#[mutable]
struct Foo { a: int }
fn bar<T: Const>(_: T) {}
fn bar<T: Freeze>(_: T) {}
fn main() {
let x = Foo { a: 5 };
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Const`
bar(x); //~ ERROR instantiating a type parameter with an incompatible type `Foo`, which does not fulfill `Freeze`
}

View File

@ -12,7 +12,7 @@
// are const.
fn foo<T:Copy + Const>(x: T) -> T { x }
fn foo<T:Copy + Freeze>(x: T) -> T { x }
struct F { field: int }

View File

@ -12,7 +12,7 @@
// than the traits require.
trait A {
fn b<C:Copy + Const,D>(x: C) -> C;
fn b<C:Copy + Freeze,D>(x: C) -> C;
}
struct E {