Skip to content

Commit d0a13a7

Browse files
committed
---
yaml --- r: 60041 b: refs/heads/master c: 9b09dce h: refs/heads/master i: 60039: df2275a v: v3
1 parent 7885cd9 commit d0a13a7

File tree

11 files changed

+75
-156
lines changed

11 files changed

+75
-156
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: bdb52e58b43736b1351fa20a2b3dcff619a5fd09
2+
refs/heads/master: 9b09dce3e1a9935bbe443a976e47ed9f71227883
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/libcore/cell.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ A dynamic, mutable location.
1919
Similar to a mutable option type, but friendlier.
2020
*/
2121

22-
#[mutable]
2322
pub struct Cell<T> {
2423
priv value: Option<T>
2524
}

trunk/src/libcore/num/f32.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ pub mod consts {
195195
pub static ln_10: f32 = 2.30258509299404568401799145468436421_f32;
196196
}
197197

198-
#[inline(always)]
199-
pub fn logarithm(n: f32, b: f32) -> f32 {
200-
return log2(n) / log2(b);
201-
}
202-
203198
impl Num for f32 {}
204199

205200
#[cfg(notest)]
@@ -422,12 +417,19 @@ impl Exponential for f32 {
422417
#[inline(always)]
423418
fn expm1(&self) -> f32 { expm1(*self) }
424419

420+
/// Returns the natural logarithm of the number
425421
#[inline(always)]
426-
fn log(&self) -> f32 { ln(*self) }
422+
fn ln(&self) -> f32 { ln(*self) }
427423

424+
/// Returns the logarithm of the number with respect to an arbitrary base
425+
#[inline(always)]
426+
fn log(&self, base: f32) -> f32 { self.ln() / base.ln() }
427+
428+
/// Returns the base 2 logarithm of the number
428429
#[inline(always)]
429430
fn log2(&self) -> f32 { log2(*self) }
430431

432+
/// Returns the base 10 logarithm of the number
431433
#[inline(always)]
432434
fn log10(&self) -> f32 { log10(*self) }
433435
}
@@ -504,13 +506,13 @@ impl Real for f32 {
504506
#[inline(always)]
505507
fn log10_e() -> f32 { 0.434294481903251827651128918916605082 }
506508

507-
/// log(2.0)
509+
/// ln(2.0)
508510
#[inline(always)]
509-
fn log_2() -> f32 { 0.693147180559945309417232121458176568 }
511+
fn ln_2() -> f32 { 0.693147180559945309417232121458176568 }
510512

511-
/// log(10.0)
513+
/// ln(10.0)
512514
#[inline(always)]
513-
fn log_10() -> f32 { 2.30258509299404568401799145468436421 }
515+
fn ln_10() -> f32 { 2.30258509299404568401799145468436421 }
514516

515517
/// Converts to degrees, assuming the number is in radians
516518
#[inline(always)]
@@ -938,8 +940,8 @@ mod tests {
938940
assert_approx_eq!(Real::frac_1_sqrt2::<f32>(), 1f32 / 2f32.sqrt());
939941
assert_approx_eq!(Real::log2_e::<f32>(), Real::e::<f32>().log2());
940942
assert_approx_eq!(Real::log10_e::<f32>(), Real::e::<f32>().log10());
941-
assert_approx_eq!(Real::log_2::<f32>(), 2f32.log());
942-
assert_approx_eq!(Real::log_10::<f32>(), 10f32.log());
943+
assert_approx_eq!(Real::ln_2::<f32>(), 2f32.ln());
944+
assert_approx_eq!(Real::ln_10::<f32>(), 10f32.ln());
943945
}
944946

945947
#[test]

trunk/src/libcore/num/f64.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ pub mod consts {
218218
pub static ln_10: f64 = 2.30258509299404568401799145468436421_f64;
219219
}
220220

221-
#[inline(always)]
222-
pub fn logarithm(n: f64, b: f64) -> f64 {
223-
return log2(n) / log2(b);
224-
}
225-
226221
impl Num for f64 {}
227222

228223
#[cfg(notest)]
@@ -435,12 +430,19 @@ impl Exponential for f64 {
435430
#[inline(always)]
436431
fn expm1(&self) -> f64 { expm1(*self) }
437432

433+
/// Returns the natural logarithm of the number
438434
#[inline(always)]
439-
fn log(&self) -> f64 { ln(*self) }
435+
fn ln(&self) -> f64 { ln(*self) }
440436

437+
/// Returns the logarithm of the number with respect to an arbitrary base
438+
#[inline(always)]
439+
fn log(&self, base: f64) -> f64 { self.ln() / base.ln() }
440+
441+
/// Returns the base 2 logarithm of the number
441442
#[inline(always)]
442443
fn log2(&self) -> f64 { log2(*self) }
443444

445+
/// Returns the base 10 logarithm of the number
444446
#[inline(always)]
445447
fn log10(&self) -> f64 { log10(*self) }
446448
}
@@ -517,13 +519,13 @@ impl Real for f64 {
517519
#[inline(always)]
518520
fn log10_e() -> f64 { 0.434294481903251827651128918916605082 }
519521

520-
/// log(2.0)
522+
/// ln(2.0)
521523
#[inline(always)]
522-
fn log_2() -> f64 { 0.693147180559945309417232121458176568 }
524+
fn ln_2() -> f64 { 0.693147180559945309417232121458176568 }
523525

524-
/// log(10.0)
526+
/// ln(10.0)
525527
#[inline(always)]
526-
fn log_10() -> f64 { 2.30258509299404568401799145468436421 }
528+
fn ln_10() -> f64 { 2.30258509299404568401799145468436421 }
527529

528530
/// Converts to degrees, assuming the number is in radians
529531
#[inline(always)]
@@ -985,8 +987,8 @@ mod tests {
985987
assert_approx_eq!(Real::frac_1_sqrt2::<f64>(), 1f64 / 2f64.sqrt());
986988
assert_approx_eq!(Real::log2_e::<f64>(), Real::e::<f64>().log2());
987989
assert_approx_eq!(Real::log10_e::<f64>(), Real::e::<f64>().log10());
988-
assert_approx_eq!(Real::log_2::<f64>(), 2f64.log());
989-
assert_approx_eq!(Real::log_10::<f64>(), 10f64.log());
990+
assert_approx_eq!(Real::ln_2::<f64>(), 2f64.ln());
991+
assert_approx_eq!(Real::ln_10::<f64>(), 10f64.ln());
990992
}
991993

992994
#[test]

trunk/src/libcore/num/float.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use num::{Zero, One, strconv};
2525
use prelude::*;
2626

2727
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
28-
pub use f64::logarithm;
2928
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
3029
pub use f64::{erf, erfc, exp, expm1, exp2, abs_sub};
3130
pub use f64::{mul_add, fmax, fmin, next_after, frexp, hypot, ldexp};
@@ -548,16 +547,25 @@ impl Exponential for float {
548547
(*self as f64).expm1() as float
549548
}
550549
550+
/// Returns the natural logarithm of the number
551551
#[inline(always)]
552-
fn log(&self) -> float {
553-
(*self as f64).log() as float
552+
fn ln(&self) -> float {
553+
(*self as f64).ln() as float
554554
}
555555
556+
/// Returns the logarithm of the number with respect to an arbitrary base
557+
#[inline(always)]
558+
fn log(&self, base: float) -> float {
559+
(*self as f64).log(base as f64) as float
560+
}
561+
562+
/// Returns the base 2 logarithm of the number
556563
#[inline(always)]
557564
fn log2(&self) -> float {
558565
(*self as f64).log2() as float
559566
}
560567
568+
/// Returns the base 10 logarithm of the number
561569
#[inline(always)]
562570
fn log10(&self) -> float {
563571
(*self as f64).log10() as float
@@ -642,13 +650,13 @@ impl Real for float {
642650
#[inline(always)]
643651
fn log10_e() -> float { 0.434294481903251827651128918916605082 }
644652
645-
/// log(2.0)
653+
/// ln(2.0)
646654
#[inline(always)]
647-
fn log_2() -> float { 0.693147180559945309417232121458176568 }
655+
fn ln_2() -> float { 0.693147180559945309417232121458176568 }
648656
649-
/// log(10.0)
657+
/// ln(10.0)
650658
#[inline(always)]
651-
fn log_10() -> float { 2.30258509299404568401799145468436421 }
659+
fn ln_10() -> float { 2.30258509299404568401799145468436421 }
652660
653661
/// Converts to degrees, assuming the number is in radians
654662
#[inline(always)]
@@ -949,8 +957,8 @@ mod tests {
949957
assert_approx_eq!(Real::frac_1_sqrt2::<float>(), 1f / 2f.sqrt());
950958
assert_approx_eq!(Real::log2_e::<float>(), Real::e::<float>().log2());
951959
assert_approx_eq!(Real::log10_e::<float>(), Real::e::<float>().log10());
952-
assert_approx_eq!(Real::log_2::<float>(), 2f.log());
953-
assert_approx_eq!(Real::log_10::<float>(), 10f.log());
960+
assert_approx_eq!(Real::ln_2::<float>(), 2f.ln());
961+
assert_approx_eq!(Real::ln_10::<float>(), 10f.ln());
954962
}
955963
956964
#[test]

trunk/src/libcore/num/num.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ pub trait Exponential {
122122
fn exp(&self) -> Self;
123123
fn exp2(&self) -> Self;
124124
fn expm1(&self) -> Self;
125-
fn log(&self) -> Self;
125+
fn ln(&self) -> Self;
126+
fn log(&self, base: Self) -> Self;
126127
fn log2(&self) -> Self;
127128
fn log10(&self) -> Self;
128129
}
@@ -158,8 +159,8 @@ pub trait Real: Signed
158159
fn e() -> Self;
159160
fn log2_e() -> Self;
160161
fn log10_e() -> Self;
161-
fn log_2() -> Self;
162-
fn log_10() -> Self;
162+
fn ln_2() -> Self;
163+
fn ln_10() -> Self;
163164

164165
// Angular conversions
165166
fn to_degrees(&self) -> Self;

trunk/src/librustc/middle/ty.rs

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@ pub impl TypeContents {
17951795
}
17961796
17971797
fn nonowned(_cx: ctxt) -> TypeContents {
1798-
TC_MANAGED + TC_BORROWED_POINTER + TC_NON_OWNED
1798+
TC_MANAGED + TC_BORROWED_POINTER
17991799
}
18001800
18011801
fn contains_managed(&self) -> bool {
@@ -1849,43 +1849,40 @@ impl ToStr for TypeContents {
18491849
}
18501850
18511851
/// Constant for a type containing nothing of interest.
1852-
static TC_NONE: TypeContents = TypeContents{bits: 0b0000_0000_0000};
1852+
static TC_NONE: TypeContents = TypeContents{bits:0b0000_00000000};
18531853
18541854
/// Contains a borrowed value with a lifetime other than static
1855-
static TC_BORROWED_POINTER: TypeContents = TypeContents{bits: 0b0000_0000_0001};
1855+
static TC_BORROWED_POINTER: TypeContents = TypeContents{bits:0b0000_00000001};
18561856
18571857
/// Contains an owned pointer (~T) but not slice of some kind
1858-
static TC_OWNED_POINTER: TypeContents = TypeContents{bits: 0b0000_0000_0010};
1858+
static TC_OWNED_POINTER: TypeContents = TypeContents{bits:0b000000000010};
18591859
18601860
/// Contains an owned vector ~[] or owned string ~str
1861-
static TC_OWNED_VEC: TypeContents = TypeContents{bits: 0b0000_0000_0100};
1861+
static TC_OWNED_VEC: TypeContents = TypeContents{bits:0b000000000100};
18621862
18631863
/// Contains a ~fn() or a ~Trait, which is non-copyable.
1864-
static TC_OWNED_CLOSURE: TypeContents = TypeContents{bits: 0b0000_0000_1000};
1864+
static TC_OWNED_CLOSURE: TypeContents = TypeContents{bits:0b000000001000};
18651865
18661866
/// Type with a destructor
1867-
static TC_DTOR: TypeContents = TypeContents{bits: 0b0000_0001_0000};
1867+
static TC_DTOR: TypeContents = TypeContents{bits:0b000000010000};
18681868
18691869
/// Contains a managed value
1870-
static TC_MANAGED: TypeContents = TypeContents{bits: 0b0000_0010_0000};
1870+
static TC_MANAGED: TypeContents = TypeContents{bits:0b000000100000};
18711871
18721872
/// &mut with any region
1873-
static TC_BORROWED_MUT: TypeContents = TypeContents{bits: 0b0000_0100_0000};
1873+
static TC_BORROWED_MUT: TypeContents = TypeContents{bits:0b000001000000};
18741874
18751875
/// Mutable content, whether owned or by ref
1876-
static TC_MUTABLE: TypeContents = TypeContents{bits: 0b0000_1000_0000};
1876+
static TC_MUTABLE: TypeContents = TypeContents{bits:0b000010000000};
18771877
1878-
/// One-shot closure
1879-
static TC_ONCE_CLOSURE: TypeContents = TypeContents{bits: 0b0001_0000_0000};
1878+
/// Mutable content, whether owned or by ref
1879+
static TC_ONCE_CLOSURE: TypeContents = TypeContents{bits:0b000100000000};
18801880
18811881
/// An enum with no variants.
1882-
static TC_EMPTY_ENUM: TypeContents = TypeContents{bits: 0b0010_0000_0000};
1883-
1884-
/// Contains a type marked with `#[non_owned]`
1885-
static TC_NON_OWNED: TypeContents = TypeContents{bits: 0b0100_0000_0000};
1882+
static TC_EMPTY_ENUM: TypeContents = TypeContents{bits:0b010000000000};
18861883
18871884
/// All possible contents.
1888-
static TC_ALL: TypeContents = TypeContents{bits: 0b0111_1111_1111};
1885+
static TC_ALL: TypeContents = TypeContents{bits:0b011111111111};
18891886
18901887
pub fn type_is_copyable(cx: ctxt, t: ty::t) -> bool {
18911888
type_contents(cx, t).is_copy(cx)
@@ -2027,13 +2024,14 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20272024
20282025
ty_struct(did, ref substs) => {
20292026
let flds = struct_fields(cx, did, substs);
2030-
let mut res = flds.foldl(
2027+
let flds_tc = flds.foldl(
20312028
TC_NONE,
20322029
|tc, f| tc + tc_mt(cx, f.mt, cache));
20332030
if ty::has_dtor(cx, did) {
2034-
res += TC_DTOR;
2031+
flds_tc + TC_DTOR
2032+
} else {
2033+
flds_tc
20352034
}
2036-
apply_tc_attr(cx, did, res)
20372035
}
20382036
20392037
ty_tup(ref tys) => {
@@ -2042,7 +2040,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20422040
20432041
ty_enum(did, ref substs) => {
20442042
let variants = substd_enum_variants(cx, did, substs);
2045-
let res = if variants.is_empty() {
2043+
if variants.is_empty() {
20462044
// we somewhat arbitrary declare that empty enums
20472045
// are non-copyable
20482046
TC_EMPTY_ENUM
@@ -2052,8 +2050,7 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20522050
*tc,
20532051
|tc, arg_ty| *tc + tc_ty(cx, *arg_ty, cache))
20542052
})
2055-
};
2056-
apply_tc_attr(cx, did, res)
2053+
}
20572054
}
20582055
20592056
ty_param(p) => {
@@ -2113,16 +2110,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
21132110
mc + tc_ty(cx, mt.ty, cache)
21142111
}
21152112
2116-
fn apply_tc_attr(cx: ctxt, did: def_id, mut tc: TypeContents) -> TypeContents {
2117-
if has_attr(cx, did, "mutable") {
2118-
tc += TC_MUTABLE;
2119-
}
2120-
if has_attr(cx, did, "non_owned") {
2121-
tc += TC_NON_OWNED;
2122-
}
2123-
tc
2124-
}
2125-
21262113
fn borrowed_contents(region: ty::Region,
21272114
mutbl: ast::mutability) -> TypeContents
21282115
{
@@ -3887,32 +3874,28 @@ pub fn lookup_trait_def(cx: ctxt, did: ast::def_id) -> @ty::TraitDef {
38873874
}
38883875
}
38893876
3890-
/// Determine whether an item is annotated with an attribute
3891-
pub fn has_attr(tcx: ctxt, did: def_id, attr: &str) -> bool {
3877+
// Determine whether an item is annotated with #[packed] or not
3878+
pub fn lookup_packed(tcx: ctxt,
3879+
did: def_id) -> bool {
38923880
if is_local(did) {
38933881
match tcx.items.find(&did.node) {
38943882
Some(
38953883
&ast_map::node_item(@ast::item {
38963884
attrs: ref attrs,
38973885
_
3898-
}, _)) => attr::attrs_contains_name(*attrs, attr),
3886+
}, _)) => attr::attrs_contains_name(*attrs, "packed"),
38993887
_ => tcx.sess.bug(fmt!("lookup_packed: %? is not an item",
39003888
did))
39013889
}
39023890
} else {
39033891
let mut ret = false;
39043892
do csearch::get_item_attrs(tcx.cstore, did) |meta_items| {
3905-
ret = attr::contains_name(meta_items, attr);
3893+
ret = attr::contains_name(meta_items, "packed");
39063894
}
39073895
ret
39083896
}
39093897
}
39103898
3911-
/// Determine whether an item is annotated with `#[packed]` or not
3912-
pub fn lookup_packed(tcx: ctxt, did: def_id) -> bool {
3913-
has_attr(tcx, did, "packed")
3914-
}
3915-
39163899
// Look up a field ID, whether or not it's local
39173900
// Takes a list of type substs in case the struct is generic
39183901
pub fn lookup_field_type(tcx: ctxt,

0 commit comments

Comments
 (0)