<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/libcore/tests, branch try</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2020-07-28T00:51:13+00:00</updated>
<entry>
<title>mv std libs to library/</title>
<updated>2020-07-28T00:51:13+00:00</updated>
<author>
<name>mark</name>
<email>markm@cs.wisc.edu</email>
</author>
<published>2020-06-12T02:31:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2c31b45ae878b821975c4ebd94cc1e49f6073fd0'/>
<id>urn:sha1:2c31b45ae878b821975c4ebd94cc1e49f6073fd0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Auto merge of #74510 - LukasKalbertodt:fix-range-from-index-panic, r=hanna-kruppe</title>
<updated>2020-07-25T16:27:24+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2020-07-25T16:27:24+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=fe08fb7b1e7cc5ef45e107f05b3cd30d48313d2b'/>
<id>urn:sha1:fe08fb7b1e7cc5ef45e107f05b3cd30d48313d2b</id>
<content type='text'>
Fix panic message when `RangeFrom` index is out of bounds

Before, the `Range` method was called with `end = slice.len()`. Unfortunately, because `Range::index` first checks the order of the indices (start has to be smaller than end), an out of bounds index leads to `core::slice::slice_index_order_fail` being called. This prints the message 'slice index starts at 27 but ends at 10', which is worse than 'index 27 out of range for slice of length 10'. This is not only useful to normal users reading panic messages, but also for people inspecting assembly and being confused by `slice_index_order_fail` calls.

