Commit Graph

105479 Commits

Author SHA1 Message Date
Dylan DPC
69eee569d6
Rollup merge of #68223 - SOF3:float-fract-doc, r=varkor
Use 3.6 instead of 3.5 in float fract() documentation

It is not self-explanatory whether the fract() function inverts the fractional part of negative numbers. This change clarifies this possible question (so that it is `.6` not `.4`)
2020-01-16 11:58:04 +05:30
Dylan DPC
1389caf860
Rollup merge of #68096 - varkor:diagnostic-cleanup, r=Centril
Clean up some diagnostics by making them more consistent

In general:

- Diagnostic should start with a lowercase letter.
- Diagnostics should not end with a full stop.
- Ellipses contain three dots.
- Backticks should encode Rust code.

I also reworded a couple of messages to make them read more clearly.

It might be sensible to create a style guide for diagnostics, so these informal conventions are written down somewhere, after which we could audit the existing diagnostics.

r? @Centril
2020-01-16 11:58:02 +05:30
Dylan DPC
6b83862d09
Rollup merge of #67780 - cjgillot:passes-ty, r=Zoxc
Move some queries from rustc::ty to librustc_ty.

cc #65031
2020-01-16 11:58:00 +05:30
bors
e02c475da5 Auto merge of #67339 - CAD97:rc-provenance, r=sfackler
Use pointer offset instead of deref for A/Rc::into_raw

Internals thread: https://internals.rust-lang.org/t/rc-and-internal-mutability/11463/2?u=cad97

The current implementation of (`A`)`Rc::into_raw` uses the `Deref::deref` implementation to get the pointer-to-data that is returned. This is problematic in the proposed Stacked Borrow rules, as this only gets shared provenance over the data location. (Note that the strong/weak counts are `UnsafeCell` (`Cell`/`Atomic`) so shared provenance can still mutate them, but the data itself is not.) When promoted back to a real reference counted pointer, the restored pointer can be used for mutation through `::get_mut` (if it is the only surviving reference). However, this mutates through a pointer ultimately derived from a `&T` borrow, violating the Stacked Borrow rules.

There are three known potential solutions to this issue:

- Stacked Borrows is wrong, liballoc is correct.
- Fully admit (`A`)`Rc` as an "internal mutability" type and store the data payload in an `UnsafeCell` like the strong/weak counts are. (Note: this is not needed generally since the `RcBox`/`ArcInner` is stored behind a shared `NonNull` which maintains shared write provenance as a raw pointer.)
- Adjust `into_raw` to do direct manipulation of the pointer (like `from_raw`) so that it maintains write provenance and doesn't derive the pointer from a reference.

This PR implements the third option, as recommended by @RalfJung.

