| Age | Commit message (Collapse) | Author | Lines |
|
This reverts commit 6484258f1749499d3e51685df867b3d460a7f0be.
|
|
Fixes #41701.
|
|
This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.
[RFC 1974]: https://github.com/rust-lang/rfcs/pull/197
The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.
cc #27389
|
|
This reverts commit 143206d54d7558c2326212df99efc98110904fdb.
|
|
Move it and Bound to core::ops while we're at it.
Closes #30877
|
|
|
|
|
|
Add overflow checking for `str::get` with inclusive ranges
Fixes https://github.com/rust-lang/rust/issues/42401
Two commits here:
1. The first makes `str::index` just call `SliceIndex<str>::index`. It's intended to have no behavior change, except where the two methods were inconsistent.
2. The second actually adds the overflow checking to `get(_mut)` (and tests for it)
|
|
This follows `match_indices`
|
|
Vec<T> is pronounced 'vec'
I've never heard it pronounced "vector". Is this an outdated recommendation?
(or have I been doing it wrong all this time)
r? @steveklabnik
|
|
Fixes #42401
|
|
|
|
|
|
Improve reallocation in alloc_system on Windows
Fixes https://github.com/rust-lang/rust/issues/42025
|
|
|
|
Add [[T]] -> [T] examples to SliceConcatExt docs
None
|
|
Deprecate range-specific `step_by`
Deprecation attributes and test updates only.
Was replaced by an any-iterator version in https://github.com/rust-lang/rust/pull/41439
Last follow-up (this release) to https://github.com/rust-lang/rust/pull/42110#issuecomment-303210138
r? @alexcrichton
|
|
|
|
Add an in-place rotate method for slices to libcore
A helpful primitive for moving chunks of data around inside a slice.
For example, if you have a range selected and are drag-and-dropping it somewhere else (Example from [Sean Parent's talk](https://youtu.be/qH6sSOr-yk8?t=560)).
(If this should be an RFC instead of a PR, please let me know.)
Edit: changed example
|
|
|
|
|
|
|
|
Docs: impls of PartialEq/PartialOrd/Ord must agree
Fixes #41270.
This PR brings two improvements to the docs:
1. Docs for `PartialEq`, `PartialOrd`, and `Ord` clarify that their implementations must agree.
2. Fixes a subtle bug in the Dijkstra example for `BinaryHeap`, where the impls are inconsistent.
Thanks @Rufflewind for spotting the bug!
r? @alexcrichton
cc @frankmcsherry
|
|
|
|
|
|
r=GuillaumeGomez
Update documentation for indexing/slicing methods
See #39911
r? @steveklabnik
|
|
Remove superfluous `;;` sequences
Ran across a doubled `;;` in the docstring for `str::split`. Grep found a few more. :)
|
|
See #39911
|
|
|
|
Make RangeInclusive just a two-field struct
Not being an enum improves ergonomics and consistency, especially since NonEmpty variant wasn't prevented from being empty. It can still be iterable without an extra "done" bit by making the range have !(start <= end), which is even possible without changing the Step trait.
Implements merged https://github.com/rust-lang/rfcs/pull/1980; tracking issue https://github.com/rust-lang/rust/issues/28237.
This is definitely a breaking change to anything consuming `RangeInclusive` directly (not as an Iterator) or constructing it without using the sugar. Is there some change that would make sense before this so compilation failures could be compatibly fixed ahead of time?
r? @aturon (as FCP proposer on the RFC)
|
|
The documentation for this method appears on multiple different pages,
which causes the relative links to not always work.
|
|
`Vec::into_boxed_slice` and `[T]::into_vec` are inverses, so it makes sense
to mention the other in their respective documentation for visibility.
`Vec::into_boxed_slice` already mentions `[T]::into_vec`, but not the other
way around until now.
|
|
Stabilize library features for 1.18.0
Closes #38863
Closes #38980
Closes #38903
Closes #36648
r? @alexcrichton
@rust-lang/libs
|
|
|
|
|
|
|
|
Batch-insert is better done with Vec::splice
|
|
A helpful primitive for moving chunks of data around inside a slice.
In particular, adding elements to the end of a Vec then moving them
somewhere else, as a way to do efficient multiple-insert. (There's
drain for efficient block-remove, but no easy way to block-insert.)
Talk with another example: <https://youtu.be/qH6sSOr-yk8?t=560>
|
|
Not being an enum improves ergonomics, especially since NonEmpty could be Empty. It can still be iterable without an extra "done" bit by making the range have !(start <= end), which is even possible without changing the Step trait.
Implements RFC 1980
|
|
Closes #38863
Closes #38980
Closes #38903
Closes #36648
|
|
Correct some stability versions
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
|
|
These were found by running tidy on stable versions of rust and finding
features stabilised with the wrong version numbers.
|
|
Minor optimisation of the string operations
The interesting benchmarks are
<table cellspacing="0" border="0">
<tr>
<th height="17" align="right"><b> (<100% → better than original )</b></th>
<th align="left" sdnum="2057;0;0.00%">Delta</th>
<th align="left">Original ns/i</th>
<th align="left">This Patch ns/i</th>
</tr>
<tr>
<td height="17" align="left">str::contains_bang_char::long_lorem_ipsum</td>
<td align="right" sdval="0.249775381850854" sdnum="2057;0;0.00%">24.98%</td>
<td align="right" sdval="5565" sdnum="2057;">5565</td>
<td align="right" sdval="1390" sdnum="2057;">1390</td>
</tr>
<tr>
<td height="17" align="left">str::contains_bang_char::short_ascii</td>
<td align="right" sdval="0.277777777777778" sdnum="2057;0;0.00%">27.78%</td>
<td align="right" sdval="144" sdnum="2057;">144</td>
<td align="right" sdval="40" sdnum="2057;">40</td>
</tr>
<tr>
<td height="17" align="left">str::contains_bang_char::short_mixed</td>
<td align="right" sdval="0.333333333333333" sdnum="2057;0;0.00%">33.33%</td>
<td align="right" sdval="120" sdnum="2057;">120</td>
<td align="right" sdval="40" sdnum="2057;">40</td>
</tr>
<tr>
<td height="17" align="left">str::contains_bang_char::short_pile_of_poo</td>
<td align="right" sdval="0.594202898550725" sdnum="2057;0;0.00%">59.42%</td>
<td align="right" sdval="69" sdnum="2057;">69</td>
<td align="right" sdval="41" sdnum="2057;">41</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_ascii_char::long_lorem_ipsum</td>
<td align="right" sdval="0.452629649990837" sdnum="2057;0;0.00%">45.26%</td>
<td align="right" sdval="5457" sdnum="2057;">5457</td>
<td align="right" sdval="2470" sdnum="2057;">2470</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_ascii_char::short_ascii</td>
<td align="right" sdval="0.450054684651841" sdnum="2057;0;0.00%">45.01%</td>
<td align="right" sdval="5486" sdnum="2057;">5486</td>
<td align="right" sdval="2469" sdnum="2057;">2469</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_ascii_char::short_mixed</td>
<td align="right" sdval="0.463132795304475" sdnum="2057;0;0.00%">46.31%</td>
<td align="right" sdval="5452" sdnum="2057;">5452</td>
<td align="right" sdval="2525" sdnum="2057;">2525</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_ascii_char::short_pile_of_poo</td>
<td align="right" sdval="0.453426419254088" sdnum="2057;0;0.00%">45.34%</td>
<td align="right" sdval="5443" sdnum="2057;">5443</td>
<td align="right" sdval="2468" sdnum="2057;">2468</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_unichar::long_lorem_ipsum</td>
<td align="right" sdval="0.459385290889133" sdnum="2057;0;0.00%">45.94%</td>
<td align="right" sdval="5466" sdnum="2057;">5466</td>
<td align="right" sdval="2511" sdnum="2057;">2511</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_unichar::short_ascii</td>
<td align="right" sdval="0.460593841642229" sdnum="2057;0;0.00%">46.06%</td>
<td align="right" sdval="5456" sdnum="2057;">5456</td>
<td align="right" sdval="2513" sdnum="2057;">2513</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_unichar::short_mixed</td>
<td align="right" sdval="0.454976303317536" sdnum="2057;0;0.00%">45.50%</td>
<td align="right" sdval="5486" sdnum="2057;">5486</td>
<td align="right" sdval="2496" sdnum="2057;">2496</td>
</tr>
<tr>
<td height="17" align="left">str::ends_with_unichar::short_pile_of_poo</td>
<td align="right" sdval="0.456497797356828" sdnum="2057;0;0.00%">45.65%</td>
<td align="right" sdval="5448" sdnum="2057;">5448</td>
<td align="right" sdval="2487" sdnum="2057;">2487</td>
</tr>
<tr>
<td height="17" align="left">str::find_underscore_char::long_lorem_ipsum</td>
<td align="right" sdval="0.622058559367703" sdnum="2057;0;0.00%">62.21%</td>
<td align="right" sdval="5567" sdnum="2057;">5567</td>
<td align="right" sdval="3463" sdnum="2057;">3463</td>
</tr>
<tr>
<td height="17" align="left">str::find_underscore_char::short_ascii</td>
<td align="right" sdval="0.664383561643836" sdnum="2057;0;0.00%">66.44%</td>
<td align="right" sdval="146" sdnum="2057;">146</td>
<td align="right" sdval="97" sdnum="2057;">97</td>
</tr>
<tr>
<td height="17" align="left">str::find_underscore_char::short_mixed</td>
<td align="right" sdval="0.762295081967213" sdnum="2057;0;0.00%">76.23%</td>
<td align="right" sdval="122" sdnum="2057;">122</td>
<td align="right" sdval="93" sdnum="2057;">93</td>
</tr>
<tr>
<td height="17" align="left">str::find_underscore_str::short_pile_of_poo</td>
<td align="right" sdval="0.476190476190476" sdnum="2057;0;0.00%">47.62%</td>
<td align="right" sdval="252" sdnum="2057;">252</td>
<td align="right" sdval="120" sdnum="2057;">120</td>
</tr>
<tr>
<td height="17" align="left">str::find_zzz_char::long_lorem_ipsum</td>
<td align="right" sdval="0.621655593463818" sdnum="2057;0;0.00%">62.17%</td>
<td align="right" sdval="5569" sdnum="2057;">5569</td>
<td align="right" sdval="3462" sdnum="2057;">3462</td>
</tr>
<tr>
<td height="17" align="left">str::find_zzz_char::short_ascii</td>
<td align="right" sdval="0.666666666666667" sdnum="2057;0;0.00%">66.67%</td>
<td align="right" sdval="147" sdnum="2057;">147</td>
<td align="right" sdval="98" sdnum="2057;">98</td>
</tr>
<tr>
<td height="17" align="left">str::find_zzz_char::short_mixed</td>
<td align="right" sdval="0.754098360655738" sdnum="2057;0;0.00%">75.41%</td>
<td align="right" sdval="122" sdnum="2057;">122</td>
<td align="right" sdval="92" sdnum="2057;">92</td>
</tr>
<tr>
<td height="17" align="left">str::find_zzz_str::long_lorem_ipsum</td>
<td align="right" sdval="0.728648648648649" sdnum="2057;0;0.00%">72.86%</td>
<td align="right" sdval="925" sdnum="2057;">925</td>
<td align="right" sdval="674" sdnum="2057;">674</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_underscore_char::long_lorem_ipsum</td>
<td align="right" sdval="0.3418911335578" sdnum="2057;0;0.00%">34.19%</td>
<td align="right" sdval="7128" sdnum="2057;">7128</td>
<td align="right" sdval="2437" sdnum="2057;">2437</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_underscore_char::short_ascii</td>
<td align="right" sdval="0.373056994818653" sdnum="2057;0;0.00%">37.31%</td>
<td align="right" sdval="193" sdnum="2057;">193</td>
<td align="right" sdval="72" sdnum="2057;">72</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_underscore_char::short_mixed</td>
<td align="right" sdval="0.414201183431953" sdnum="2057;0;0.00%">41.42%</td>
<td align="right" sdval="169" sdnum="2057;">169</td>
<td align="right" sdval="70" sdnum="2057;">70</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_underscore_char::short_pile_of_poo</td>
<td align="right" sdval="0.505050505050505" sdnum="2057;0;0.00%">50.51%</td>
<td align="right" sdval="99" sdnum="2057;">99</td>
<td align="right" sdval="50" sdnum="2057;">50</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_zzz_char::long_lorem_ipsum</td>
<td align="right" sdval="0.341983447888904" sdnum="2057;0;0.00%">34.20%</td>
<td align="right" sdval="7129" sdnum="2057;">7129</td>
<td align="right" sdval="2438" sdnum="2057;">2438</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_zzz_char::short_ascii</td>
<td align="right" sdval="0.371134020618557" sdnum="2057;0;0.00%">37.11%</td>
<td align="right" sdval="194" sdnum="2057;">194</td>
<td align="right" sdval="72" sdnum="2057;">72</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_zzz_char::short_mixed</td>
<td align="right" sdval="0.409356725146199" sdnum="2057;0;0.00%">40.94%</td>
<td align="right" sdval="171" sdnum="2057;">171</td>
<td align="right" sdval="70" sdnum="2057;">70</td>
</tr>
<tr>
<td height="17" align="left">str::rfind_zzz_char::short_pile_of_poo</td>
<td align="right" sdval="0.548076923076923" sdnum="2057;0;0.00%">54.81%</td>
<td align="right" sdval="104" sdnum="2057;">104</td>
<td align="right" sdval="57" sdnum="2057;">57</td>
</tr>
<tr>
<td height="17" align="left">str::trim_right_ascii_char::short_mixed</td>
<td align="right" sdval="1.10416666666667" sdnum="2057;0;0.00%">110.42%</td>
<td align="right" sdval="48" sdnum="2057;">48</td>
<td align="right" sdval="53" sdnum="2057;">53</td>
</tr>
<tr>
<td height="17" align="left">string::bench_from</td>
<td align="right" sdval="1.17241379310345" sdnum="2057;0;0.00%">117.24%</td>
<td align="right" sdval="58" sdnum="2057;">58</td>
<td align="right" sdval="68" sdnum="2057;">68</td>
</tr>
<tr>
<td height="17" align="left">string::bench_from_str</td>
<td align="right" sdval="1.17241379310345" sdnum="2057;0;0.00%">117.24%</td>
<td align="right" sdval="58" sdnum="2057;">58</td>
<td align="right" sdval="68" sdnum="2057;">68</td>
</tr>
<tr>
<td height="17" align="left">string::bench_push_str</td>
<td align="right" sdval="1.11111111111111" sdnum="2057;0;0.00%">111.11%</td>
<td align="right" sdval="54" sdnum="2057;">54</td>
<td align="right" sdval="60" sdnum="2057;">60</td>
</tr>
<tr>
<td height="17" align="left">string::bench_to_string</td>
<td align="right" sdval="1.12068965517241" sdnum="2057;0;0.00%">112.07%</td>
<td align="right" sdval="58" sdnum="2057;">58</td>
<td align="right" sdval="65" sdnum="2057;">65</td>
</tr>
<tr>
<td height="17" align="left">string::from_utf8_lossy_100_invalid</td>
<td align="right" sdval="1.1131458469588" sdnum="2057;0;0.00%">111.31%</td>
<td align="right" sdval="1529" sdnum="2057;">1529</td>
<td align="right" sdval="1702" sdnum="2057;">1702</td>
</tr>
</table>
|
|
|
|
Add Vec::resize_default.
As suggested by #41758.
|
|
Removes unused macros from:
* libcore
* libcollections
The last use of these two macros was removed in commit
b64c9d56700e2c41207166fe8709711ff02488ff
when the char_range_at_reverse function was been removed.
* librustc_errors
Their last use was removed by commits
2f2c3e178325dc1837badcd7573c2c0905fab979
and 11dc974a38fd533aa692cea213305056cd3a6902.
* libsyntax_ext
* librustc_trans
Also, put the otry macro in back/msvc/mod.rs under the
same cfg argument as the places that use it.
|
|
|
|
Make [u8]::reverse() 5x faster
Since LLVM doesn't vectorize the loop for us, do unaligned reads of a larger type and use LLVM's bswap intrinsic to do the reversing of the actual bytes. cfg!-restricted to x86 and x86_64, as I assume it wouldn't help on things like ARMv5.
Also makes [u16]::reverse() a more modest 1.5x faster by loading/storing u32 and swapping the u16s with ROT16.
Thank you ptr::*_unaligned for making this easy :)
Benchmark results (from my i5-2500K):
```text
# Before
test slice::reverse_u8 ... bench: 273,836 ns/iter (+/- 15,592) = 3829 MB/s
test slice::reverse_u16 ... bench: 139,793 ns/iter (+/- 17,748) = 7500 MB/s
test slice::reverse_u32 ... bench: 74,997 ns/iter (+/- 5,130) = 13981 MB/s
test slice::reverse_u64 ... bench: 47,452 ns/iter (+/- 2,213) = 22097 MB/s
# After
test slice::reverse_u8 ... bench: 52,170 ns/iter (+/- 3,962) = 20099 MB/s
test slice::reverse_u16 ... bench: 93,330 ns/iter (+/- 4,412) = 11235 MB/s
test slice::reverse_u32 ... bench: 74,731 ns/iter (+/- 1,425) = 14031 MB/s
test slice::reverse_u64 ... bench: 47,556 ns/iter (+/- 3,025) = 22049 MB/s
```
If you're curious about the assembly, instead of doing this
```
movzx eax, byte ptr [rdi]
movzx ecx, byte ptr [rsi]
mov byte ptr [rdi], cl
mov byte ptr [rsi], al
```
it does this
```
mov rax, qword ptr [rdx]
mov rbx, qword ptr [r11 + rcx - 8]
bswap rbx
mov qword ptr [rdx], rbx
bswap rax
mov qword ptr [r11 + rcx - 8], rax
```
|
|
|
|
None of these are affected by e8fad325fe.
|