Commit graph

46426 commits

Author SHA1 Message Date
Andrea Canciani
369a9dc302 Remove boundary checks in slice comparison operators
In order to get rid of all range checks, the compiler needs to
explicitly see that the slices it iterates over are as long as the
loop variable upper bound.

This further improves the performance of slice comparison:

```
test u8_cmp          ... bench:       4,761 ns/iter (+/- 1,203)
test u8_lt           ... bench:       4,579 ns/iter (+/- 649)
test u8_partial_cmp  ... bench:       4,768 ns/iter (+/- 761)
test u16_cmp         ... bench:       4,607 ns/iter (+/- 580)
test u16_lt          ... bench:       4,681 ns/iter (+/- 567)
test u16_partial_cmp ... bench:       4,607 ns/iter (+/- 967)
test u32_cmp         ... bench:       4,448 ns/iter (+/- 891)
test u32_lt          ... bench:       4,546 ns/iter (+/- 992)
test u32_partial_cmp ... bench:       4,415 ns/iter (+/- 646)
test u64_cmp         ... bench:       4,380 ns/iter (+/- 1,184)
test u64_lt          ... bench:       5,684 ns/iter (+/- 602)
test u64_partial_cmp ... bench:       4,663 ns/iter (+/- 1,158)
```
2015-09-16 15:27:14 +02:00
Andrea Canciani
bf9254a75e Reuse cmp in totally ordered types
Instead of manually defining it, `partial_cmp` can simply wrap the
result of `cmp` for totally ordered types.
2015-09-16 15:25:51 +02:00
Andrea Canciani
d04b8b5818 Improve PartialOrd for slices
Reusing the same idea as in #26884, we can exploit the fact that the
length of slices is known, hence we can use a counted loop instead of
iterators, which means that we only need a single counter, instead of
having to increment and check one pointer for each iterator.

Using the generic implementation of the boolean comparison operators
(`lt`, `le`, `gt`, `ge`) provides further speedup for simple
types. This happens because the loop scans elements checking for
equality and dispatches to element comparison or length comparison
depending on the result of the prefix comparison.

```
test u8_cmp          ... bench:      14,043 ns/iter (+/- 1,732)
test u8_lt           ... bench:      16,156 ns/iter (+/- 1,864)
test u8_partial_cmp  ... bench:      16,250 ns/iter (+/- 2,608)
test u16_cmp         ... bench:      15,764 ns/iter (+/- 1,420)
test u16_lt          ... bench:      19,833 ns/iter (+/- 2,826)
test u16_partial_cmp ... bench:      19,811 ns/iter (+/- 2,240)
test u32_cmp         ... bench:      15,792 ns/iter (+/- 3,409)
test u32_lt          ... bench:      18,577 ns/iter (+/- 2,075)
test u32_partial_cmp ... bench:      18,603 ns/iter (+/- 5,666)
test u64_cmp         ... bench:      16,337 ns/iter (+/- 2,511)
test u64_lt          ... bench:      18,074 ns/iter (+/- 7,914)
test u64_partial_cmp ... bench:      17,909 ns/iter (+/- 1,105)
```

```
test u8_cmp          ... bench:       6,511 ns/iter (+/- 982)
test u8_lt           ... bench:       6,671 ns/iter (+/- 919)
test u8_partial_cmp  ... bench:       7,118 ns/iter (+/- 1,623)
test u16_cmp         ... bench:       6,689 ns/iter (+/- 921)
test u16_lt          ... bench:       6,712 ns/iter (+/- 947)
test u16_partial_cmp ... bench:       6,725 ns/iter (+/- 780)
test u32_cmp         ... bench:       7,704 ns/iter (+/- 1,294)
test u32_lt          ... bench:       7,611 ns/iter (+/- 3,062)
test u32_partial_cmp ... bench:       7,640 ns/iter (+/- 1,149)
test u64_cmp         ... bench:       7,517 ns/iter (+/- 2,164)
test u64_lt          ... bench:       7,579 ns/iter (+/- 1,048)
test u64_partial_cmp ... bench:       7,629 ns/iter (+/- 1,195)
```
2015-09-16 12:00:56 +02:00
Andrea Canciani
1614173b58 Specialize PartialOrd for totally ordered primitive types
Knowing the result of equality comparison can enable additional
optimizations in LLVM.

