Alex Crichton
02882fbd7e
std: Change assert_eq!() to use {} instead of {:?}
...
Formatting via reflection has been a little questionable for some time now, and
it's a little unfortunate that one of the standard macros will silently use
reflection when you weren't expecting it. This adds small bits of code bloat to
libraries, as well as not always being necessary. In light of this information,
this commit switches assert_eq!() to using {} in the error message instead of
{:?}.
In updating existing code, there were a few error cases that I encountered:
* It's impossible to define Show for [T, ..N]. I think DST will alleviate this
because we can define Show for [T].
* A few types here and there just needed a #[deriving(Show)]
* Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
* `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
I don't think this is much of a regression though because {:?} on paths looks
awful (it's a byte array).
Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
significant for smaller binaries.
2014-02-28 23:01:54 -08:00
Brian Anderson
4d10bdc5b9
std: Move intrinsics to std::intrinsics.
...
Issue #1457
2014-02-23 01:07:53 -08:00
Felix S. Klock II
e2f99b93cd
ptr::RawPtr, spell out units used for the offset
argument.
...
spell out units used for the `offset` argument, so that callers do not
try to scale to byte units themselves.
2014-02-20 14:58:46 +01:00
Corey Richardson
49e11630fa
std: clean up ptr a bit
2014-02-15 12:11:41 -05:00
JeremyLetang
60bc76fb78
remove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset)
2014-02-13 12:54:17 -08:00
Edward Wang
e9ff91e9be
Move replace and swap to std::mem. Get rid of std::util
...
Also move Void to std::any, move drop to std::mem and reexport in
prelude.
2014-02-11 05:21:35 +08:00
Brian Anderson
1b7733109d
std: Stop parameterizing some memcpy functions over RawPtr
...
It unsafe assumptions that any impl of RawPtr is for actual pointers,
that they can be copied by memcpy. Removing it is easy, so I don't
think it's solving a real problem.
2014-02-09 16:23:10 -08:00
Brian Anderson
d433b80e02
std: Add init and uninit to mem. Replace direct intrinsic usage
2014-02-09 00:17:40 -08:00
Huon Wilson
39713b8295
Remove unnecessary parentheses.
2014-01-21 22:00:18 +11:00
Huon Wilson
c00104f36a
std: silence warnings when compiling test.
2013-12-20 01:26:03 +11:00
Huon Wilson
4c79b22ef2
std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.
...
There's no need for the restrictions of a closure with the above methods.
2013-12-19 09:26:13 +11:00
Felix S. Klock II
16f69b225b
Spell out the units used for the offset
argument, so that people do
...
not try to scale to units of bytes themselves.
2013-12-16 17:07:04 +01:00
Huon Wilson
164f7a290e
std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].
2013-12-15 23:37:41 +11:00
Patrick Walton
f571e46ddb
test: Remove non-procedure uses of do
from compiletest, libstd tests,
...
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-26 08:25:27 -08:00
Ziad Hatahet
248cb90dfa
std::ptr::read_ptr
now takes *T
instead of *mut T
...
Closes #10579
2013-11-21 11:31:58 -08:00
Patrick Walton
1946265e1a
libstd: Change all uses of &fn(A)->B
over to |A|->B
in libstd
2013-11-19 12:40:19 -08:00
Alex Crichton
4b770446b4
Register new snapshots
2013-11-06 20:24:36 -08:00
Daniel Micay
67966fa9de
simplify memcpy/memmove/memset intrinsics
...
This moves the per-architecture difference into the compiler.
2013-11-03 20:31:57 -05:00
Seo Sanghyeon
568576bab0
Implement Clone trait for mutable unsafe pointers
2013-10-25 18:43:55 +09:00
Alex Crichton
daf5f5a4d1
Drop the '2' suffix from logging macros
...
Who doesn't like a massive renaming?
2013-10-22 08:09:56 -07:00
Alex Crichton
a8ba31dbf3
std: Remove usage of fmt!
2013-09-30 23:21:18 -07:00
Alex Crichton
817576ee70
Register new snapshots
2013-09-18 11:07:22 -07:00
Daniel Micay
b7435cf447
implement raw pointer comparisons in librustc
...
This is mostly for consistency, as you can now compare raw pointers in
constant expressions or without the standard library.
It also reduces the number of `ptrtoint` instructions in the IR, making
tracking down culprits of what's usually an anti-pattern easier.
2013-09-12 01:58:39 -04:00
Daniel Micay
6919cf5fe1
rename std::iterator
to std::iter
...
The trait will keep the `Iterator` naming, but a more concise module
name makes using the free functions less verbose. The module will define
iterables in addition to iterators, as it deals with iteration in
general.
2013-09-09 03:21:46 -04:00
Erick Tryzelaar
91d6c60bed
fix various warnings
2013-08-30 15:10:55 -07:00
Alex Crichton
e3662b1880
Remove offset_inbounds for an unsafe offset function
2013-08-27 23:22:52 -07:00
Patrick Walton
5c3504799d
librustc: Remove &const
and *const
from the language.
...
They are still present as part of the borrow check.
2013-08-27 18:46:51 -07:00
bors
9e1e152091
auto merge of #8596 : vadimcn/rust/master, r=alexcrichton
...
This resolves issue #908 .
Notable changes:
- On Windows, LLVM integrated assembler emits bad stack unwind tables when segmented stacks are enabled. However, unwind info directives in the assembly output are correct, so we generate assembly first and then run it through an external assembler, just like it is already done for Android builds.
- Linker is invoked via "g++" command instead of "gcc": g++ passes the appropriate magic parameters to the linker, which ensure correct registration of stack unwind tables in dynamic libraries.
2013-08-22 21:06:25 -07:00
Vadim Chugunov
12ecdb6381
Enabled unit tests in std and extra.
2013-08-22 20:02:20 -07:00
Niko Matsakis
ffb6404c5a
Adjust callbacks in the libraries for the new type of extern fns
...
cc #3678
2013-08-21 10:50:42 -04:00
bors
3bc6858428
auto merge of #8551 : huonw/rust/speling, r=alexcrichton
...
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-18 05:11:58 -07:00
Erick Tryzelaar
be86bc81a7
Fix warnings in tests
2013-08-17 08:41:35 -07:00
bors
680eb71564
auto merge of #8532 : kballard/rust/cstr-cleanup, r=erickt
...
Implement interior null checking in `.to_c_str()`, among other changes.
2013-08-16 06:02:14 -07:00
Huon Wilson
abe94f9b4d
doc: correct spelling in documentation.
2013-08-16 15:41:28 +10:00
Daniel Micay
062747b9c9
ptr: inline the Clone implementation
2013-08-15 21:12:34 -04:00
Kevin Ballard
03ef71e262
Add ToCStr method .with_c_str()
...
.with_c_str() is a replacement for the old .as_c_str(), to avoid
unnecessary boilerplate.
Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-15 01:33:10 -07:00
Alex Crichton
930885d5e5
Forbid pub/priv where it has no effect
...
Closes #5495
2013-08-12 23:20:46 -07:00
Daniel Micay
0cb0ef2ca5
fix build with the new snapshot compiler
2013-08-12 17:37:46 -04:00
Erick Tryzelaar
a54476b0aa
Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls
2013-08-07 14:10:39 -07:00
Daniel Micay
55f3d04101
vec: use offset_inbounds
for iterators
...
This allows LLVM to optimize vector iterators to an `getelementptr` and
`icmp` pair, instead of `getelementptr` and *two* comparisons.
Code snippet:
~~~
fn foo(xs: &mut [f64]) {
for x in xs.mut_iter() {
*x += 10.0;
}
}
~~~
LLVM IR at stage0:
~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
%2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
%3 = load double** %2, align 8
%4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
%5 = load i64* %4, align 8
%6 = ptrtoint double* %3 to i64
%7 = and i64 %5, -8
%8 = add i64 %7, %6
%9 = inttoptr i64 %8 to double*
%10 = icmp eq double* %3, %9
%11 = icmp eq double* %3, null
%or.cond6 = or i1 %10, %11
br i1 %or.cond6, label %match_case, label %match_else
match_else: ; preds = %"function top level", %match_else
%12 = phi double* [ %13, %match_else ], [ %3, %"function top level" ]
%13 = getelementptr double* %12, i64 1
%14 = load double* %12, align 8
%15 = fadd double %14, 1.000000e+01
store double %15, double* %12, align 8
%16 = icmp eq double* %13, %9
%17 = icmp eq double* %13, null
%or.cond = or i1 %16, %17
br i1 %or.cond, label %match_case, label %match_else
match_case: ; preds = %match_else, %"function top level"
ret void
}
~~~
Optimized LLVM IR at stage1/stage2:
~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
%2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
%3 = load double** %2, align 8
%4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
%5 = load i64* %4, align 8
%6 = lshr i64 %5, 3
%7 = getelementptr inbounds double* %3, i64 %6
%8 = icmp eq i64 %6, 0
%9 = icmp eq double* %3, null
%or.cond6 = or i1 %8, %9
br i1 %or.cond6, label %match_case, label %match_else
match_else: ; preds = %"function top level", %match_else
%.sroa.0.0.in7 = phi double* [ %10, %match_else ], [ %3, %"function top level" ]
%10 = getelementptr inbounds double* %.sroa.0.0.in7, i64 1
%11 = load double* %.sroa.0.0.in7, align 8
%12 = fadd double %11, 1.000000e+01
store double %12, double* %.sroa.0.0.in7, align 8
%13 = icmp eq double* %10, %7
br i1 %13, label %match_case, label %match_else
match_case: ; preds = %match_else, %"function top level"
ret void
}
~~~
2013-08-06 23:54:24 -04:00
Daniel Micay
7d115c9420
add an intrinsic for inbounds GEP
2013-08-06 23:41:20 -04:00
Erick Tryzelaar
5eaa4d1d2f
Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls
2013-08-06 16:21:02 -07:00
blake2-ppc
ea9c5c405e
std: Remove uint::iterate, replaced by range
2013-08-06 04:05:08 +02:00
Erick Tryzelaar
3c94b5044c
Merge remote-tracking branch 'remotes/origin/master' into str-remove-null
2013-08-04 16:23:41 -07:00
Erick Tryzelaar
bd908d4c0e
std and rustc: explicitly pass c strings to c functions
...
When strings lose their trailing null, this pattern will become dangerous:
let foo = "bar";
let foo_ptr: *u8 = &foo[0];
Instead we should use c_strs to handle this correctly.
2013-08-04 15:45:16 -07:00
Erick Tryzelaar
3102b1797e
std: replace str::as_c_str with std::c_str
2013-08-04 14:13:17 -07:00
Daniel Micay
9f74217d80
register snapshots
2013-08-03 21:09:28 -04:00
Daniel Micay
ef870d37a5
implement pointer arithmetic with GEP
...
Closes #8118 , #7136
~~~rust
extern mod extra;
use std::vec;
use std::ptr;
fn bench_from_elem(b: &mut extra::test::BenchHarness) {
do b.iter {
let v: ~[u8] = vec::from_elem(1024, 0u8);
}
}
fn bench_set_memory(b: &mut extra::test::BenchHarness) {
do b.iter {
let mut v: ~[u8] = vec::with_capacity(1024);
unsafe {
let vp = vec::raw::to_mut_ptr(v);
ptr::set_memory(vp, 0, 1024);
vec::raw::set_len(&mut v, 1024);
}
}
}
fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
do b.iter {
let v: ~[u8] = ~[0u8, ..1024];
}
}
~~~
Before:
test bench_from_elem ... bench: 415 ns/iter (+/- 17)
test bench_set_memory ... bench: 85 ns/iter (+/- 4)
test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)
After:
test bench_from_elem ... bench: 84 ns/iter (+/- 2)
test bench_set_memory ... bench: 84 ns/iter (+/- 5)
test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 02:50:31 -04:00
Erick Tryzelaar
7af56bb921
std: move StrUtil::as_c_str into StrSlice
2013-07-23 16:56:22 -07:00
bors
3514a5af06
auto merge of #7857 : blake2-ppc/rust/fix-test-warnings, r=alexcrichton
...
Fix warnings that only show up when compiling the tests for libstd, libextra and one in librusti. Only trivial changes.
2013-07-18 20:55:38 -07:00