Skip to content

Commit c8bce58

Browse files
committed
librustc: Rename Const to Freeze
1 parent bd53602 commit c8bce58

File tree

21 files changed

+90
-90
lines changed

21 files changed

+90
-90
lines changed

src/libextra/arc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ impl<'self> Condvar<'self> {
112112
pub struct ARC<T> { x: UnsafeAtomicRcBox<T> }
113113

114114
/// Create an atomically reference counted wrapper.
115-
pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> {
115+
pub fn ARC<T:Freeze + Owned>(data: T) -> ARC<T> {
116116
ARC { x: UnsafeAtomicRcBox::new(data) }
117117
}
118118

119119
/**
120120
* Access the underlying data in an atomically reference counted
121121
* wrapper.
122122
*/
123-
impl<T:Const+Owned> ARC<T> {
123+
impl<T:Freeze+Owned> ARC<T> {
124124
pub fn get<'a>(&'a self) -> &'a T {
125125
unsafe { &*self.x.get_immut() }
126126
}
@@ -133,7 +133,7 @@ impl<T:Const+Owned> ARC<T> {
133133
* object. However, one of the `arc` objects can be sent to another task,
134134
* allowing them to share the underlying data.
135135
*/
136-
impl<T:Const + Owned> Clone for ARC<T> {
136+
impl<T:Freeze + Owned> Clone for ARC<T> {
137137
fn clone(&self) -> ARC<T> {
138138
ARC { x: self.x.clone() }
139139
}
@@ -285,14 +285,14 @@ struct RWARC<T> {
285285
}
286286

287287
/// Create a reader/writer ARC with the supplied data.
288-
pub fn RWARC<T:Const + Owned>(user_data: T) -> RWARC<T> {
288+
pub fn RWARC<T:Freeze + Owned>(user_data: T) -> RWARC<T> {
289289
rw_arc_with_condvars(user_data, 1)
290290
}
291291
/**
292292
* Create a reader/writer ARC with the supplied data and a specified number
293293
* of condvars (as sync::rwlock_with_condvars).
294294
*/
295-
pub fn rw_arc_with_condvars<T:Const + Owned>(
295+
pub fn rw_arc_with_condvars<T:Freeze + Owned>(
296296
user_data: T,
297297
num_condvars: uint) -> RWARC<T>
298298
{
@@ -302,7 +302,7 @@ pub fn rw_arc_with_condvars<T:Const + Owned>(
302302
RWARC { x: UnsafeAtomicRcBox::new(data), cant_nest: () }
303303
}
304304

305-
impl<T:Const + Owned> RWARC<T> {
305+
impl<T:Freeze + Owned> RWARC<T> {
306306
/// Duplicate a rwlock-protected ARC, as arc::clone.
307307
pub fn clone(&self) -> RWARC<T> {
308308
RWARC {
@@ -313,7 +313,7 @@ impl<T:Const + Owned> RWARC<T> {
313313

314314
}
315315

316-
impl<T:Const + Owned> RWARC<T> {
316+
impl<T:Freeze + Owned> RWARC<T> {
317317
/**
318318
* Access the underlying data mutably. Locks the rwlock in write mode;
319319
* other readers and writers will block.
@@ -439,7 +439,7 @@ impl<T:Const + Owned> RWARC<T> {
439439
// lock it. This wraps the unsafety, with the justification that the 'lock'
440440
// field is never overwritten; only 'failed' and 'data'.
441441
#[doc(hidden)]
442-
fn borrow_rwlock<T:Const + Owned>(state: *const RWARCInner<T>) -> *RWlock {
442+
fn borrow_rwlock<T:Freeze + Owned>(state: *const RWARCInner<T>) -> *RWlock {
443443
unsafe { cast::transmute(&const (*state).lock) }
444444
}
445445

@@ -456,7 +456,7 @@ pub struct RWReadMode<'self, T> {
456456
token: sync::RWlockReadMode<'self>,
457457
}
458458

459-
impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
459+
impl<'self, T:Freeze + Owned> RWWriteMode<'self, T> {
460460
/// Access the pre-downgrade RWARC in write mode.
461461
pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
462462
match *self {
@@ -497,7 +497,7 @@ impl<'self, T:Const + Owned> RWWriteMode<'self, T> {
497497
}
498498
}
499499

500-
impl<'self, T:Const + Owned> RWReadMode<'self, T> {
500+
impl<'self, T:Freeze + Owned> RWReadMode<'self, T> {
501501
/// Access the post-downgrade rwlock in read mode.
502502
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
503503
match *self {

src/libextra/rc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
/** Task-local reference counted smart pointers
1414
1515
Task-local reference counted smart pointers are an alternative to managed boxes with deterministic
16-
destruction. They are restricted to containing types that are either `Owned` or `Const` (or both) to
16+
destruction. They are restricted to containing types that are either `Owned` or `Freeze` (or both) to
1717
prevent cycles.
1818
19-
Neither `Rc<T>` or `RcMut<T>` is ever `Owned` and `RcMut<T>` is never `Const`. If `T` is `Const`, a
19+
Neither `Rc<T>` or `RcMut<T>` is ever `Owned` and `RcMut<T>` is never `Freeze`. If `T` is `Freeze`, a
2020
cycle cannot be created with `Rc<T>` because there is no way to modify it after creation.
2121
2222
*/
@@ -56,7 +56,7 @@ pub fn rc_from_owned<T: Owned>(value: T) -> Rc<T> {
5656
}
5757

5858
// FIXME: #6516: should be a static method
59-
pub fn rc_from_const<T: Const>(value: T) -> Rc<T> {
59+
pub fn rc_from_const<T: Freeze>(value: T) -> Rc<T> {
6060
unsafe { Rc::new(value) }
6161
}
6262

@@ -187,7 +187,7 @@ pub fn rc_mut_from_owned<T: Owned>(value: T) -> RcMut<T> {
187187
}
188188

189189
// FIXME: #6516: should be a static method
190-
pub fn rc_mut_from_const<T: Const>(value: T) -> RcMut<T> {
190+
pub fn rc_mut_from_const<T: Freeze>(value: T) -> RcMut<T> {
191191
unsafe { RcMut::new(value) }
192192
}
193193

src/librustc/metadata/decoder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
9797

9898
#[deriving(Eq)]
9999
enum Family {
100-
Const, // c
100+
Freeze, // c
101101
Fn, // f
102102
UnsafeFn, // u
103103
PureFn, // p
@@ -122,7 +122,7 @@ enum Family {
122122
fn item_family(item: ebml::Doc) -> Family {
123123
let fam = reader::get_doc(item, tag_items_data_item_family);
124124
match reader::doc_as_u8(fam) as char {
125-
'c' => Const,
125+
'c' => Freeze,
126126
'f' => Fn,
127127
'u' => UnsafeFn,
128128
'p' => PureFn,
@@ -321,7 +321,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
321321
-> def_like {
322322
let fam = item_family(item);
323323
match fam {
324-
Const => dl_def(ast::def_const(did)),
324+
Freeze => dl_def(ast::def_const(did)),
325325
Struct => dl_def(ast::def_struct(did)),
326326
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)),
327327
Fn => dl_def(ast::def_fn(did, ast::impure_fn)),
@@ -927,7 +927,7 @@ pub fn get_item_visibility(cdata: cmd, id: ast::node_id)
927927

928928
fn family_has_type_params(fam: Family) -> bool {
929929
match fam {
930-
Const | ForeignType | Mod | ForeignMod | PublicField | PrivateField
930+
Freeze | ForeignType | Mod | ForeignMod | PublicField | PrivateField
931931
| ForeignFn => false,
932932
_ => true
933933
}
@@ -958,7 +958,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str {
958958

959959
fn item_family_to_str(fam: Family) -> ~str {
960960
match fam {
961-
Const => ~"const",
961+
Freeze => ~"const",
962962
Fn => ~"fn",
963963
UnsafeFn => ~"unsafe fn",
964964
PureFn => ~"pure fn",

src/librustc/middle/borrowck/doc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,14 @@ mutable borrowed pointers.
539539
540540
### Restrictions for loans of const aliasable pointees
541541
542-
Const pointers are read-only. There may be `&mut` or `&` aliases, and
542+
Freeze pointers are read-only. There may be `&mut` or `&` aliases, and
543543
we can not prevent *anything* but moves in that case. So the
544544
`RESTRICTIONS` function is only defined if `ACTIONS` is the empty set.
545545
Because moves from a `&const` or `@const` lvalue are never legal, it
546546
is not necessary to add any restrictions at all to the final
547547
result.
548548
549-
RESTRICTIONS(*LV, []) = [] // R-Deref-Const-Borrowed
549+
RESTRICTIONS(*LV, []) = [] // R-Deref-Freeze-Borrowed
550550
TYPE(LV) = &const Ty or @const Ty
551551
552552
### Restrictions for loans of mutable borrowed pointees

src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl RestrictionsContext {
125125

126126
mc::cat_deref(_, _, mc::region_ptr(m_const, _)) |
127127
mc::cat_deref(_, _, mc::gc_ptr(m_const)) => {
128-
// R-Deref-Const-Borrowed
128+
// R-Deref-Freeze-Borrowed
129129
self.check_no_mutability_control(cmt, restrictions);
130130
Safe
131131
}

src/librustc/middle/typeck/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
12041204
* enum consisting of a newtyped Ty or a region) to ty's
12051205
* notion of ty param bounds, which can either be user-defined
12061206
* traits, or one of the four built-in traits (formerly known
1207-
* as kinds): Const, Copy, and Send.
1207+
* as kinds): Freeze, Copy, and Send.
12081208
*/
12091209

12101210
let mut param_bounds = ty::ParamBounds {

src/librustdoc/markdown_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
152152
~"Function"
153153
}
154154
doc::ConstTag(_) => {
155-
~"Const"
155+
~"Freeze"
156156
}
157157
doc::EnumTag(_) => {
158158
~"Enum"
@@ -793,7 +793,7 @@ mod test {
793793
#[test]
794794
fn should_write_const_header() {
795795
let markdown = render(~"static a: bool = true;");
796-
assert!(markdown.contains("## Const `a`\n\n"));
796+
assert!(markdown.contains("## Freeze `a`\n\n"));
797797
}
798798

799799
#[test]

src/libstd/clone.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ by convention implementing the `Clone` trait and calling the
2222
2323
*/
2424

25-
use core::kinds::Const;
25+
use core::kinds::Freeze;
2626

2727
/// A common trait for cloning an object.
2828
pub trait Clone {
@@ -101,16 +101,16 @@ impl<T: DeepClone> DeepClone for ~T {
101101
}
102102

103103
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
104-
impl<T: Const + DeepClone> DeepClone for @T {
105-
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
104+
impl<T: Freeze + DeepClone> DeepClone for @T {
105+
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
106106
/// a deep clone of a potentially cyclical type.
107107
#[inline(always)]
108108
fn deep_clone(&self) -> @T { @(**self).deep_clone() }
109109
}
110110

111111
// FIXME: #6525: should also be implemented for `T: Owned + DeepClone`
112-
impl<T: Const + DeepClone> DeepClone for @mut T {
113-
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
112+
impl<T: Freeze + DeepClone> DeepClone for @mut T {
113+
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
114114
/// a deep clone of a potentially cyclical type.
115115
#[inline(always)]
116116
fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() }

src/libstd/kinds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ pub trait Owned {
5757

5858
#[cfg(stage0)]
5959
#[lang="const"]
60-
pub trait Const {
60+
pub trait Freeze {
6161
// empty.
6262
}
6363

6464
#[cfg(not(stage0))]
6565
#[lang="freeze"]
66-
pub trait Const {
66+
pub trait Freeze {
6767
// empty.
6868
}
6969

src/libstd/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Rust's prelude has three main parts:
3030
// Reexported core operators
3131
pub use either::{Either, Left, Right};
3232
pub use kinds::{Copy, Sized};
33-
pub use kinds::{Const, Owned};
33+
pub use kinds::{Freeze, Owned};
3434
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
3535
pub use ops::{BitAnd, BitOr, BitXor};
3636
pub use ops::{Drop};

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub static crate_node_id: node_id = 0;
149149
// The AST represents all type param bounds as types.
150150
// typeck::collect::compute_bounds matches these against
151151
// the "special" built-in traits (see middle::lang_items) and
152-
// detects Copy, Send, Owned, and Const.
152+
// detects Copy, Send, Owned, and Freeze.
153153
pub enum TyParamBound {
154154
TraitTyParamBound(@trait_ref),
155155
RegionTyParamBound

src/libsyntax/parse/parser.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,14 +1140,14 @@ impl Parser {
11401140

11411141
pub fn token_is_mutability(&self, tok: &token::Token) -> bool {
11421142
token::is_keyword(keywords::Mut, tok) ||
1143-
token::is_keyword(keywords::Const, tok)
1143+
token::is_keyword(keywords::Freeze, tok)
11441144
}
11451145

11461146
// parse mutability declaration (mut/const/imm)
11471147
pub fn parse_mutability(&self) -> mutability {
11481148
if self.eat_keyword(keywords::Mut) {
11491149
m_mutbl
1150-
} else if self.eat_keyword(keywords::Const) {
1150+
} else if self.eat_keyword(keywords::Freeze) {
11511151
m_const
11521152
} else {
11531153
m_imm
@@ -3040,7 +3040,7 @@ impl Parser {
30403040
) -> ast::explicit_self_ {
30413041
// We need to make sure it isn't a mode or a type
30423042
if token::is_keyword(keywords::Self, &p.look_ahead(1)) ||
3043-
((token::is_keyword(keywords::Const, &p.look_ahead(1)) ||
3043+
((token::is_keyword(keywords::Freeze, &p.look_ahead(1)) ||
30443044
token::is_keyword(keywords::Mut, &p.look_ahead(1))) &&
30453045
token::is_keyword(keywords::Self, &p.look_ahead(2))) {
30463046

@@ -3675,7 +3675,7 @@ impl Parser {
36753675
let lo = self.span.lo;
36763676

36773677
// XXX: Obsolete; remove after snap.
3678-
if self.eat_keyword(keywords::Const) {
3678+
if self.eat_keyword(keywords::Freeze) {
36793679
self.obsolete(*self.last_span, ObsoleteConstItem);
36803680
} else {
36813681
self.expect_keyword(keywords::Static);
@@ -4062,11 +4062,11 @@ impl Parser {
40624062
}
40634063
}
40644064
// the rest are all guaranteed to be items:
4065-
if (self.is_keyword(keywords::Const) ||
4065+
if (self.is_keyword(keywords::Freeze) ||
40664066
(self.is_keyword(keywords::Static) &&
40674067
!token::is_keyword(keywords::Fn, &self.look_ahead(1)))) {
40684068
// CONST / STATIC ITEM
4069-
if self.is_keyword(keywords::Const) {
4069+
if self.is_keyword(keywords::Freeze) {
40704070
self.obsolete(*self.span, ObsoleteConstItem);
40714071
}
40724072
self.bump();
@@ -4164,7 +4164,7 @@ impl Parser {
41644164

41654165
let visibility = self.parse_visibility();
41664166

4167-
if (self.is_keyword(keywords::Const) || self.is_keyword(keywords::Static)) {
4167+
if (self.is_keyword(keywords::Freeze) || self.is_keyword(keywords::Static)) {
41684168
// FOREIGN CONST ITEM
41694169
let item = self.parse_item_foreign_const(visibility, attrs);
41704170
return iovi_foreign_item(item);

0 commit comments

Comments
 (0)