Commit Graph

86262 Commits

Author SHA1 Message Date
Pietro Albini
3b40434940
Rollup merge of #55530 - ljedrz:speed_up_String_from_utf16, r=SimonSapin
Speed up String::from_utf16

Collecting into a `Result` is idiomatic, but not necessarily fast due to rustc not being able to preallocate for the resulting collection. This is fine in case of an error, but IMO we should optimize for the common case, i.e. a successful conversion.

This changes the behavior of `String::from_utf16` from collecting into a `Result` to pushing to a preallocated `String` in a loop.

According to [my simple benchmark](https://gist.github.com/ljedrz/953a3fb74058806519bd4d640d6f65ae) this change makes `String::from_utf16` around **twice** as fast.
2018-11-15 11:04:31 +01:00
Pietro Albini
d7c833b7ef
Rollup merge of #55507 - fhartwig:size_of_intrinsic_docs, r=frewsxcv
Add link to std::mem::size_of to size_of intrinsic documentation

The other intrinsics with safe/stable alternatives already have documentation to this effect.
2018-11-15 11:04:30 +01:00
Pietro Albini
b20bba4f37
Rollup merge of #55211 - fintelia:bufwriter-buffer, r=shepmaster
Add BufWriter::buffer method

CC #45323
2018-11-15 11:04:28 +01:00
Pietro Albini
f4ecc1f521
Rollup merge of #55182 - jD91mZM2:rebased, r=alexcrichton
Redox: Update to new changes

These are all cherry-picked from our fork:

 - Remove the `env:` scheme
 - Update `execve` system call to `fexec`
 - Interpret shebangs: these are no longer handled by the kernel, which like usual tries to be as minimal as possible
2018-11-15 11:04:27 +01:00
Ralf Jung
b8915f2ba8 fix other affected tests 2018-11-15 10:59:42 +01:00
Ralf Jung
a3770c2547 do not accept out-of-bounds pointers in enum discriminants, they might be NULL 2018-11-15 10:59:39 +01:00
bors
99e3fca27d Auto merge of #54906 - qnighy:fix-issue-50452, r=nikomatsakis
Reattach all grandchildren when constructing specialization graph.

Specialization graphs are constructed by incrementally adding impls in the order of declaration. If the impl being added has its specializations in the graph already, they should be reattached under the impl. However, the current implementation only reattaches the one found first. Therefore, in the following specialization graph,

```
  Tr1
   |
   I3
  /  \
 I1  I2
```

If `I1`, `I2`, and `I3` are declared in this order, the compiler mistakenly constructs the following graph:

```
  Tr1
  /  \
 I3  I2
  |
 I1
```

This patch fixes the reattach procedure to include all specializing grandchildren-to-be.

Fixes #50452.
2018-11-15 09:51:53 +00:00
Ralf Jung
ffb6ba0828 validation: better error when the enum discriminant is Undef 2018-11-15 09:58:09 +01:00
ljedrz
e6e5635730 ty: return impl Iterator from Predicate::walk_tys 2018-11-15 09:22:00 +01:00
Ralf Jung
62cf9abcf6 rename FrameInfo span field to call_site 2018-11-15 08:59:49 +01:00
Ralf Jung
e4d03f82b5 miri value visitor: provide place when visiting a primitive 2018-11-15 08:51:32 +01:00
Ralf Jung
c5bc83b60d expose MutValueVisitor 2018-11-15 08:51:32 +01:00
Blitzerr
6779bb485c capture_disjoint_fields(rust-lang#53488)
Refactoring out the HirId of the UpvarId in another struct.
2018-11-14 21:18:48 -08:00
Eric Huss
7f4bc2247a Clean up some non-mod-rs stuff. 2018-11-14 18:55:41 -08:00
bors
4ec0ba9545 Auto merge of #55716 - RalfJung:escape-to-raw, r=oli-obk
Add escape-to-raw MIR statement

Add a new MIR "ghost state statement": Escaping a ptr to permit raw accesses.

~~This includes #55549, [click here](https://github.com/RalfJung/rust/compare/miri-visitor...RalfJung:escape-to-raw) for just the new commits.~~
2018-11-15 01:12:01 +00:00
Stepan Koltsov
a1f83e75af Stress test for MPSC
`concurrent_recv_timeout_and_upgrade` reproduces a problem 100%
times on my MacBook with command:

```
./x.py test --stage 0 ./src/test/run-pass/mpsc_stress.rs
```

Thus it is commented out.

Other tests cases were useful for catching another test cases
which may arise during the fix.

This diff is a part of my previous rewrite attempt: #42883

CC #39364
2018-11-15 00:18:19 +00:00
QuietMisdreavus
aa3d7a4e6e properly calculate spans for intra-doc link resolution errors 2018-11-14 18:14:31 -06:00
bors
7d3b9b1640 Auto merge of #55939 - alexcrichton:path-regression-again, r=sfackler
std: Synchronize access to global env during `exec`

This commit, after reverting #55359, applies a different fix for #46775
while also fixing #55775. The basic idea was to go back to pre-#55359
libstd, and then fix #46775 in a way that doesn't expose #55775.

The issue described in #46775 boils down to two problems:

* First, the global environment is reset during `exec` but, but if the
  `exec` call fails then the global environment was a dangling pointer
  into free'd memory as the block of memory was deallocated when
  `Command` is dropped. This is fixed in this commit by installing a
  `Drop` stack object which ensures that the `environ` pointer is
  preserved on a failing `exec`.

* Second, the global environment was accessed in an unsynchronized
  fashion during `exec`. This was fixed by ensuring that the
  Rust-specific environment lock is acquired for these system-level
  operations.

Thanks to Alex Gaynor for pioneering the solution here!

Closes #55775
2018-11-14 22:15:35 +00:00
Ralf Jung
b396505425 put file and line into miri backtrace 2018-11-14 23:14:57 +01:00
Alex Crichton
4032b7a429 std: Synchronize access to global env during exec
This commit, after reverting #55359, applies a different fix for #46775
while also fixing #55775. The basic idea was to go back to pre-#55359
libstd, and then fix #46775 in a way that doesn't expose #55775.

The issue described in #46775 boils down to two problems:

* First, the global environment is reset during `exec` but, but if the
  `exec` call fails then the global environment was a dangling pointer
  into free'd memory as the block of memory was deallocated when
  `Command` is dropped. This is fixed in this commit by installing a
  `Drop` stack object which ensures that the `environ` pointer is
  preserved on a failing `exec`.

* Second, the global environment was accessed in an unsynchronized
  fashion during `exec`. This was fixed by ensuring that the
  Rust-specific environment lock is acquired for these system-level
  operations.

Thanks to Alex Gaynor for pioneering the solution here!

Closes #55775

Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2018-11-14 12:46:57 -08:00
bors
6f93e93af6 Auto merge of #55947 - michaelwoerister:xlto-fix-lld-opt, r=Mark-Simulacrum
xLTO: Don't pass --plugin-opt=thin to LLD. That's not supported anymore.

It seems that `-plugin-opt=thin` is not needed anymore when invoking LLD for ThinLTO. Unfortunately, still passing the option makes LLD crash instead of giving a deprecation warning or something.
2018-11-14 19:25:54 +00:00
Andy Russell
e2ef0f742c
add test for issue #54348 2018-11-14 12:54:32 -05:00
Andy Russell
055e7b7258
add test for issue #55587 2018-11-14 12:41:39 -05:00
Olivier Goffart
c040a483bc Remove extern and some return value as an attempt to make the test pass on more platforms 2018-11-14 18:09:54 +01:00
Blitzerr
1ca505a30a capture_disjoint_fields(rust-lang#53488)
Just running RustFmt on upvar.rs
2018-11-14 08:53:02 -08:00
Ralf Jung
fb5135a6fc prettier miri backtrace printing 2018-11-14 17:48:17 +01:00
Michael Woerister
f6b8eb7987 Update CI-clang to 7.0.0 for macOS dists. 2018-11-14 17:42:53 +01:00
Michael Woerister
2ec6f340cd Update CI-clang to 7.0.0 for Linux dists. 2018-11-14 17:42:06 +01:00
Ralf Jung
57a7c85f93 miri: backtraces with instances 2018-11-14 17:25:06 +01:00
Alex Crichton
5856797bda Revert "Fixes #46775 -- don't mutate the process's environment in Command::exec"
This reverts commit 36fe3b605a.
2018-11-14 07:21:01 -08:00
Tobias Bieniek
cfbae3e194 core/tests/num: Simplify test_int_from_str_overflow() test code
This commit changes the test code to compare against easier-to-read, static values instead of relying on the result of `wrapping_add()` which may or may not result in the value that we expect.
2018-11-14 15:01:27 +01:00
Michael Woerister
4cfc97924f xLTO: Don't pass --plugin-opt=thin to LLD. That's not supported anymore. 2018-11-14 14:42:49 +01:00
bors
6f244c9011 Auto merge of #55934 - alexcrichton:appveyor-gce, r=Mark-Simulacrum
Switch AppVeyor builds to the GCE cloud

[Recommended by AppVeyor][1] this isn't done by default for all builds
due to the high startup overhead (3-4 minutes for a VM), but that's
paltry compared to our overall build times so should be more than
applicable!

[1]: https://help.appveyor.com/discussions/questions/29832-did-recent-changes-apply-to-possibly-slow-down-builds#comment_46494058
2018-11-14 11:54:14 +00:00
Tobias Bieniek
7843e2792d core/char: Add comment to to_digit() 2018-11-14 11:26:00 +01:00
Tobias Bieniek
64a5172652 core/char: Drop radix == 10 special case
This seems to perform equally well
2018-11-14 08:55:53 +01:00
Nicholas Nethercote
818257e702 Use Mmap to open the rmeta file.
Because those files are quite large, contribute significantly to peak
memory usage, but only a small fraction of the data is ever read.
2018-11-14 05:55:10 +02:00
Nick Cameron
547ac5ef0a save-analysis: be even more aggressive about ignorning macro-generated defs 2018-11-14 16:52:08 +13:00
bors
126a0e2aad Auto merge of #52153 - csmoe:projeq_normal, r=scalexm
chalk lowering rule: ProjectionEq-Normalize

cc #49177
r? @scalexm
2018-11-14 02:46:24 +00:00
Corey Farwell
15e7df8b51
Remove unneeded newline. 2018-11-13 21:34:44 -05:00
Nicholas Nethercote
98dab3335f Wrap some query results in Lrc.
So that the frequent clones in `try_get` are cheaper.

Fixes #54274.
2018-11-14 12:31:27 +11:00
bors
f1d61837d1 Auto merge of #55912 - kennytm:rollup, r=kennytm
Rollup of 20 pull requests

Successful merges:

 - #55136 (Remove short doc where it starts with a codeblock)
 - #55711 (Format BtreeMap::range_mut example)
 - #55722 (impl_stable_hash_for: support enums and tuple structs with generic parameters)
 - #55754 (Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/err)
 - #55804 (rustdoc: don't inline `pub use some_crate` unless directly asked to)
 - #55805 (Move `static_assert!` into librustc_data_structures)
 - #55837 (Make PhantomData #[structural_match])
 - #55840 (Fix TLS errors when downloading stage0)
 - #55843 (add FromIterator<A> to Box<[A]>)
 - #55858 (Small fixes on code blocks in rustdoc)
 - #55863 (Fix a typo in std::panic)
 - #55870 (Fix typos.)
 - #55874 (string: Add documentation for `From` impls)
 - #55879 (save-analysis: Don't panic for macro-generated use globs)
 - #55882 (Reference count `crate_inherent_impls`s return value.)
 - #55888 (miri: for uniformity, also move memory_deallocated to AllocationExtra)
 - #55889 (global allocators: add a few comments)
 - #55896 (Document optimizations enabled by FusedIterator)
 - #55905 (Change `Lit::short_name` to `Lit::literal_name`.)
 - #55908 (Fix their/there grammar nit)
2018-11-13 22:17:46 +00:00
Alex Crichton
0d990c7d54 Switch AppVeyor builds to the GCE cloud
[Recommended by AppVeyor][1] this isn't done by default for all builds
due to the high startup overhead (3-4 minutes for a VM), but that's
paltry compared to our overall build times so should be more than
applicable!

[1]: https://help.appveyor.com/discussions/questions/29832-did-recent-changes-apply-to-possibly-slow-down-builds#comment_46494058
2018-11-13 13:38:04 -08:00
Tobias Bieniek
17f08fecfd core/char: Speed up to_digit() for radix <= 10
### Before

```
# Run 1
test char::methods::bench_to_digit_radix_10                ... bench:      16,265 ns/iter (+/- 1,774)
test char::methods::bench_to_digit_radix_16                ... bench:      13,938 ns/iter (+/- 2,479)
test char::methods::bench_to_digit_radix_2                 ... bench:      13,090 ns/iter (+/- 524)
test char::methods::bench_to_digit_radix_36                ... bench:      14,236 ns/iter (+/- 1,949)

# Run 2
test char::methods::bench_to_digit_radix_10                ... bench:      16,176 ns/iter (+/- 1,589)
test char::methods::bench_to_digit_radix_16                ... bench:      13,896 ns/iter (+/- 3,140)
test char::methods::bench_to_digit_radix_2                 ... bench:      13,158 ns/iter (+/- 1,112)
test char::methods::bench_to_digit_radix_36                ... bench:      14,206 ns/iter (+/- 1,312)

# Run 3
test char::methods::bench_to_digit_radix_10                ... bench:      16,221 ns/iter (+/- 2,423)
test char::methods::bench_to_digit_radix_16                ... bench:      14,361 ns/iter (+/- 3,926)
test char::methods::bench_to_digit_radix_2                 ... bench:      13,097 ns/iter (+/- 671)
test char::methods::bench_to_digit_radix_36                ... bench:      14,388 ns/iter (+/- 1,068)
```

### After

```
# Run 1
test char::methods::bench_to_digit_radix_10      ... bench:      11,521 ns/iter (+/- 552)
test char::methods::bench_to_digit_radix_16      ... bench:      12,926 ns/iter (+/- 684)
test char::methods::bench_to_digit_radix_2       ... bench:      11,266 ns/iter (+/- 1,085)
test char::methods::bench_to_digit_radix_36      ... bench:      14,213 ns/iter (+/- 614)

# Run 2
test char::methods::bench_to_digit_radix_10      ... bench:      11,424 ns/iter (+/- 1,042)
test char::methods::bench_to_digit_radix_16      ... bench:      12,854 ns/iter (+/- 1,193)
test char::methods::bench_to_digit_radix_2       ... bench:      11,193 ns/iter (+/- 716)
test char::methods::bench_to_digit_radix_36      ... bench:      14,249 ns/iter (+/- 3,514)

# Run 3
test char::methods::bench_to_digit_radix_10      ... bench:      11,469 ns/iter (+/- 685)
test char::methods::bench_to_digit_radix_16      ... bench:      12,852 ns/iter (+/- 568)
test char::methods::bench_to_digit_radix_2       ... bench:      11,275 ns/iter (+/- 1,356)
test char::methods::bench_to_digit_radix_36      ... bench:      14,188 ns/iter (+/- 1,501)
```
2018-11-13 22:02:51 +01:00
Tobias Bieniek
04aade83f2 core/char: Replace condition + panic!() with assert!() 2018-11-13 22:02:51 +01:00
Tobias Bieniek
98f61a3195 core/benches: Add char::to_digit() benchmarks 2018-11-13 22:02:51 +01:00
Andy Russell
4e35cbb22e
fix various typos in doc comments 2018-11-13 14:45:31 -05:00
csmoe
e853d6c5b6 Implement ProjectionEq-Normalize 2018-11-13 20:33:21 +01:00
bors
9fefb67669 Auto merge of #55356 - Aaron1011:fix/rustdoc-negative-auto, r=nikomatsakis
Check for negative impls when finding auto traits

Fixes #55321

When AutoTraitFinder begins examining a type, it checks for an explicit
negative impl. However, it wasn't checking for negative impls found when
calling 'select' on predicates found from nested obligations.

This commit makes AutoTraitFinder check for negative impls whenever it
makes a call to 'select'. If a negative impl is found, it immediately
bails out.

Normal users of SelectioContext don't need to worry about this, since
they stop as soon as an Unimplemented error is encountered. However, we
add predicates to our ParamEnv when we encounter this error, so we need
to handle negative impls specially (so that we don't try adding them to
our ParamEnv).
2018-11-13 19:16:18 +00:00
ljedrz
cf4f5c3b34 hir: simplify a match expression 2018-11-13 17:35:56 +01:00
ljedrz
3d919297b9 hir: remove an unused type alias 2018-11-13 17:35:25 +01:00