Additionally, this makes it obvious that `partial_cmp` on totally
ordered types cannot return `None`.
2015-09-16 11:26:56 +02:00
bors
0f1f5fc746 Auto merge of #28417 - apasel422:issue-23036, r=arielb1
Closes #23036.
2015-09-16 04:07:07 +00:00
bors
405f8f1f25 Auto merge of #28401 - christopherdumas:beginners_manuel, r=Gankro
r? @steveklabnik
2015-09-16 02:18:01 +00:00
bors
fc4d566b43 Auto merge of #28399 - nrc:attrs, r=nikomatsakis
This could be a [breaking-change] if your lint or syntax extension (is that even possible?) uses HIR attributes or literals.
2015-09-16 00:35:24 +00:00
Nick Cameron
e9f1b06329 Use ast attributes every where (remove HIR attributes).
This could be a [breaking-change] if your lint or syntax extension (is that even possible?) uses HIR attributes or literals.
2015-09-16 10:57:06 +12:00
bors
9bc1fae4aa Auto merge of #28426 - brson:ver, r=alexcrichton 2015-09-15 22:52:59 +00:00
bors
5e44115970 Auto merge of #28408 - brson:relnotes, r=aturon
I'd love to have any tips about highlights and lang stuff I missed. Sadly, this needs to be merged *tomorrow*.

