Skip to content

Commit 3ee5679

Browse files
---
yaml --- r: 153310 b: refs/heads/try2 c: f8bc571 h: refs/heads/master v: v3
1 parent e16124f commit 3ee5679

File tree

15 files changed

+636
-576
lines changed

15 files changed

+636
-576
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: 7ab9bfab4e623f67ea32db1ec50f8b79c1514e40
8+
refs/heads/try2: f8bc571df70a0832890bbed82ff80d4c9921b6ac
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/dist.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ distcheck-tar-bins: dist-tar-bins
259259
$(Q)cd tmp/distcheck && tar -xzf ../../dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz
260260
$(Q)mkdir -p tmp/distcheck/tarbininstall
261261
$(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall
262+
$(Q)tmp/distcheck/tarbininstall/bin/rustc --version
262263
$(Q)sh tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix=tmp/distcheck/tarbininstall --uninstall
263264
$(Q)rm -Rf tmp/distcheck/$(PKG_NAME)-$(CFG_BUILD)
264265
$(Q)rm -Rf tmp/distcheck/tarbininstall

branches/try2/src/libcore/intrinsics.rs

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -326,73 +326,19 @@ extern "rust-intrinsic" {
326326
/// integer, since the conversion would throw away aliasing information.
327327
pub fn offset<T>(dst: *const T, offset: int) -> *const T;
328328

329-
/// Copies data from one location to another.
330-
///
331-
/// Copies `count` elements (not bytes) from `src` to `dst`. The source
332-
/// and destination may *not* overlap.
333-
///
334-
/// `copy_nonoverlapping_memory` is semantically equivalent to C's `memcpy`.
335-
///
336-
/// # Example
337-
///
338-
/// A safe swap function:
339-
///
340-
/// ```
341-
/// use std::mem;
342-
/// use std::ptr;
343-
///
344-
/// fn swap<T>(x: &mut T, y: &mut T) {
345-
/// unsafe {
346-
/// // Give ourselves some scratch space to work with
347-
/// let mut t: T = mem::uninitialized();
348-
///
349-
/// // Perform the swap, `&mut` pointers never alias
350-
/// ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);
351-
/// ptr::copy_nonoverlapping_memory(x, &*y, 1);
352-
/// ptr::copy_nonoverlapping_memory(y, &t, 1);
353-
///
354-
/// // y and t now point to the same thing, but we need to completely forget `tmp`
355-
/// // because it's no longer relevant.
356-
/// mem::forget(t);
357-
/// }
358-
/// }
359-
/// ```
360-
///
361-
/// # Safety Note
362-
///
363-
/// If the source and destination overlap then the behavior of this
364-
/// function is undefined.
365-
#[unstable]
329+
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
330+
/// a size of `count` * `size_of::<T>()` and an alignment of
331+
/// `min_align_of::<T>()`
366332
pub fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint);
367333

368-
/// Copies data from one location to another.
369-
///
370-
/// Copies `count` elements (not bytes) from `src` to `dst`. The source
371-
/// and destination may overlap.
372-
///
373-
/// `copy_memory` is semantically equivalent to C's `memmove`.
374-
///
375-
/// # Example
376-
///
377-
/// Efficiently create a Rust vector from an unsafe buffer:
378-
///
379-
/// ```
380-
/// use std::ptr;
381-
///
382-
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> {
383-
/// let mut dst = Vec::with_capacity(elts);
384-
/// dst.set_len(elts);
385-
/// ptr::copy_memory(dst.as_mut_ptr(), ptr, elts);
386-
/// dst
387-
/// }
388-
/// ```
389-
///
390-
#[unstable]
334+
/// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
335+
/// a size of `count` * `size_of::<T>()` and an alignment of
336+
/// `min_align_of::<T>()`
391337
pub fn copy_memory<T>(dst: *mut T, src: *const T, count: uint);
392338

393-
/// Invokes memset on the specified pointer, setting `count * size_of::<T>()`
394-
/// bytes of memory starting at `dst` to `c`.
395-
#[experimental = "uncertain about naming and semantics"]
339+
/// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
340+
/// size of `count` * `size_of::<T>()` and an alignment of
341+
/// `min_align_of::<T>()`
396342
pub fn set_memory<T>(dst: *mut T, val: u8, count: uint);
397343

398344
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with

branches/try2/src/libcore/num/f32.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//! Operations and constants for 32-bits floats (`f32` type)
1212
1313
#![doc(primitive = "f32")]
14+
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
15+
#![allow(type_overflow)]
1416

1517
use intrinsics;
1618
use mem;

branches/try2/src/libcore/num/f64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//! Operations and constants for 64-bits floats (`f64` type)
1212
1313
#![doc(primitive = "f64")]
14+
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
15+
#![allow(type_overflow)]
1416

1517
use intrinsics;
1618
use mem;

branches/try2/src/libcore/ptr.rs

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ use option::{Some, None, Option};
9595

9696
use cmp::{PartialEq, Eq, PartialOrd, Equiv, Ordering, Less, Equal, Greater};
9797

98-
pub use intrinsics::copy_memory;
99-
pub use intrinsics::copy_nonoverlapping_memory;
100-
pub use intrinsics::set_memory;
101-
10298
/// Create a null pointer.
10399
///
104100
/// # Example
@@ -127,6 +123,86 @@ pub fn null<T>() -> *const T { 0 as *const T }
127123
#[unstable = "may need a different name after pending changes to pointer types"]
128124
pub fn mut_null<T>() -> *mut T { 0 as *mut T }
129125

126+
/// Copies data from one location to another.
127+
///
128+
/// Copies `count` elements (not bytes) from `src` to `dst`. The source
129+
/// and destination may overlap.
130+
///
131+
/// `copy_memory` is semantically equivalent to C's `memmove`.
132+
///
133+
/// # Example
134+
///
135+
/// Efficiently create a Rust vector from an unsafe buffer:
136+
///
137+
/// ```
138+
/// use std::ptr;
139+
///
140+
/// unsafe fn from_buf_raw<T>(ptr: *const T, elts: uint) -> Vec<T> {
141+
/// let mut dst = Vec::with_capacity(elts);
142+
/// dst.set_len(elts);
143+
/// ptr::copy_memory(dst.as_mut_ptr(), ptr, elts);
144+
/// dst
145+
/// }
146+
/// ```
147+
///
148+
#[inline]
149+
#[unstable]
150+
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
151+
intrinsics::copy_memory(dst, src, count)
152+
}
153+
154+
/// Copies data from one location to another.
155+
///
156+
/// Copies `count` elements (not bytes) from `src` to `dst`. The source
157+
/// and destination may *not* overlap.
158+
///
159+
/// `copy_nonoverlapping_memory` is semantically equivalent to C's `memcpy`.
160+
///
161+
/// # Example
162+
///
163+
/// A safe swap function:
164+
///
165+
/// ```
166+
/// use std::mem;
167+
/// use std::ptr;
168+
///
169+
/// fn swap<T>(x: &mut T, y: &mut T) {
170+
/// unsafe {
171+
/// // Give ourselves some scratch space to work with
172+
/// let mut t: T = mem::uninitialized();
173+
///
174+
/// // Perform the swap, `&mut` pointers never alias
175+
/// ptr::copy_nonoverlapping_memory(&mut t, &*x, 1);
176+
/// ptr::copy_nonoverlapping_memory(x, &*y, 1);
177+
/// ptr::copy_nonoverlapping_memory(y, &t, 1);
178+
///
179+
/// // y and t now point to the same thing, but we need to completely forget `tmp`
180+
/// // because it's no longer relevant.
181+
/// mem::forget(t);
182+
/// }
183+
/// }
184+
/// ```
185+
///
186+
/// # Safety Note
187+
///
188+
/// If the source and destination overlap then the behavior of this
189+
/// function is undefined.
190+
#[inline]
191+
#[unstable]
192+
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T,
193+
src: *const T,
194+
count: uint) {
195+
intrinsics::copy_nonoverlapping_memory(dst, src, count)
196+
}
197+
198+
/// Invokes memset on the specified pointer, setting `count * size_of::<T>()`
199+
/// bytes of memory starting at `dst` to `c`.
200+
#[inline]
201+
#[experimental = "uncertain about naming and semantics"]
202+
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
203+
intrinsics::set_memory(dst, c, count)
204+
}
205+
130206
/// Zeroes out `count * size_of::<T>` bytes of memory at `dst`
131207
#[inline]
132208
#[experimental = "uncertain about naming and semantics"]

