Skip to content

Commit f2ee7c2

Browse files
committed
---
yaml --- r: 151376 b: refs/heads/try2 c: 5b75e44 h: refs/heads/master v: v3
1 parent 49ce33f commit f2ee7c2

File tree

6 files changed

+26
-5
lines changed

6 files changed

+26
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 836d4b96a91cd6a36228d757004655e26e3f2c46
8+
refs/heads/try2: 5b75e44fb01f0eda10ce8d8df92b80945d894768
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/intrinsics.rs renamed to branches/try2/src/libcore/intrinsics.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ A quick refresher on memory ordering:
4141
4242
*/
4343

44+
#![experimental]
4445
#![allow(missing_doc)]
4546

4647
// This is needed to prevent duplicate lang item definitions.
@@ -470,7 +471,7 @@ extern "rust-intrinsic" {
470471
/// `TypeId` represents a globally unique identifier for a type
471472
#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and
472473
// middle/lang_items.rs
473-
#[deriving(Eq, Hash, Show, TotalEq)]
474+
#[deriving(Eq, TotalEq)]
474475
#[cfg(not(test))]
475476
pub struct TypeId {
476477
t: u64,
@@ -482,4 +483,5 @@ impl TypeId {
482483
pub fn of<T: 'static>() -> TypeId {
483484
unsafe { type_id::<T>() }
484485
}
486+
pub fn hash(&self) -> u64 { self.t }
485487
}

branches/try2/src/libcore/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
#![no_std]
2121
#![feature(globs, macro_rules, managed_boxes)]
2222
#![deny(missing_doc)]
23+
24+
/* Core modules for ownership management */
25+
26+
pub mod intrinsics;

branches/try2/src/libstd/fmt/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ use str::StrSlice;
499499
use str;
500500
use slice::{Vector, ImmutableVector};
501501
use slice;
502+
use intrinsics::TypeId;
502503

503504
pub use self::num::radix;
504505
pub use self::num::Radix;
@@ -1241,5 +1242,11 @@ impl<T> Show for *mut T {
12411242
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
12421243
}
12431244

1245+
impl Show for TypeId {
1246+
fn fmt(&self, f: &mut Formatter) -> Result {
1247+
write!(f.buf, "TypeId \\{ {} \\}", self.hash())
1248+
}
1249+
}
1250+
12441251
// If you expected tests to be here, look instead at the run-pass/ifmt.rs test,
12451252
// it's a lot easier than creating all of the rt::Piece structures here.

branches/try2/src/libstd/hash/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#![allow(unused_must_use)]
6565

6666
use container::Container;
67+
use intrinsics::TypeId;
6768
use io::Writer;
6869
use iter::Iterator;
6970
use option::{Option, Some, None};
@@ -284,6 +285,13 @@ impl<S: Writer, T> Hash<S> for *mut T {
284285
}
285286
}
286287

288+
impl<S: Writer> Hash<S> for TypeId {
289+
#[inline]
290+
fn hash(&self, state: &mut S) {
291+
self.hash().hash(state)
292+
}
293+
}
294+
287295
//////////////////////////////////////////////////////////////////////////////
288296

289297
#[cfg(test)]

branches/try2/src/libstd/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@
122122
// Make and rand accessible for benchmarking/testcases
123123
#[cfg(test)] extern crate rand;
124124

125-
// we wrap some libc stuff
126125
extern crate libc;
126+
extern crate core;
127127

128128
// Make std testable by not duplicating lang items. See #2912
129129
#[cfg(test)] extern crate realstd = "std";
@@ -133,6 +133,8 @@ extern crate libc;
133133
#[cfg(test)] pub use ty = realstd::ty;
134134
#[cfg(test)] pub use owned = realstd::owned;
135135

136+
pub use core::intrinsics;
137+
136138
// Run tests with libgreen instead of libnative.
137139
//
138140
// FIXME: This egregiously hacks around starting the test runner in a different
@@ -255,8 +257,6 @@ pub mod reflect;
255257
#[unstable]
256258
pub mod unstable;
257259
#[experimental]
258-
pub mod intrinsics;
259-
#[experimental]
260260
pub mod raw;
261261

262262
/* For internal use, not exported */

0 commit comments

Comments
 (0)