[Rendered](https://github.com/brson/rust/blob/relnotes/RELEASES.md)
2015-09-15 21:10:16 +00:00
Brian Anderson
cedde0fc8a Bump to 1.5 2015-09-15 14:05:10 -07:00
Brian Anderson
f57bb9df28 1.3 release notes 2015-09-15 13:50:07 -07:00
bors
d2e13e822a Auto merge of #28263 - christopherdumas:add_help_E0118, r=nikomatsakis
Contributing to the Rust error explanations. Should I also add a better error for it by default?
2015-09-15 16:43:41 +00:00
bors
8a19b234c7 Auto merge of #28413 - arielb1:deduplication, r=eddyb
clean a few things discovered during my split_ty work

r? @eddyb
2015-09-15 15:01:05 +00:00
Andrew Paseltiner
4e25329c5e Add test for #23036
Closes #23036.
2015-09-15 10:14:11 -04:00
bors
3887ca27f1 Auto merge of #28407 - mmcco:master, r=alexcrichton
…e len is actually one more than the length of argv[0]. However, this is precarious and should probably be replaced with more robust logic.
2015-09-15 13:18:13 +00:00
bors
7161530fc4 Auto merge of #28406 - petrochenkov:primitive, r=eddyb
This was missing from https://github.com/rust-lang/rust/pull/27451

r? @eddyb
2015-09-15 11:35:11 +00:00
bors
6d154af14a Auto merge of #28393 - arielb1:required-because-it-appears, r=nikomatsakis
new error style:
```
path.rs:4:6: 4:7 error: the trait `core::marker::Sized` is not implemented for the type `[u8]` [E0277]
path.rs:4 fn f(p: Path) {}
               ^
path.rs:4:6: 4:7 help: run `rustc --explain E0277` to see a detailed explanation
path.rs:4:6: 4:7 note: `[u8]` does not have a constant size known at compile-time
path.rs:4:6: 4:7 note: required because it appears within the type `std::sys::os_str::Slice`
path.rs:4:6: 4:7 note: required because it appears within the type `std::ffi::os_str::OsStr`
path.rs:4:6: 4:7 note: required because it appears within the type `std::path::Path`
path.rs:4:6: 4:7 note: all local variables must have a statically known size
path.rs:7:5: 7:36 error: the trait `core::marker::Send` is not implemented for the type `alloc::rc::Rc<()>` [E0277]
path.rs:7     foo::<BTreeMap<Rc<()>, Rc<()>>>();
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
path.rs:7:5: 7:36 help: run `rustc --explain E0277` to see a detailed explanation
path.rs:7:5: 7:36 note: `alloc::rc::Rc<()>` cannot be sent between threads safely
path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::node::Node<alloc::rc::Rc<()>, alloc::rc::Rc<()>>`
path.rs:7:5: 7:36 note: required because it appears within the type `collections::btree::map::BTreeMap<alloc::rc::Rc<()>, alloc::rc::Rc<()>>`
path.rs:7:5: 7:36 note: required by `foo`
error: aborting due to 2 previous errors
```

Fixes #21793 
Fixes #23286

r? @nikomatsakis
2015-09-15 09:52:04 +00:00
bors
8320345221 Auto merge of #28268 - petrochenkov:fnptr, r=alexcrichton
Closes https://github.com/rust-lang/rust/issues/26082
2015-09-15 08:09:20 +00:00
bors
a7b3eed750 Auto merge of #28395 - ebfull:fix-associated-item-resolution, r=arielb1
Fixes #28344
2015-09-15 06:25:38 +00:00
bors
f3e6d31538 Auto merge of #28351 - jonas-schievink:macro-bt, r=nrc
The second commit in this PR will stop printing the macro definition site in backtraces, which cuts their length in half and increases readability (the definition site was only correct for local macros).

The third commit will not print an invocation if the last one printed occurred at the same place (span). This will make backtraces caused by a self-recursive macro much shorter.

(A possible alternative would be to capture the backtrace first, then limit it to a few frames at the start and end of the chain and print `...` inbetween. This would also work with multiple macros calling each other, which is not addressed by this PR - although the backtrace will still be halved)

Example:
```rust
macro_rules! m {
 ( 0 $($t:tt)* ) => ( m!($($t)*); );
 () => ( fn main() {0} );
}

m!(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0);
```

On a semi-recent nightly, this yields:
```
test.rs:3:21: 3:22 error: mismatched types:
 expected `()`,
    found `_`
(expected (),
    found integral variable) [E0308]
test.rs:3  () => ( fn main() {0} );
                              ^
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:2:23: 2:34 note: expansion site
test.rs:1:1: 4:2 note: in expansion of m!
test.rs:6:1: 6:35 note: expansion site
test.rs:3:21: 3:22 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
```

After this patch:
```
test.rs:3:21: 3:22 error: mismatched types:
 expected `()`,
    found `_`
(expected (),
    found integral variable) [E0308]
test.rs:3  () => ( fn main() {0} );
                              ^
test.rs:2:23: 2:34 note: in this expansion of m!
test.rs:6:1: 6:35 note: in this expansion of m!
test.rs:3:21: 3:22 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
```
2015-09-15 03:21:30 +00:00
bors
b1c9616882 Auto merge of #28274 - arielb1:split-ty, r=nikomatsakis
That file got way too big for its own good. It could be split more - this is just a start.

r? @nikomatsakis
2015-09-15 01:38:00 +00:00
bors
e629dba0ee Auto merge of #28256 - petrochenkov:conv, r=alexcrichton
This patch transforms functions of the form
```
fn f<Generic: AsRef<Concrete>>(arg: Generic) {
	let arg: &Concrete = arg.as_ref();
	// Code using arg
}
```
to the next form:
```
#[inline]
fn f<Generic: AsRef<Concrete>>(arg: Generic) {
	fn f_inner(arg: &Concrete) {
		// Code using arg
	}
	
	f_inner(arg.as_ref());
}
```

Therefore, most of the code is concrete and not duplicated during monomorphisation (unless inlined)
and only the tiny bit of conversion code is duplicated. This method was mentioned by @aturon in the
Conversion Traits RFC (https://github.com/rust-lang/rfcs/blame/master/text/0529-conversion-traits.md#L249) and similar techniques are not uncommon in C++ template libraries.

This patch goes to the extremes and applies the transformation even to smaller functions<sup>1</sup>
for purity of the experiment. *Some of them can be rolled back* if considered too ridiculous.

<sup>1</sup> However who knows how small are these functions are after inlining and everything.

The functions in question are mostly `fs`/`os` functions and not used especially often with variety
of argument types, so the code size reduction is rather small (but consistent). Here are the sizes
of stage2 artifacts before and after the patch:
https://gist.github.com/petrochenkov/e76a6b280f382da13c5d
https://gist.github.com/petrochenkov/6cc28727d5256dbdfed0

Note:
All the `inner` functions are concrete and unavailable for cross-crate inlining, some of them may
need `#[inline]` annotations in the future.

r? @aturon
2015-09-14 22:21:41 +00:00
Michael McConville
2eafd19dfa Remove a needless memset(). It's okay that we don't append NUL because len is actually one more than the length of argv[0]. However, this is precarious and should probably be replaced with more robust logic. 2015-09-14 18:12:45 -04:00
Vadim Petrochenkov
cfa2925f2e Prohibit renaming to primitive types' names in import lists 2015-09-15 01:07:17 +03:00
Ariel Ben-Yehuda
5e4704f6ee deduplicate erase_regions
there is no need for 3 versions of the function
2015-09-15 00:47:14 +03:00
bors
bc6c3970a0 Auto merge of #28247 - christopherdumas:fix_28243, r=eddyb
as per #28243.
2015-09-14 20:37:49 +00:00
bors
22071ec641 Auto merge of #28403 - sfackler:timeout-cap-removal, r=alexcrichton
Windows's scheduler apparently has "problems" unblocking calls in the
asked for time period.
2015-09-14 18:54:01 +00:00
Steven Fackler
224023dfd1 Drop upper bounds on net timeout tests
Windows's scheduler apparently has "problems" unblocking calls in the
asked for time period.
2015-09-14 10:11:40 -07:00
bors
9da7706dd6 Auto merge of #28248 - PeterReid:master, r=alexcrichton
Overflows in integer pow() computations would be missed if they
preceded a 0 bit of the exponent being processed. This made
calls such as 2i32.pow(1024) not trigger an overflow.

Fixes #28012
2015-09-14 17:10:09 +00:00
christopherdumas
4543dadd6b Cheat sheet 2015-09-14 07:28:06 -07:00
christopherdumas
afa905fcf5 Fix tuple float bug. 2015-09-14 07:26:11 -07:00
Jonas Schievink
0be755c24a Print the file in which a macro was defined 2015-09-14 16:09:57 +02:00
christopherdumas
35209dcda8 Fix typo 2015-09-14 06:29:32 -07:00
Ariel Ben-Yehuda
3dc780ed6f use RegionEscape instead of inherent has_escaping_regions fns 2015-09-14 15:15:48 +03:00
Ariel Ben-Yehuda
5a95acb8ab split ty::util and ty::adjustment 2015-09-14 14:55:56 +03:00
bors
2d4ae52cbd Auto merge of #28358 - dotdash:nounwind, r=alexcrichton
This allows to skip the codegen for all the unneeded landing pads, reducing code size across the board by about 2-5%, depending on the crate. Compile times seem to be pretty unaffected though :-/
2015-09-14 11:05:34 +00:00
Ariel Ben-Yehuda
2ad5a61fe2 move traits structural impls to traits::structural_impls 2015-09-14 12:55:51 +03:00
Björn Steinbrink
3ef75d5774 Mark all extern functions as nounwind
Unwinding across an FFI boundary is undefined behaviour, so we can mark
all external function as nounwind. The obvious exception are those
functions that actually perform the unwinding.
2015-09-14 11:36:09 +02:00
Ariel Ben-Yehuda
5f564fbbe4 split ty.rs into smaller parts 2015-09-14 12:32:52 +03:00
bors
664a45976f Auto merge of #28389 - aidanhs:aphs-update-musl-linking, r=steveklabnik
In addition to instruction updates I
 - changed from wget to curl, because curl is a prerequisite of rust itself
 - removed `[...]` because they're missing from so many places it would just obscure the instructions if they were all put in

r? @steveklabnik
2015-09-14 09:22:56 +00:00
Sean Bowe
4fec679399 Cleaner abstraction for type_substs 2015-09-14 02:33:29 -06:00
Ariel Ben-Yehuda
caa10c3bde move middle::ty and related modules to middle/ty/ 2015-09-14 10:56:13 +03:00
bors
4d6dc7f9ba Auto merge of #28396 - arielb1:misplaced-binding, r=eddyb
Technically a [breaking-change], but the broken code is useless,
like `i32<Param=()>`.

Fixes #24682

r? @eddyb
2015-09-14 06:51:18 +00:00
bors
009f2cf7dd Auto merge of #28392 - arielb1:sort-bounds-list, r=eddyb
The sort key is a (DefId, Name), which is *not* stable between
runs, so we must re-sort when loading.

Fixes #24063
Fixes #25467
Fixes #27222
Fixes #28377

r? @eddyb
2015-09-14 05:08:27 +00:00
Sean Bowe
3d0774f598 Added test for partially supplied type params in which remaining reference non-existant self 2015-09-13 21:43:37 -06:00
bors
341a91902a Auto merge of #28383 - semarie:openbsd-jemalloc, r=alexcrichton
ignore severals tests under openbsd as we have disabling jemalloc under
this target.

r? @alexcrichton
2015-09-14 03:25:25 +00:00
Sean Bowe
af3a0b0805 Refactor ty_infer invocation 2015-09-13 21:22:30 -06:00
Peter Reid
a593a211fe Add test for overflowing pow
This would catch regressions of issue #28012.
2015-09-13 22:19:36 -04:00
bors
523acd9804 Auto merge of #28368 - lfairy:write-impl, r=alexcrichton
There is already a corresponding impl for `std::io::Write`. This change
will make the two traits more consistent.
2015-09-14 01:43:10 +00:00