branches/try2/src/librustc/lint/builtin.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,7 @@ use lint::{Context, LintPass, LintArray};
3737

3838
use std::cmp;
3939
use std::collections::HashMap;
40-
use std::i16;
41-
use std::i32;
42-
use std::i64;
43-
use std::i8;
44-
use std::u16;
45-
use std::u32;
46-
use std::u64;
47-
use std::u8;
40+
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
4841
use std::gc::Gc;
4942
use syntax::abi;
5043
use syntax::ast_map;
@@ -214,7 +207,21 @@ impl LintPass for TypeLimits {
214207
"literal out of range for its type");
215208
}
216209
},
217-
210+
ty::ty_float(t) => {
211+
let (min, max) = float_ty_range(t);
212+
let lit_val: f64 = match lit.node {
213+
ast::LitFloat(ref v, _) |
214+
ast::LitFloatUnsuffixed(ref v) => match from_str(v.get()) {
215+
Some(f) => f,
216+
None => return
217+
},
218+
_ => fail!()
219+
};
220+
if lit_val < min || lit_val > max {
221+
cx.span_lint(TYPE_OVERFLOW, e.span,
222+
"literal out of range for its type");
223+
}
224+
},
218225
_ => ()
219226
};
220227
},
@@ -265,6 +272,13 @@ impl LintPass for TypeLimits {
265272
}
266273
}
267274

