Skip to content

Commit 062ac8c

Browse files
committed
---
yaml --- r: 166462 b: refs/heads/snap-stage3 c: e64a819 h: refs/heads/master v: v3
1 parent 23ce22b commit 062ac8c

File tree

14 files changed

+173
-99
lines changed

14 files changed

+173
-99
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 18842f89f084c52588fe7cffe07f87bf6e90796a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: e82215d4e28cc8376a3623673c00f1f65f588927
4+
refs/heads/snap-stage3: e64a8193b02ce72ef183274994a25eae281cb89c
55
refs/heads/try: f5d619caf9f32458680fae55526b99582ca682dd
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcore/fmt/float.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use char;
1818
use char::Char;
1919
use fmt;
2020
use iter::{range, DoubleEndedIteratorExt};
21-
use num::{Float, FPNaN, FPInfinite, ToPrimitive};
22-
use num::cast;
21+
use num::{cast, Float, ToPrimitive};
22+
use num::FpCategory as Fp;
2323
use ops::FnOnce;
2424
use result::Result::Ok;
2525
use slice::{mod, SliceExt};
@@ -109,11 +109,11 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
109109
let _1: T = Float::one();
110110

111111
match num.classify() {
112-
FPNaN => return f("NaN".as_bytes()),
113-
FPInfinite if num > _0 => {
112+
Fp::Nan => return f("NaN".as_bytes()),
113+
Fp::Infinite if num > _0 => {
114114
return f("inf".as_bytes());
115115
}
116-
FPInfinite if num < _0 => {
116+
Fp::Infinite if num < _0 => {
117117
return f("-inf".as_bytes());
118118
}
119119
_ => {}

branches/snap-stage3/src/libcore/num/f32.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
use intrinsics;
2020
use mem;
21-
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
21+
use num::Float;
22+
use num::FpCategory as Fp;
2223
use num::from_str_radix;
2324
use option::Option;
2425

@@ -156,23 +157,23 @@ impl Float for f32 {
156157
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN.
157158
#[inline]
158159
fn is_normal(self) -> bool {
159-
self.classify() == FPNormal
160+
self.classify() == Fp::Normal
160161
}
161162

162163
/// Returns the floating point category of the number. If only one property
163164
/// is going to be tested, it is generally faster to use the specific
164165
/// predicate instead.
165-
fn classify(self) -> FPCategory {
166+
fn classify(self) -> Fp {
166167
const EXP_MASK: u32 = 0x7f800000;
167168
const MAN_MASK: u32 = 0x007fffff;
168169

169170
let bits: u32 = unsafe { mem::transmute(self) };
170171
match (bits & MAN_MASK, bits & EXP_MASK) {
171-
(0, 0) => FPZero,
172-
(_, 0) => FPSubnormal,
173-
(0, EXP_MASK) => FPInfinite,
174-
(_, EXP_MASK) => FPNaN,
175-
_ => FPNormal,
172+
(0, 0) => Fp::Zero,
173+
(_, 0) => Fp::Subnormal,
174+
(0, EXP_MASK) => Fp::Infinite,
175+
(_, EXP_MASK) => Fp::Nan,
176+
_ => Fp::Normal,
176177
}
177178
}
178179

branches/snap-stage3/src/libcore/num/f64.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
use intrinsics;
2020
use mem;
21-
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
21+
use num::Float;
22+
use num::FpCategory as Fp;
2223
use num::from_str_radix;
2324
use option::Option;
2425

@@ -164,23 +165,23 @@ impl Float for f64 {
164165
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN.
165166
#[inline]
166167
fn is_normal(self) -> bool {
167-
self.classify() == FPNormal
168+
self.classify() == Fp::Normal
168169
}
169170

170171
/// Returns the floating point category of the number. If only one property
171172
/// is going to be tested, it is generally faster to use the specific
172173
/// predicate instead.
173-
fn classify(self) -> FPCategory {
174+
fn classify(self) -> Fp {
174175
const EXP_MASK: u64 = 0x7ff0000000000000;
175176
const MAN_MASK: u64 = 0x000fffffffffffff;
176177

177178
let bits: u64 = unsafe { mem::transmute(self) };
178179
match (bits & MAN_MASK, bits & EXP_MASK) {
179-
(0, 0) => FPZero,
180-
(_, 0) => FPSubnormal,
181-
(0, EXP_MASK) => FPInfinite,
182-
(_, EXP_MASK) => FPNaN,
183-
_ => FPNormal,
180+
(0, 0) => Fp::Zero,
181+
(_, 0) => Fp::Subnormal,
182+
(0, EXP_MASK) => Fp::Infinite,
183+
(_, EXP_MASK) => Fp::Nan,
184+
_ => Fp::Normal,
184185
}
185186
}
186187

branches/snap-stage3/src/libcore/num/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#![stable]
1616
#![allow(missing_docs)]
1717

18-
pub use self::FPCategory::*;
19-
2018
use {int, i8, i16, i32, i64};
2119
use {uint, u8, u16, u32, u64};
2220
use {f32, f64};
@@ -1222,17 +1220,17 @@ impl_num_cast! { f64, to_f64 }
12221220
/// Used for representing the classification of floating point numbers
12231221
#[deriving(Copy, PartialEq, Show)]
12241222
#[unstable = "may be renamed"]
1225-
pub enum FPCategory {
1223+
pub enum FpCategory {
12261224
/// "Not a Number", often obtained by dividing by zero
1227-
FPNaN,
1225+
Nan,
12281226
/// Positive or negative infinity
1229-
FPInfinite ,
1227+
Infinite ,
12301228
/// Positive or negative zero
1231-
FPZero,
1232-
/// De-normalized floating point representation (less precise than `FPNormal`)
1233-
FPSubnormal,
1229+
Zero,
1230+
/// De-normalized floating point representation (less precise than `Normal`)
1231+
Subnormal,
12341232
/// A regular floating point number
1235-
FPNormal,
1233+
Normal,
12361234
}
12371235

12381236
/// A built-in floating point number.
@@ -1277,7 +1275,7 @@ pub trait Float
12771275
/// Returns true if this number is neither zero, infinite, denormal, or NaN.
12781276
fn is_normal(self) -> bool;
12791277
/// Returns the category that this number falls into.
1280-
fn classify(self) -> FPCategory;
1278+
fn classify(self) -> FpCategory;
12811279

12821280
// FIXME (#5527): These should be associated constants
12831281

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,10 +4212,14 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
42124212
}
42134213

42144214
def::DefStruct(_) => {
4215-
match expr_ty(tcx, expr).sty {
4216-
ty_bare_fn(..) => RvalueDatumExpr,
4217-
_ => RvalueDpsExpr
4218-
}
4215+
match tcx.node_types.borrow().get(&expr.id) {
4216+
Some(ty) => match ty.sty {
4217+
ty_bare_fn(..) => RvalueDatumExpr,
4218+
_ => RvalueDpsExpr
4219+
},
4220+
// See ExprCast below for why types might be missing.
4221+
None => RvalueDatumExpr
4222+
}
42194223
}
42204224

42214225
// Special case: A unit like struct's constructor must be called without () at the

branches/snap-stage3/src/librustc_typeck/check/closure.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
//! Code for type-checking closure expressions.
1212
13-
use super::check_fn;
14-
use super::{Expectation, ExpectCastableToType, ExpectHasType, NoExpectation};
15-
use super::FnCtxt;
13+
use super::{check_fn, Expectation, FnCtxt};
1614

1715
use astconv;
1816
use middle::infer;
@@ -34,13 +32,17 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
3432
expr.repr(fcx.tcx()),
3533
expected.repr(fcx.tcx()));
3634

35+
let expected_sig_and_kind = expected.map_to_option(fcx, |ty| {
36+
deduce_unboxed_closure_expectations_from_expected_type(fcx, ty)
37+
});
38+
3739
match opt_kind {
3840
None => {
3941
// If users didn't specify what sort of closure they want,
4042
// examine the expected type. For now, if we see explicit
4143
// evidence than an unboxed closure is desired, we'll use
4244
// that, otherwise we'll fall back to boxed closures.
43-
match deduce_unboxed_closure_expectations_from_expectation(fcx, expected) {
45+
match expected_sig_and_kind {
4446
None => { // doesn't look like an unboxed closure
4547
let region = astconv::opt_ast_region_to_region(fcx,
4648
fcx.infcx(),
@@ -66,10 +68,7 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
6668
ast::FnOnceUnboxedClosureKind => ty::FnOnceUnboxedClosureKind,
6769
};
6870

69-
let expected_sig =
70-
deduce_unboxed_closure_expectations_from_expectation(fcx, expected)
71-
.map(|t| t.0);
72-
71+
let expected_sig = expected_sig_and_kind.map(|t| t.0);
7372
check_unboxed_closure(fcx, expr, kind, decl, body, expected_sig);
7473
}
7574
}
@@ -147,19 +146,6 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
147146
.insert(expr_def_id, unboxed_closure);
148147
}
149148

150-
fn deduce_unboxed_closure_expectations_from_expectation<'a,'tcx>(
151-
fcx: &FnCtxt<'a,'tcx>,
152-
expected: Expectation<'tcx>)
153-
-> Option<(ty::FnSig<'tcx>,ty::UnboxedClosureKind)>
154-
{
155-
match expected.resolve(fcx) {
156-
NoExpectation => None,
157-
ExpectCastableToType(t) | ExpectHasType(t) => {
158-
deduce_unboxed_closure_expectations_from_expected_type(fcx, t)
159-
}
160-
}
161-
}
162-
163149
fn deduce_unboxed_closure_expectations_from_expected_type<'a,'tcx>(
164150
fcx: &FnCtxt<'a,'tcx>,
165151
expected_ty: Ty<'tcx>)

0 commit comments

Comments
 (0)