Potential future work: provide `as_raw` and `clone_raw` associated functions to allow the [`&T` -> (`A`)`Rc<T>` pattern](https://internals.rust-lang.org/t/rc-and-internal-mutability/11463/2?u=cad97) to be used soundly without creating (`A`)`Rc` from references.
2020-01-16 00:47:45 +00:00
bors
3291ae3390 Auto merge of #68254 - Dylan-DPC:rollup-9vhc59u, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #68123 (Implement Cursor for linked lists. (RFC 2570).)
 - #68212 (Suggest to shorten temporary lifetime during method call inside generator)
 - #68232 (Optimize size/speed of Unicode datasets)
 - #68236 (Add some regression tests)
 - #68237 (Account for `Path`s in `is_suggestable_infer_ty`)
 - #68252 (remove redundant clones, found by clippy)

Failed merges:

r? @ghost
2020-01-15 19:40:45 +00:00
SOFe
33bc9ef513
Use 3.6 instead of 3.5 in float fract() documentation
It is not self-explanatory whether the fract() function inverts the fractional part of negative numbers.

Co-Authored-By: Mateusz Mikuła <mati865@users.noreply.github.com>
2020-01-15 18:46:44 +00:00
Dylan DPC
4ff6195929
Rollup merge of #68252 - matthiaskrgr:redundant_clones, r=oli-obk
remove redundant clones, found by clippy
2020-01-15 22:49:32 +05:30
Dylan DPC
9de54fadae
Rollup merge of #68237 - estebank:bad-bad-ice, r=petrochenkov
Account for `Path`s in `is_suggestable_infer_ty`

Fix #68162.
2020-01-15 22:49:30 +05:30
Dylan DPC
2039d7ee49
Rollup merge of #68236 - JohnTitor:ice-tests, r=Centril
Add some regression tests

Closes #64848 (fixed by #67631)
Closes #65918 (ICE is hidden by #67000, no longer ICE)
Closes #66473 (fixed by #68084)
Closes #67550 (set mir-opt-level to 3)

r? @Centril
2020-01-15 22:49:28 +05:30
Dylan DPC
6270e49ce7
Rollup merge of #68232 - Mark-Simulacrum:unicode-tables, r=joshtriplett
Optimize size/speed of Unicode datasets

The overall implementation has the same general idea as the prior approach,
which was based on a compressed trie structure, but modified to use less space
(and, coincidentally, be an overall performance improvement).

Sizes | Old | New | New/current
-- | -- | -- | --
Alphabetic | 4616 | 2982 | 64.60%
Case_Ignorable | 3144 | 2112 | 67.18%
Cased | 2376 | 934 | 39.31%
Cc | 19 | 43 | 226.32%
Grapheme_Extend | 3072 | 1734 | 56.45%
Lowercase | 2328 | 985 | 42.31%
N | 2648 | 1239 | 46.79%
Uppercase | 1978 | 934 | 47.22%
White_Space | 241 | 140 | 58.09%
  |   |   |
Total | 20422 | 11103 | 54.37%

This table shows the size of the old and new tables in bytes. The most important
of these tables is "Grapheme_Extend", as it is present in essentially all Rust
programs due to being called from `str`'s Debug impl (`char::escape_debug`). In
a representative case given by this [blog post] for the embedded world, the
shrinking in this PR shrinks the final binary by 1,604 bytes, from 14,440 to
12,836.

The performance of these new tables, based on the (rough) benchmark of linearly
scanning the entire valid set of chars, querying for each `is_*`, is roughly
~50% better, though in some cases is either on par or slightly (3-5%) worse. In
practice, I believe the size benefits of this PR are the main concern. The new
implementation has been tested to be equivalent to the current nightly in terms
of returned values on the set of valid chars.

A (relatively) high-level explanation of the specific compression scheme used
can be found [in the generator].

This is split into three commits -- the first adds the generator which produces
the Rust code for the tables, the second adds support code for the lookup, and
the third actually swaps the current implementation out for the new one.

[blog post]: https://jamesmunns.com/blog/fmt-unreasonably-expensive/
[in the generator]: https://github.com/Mark-Simulacrum/rust/blob/unicode-tables/src/tools/unicode-table-generator/src/raw_emitter.rs
2020-01-15 22:49:27 +05:30
Dylan DPC
ae1e75bf4e
Rollup merge of #68212 - csmoe:temp, r=estebank
Suggest to shorten temporary lifetime during method call inside generator

Closes https://github.com/rust-lang/rust/issues/67376
![image](https://user-images.githubusercontent.com/35686186/72364752-f6b1e400-3731-11ea-8ec9-8297ba4c6c77.png)

r? @estebank
cc @tmandry @nikomatsakis
2020-01-15 22:49:26 +05:30
Dylan DPC
1b7b8cbed3
Rollup merge of #68123 - crlf0710:linked_list_cursor, r=Amanieu
Implement Cursor for linked lists. (RFC 2570).

cc. #58533 cc. @Gankra

r? @Amanieu
2020-01-15 22:49:24 +05:30
bors
faf45c5dad Auto merge of #67603 - oli-obk:no_mut_static_ref_from_const, r=RalfJung
Promoteds can contain raw pointers, but these must still only point to immutable allocations

fixes #67601

r? @RalfJung

cc @wesleywiser in order to not change behaviour in this PR, const prop uses the constant rules for interning, but at least there's an explicit mode for it now that we can think about this in the future
2020-01-15 16:28:06 +00:00
Yuki Okushi
3ba15bda53 Set mir-opt-level to 3 to prevent regressions 2020-01-15 23:41:37 +09:00
Yuki Okushi
27a810c719 Add test for issue-66473 2020-01-15 23:41:37 +09:00
Yuki Okushi
ce8fed65f5 Add test for issue-65918 2020-01-15 23:41:37 +09:00
Yuki Okushi
406049df49 Add test for issue-64848 2020-01-15 23:41:37 +09:00
Matthias Krüger
312c3a067a remove redundant clones, found by clippy 2020-01-15 15:00:25 +01:00
bors
6d0bb91bcb Auto merge of #68248 - JohnTitor:rollup-x0kml5f, r=JohnTitor
Rollup of 12 pull requests

Successful merges:

 - #67784 (Reset Formatter flags on exit from pad_integral)
 - #67914 (Don't run const propagation on items with inconsistent bounds)
 - #68141 (use winapi for non-stdlib Windows bindings)
 - #68211 (Add failing example for E0170 explanation)
 - #68219 (Untangle ZST validation from integer validation and generalize it to all zsts)
 - #68222 (Update the wasi-libc bundled with libstd)
 - #68226 (Avoid calling tcx.hir().get() on CRATE_HIR_ID)
 - #68227 (Update to a version of cmake with windows arm64 support)
 - #68229 (Update iovec to a version with no winapi dependency)
 - #68230 (Update libssh2-sys to a version that can build for aarch64-pc-windows…)
 - #68231 (Better support for cross compilation on Windows.)
 - #68233 (Update compiler_builtins with changes to fix 128 bit integer remainder for aarch64 windows.)

Failed merges:

r? @ghost
2020-01-15 13:00:43 +00:00
Yuki Okushi
d2840e6bf1
Rollup merge of #68233 - danielframpton:update-compiler-builtins, r=alexcrichton
Update compiler_builtins with changes to fix 128 bit integer remainder for aarch64 windows.

I have been investigating enabling panic=unwind for aarch64-pc-windows-msvc (see #65313) and building rustc and cargo hosted on aarch64-pc-windows-msvc.
2020-01-15 21:51:59 +09:00
Yuki Okushi
1859d57065
Rollup merge of #68231 - danielframpton:windows-crosscompile, r=alexcrichton
Better support for cross compilation on Windows.

I have been investigating enabling panic=unwind for aarch64-pc-windows-msvc (see #65313) and building rustc and cargo hosted on aarch64-pc-windows-msvc.

Without the libpath changes we were trying to link a mix of amd64 and arm64 binaries.

Without the cmake system name change, the llvm build was trying to run an arm64 build tool on the x86_64 build machine.

That said, I haven't tested all different combinations here and am very open to resolving this a different way.
2020-01-15 21:51:58 +09:00
Yuki Okushi
2c994f22d6
Rollup merge of #68230 - danielframpton:update-libssh2-sys, r=alexcrichton
Update libssh2-sys to a version that can build for aarch64-pc-windows…

I have been investigating enabling panic=unwind for aarch64-pc-windows-msvc (see #65313) and building rustc and cargo hosted on aarch64-pc-windows-msvc.
2020-01-15 21:51:57 +09:00
Yuki Okushi
cc07710196
Rollup merge of #68229 - danielframpton:update-iovec, r=alexcrichton
Update iovec to a version with no winapi dependency

I have been investigating enabling panic=unwind for aarch64-pc-windows-msvc (see #65313) and building rustc and cargo hosted on aarch64-pc-windows-msvc.
2020-01-15 21:51:55 +09:00
Yuki Okushi
58d348d3ab
Rollup merge of #68227 - danielframpton:update-cmake, r=alexcrichton
Update to a version of cmake with windows arm64 support

I have been investigating enabling panic=unwind for aarch64-pc-windows-msvc (see #65313) and building rustc and cargo hosted on aarch64-pc-windows-msvc.
2020-01-15 21:51:54 +09:00
Yuki Okushi
38ca7b707e
Rollup merge of #68226 - Aaron1011:fix/opaque-trace, r=matthewjasper
Avoid calling tcx.hir().get() on CRATE_HIR_ID

This was causing an ICE when enabling trace logging for an unrelated
module, since the arguments to `trace!` ended up getting evaluated
2020-01-15 21:51:52 +09:00
Yuki Okushi
eed625671a
Rollup merge of #68222 - alexcrichton:update-wasi-libc, r=kennytm
Update the wasi-libc bundled with libstd
2020-01-15 21:51:51 +09:00
Yuki Okushi
610ea80710
Rollup merge of #68219 - oli-obk:fix_miri, r=RalfJung,wesleywiser
Untangle ZST validation from integer validation and generalize it to all zsts

cc @RalfJung

r? @wesleywiser
2020-01-15 21:51:50 +09:00
Yuki Okushi
20c49fc797
Rollup merge of #68211 - GuillaumeGomez:add-failing-example-e0170, r=Dylan-DPC
Add failing example for E0170 explanation

r? @Dylan-DPC
2020-01-15 21:51:48 +09:00
Yuki Okushi
be1ecce01f
Rollup merge of #68141 - euclio:replace-bindings-with-winapi, r=alexcrichton
use winapi for non-stdlib Windows bindings
2020-01-15 21:51:45 +09:00
Yuki Okushi
89b065dbd2
Rollup merge of #67914 - Aaron1011:fix/const-prop-impossible, r=matthewjasper,oli-obk
Don't run const propagation on items with inconsistent bounds

Fixes #67696

Using `#![feature(trivial_bounds)]`, it's possible to write functions
with unsatisfiable 'where' clauses, making them uncallable. However, the
user can act as if these 'where' clauses are true inside the body of the
function, leading to code that would normally be impossible to write.

Since const propgation can run even without any user-written calls to a
function, we need to explcitly check for these uncallable functions.
2020-01-15 21:51:43 +09:00
Yuki Okushi
e800fe199c
Rollup merge of #67784 - Mark-Simulacrum:residual-pad-integral, r=dtolnay
Reset Formatter flags on exit from pad_integral

This fixes a bug where after calling pad_integral with appropriate flags, the
fill and alignment flags would be set to '0' and 'Right' and left as such even
after exiting pad_integral, which meant that future calls on the same Formatter
would get incorrect flags reported.

This is quite difficult to observe in practice, as almost all formatting
implementations in practice don't call `Display::fmt` directly, but rather use
`write!` or a similar macro, which means that they cannot observe the effects of
the wrong flags (as `write!` creates a fresh Formatter instance). However, we
include a test case.

A manual check leads me to believe this is the only case where we failed to reset the flags appropriately, but I could have missed something.
2020-01-15 21:51:42 +09:00
Oliver Scherer
69ffe7bb13 Address review comments 2020-01-15 11:36:06 +01:00
Oliver Scherer
7bd01ed3c4 Typo 2020-01-15 11:33:49 +01:00
Oliver Scherer
a81784a09a Undo a change not neceesary for this bugfix 2020-01-15 10:48:22 +01:00
Oliver Scherer
b2c43dc1ad Update src/librustc_mir/interpret/intern.rs
Co-Authored-By: Ralf Jung <post@ralfj.de>
2020-01-15 10:48:22 +01:00
Oliver Scherer
eadfd63e3f Clean up comment 2020-01-15 10:48:22 +01:00
Oliver Scherer
1ea44663c5 Elaborate on the details in some comments 2020-01-15 10:48:22 +01:00
Oliver Scherer
658c27b011 Elaborate on comments 2020-01-15 10:48:22 +01:00
Oliver Scherer
10f439a011 Promoteds can contain raw pointers, but these must still only point to immutable allocations 2020-01-15 10:48:22 +01:00
bors
c74353c7d2 Auto merge of #68221 - ehuss:update-cargo-rls, r=alexcrichton
Update cargo rls

## cargo

12 commits in 6e1ca924a67dd1ac89c33f294ef26b5c43b89168..ad3dbe10e1e654fb1f032a5dd9481d7cbaa00d65
2020-01-06 19:11:37 +0000 to 2020-01-13 21:37:15 +0000
- Add named config profiles. (rust-lang/cargo#7750)
- Make cargo-rustc crate-type-aware (rust-lang/cargo#7755)
- Rename `Kind` (rust-lang/cargo#7791)
- Update bash completion (rust-lang/cargo#7789)
- Add another curl spurious network error (rust-lang/cargo#7788)
- Some small tweaks around error in configuration (rust-lang/cargo#7783)
- Fix tests with `url` crate update (rust-lang/cargo#7787)
- Fix .gitignore of Cargo.lock in a subdirectory. (rust-lang/cargo#7779)
- Bump crates-io (rust-lang/cargo#7778)
- Migrate from the `failure` crate to `anyhow` (rust-lang/cargo#7776)
- Fix several needless_borrow clippy lints. (rust-lang/cargo#7771)
- Fix some links (rust-lang/cargo#7770)

## rls

2 commits in 7c0489c5ff4f5c594e65a3b22efd9ce373deab9b..b27e1173969639448cd2e486b1c5f0fcb1b3b17c
2020-01-04 20:15:37 +0100 to 2020-01-13 11:40:20 +0100
- Update Cargo (rust-lang-nursery/rls#1613)
- Rustup to rust-lang/rust#68024 (rust-lang-nursery/rls#1612)
2020-01-15 09:34:49 +00:00
Oliver Scherer
0e14b9ff26 Add tests 2020-01-15 10:30:26 +01:00
csmoe
4eb47ded54 wrap expr id into GeneratorInteriorTypeCause 2020-01-15 15:13:51 +08:00
Dylan DPC
6801cf436b
Update E0170.md 2020-01-15 11:52:21 +05:30
bors
632387f38d Auto merge of #66329 - ktrianta:mir-opt-unreachable-propagation, r=oli-obk
Add unreachable propagation mir optimization pass

@oli-obk suggested we create a MIR pass that optimizes away basic blocks that lead only to basic blocks with terminator kind **unreachable**. This is a first take on this, which we started with @gilescope at RustFest Impl Days.

The test currently fails when the compiled program runs (undefined behaviour). Is there a way to avoid running the compiled program?
2020-01-15 05:01:10 +00:00
bors
4b172cc73f Auto merge of #68118 - skinny121:eager_lit_eval, r=varkor
perf: Eagerly convert literals to consts

Previousely even literal constants were being converted to an `Unevaluted` constant for evaluation later. This seems unecessary as no more information is needed to be able to convert the literal to a mir constant.

Hopefully this will also minimise the performance impact of #67717, as far less constant evaluations are needed.
2020-01-15 00:56:53 +00:00
Esteban Küber
268a1ff3fb Account for Paths on is_suggestable_infer_ty
Fix #68162.
2020-01-14 16:18:21 -08:00
Mark Rousskov
efcda04739 Replace old tables with new unicode data 2020-01-14 19:11:28 -05:00
Mark Rousskov
40ad877851 Add support code for new unicode_data module 2020-01-14 19:11:15 -05:00
Mark Rousskov
064f8885d5 Add unicode table generator 2020-01-14 19:11:15 -05:00
Aaron Hill
01dc44bfe0
Avoid calling tcx.hir().get() on CRATE_HIR_ID
This was causing an ICE when enabling trace logging for an unrelated
module, since the arguments to `trace!` ended up getting evaluated
2020-01-14 16:41:43 -05:00