275+
fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) {
276+
match float_ty {
277+
ast::TyF32 => (f32::MIN_VALUE as f64, f32::MAX_VALUE as f64),
278+
ast::TyF64 => (f64::MIN_VALUE, f64::MAX_VALUE)
279+
}
280+
}
281+
268282
fn check_limits(tcx: &ty::ctxt, binop: ast::BinOp,
269283
l: &ast::Expr, r: &ast::Expr) -> bool {
270284
let (lit, expr, swap) = match (&l.node, &r.node) {

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,12 +862,9 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val
862862
ty::ty_bare_fn(ref fn_ty) => {
863863
match fn_ty.abi.for_target(ccx.sess().targ_cfg.os,
864864
ccx.sess().targ_cfg.arch) {
865-
Some(Rust) => {
865+
Some(Rust) | Some(RustIntrinsic) => {
866866
get_extern_rust_fn(ccx, t, name.as_slice(), did)
867867
}
868-
Some(RustIntrinsic) => {
869-
ccx.sess().bug("unexpected intrinsic in trans_external_path")
870-
}
871868
Some(..) | None => {
872869
foreign::register_foreign_item_fn(ccx, fn_ty.abi, t,
873870
name.as_slice(), None)
@@ -1784,9 +1781,9 @@ fn register_fn(ccx: &CrateContext,
17841781
-> ValueRef {
17851782
match ty::get(node_type).sty {
17861783
ty::ty_bare_fn(ref f) => {
1787-
assert!(f.abi == Rust);
1784+
assert!(f.abi == Rust || f.abi == RustIntrinsic);
17881785
}
1789-
_ => fail!("expected bare rust fn")
1786+
_ => fail!("expected bare rust fn or an intrinsic")
17901787
};
17911788

17921789
let llfn = decl_rust_fn(ccx, node_type, sym.as_slice());

0 commit comments

Comments
 (0)