Skip to content

Commit 1aba595

Browse files
committed
librustc: Change Const to Freeze in the compiler
1 parent 6a540d2 commit 1aba595

File tree

9 files changed

+38
-31
lines changed

9 files changed

+38
-31
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> ty::ParamBounds {
564564
param_bounds.builtin_bounds.add(ty::BoundCopy);
565565
}
566566
'K' => {
567-
param_bounds.builtin_bounds.add(ty::BoundConst);
567+
param_bounds.builtin_bounds.add(ty::BoundFreeze);
568568
}
569569
'O' => {
570570
param_bounds.builtin_bounds.add(ty::BoundStatic);

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: &ty::ParamBounds) {
401401
match bound {
402402
ty::BoundSend => w.write_char('S'),
403403
ty::BoundCopy => w.write_char('C'),
404-
ty::BoundConst => w.write_char('K'),
404+
ty::BoundFreeze => w.write_char('K'),
405405
ty::BoundStatic => w.write_char('O'),
406406
ty::BoundSized => w.write_char('Z'),
407407
}

src/librustc/middle/kind.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use syntax::{visit, ast_util};
3333
//
3434
// send: Things that can be sent on channels or included in spawned closures.
3535
// copy: Things that can be copied.
36-
// const: Things thare are deeply immutable. They are guaranteed never to
36+
// freeze: Things thare are deeply immutable. They are guaranteed never to
3737
// change, and can be safely shared without copying between tasks.
3838
// 'static: Things that do not contain borrowed pointers.
3939
//
@@ -42,12 +42,12 @@ use syntax::{visit, ast_util};
4242
//
4343
// Copy includes boxes, closure and unique types containing copyable types.
4444
//
45-
// Const include scalar types, things without non-const fields, and pointers
46-
// to const things.
45+
// Freeze include scalar types, things without non-const fields, and pointers
46+
// to freezable things.
4747
//
4848
// This pass ensures that type parameters are only instantiated with types
4949
// whose kinds are equal or less general than the way the type parameter was
50-
// annotated (with the `send`, `copy` or `const` keyword).
50+
// annotated (with the `Send`, `Copy` or `Freeze` bound).
5151
//
5252
// It also verifies that noncopyable kinds are not copied. Sendability is not
5353
// applied, since none of our language primitives send. Instead, the sending

src/librustc/middle/lang_items.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
// Language items are items that represent concepts intrinsic to the language
1414
// itself. Examples are:
1515
//
16-
// * Traits that specify "kinds"; e.g. "const", "copy", "send".
16+
// * Traits that specify "kinds"; e.g. "Freeze", "Copy", "Send".
1717
//
18-
// * Traits that represent operators; e.g. "add", "sub", "index".
18+
// * Traits that represent operators; e.g. "Add", "Sub", "Index".
1919
//
2020
// * Functions called by the compiler itself.
2121

@@ -33,7 +33,7 @@ use syntax::visit::visit_crate;
3333
use core::hashmap::HashMap;
3434

3535
pub enum LangItem {
36-
ConstTraitLangItem, // 0
36+
FreezeTraitLangItem, // 0
3737
CopyTraitLangItem, // 1
3838
SendTraitLangItem, // 2
3939
SizedTraitLangItem, // 3
@@ -95,7 +95,7 @@ impl LanguageItems {
9595

9696
pub fn item_name(index: uint) -> &'static str {
9797
match index {
98-
0 => "const",
98+
0 => "freeze",
9999
1 => "copy",
100100
2 => "send",
101101
3 => "sized",
@@ -144,8 +144,8 @@ impl LanguageItems {
144144

145145
// FIXME #4621: Method macros sure would be nice here.
146146

147-
pub fn const_trait(&const self) -> def_id {
148-
self.items[ConstTraitLangItem as uint].get()
147+
pub fn freeze_trait(&const self) -> def_id {
148+
self.items[FreezeTraitLangItem as uint].get()
149149
}
150150
pub fn copy_trait(&const self) -> def_id {
151151
self.items[CopyTraitLangItem as uint].get()
@@ -269,7 +269,7 @@ fn LanguageItemCollector(crate: @crate,
269269
-> LanguageItemCollector {
270270
let mut item_refs = HashMap::new();
271271

272-
item_refs.insert(@~"const", ConstTraitLangItem as uint);
272+
item_refs.insert(@~"freeze", FreezeTraitLangItem as uint);
273273
item_refs.insert(@~"copy", CopyTraitLangItem as uint);
274274
item_refs.insert(@~"send", SendTraitLangItem as uint);
275275
item_refs.insert(@~"sized", SizedTraitLangItem as uint);

src/librustc/middle/ty.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ pub enum BuiltinBound {
685685
BoundCopy,
686686
BoundStatic,
687687
BoundSend,
688-
BoundConst,
688+
BoundFreeze,
689689
BoundSized,
690690
}
691691

@@ -698,7 +698,7 @@ pub fn AllBuiltinBounds() -> BuiltinBounds {
698698
set.add(BoundCopy);
699699
set.add(BoundStatic);
700700
set.add(BoundSend);
701-
set.add(BoundConst);
701+
set.add(BoundFreeze);
702702
set.add(BoundSized);
703703
set
704704
}
@@ -1831,7 +1831,7 @@ impl TypeContents {
18311831
match bb {
18321832
BoundCopy => self.is_copy(cx),
18331833
BoundStatic => self.is_static(cx),
1834-
BoundConst => self.is_const(cx),
1834+
BoundFreeze => self.is_freezable(cx),
18351835
BoundSend => self.is_sendable(cx),
18361836
BoundSized => self.is_sized(cx),
18371837
}
@@ -1870,11 +1870,11 @@ impl TypeContents {
18701870
self.intersects(TC_MANAGED)
18711871
}
18721872

1873-
pub fn is_const(&self, cx: ctxt) -> bool {
1874-
!self.intersects(TypeContents::nonconst(cx))
1873+
pub fn is_freezable(&self, cx: ctxt) -> bool {
1874+
!self.intersects(TypeContents::nonfreezable(cx))
18751875
}
18761876

1877-
pub fn nonconst(_cx: ctxt) -> TypeContents {
1877+
pub fn nonfreezable(_cx: ctxt) -> TypeContents {
18781878
TC_MUTABLE
18791879
}
18801880

@@ -1977,8 +1977,8 @@ pub fn type_is_sendable(cx: ctxt, t: ty::t) -> bool {
19771977
type_contents(cx, t).is_sendable(cx)
19781978
}
19791979

1980-
pub fn type_is_const(cx: ctxt, t: ty::t) -> bool {
1981-
type_contents(cx, t).is_const(cx)
1980+
pub fn type_is_freezable(cx: ctxt, t: ty::t) -> bool {
1981+
type_contents(cx, t).is_freezable(cx)
19821982
}
19831983

19841984
pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
@@ -2032,7 +2032,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20322032
let _i = indenter();
20332033

20342034
let result = match get(ty).sty {
2035-
// Scalar and unique types are sendable, constant, and durable
2035+
// Scalar and unique types are sendable, freezable, and durable
20362036
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
20372037
ty_bare_fn(_) | ty_ptr(_) => {
20382038
TC_NONE
@@ -2274,7 +2274,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
22742274
BoundCopy => TypeContents::nonimplicitly_copyable(cx),
22752275
BoundStatic => TypeContents::nonstatic(cx),
22762276
BoundSend => TypeContents::nonsendable(cx),
2277-
BoundConst => TypeContents::nonconst(cx),
2277+
BoundFreeze => TypeContents::nonfreezable(cx),
22782278
// The dynamic-size bit can be removed at pointer-level, etc.
22792279
BoundSized => TypeContents::dynamically_sized(cx),
22802280
};

src/librustc/middle/typeck/astconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,8 @@ pub fn try_add_builtin_trait(tcx: ty::ctxt,
779779
} else if trait_def_id == li.copy_trait() {
780780
builtin_bounds.add(ty::BoundCopy);
781781
true
782-
} else if trait_def_id == li.const_trait() {
783-
builtin_bounds.add(ty::BoundConst);
782+
} else if trait_def_id == li.freeze_trait() {
783+
builtin_bounds.add(ty::BoundFreeze);
784784
true
785785
} else if trait_def_id == li.sized_trait() {
786786
builtin_bounds.add(ty::BoundSized);

src/librustc/util/ppaux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ impl Repr for ty::ParamBounds {
561561
ty::BoundCopy => ~"Copy",
562562
ty::BoundStatic => ~"'static",
563563
ty::BoundSend => ~"Send",
564-
ty::BoundConst => ~"Const",
564+
ty::BoundFreeze => ~"Freeze",
565565
ty::BoundSized => ~"Sized",
566566
});
567567
}
@@ -767,7 +767,7 @@ impl UserString for ty::BuiltinBound {
767767
ty::BoundCopy => ~"Copy",
768768
ty::BoundStatic => ~"'static",
769769
ty::BoundSend => ~"Send",
770-
ty::BoundConst => ~"Const",
770+
ty::BoundFreeze => ~"Freeze",
771771
ty::BoundSized => ~"Sized",
772772
}
773773
}

src/libstd/kinds.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ The 4 kinds are
2727
* Owned - owned types and types containing owned types. These types
2828
may be transferred across task boundaries.
2929
30-
* Const - types that are deeply immutable. Const types are used for
31-
freezable data structures.
30+
* Freeze - types that are deeply immutable.
3231
3332
`Copy` types include both implicitly copyable types that the compiler
3433
will copy automatically and non-implicitly copyable types that require
@@ -56,9 +55,16 @@ pub trait Owned {
5655
// empty.
5756
}
5857

58+
#[cfg(stage0)]
5959
#[lang="const"]
6060
pub trait Const {
61-
// Empty.
61+
// empty.
62+
}
63+
64+
#[cfg(not(stage0))]
65+
#[lang="freeze"]
66+
pub trait Const {
67+
// empty.
6268
}
6369

6470
#[lang="sized"]

src/libstd/prelude.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Rust's prelude has three main parts:
2929

3030
// Reexported core operators
3131
pub use either::{Either, Left, Right};
32-
pub use kinds::{Const, Copy, Owned, Sized};
32+
pub use kinds::{Copy, Sized};
33+
pub use kinds::{Const, Owned};
3334
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
3435
pub use ops::{BitAnd, BitOr, BitXor};
3536
pub use ops::{Drop};

0 commit comments

Comments
 (0)