From 1eec3bba13fef50324d1a7542713b3189a627547 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 5 Jun 2013 15:53:17 -0700 Subject: [PATCH] librustc: Rename Const to Freeze --- src/libextra/arc.rs | 20 +++++++++---------- src/libextra/rc.rs | 8 ++++---- src/librustc/middle/borrowck/doc.rs | 4 ++-- .../borrowck/gather_loans/restrictions.rs | 2 +- src/librustc/middle/typeck/collect.rs | 2 +- src/librustdoc/markdown_pass.rs | 4 ++-- src/libstd/clone.rs | 10 +++++----- src/libstd/kinds.rs | 4 ++-- src/libstd/prelude.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/parse/token.rs | 2 +- src/libsyntax/util/interner.rs | 2 +- src/test/auxiliary/issue-2526.rs | 6 +++--- src/test/compile-fail/issue-2611-4.rs | 2 +- .../compile-fail/issue-3177-mutable-struct.rs | 2 +- src/test/compile-fail/mutable-enum.rs | 4 ++-- src/test/compile-fail/mutable-struct.rs | 4 ++-- src/test/run-pass/const-bound.rs | 2 +- src/test/run-pass/issue-2611-3.rs | 2 +- 19 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index 5e3b60bb3a8c..e0ab2558e3fe 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -112,7 +112,7 @@ impl<'self> Condvar<'self> { pub struct ARC { x: UnsafeAtomicRcBox } /// Create an atomically reference counted wrapper. -pub fn ARC(data: T) -> ARC { +pub fn ARC(data: T) -> ARC { ARC { x: UnsafeAtomicRcBox::new(data) } } @@ -120,7 +120,7 @@ pub fn ARC(data: T) -> ARC { * Access the underlying data in an atomically reference counted * wrapper. */ -impl ARC { +impl ARC { pub fn get<'a>(&'a self) -> &'a T { unsafe { &*self.x.get_immut() } } @@ -133,7 +133,7 @@ impl ARC { * object. However, one of the `arc` objects can be sent to another task, * allowing them to share the underlying data. */ -impl Clone for ARC { +impl Clone for ARC { fn clone(&self) -> ARC { ARC { x: self.x.clone() } } @@ -282,14 +282,14 @@ struct RWARC { } /// Create a reader/writer ARC with the supplied data. -pub fn RWARC(user_data: T) -> RWARC { +pub fn RWARC(user_data: T) -> RWARC { 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( +pub fn rw_arc_with_condvars( user_data: T, num_condvars: uint) -> RWARC { @@ -299,7 +299,7 @@ pub fn rw_arc_with_condvars( RWARC { x: UnsafeAtomicRcBox::new(data), } } -impl RWARC { +impl RWARC { /// Duplicate a rwlock-protected ARC, as arc::clone. pub fn clone(&self) -> RWARC { RWARC { @@ -309,7 +309,7 @@ impl RWARC { } -impl RWARC { +impl RWARC { /** * Access the underlying data mutably. Locks the rwlock in write mode; * other readers and writers will block. @@ -435,7 +435,7 @@ impl RWARC { // 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(state: *const RWARCInner) -> *RWlock { +fn borrow_rwlock(state: *const RWARCInner) -> *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(&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(&self, blk: &fn(x: &T) -> U) -> U { match *self { diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 8bd42eae2406..ca3229d4b25c 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -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` or `RcMut` is ever `Owned` and `RcMut` is never `Const`. If `T` is `Const`, a +Neither `Rc` or `RcMut` is ever `Owned` and `RcMut` is never `Freeze`. If `T` is `Freeze`, a cycle cannot be created with `Rc` because there is no way to modify it after creation. */ @@ -56,7 +56,7 @@ pub fn rc_from_owned(value: T) -> Rc { } // FIXME: #6516: should be a static method -pub fn rc_from_const(value: T) -> Rc { +pub fn rc_from_const(value: T) -> Rc { unsafe { Rc::new(value) } } @@ -190,7 +190,7 @@ pub fn rc_mut_from_owned(value: T) -> RcMut { } // FIXME: #6516: should be a static method -pub fn rc_mut_from_const(value: T) -> RcMut { +pub fn rc_mut_from_const(value: T) -> RcMut { unsafe { RcMut::new(value) } } diff --git a/src/librustc/middle/borrowck/doc.rs b/src/librustc/middle/borrowck/doc.rs index cb3983117e97..7a91f204b131 100644 --- a/src/librustc/middle/borrowck/doc.rs +++ b/src/librustc/middle/borrowck/doc.rs @@ -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 diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index bedb465c5c14..a867ea948025 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -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 } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 0e118adb8f42..94520b6faca6 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -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 { diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 6622ea1551bf..ca167c3726ae 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -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] diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index 046693632c60..4a85a8c871d6 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -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 DeepClone for ~T { } // FIXME: #6525: should also be implemented for `T: Owned + DeepClone` -impl DeepClone for @T { - /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing +impl 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 DeepClone for @mut T { - /// Return a deep copy of the managed box. The `Const` trait is required to prevent performing +impl 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() } diff --git a/src/libstd/kinds.rs b/src/libstd/kinds.rs index b7ec90574e29..9d5348ff98f0 100644 --- a/src/libstd/kinds.rs +++ b/src/libstd/kinds.rs @@ -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. } diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs index 8e240a62236f..5959cdaf318c 100644 --- a/src/libstd/prelude.rs +++ b/src/libstd/prelude.rs @@ -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}; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index feb03896558e..a9b0c3986f8b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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 diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2ddae73a3fcd..df599596d7d0 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -563,7 +563,7 @@ pub mod keywords { // Strict keywords As, Break, - Const, + Freeze, Copy, Do, Else, diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index af37c1d27d82..3cdc4fd0fa10 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -21,7 +21,7 @@ pub struct Interner { } // when traits can extend traits, we should extend index to get [] -impl Interner { +impl Interner { pub fn new() -> Interner { Interner { map: @mut HashMap::new(), diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index d4f6a1ec4040..8c491a4dfc83 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -20,17 +20,17 @@ struct arc_destruct { } #[unsafe_destructor] -impl Drop for arc_destruct { +impl Drop for arc_destruct { fn drop(&self) {} } -fn arc_destruct(data: int) -> arc_destruct { +fn arc_destruct(data: int) -> arc_destruct { arc_destruct { _data: data } } -fn arc(_data: T) -> arc_destruct { +fn arc(_data: T) -> arc_destruct { arc_destruct(0) } diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 2385be5723e2..531d4eab5357 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -20,7 +20,7 @@ struct E { } impl A for E { - fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Const` + fn b(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze` } fn main() {} diff --git a/src/test/compile-fail/issue-3177-mutable-struct.rs b/src/test/compile-fail/issue-3177-mutable-struct.rs index 31c0dc7d9c4e..180f13d03719 100644 --- a/src/test/compile-fail/issue-3177-mutable-struct.rs +++ b/src/test/compile-fail/issue-3177-mutable-struct.rs @@ -10,7 +10,7 @@ // xfail-test // error-pattern: instantiating a type parameter with an incompatible type -struct S { +struct S { s: T, cant_nest: () } diff --git a/src/test/compile-fail/mutable-enum.rs b/src/test/compile-fail/mutable-enum.rs index 2368e5eb5c51..db2172b2e570 100644 --- a/src/test/compile-fail/mutable-enum.rs +++ b/src/test/compile-fail/mutable-enum.rs @@ -11,9 +11,9 @@ #[mutable] enum Foo { A } -fn bar(_: T) {} +fn bar(_: 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` } diff --git a/src/test/compile-fail/mutable-struct.rs b/src/test/compile-fail/mutable-struct.rs index ee040506c40b..8511bcdcd350 100644 --- a/src/test/compile-fail/mutable-struct.rs +++ b/src/test/compile-fail/mutable-struct.rs @@ -11,9 +11,9 @@ #[mutable] struct Foo { a: int } -fn bar(_: T) {} +fn bar(_: 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` } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 685d86c740d9..05f586f76e95 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -12,7 +12,7 @@ // are const. -fn foo(x: T) -> T { x } +fn foo(x: T) -> T { x } struct F { field: int } diff --git a/src/test/run-pass/issue-2611-3.rs b/src/test/run-pass/issue-2611-3.rs index acc6ffd0dd1b..7f6535526312 100644 --- a/src/test/run-pass/issue-2611-3.rs +++ b/src/test/run-pass/issue-2611-3.rs @@ -12,7 +12,7 @@ // than the traits require. trait A { - fn b(x: C) -> C; + fn b(x: C) -> C; } struct E {