Skip to content

Commit 228e0a8

Browse files
committed
librustc: Rename Const to Freeze
1 parent 1aba595 commit 228e0a8

File tree

21 files changed

+55
-55
lines changed

21 files changed

+55
-55
lines changed

src/libextra/arc.rs

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

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

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

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

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

315315
}
316316

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

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

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

501-
impl<'self, T:Const + Owned> RWReadMode<'self, T> {
501+
impl<'self, T:Freeze + Owned> RWReadMode<'self, T> {
502502
/// Access the post-downgrade rwlock in read mode.
503503
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
504504
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
@@ -96,7 +96,7 @@ fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
9696

9797
#[deriving(Eq)]
9898
enum Family {
99-
Const, // c
99+
Freeze, // c
100100
Fn, // f
101101
UnsafeFn, // u
102102
PureFn, // p
@@ -121,7 +121,7 @@ enum Family {
121121
fn item_family(item: ebml::Doc) -> Family {
122122
let fam = reader::get_doc(item, tag_items_data_item_family);
123123
match reader::doc_as_u8(fam) as char {
124-
'c' => Const,
124+
'c' => Freeze,
125125
'f' => Fn,
126126
'u' => UnsafeFn,
127127
'p' => PureFn,
@@ -324,7 +324,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
324324
-> def_like {
325325
let fam = item_family(item);
326326
match fam {
327-
Const => dl_def(ast::def_const(did)),
327+
Freeze => dl_def(ast::def_const(did)),
328328
Struct => dl_def(ast::def_struct(did)),
329329
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)),
330330
Fn => dl_def(ast::def_fn(did, ast::impure_fn)),
@@ -951,7 +951,7 @@ pub fn get_item_visibility(cdata: cmd, id: ast::node_id)
951951

952952
fn family_has_type_params(fam: Family) -> bool {
953953
match fam {
954-
Const | ForeignType | Mod | ForeignMod | PublicField | PrivateField
954+
Freeze | ForeignType | Mod | ForeignMod | PublicField | PrivateField
955955
| ForeignFn => false,
956956
_ => true
957957
}
@@ -981,7 +981,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str {
981981

982982
fn item_family_to_str(fam: Family) -> ~str {
983983
match fam {
984-
Const => ~"const",
984+
Freeze => ~"const",
985985
Fn => ~"fn",
986986
UnsafeFn => ~"unsafe fn",
987987
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"
@@ -795,7 +795,7 @@ mod test {
795795
#[test]
796796
fn should_write_const_header() {
797797
let markdown = render(~"static a: bool = true;");
798-
assert!(str::contains(markdown, "## Const `a`\n\n"));
798+
assert!(str::contains(markdown, "## Freeze `a`\n\n"));
799799
}
800800

801801
#[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
@@ -147,7 +147,7 @@ pub static crate_node_id: node_id = 0;
147147
// The AST represents all type param bounds as types.
148148
// typeck::collect::compute_bounds matches these against
149149
// the "special" built-in traits (see middle::lang_items) and
150-
// detects Copy, Send, Owned, and Const.
150+
// detects Copy, Send, Owned, and Freeze.
151151
pub enum TyParamBound {
152152
TraitTyParamBound(@trait_ref),
153153
RegionTyParamBound

src/libsyntax/parse/parser.rs

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

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

11451145
// parse mutability declaration (mut/const/imm)
11461146
pub fn parse_mutability(&self) -> mutability {
11471147
if self.eat_keyword(keywords::Mut) {
11481148
m_mutbl
1149-
} else if self.eat_keyword(keywords::Const) {
1149+
} else if self.eat_keyword(keywords::Freeze) {
11501150
m_const
11511151
} else {
11521152
m_imm
@@ -3032,7 +3032,7 @@ impl Parser {
30323032
) -> ast::explicit_self_ {
30333033
// We need to make sure it isn't a mode or a type
30343034
if token::is_keyword(keywords::Self, &p.look_ahead(1)) ||
3035-
((token::is_keyword(keywords::Const, &p.look_ahead(1)) ||
3035+
((token::is_keyword(keywords::Freeze, &p.look_ahead(1)) ||
30363036
token::is_keyword(keywords::Mut, &p.look_ahead(1))) &&
30373037
token::is_keyword(keywords::Self, &p.look_ahead(2))) {
30383038

@@ -3667,7 +3667,7 @@ impl Parser {
36673667
let lo = self.span.lo;
36683668

36693669
// XXX: Obsolete; remove after snap.
3670-
if self.eat_keyword(keywords::Const) {
3670+
if self.eat_keyword(keywords::Freeze) {
36713671
self.obsolete(*self.last_span, ObsoleteConstItem);
36723672
} else {
36733673
self.expect_keyword(keywords::Static);
@@ -4058,11 +4058,11 @@ impl Parser {
40584058
}
40594059
}
40604060
// the rest are all guaranteed to be items:
4061-
if (self.is_keyword(keywords::Const) ||
4061+
if (self.is_keyword(keywords::Freeze) ||
40624062
(self.is_keyword(keywords::Static) &&
40634063
!token::is_keyword(keywords::Fn, &self.look_ahead(1)))) {
40644064
// CONST / STATIC ITEM
4065-
if self.is_keyword(keywords::Const) {
4065+
if self.is_keyword(keywords::Freeze) {
40664066
self.obsolete(*self.span, ObsoleteConstItem);
40674067
}
40684068
self.bump();
@@ -4160,7 +4160,7 @@ impl Parser {
41604160

41614161
let visibility = self.parse_visibility();
41624162

4163-
if (self.is_keyword(keywords::Const) || self.is_keyword(keywords::Static)) {
4163+
if (self.is_keyword(keywords::Freeze) || self.is_keyword(keywords::Static)) {
41644164
// FOREIGN CONST ITEM
41654165
let item = self.parse_item_foreign_const(visibility, attrs);
41664166
return iovi_foreign_item(item);

src/libsyntax/parse/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ pub mod keywords {
549549
// Strict keywords
550550
As,
551551
Break,
552-
Const,
552+
Freeze,
553553
Copy,
554554
Do,
555555
Else,
@@ -592,7 +592,7 @@ pub mod keywords {
592592
match *self {
593593
As => ident { repr: 35, ctxt: 0 },
594594
Break => ident { repr: 36, ctxt: 0 },
595-
Const => ident { repr: 37, ctxt: 0 },
595+
Freeze => ident { repr: 37, ctxt: 0 },
596596
Copy => ident { repr: 38, ctxt: 0 },
597597
Do => ident { repr: 39, ctxt: 0 },
598598
Else => ident { repr: 41, ctxt: 0 },

src/libsyntax/util/interner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct Interner<T> {
2727
}
2828

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

src/test/auxiliary/issue-2526.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ struct arc_destruct<T> {
2020
}
2121

2222
#[unsafe_destructor]
23-
impl<T:Const> Drop for arc_destruct<T> {
23+
impl<T:Freeze> Drop for arc_destruct<T> {
2424
fn finalize(&self) {}
2525
}
2626

27-
fn arc_destruct<T:Const>(data: int) -> arc_destruct<T> {
27+
fn arc_destruct<T:Freeze>(data: int) -> arc_destruct<T> {
2828
arc_destruct {
2929
_data: data
3030
}
3131
}
3232

33-
fn arc<T:Const>(_data: T) -> arc_destruct<T> {
33+
fn arc<T:Freeze>(_data: T) -> arc_destruct<T> {
3434
arc_destruct(0)
3535
}
3636

src/test/compile-fail/issue-2611-4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct E {
2020
}
2121

2222
impl A for E {
23-
fn b<F:Copy + Const,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Const`
23+
fn b<F:Copy + Freeze,G>(_x: F) -> F { fail!() } //~ ERROR type parameter 0 requires `Freeze`
2424
}
2525

2626
fn main() {}

0 commit comments

Comments
 (0)