You can see the produced assembly [here](https://rust.godbolt.org/z/GzMGWf) and try on Playground [here](https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=aada5996b2f3848075a6d02cf4055743). (By the way. this is only about which panic function is called; I'm pretty sure it does not improve anything about performance).
</content>
</entry>
<entry>
<title>Rollup merge of #74367 - Neutron3529:patch-1, r=nagisa</title>
<updated>2020-07-24T17:01:30+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-24T17:01:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3226d723381a24118f6aaa73b096c8ef4510f189'/>
<id>urn:sha1:3226d723381a24118f6aaa73b096c8ef4510f189</id>
<content type='text'>
Rearrange the pipeline of `pow` to gain efficiency

The check of the `exp` parameter seems useless if we execute the while-loop more than once.
The original implementation of `pow` function using one more comparison if the `exp==0` and may break the pipeline of the cpu, which may generate a slower code.
The performance gap between the old and the new implementation may be small, but IMO, at least the newer one looks more beautiful.

---

bench prog:
```
#![feature(test)]
extern crate test;
#[macro_export]macro_rules! timing{
($a:expr)=&gt;{let time=std::time::Instant::now();{$a;}print!("{:?} ",time.elapsed())};
($a:expr,$b:literal)=&gt;{let time=std::time::Instant::now();let mut a=0;for _ in 0..$b{a^=$a;}print!("{:?} {} ",time.elapsed(),a)}
}
#[inline]
pub fn pow_rust(x:i64, mut exp: u32) -&gt; i64 {
    let mut base = x;
    let mut acc = 1;
    while exp &gt; 1 {
        if (exp &amp; 1) == 1 {
            acc = acc * base;
        }
        exp /= 2;
        base = base * base;
    }
    if exp == 1 {
        acc = acc * base;
    }
    acc
}
#[inline]
pub fn pow_new(x:i64, mut exp: u32) -&gt; i64 {
    if exp==0{
        1
    }else{
        let mut base = x;
        let mut acc = 1;
        while exp &gt; 1 {
            if (exp &amp; 1) == 1 {
                acc = acc * base;
            }
            exp &gt;&gt;= 1;
            base = base * base;
        }
        acc * base
    }
}

fn main(){
let a=2i64;
let b=1_u32;
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
}
```
bench in my laptop:
```
neutron@Neutron:/me/rust$ rc commit.rs
rustc commit.rs  &amp;&amp; ./commit

3.978419716s 0 4.079765171s 0 3.964630622s 0
3.997127013s 0 4.260304804s 0 3.997638211s 0
3.963195544s 0 4.11657718s 0 4.176054164s 0
3.830128579s 0 3.980396122s 0 3.937258567s 0
3.986055948s 0 4.127804162s 0 4.018943411s 0
4.185568857s 0 4.217512517s 0 3.98313603s 0
3.863018225s 0 4.030447988s 0 3.694878237s 0
4.206987927s 0 4.137608047s 0 4.115564664s 0
neutron@Neutron:/me/rust$ rc commit.rs -O
rustc commit.rs -O &amp;&amp; ./commit

162.111993ms 0 165.107125ms 0 166.26924ms 0
175.20479ms 0 205.062565ms 0 176.278791ms 0
174.408975ms 0 166.526899ms 0 201.857604ms 0
146.190062ms 0 168.592821ms 0 154.61411ms 0
199.678912ms 0 168.411598ms 0 162.129996ms 0
147.420765ms 0 209.759326ms 0 154.807907ms 0
165.507134ms 0 188.476239ms 0 157.351524ms 0
121.320123ms 0 126.401229ms 0 114.86428ms 0
```
</content>
</entry>
<entry>
<title>Rearrange the pipeline of `pow` to gain efficiency</title>
<updated>2020-07-23T06:55:15+00:00</updated>
<author>
<name>Neutron3529</name>
<email>qweytr_1@163.com</email>
</author>
<published>2020-07-15T14:39:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ef74e5084386f82b4285fd7d3630cf1088eebb3f'/>
<id>urn:sha1:ef74e5084386f82b4285fd7d3630cf1088eebb3f</id>
<content type='text'>
The check of the `exp` parameter seems useless if we execute the while-loop more than once.
The original implementation of `pow` function using one more comparison if the `exp==0` and may break the pipeline of the cpu, which may generate a slower code.
The performance gap between the old and the new implementation may be small, but IMO, at least the newer one looks more beautiful.

---

bench prog:
```
extern crate test;
($a:expr)=&gt;{let time=std::time::Instant::now();{$a;}print!("{:?} ",time.elapsed())};
($a:expr,$b:literal)=&gt;{let time=std::time::Instant::now();let mut a=0;for _ in 0..$b{a^=$a;}print!("{:?} {} ",time.elapsed(),a)}
}
pub fn pow_rust(x:i64, mut exp: u32) -&gt; i64 {
    let mut base = x;
    let mut acc = 1;
    while exp &gt; 1 {
        if (exp &amp; 1) == 1 {
            acc = acc * base;
        }
        exp /= 2;
        base = base * base;
    }
    if exp == 1 {
        acc = acc * base;
    }
    acc
}
pub fn pow_new(x:i64, mut exp: u32) -&gt; i64 {
    if exp==0{
        1
    }else{
        let mut base = x;
        let mut acc = 1;
        while exp &gt; 1 {
            if (exp &amp; 1) == 1 {
                acc = acc * base;
            }
            exp &gt;&gt;= 1;
            base = base * base;
        }
        acc * base
    }
}

fn main(){
let a=2i64;
let b=1_u32;
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
timing!(test::black_box(a).pow(test::black_box(b)),100000000);
timing!(pow_new(test::black_box(a),test::black_box(b)),100000000);
timing!(pow_rust(test::black_box(a),test::black_box(b)),100000000);
println!();
}
```
bench in my laptop:
```
neutron@Neutron:/me/rust$ rc commit.rs
rustc commit.rs  &amp;&amp; ./commit

3.978419716s 0 4.079765171s 0 3.964630622s 0
3.997127013s 0 4.260304804s 0 3.997638211s 0
3.963195544s 0 4.11657718s 0 4.176054164s 0
3.830128579s 0 3.980396122s 0 3.937258567s 0
3.986055948s 0 4.127804162s 0 4.018943411s 0
4.185568857s 0 4.217512517s 0 3.98313603s 0
3.863018225s 0 4.030447988s 0 3.694878237s 0
4.206987927s 0 4.137608047s 0 4.115564664s 0
neutron@Neutron:/me/rust$ rc commit.rs -O
rustc commit.rs -O &amp;&amp; ./commit

162.111993ms 0 165.107125ms 0 166.26924ms 0
175.20479ms 0 205.062565ms 0 176.278791ms 0
174.408975ms 0 166.526899ms 0 201.857604ms 0
146.190062ms 0 168.592821ms 0 154.61411ms 0
199.678912ms 0 168.411598ms 0 162.129996ms 0
147.420765ms 0 209.759326ms 0 154.807907ms 0
165.507134ms 0 188.476239ms 0 157.351524ms 0
121.320123ms 0 126.401229ms 0 114.86428ms 0
```

delete an unnecessary semicolon...

Sorry for the typo.

delete trailing whitespace

Sorry, too..

Sorry for the missing...

I checked all the implementations, and finally found that there is one function that does not check whether `exp == 0`

add extra tests

add extra tests.

finished adding the extra tests to prevent further typo

add pow(2) to negative exp

add whitespace.

add whitespace

add whitespace

delete extra line
</content>
</entry>
<entry>
<title>Fix panic message when `RangeFrom` index is out of bounds</title>
<updated>2020-07-19T14:11:07+00:00</updated>
<author>
<name>Lukas Kalbertodt</name>
<email>lukas.kalbertodt@gmail.com</email>
</author>
<published>2020-07-19T11:45:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ce338046c8b40e3284707d2ab725e9f076592959'/>
<id>urn:sha1:ce338046c8b40e3284707d2ab725e9f076592959</id>
<content type='text'>
Before, the `Range` method was called with `end = slice.len()`.
Unfortunately, because `Range::index` first checks the order of the
indices (start has to be smaller than end), an out of bounds index
leads to `core::slice::slice_index_order_fail` being called. This
prints the message 'slice index starts at 27 but ends at 10', which is
worse than 'index 27 out of range for slice of length 10'. This is not
only useful to normal users reading panic messages, but also for people
inspecting assembly and being confused by `slice_index_order_fail`
calls.
</content>
</entry>
<entry>
<title>integrate Lazy into std layout</title>
<updated>2020-07-16T21:25:32+00:00</updated>
<author>
<name>Ashley Mannix</name>
<email>ashleymannix@live.com.au</email>
</author>
<published>2020-01-14T03:34:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=237a97760ad79a21ce0655b9f5adc0cc5b5cbc79'/>
<id>urn:sha1:237a97760ad79a21ce0655b9f5adc0cc5b5cbc79</id>
<content type='text'>
This commit refactors the initial implementation to fit into std and
makes some other changes:

- use MaybeUninit internally in SyncOnceCell
- correctly impl Drop for lazy::Once
- port Lazy::take from once_cell from: https://github.com/matklad/once_cell/pull/100

Co-Authored-By: Paul Dicker &lt;pitdicker@users.noreply.github.com&gt;
</content>
</entry>
<entry>
<title>Rollup merge of #74066 - thomcc:optimize-is-ascii, r=nagisa</title>
<updated>2020-07-11T15:53:16+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-11T15:53:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1979fa86f9fd8cc53384d2dabe775bcbf012a5ad'/>
<id>urn:sha1:1979fa86f9fd8cc53384d2dabe775bcbf012a5ad</id>
<content type='text'>
Optimize is_ascii for str and [u8].

This optimizes the `is_ascii` function for `[u8]` and `str`. I've been surprised this wasn't done for a while, so I just did it.

Benchmarks comparing before/after look like:

```
test ascii::long_readonly::is_ascii_slice_iter_all              ... bench:         174 ns/iter (+/- 79) = 40172 MB/s
test ascii::long_readonly::is_ascii_slice_libcore               ... bench:          16 ns/iter (+/- 5) = 436875 MB/s
test ascii::medium_readonly::is_ascii_slice_iter_all            ... bench:          12 ns/iter (+/- 3) = 2666 MB/s
test ascii::medium_readonly::is_ascii_slice_libcore             ... bench:           2 ns/iter (+/- 0) = 16000 MB/s
test ascii::short_readonly::is_ascii_slice_iter_all             ... bench:           3 ns/iter (+/- 0) = 2333 MB/s
test ascii::short_readonly::is_ascii_slice_libcore              ... bench:           4 ns/iter (+/- 0) = 1750 MB/s
```

(Taken on a x86_64 macbook 2.9 GHz Intel Core i9 with 6 cores)

Where `is_ascii_slice_iter_all` is the old version, and `is_ascii_slice_libcore` is the new.

I tried to document the code well, so hopefully it's understandable. It has fairly exhaustive tests ensuring size/align doesn't get violated -- because `miri` doesn't really help a lot for this sort of code right now, I tried to `debug_assert` all the safety invariants I'm depending on. (Of course, none of them are required for correctness or soundness -- just allows us to test that this sort of pointer manipulation is sound and such).

Anyway, thanks. Let me know if you have questions/desired changes.
</content>
</entry>
<entry>
<title>Rollup merge of #73887 - DutchGhost:master, r=oli-obk</title>
<updated>2020-07-11T06:26:28+00:00</updated>
<author>
<name>Manish Goregaokar</name>
<email>manishsmail@gmail.com</email>
</author>
<published>2020-07-11T06:26:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=efda2b58b095306d068a3a165de62acd1e94911b'/>
<id>urn:sha1:efda2b58b095306d068a3a165de62acd1e94911b</id>
<content type='text'>
stabilize const mem::forget

Stabilizes const `mem::forget` as implemented in https://github.com/rust-lang/rust/pull/69617 and tracked in https://github.com/rust-lang/rust/issues/69616.

Closes https://github.com/rust-lang/rust/issues/69616
</content>
</entry>
<entry>
<title>Optimize is_ascii for &amp;str and &amp;[u8]</title>
<updated>2020-07-05T17:23:50+00:00</updated>
<author>
<name>Thom Chiovoloni</name>
<email>tchiovoloni@mozilla.com</email>
</author>
<published>2020-07-05T17:09:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=980d8e1a0b18e89129cce23bb5a46c6a498dc5d2'/>
<id>urn:sha1:980d8e1a0b18e89129cce23bb5a46c6a498dc5d2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Deny unsafe ops in unsafe fns, part 3</title>
<updated>2020-06-30T15:06:16+00:00</updated>
<author>
<name>LeSeulArtichaut</name>
<email>leseulartichaut@gmail.com</email>
</author>
<published>2020-06-24T11:15:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ac7539c6d1036e42e84d388a57a656c420cb9eee'/>
<id>urn:sha1:ac7539c6d1036e42e84d388a57a656c420cb9eee</id>
<content type='text'>
</content>
</entry>
</feed>
