Skip to content

Commit 96b1c14

Browse files
committed
---
yaml --- r: 55695 b: refs/heads/master c: 5c2e9b2 h: refs/heads/master i: 55693: 3c5d0ca 55691: cdcf5f3 55687: 204cfd2 55679: 8ce5392 v: v3
1 parent c59099b commit 96b1c14

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 047ba2642f39baa60c13aa0318ddcb09d9ca5301
2+
refs/heads/master: 5c2e9b29f10694ad76dcb6b88e95243a44813c05
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 79a2b2eafc3c766cecec8a5f76317693bae9ed17
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a

trunk/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ do spawn {
16701670
~~~~
16711671

16721672
If you want to see the output of `debug!` statements, you will need to turn on `debug!` logging.
1673-
To enable `debug!` logging, set the RUST_LOG environment variable to the name of your crate, which, for a file named `foo.rs`, will be `foo` (e.g., with bash, `export RUST_LOG=foo`).
1673+
To enable `debug!` logging, set the RUST_LOG environment variable to `debug` (e.g., with bash, `export RUST_LOG=debug`)
16741674

16751675
## For loops
16761676

trunk/src/libcore/sys.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,24 @@ pub fn get_type_desc<T>() -> *TypeDesc {
8383
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
8484
}
8585

86+
/// Returns a pointer to a type descriptor.
87+
#[inline(always)]
88+
pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
89+
get_type_desc::<T>()
90+
}
91+
8692
/// Returns the size of a type
8793
#[inline(always)]
8894
pub fn size_of<T>() -> uint {
8995
unsafe { rusti::size_of::<T>() }
9096
}
9197

98+
/// Returns the size of the type that `_val` points to
99+
#[inline(always)]
100+
pub fn size_of_val<T>(_val: &T) -> uint {
101+
size_of::<T>()
102+
}
103+
92104
/**
93105
* Returns the size of a type, or 1 if the actual size is zero.
94106
*
@@ -100,6 +112,13 @@ pub fn nonzero_size_of<T>() -> uint {
100112
if s == 0 { 1 } else { s }
101113
}
102114

115+
/// Returns the size of the type of the value that `_val` points to
116+
#[inline(always)]
117+
pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
118+
nonzero_size_of::<T>()
119+
}
120+
121+
103122
/**
104123
* Returns the ABI-required minimum alignment of a type
105124
*
@@ -111,12 +130,26 @@ pub fn min_align_of<T>() -> uint {
111130
unsafe { rusti::min_align_of::<T>() }
112131
}
113132

133+
/// Returns the ABI-required minimum alignment of the type of the value that
134+
/// `_val` points to
135+
#[inline(always)]
136+
pub fn min_align_of_val<T>(_val: &T) -> uint {
137+
min_align_of::<T>()
138+
}
139+
114140
/// Returns the preferred alignment of a type
115141
#[inline(always)]
116142
pub fn pref_align_of<T>() -> uint {
117143
unsafe { rusti::pref_align_of::<T>() }
118144
}
119145

146+
/// Returns the preferred alignment of the type of the value that
147+
/// `_val` points to
148+
#[inline(always)]
149+
pub fn pref_align_of_val<T>(_val: &T) -> uint {
150+
pref_align_of::<T>()
151+
}
152+
120153
/// Returns the refcount of a shared box (as just before calling this)
121154
#[inline(always)]
122155
pub fn refcount<T>(t: @T) -> uint {
@@ -162,7 +195,7 @@ pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! {
162195
#[cfg(test)]
163196
mod tests {
164197
use cast;
165-
use sys::{Closure, pref_align_of, size_of, nonzero_size_of};
198+
use sys::*;
166199
167200
#[test]
168201
fn size_of_basic() {
@@ -188,6 +221,14 @@ mod tests {
188221
assert!(size_of::<*uint>() == 8u);
189222
}
190223

224+
#[test]
225+
fn size_of_val_basic() {
226+
assert_eq!(size_of_val(&1u8), 1);
227+
assert_eq!(size_of_val(&1u16), 2);
228+
assert_eq!(size_of_val(&1u32), 4);
229+
assert_eq!(size_of_val(&1u64), 8);
230+
}
231+
191232
#[test]
192233
fn nonzero_size_of_basic() {
193234
type Z = [i8, ..0];
@@ -196,6 +237,14 @@ mod tests {
196237
assert!(nonzero_size_of::<uint>() == size_of::<uint>());
197238
}
198239

240+
#[test]
241+
fn nonzero_size_of_val_basic() {
242+
let z = [0u8, ..0];
243+
assert_eq!(size_of_val(&z), 0u);
244+
assert_eq!(nonzero_size_of_val(&z), 1u);
245+
assert_eq!(nonzero_size_of_val(&1u), size_of_val(&1u));
246+
}
247+
199248
#[test]
200249
fn align_of_basic() {
201250
assert!(pref_align_of::<u8>() == 1u);
@@ -219,6 +268,13 @@ mod tests {
219268
assert!(pref_align_of::<*uint>() == 8u);
220269
}
221270

271+
#[test]
272+
fn align_of_val_basic() {
273+
assert_eq!(pref_align_of_val(&1u8), 1u);
274+
assert_eq!(pref_align_of_val(&1u16), 2u);
275+
assert_eq!(pref_align_of_val(&1u32), 4u);
276+
}
277+
222278
#[test]
223279
fn synthesize_closure() {
224280
unsafe {

0 commit comments

Comments
 (0)