Commit Graph

95984 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
ea62f9b3ec
Rollup merge of #61665 - aschampion:slice-eq-ptr, r=sfackler
core: check for pointer equality when comparing Eq slices

Because `Eq` types must be reflexively equal, an equal-length slice to the same memory location must be equal.

This is related to #33892 (and #32699) answering this comment from that PR:

> Great! One more easy question: why does this optimization not apply in the non-BytewiseEquality implementation directly above?

Because slices of non-reflexively equal types (like `f64`) are not equal even if it's the same slice. But if the types are `Eq`, we can use this same-address optimization, which this PR implements. Obviously this changes behavior if types violate the reflexivity condition of `Eq`, because their impls of `PartialEq` will no longer be called per-item, but 🤷‍♂ .

It's not clear how often this optimization comes up in the real world outside of the same-`&str` case covered by #33892, so **I'm requesting a perf run** (on MacOS today, so can't run `rustc_perf` myself). I'm going ahead and making the PR on the basis of being surprised things didn't already work this way.

This is my first time hacking rust itself, so as a perf sanity check I ran `./x.py bench --stage 0 src/lib{std,alloc}`, but the differences were noisy.

To make the existing specialization for `BytewiseEquality` explicit, it's now a supertrait of `Eq + Copy`. `Eq` should be sufficient, but `Copy` was included for clarity.
2019-07-11 04:33:11 +02:00
bors
35cacbce16 Auto merge of #62561 - Centril:rollup-5pxj3bo, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #62275 (rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.)
 - #62465 (Sometimes generate storage statements for temporaries with type `!`)
 - #62481 (Use `fold` in `Iterator::last` default implementation)
 - #62493 (#62357: doc(ptr): add example for {read,write}_unaligned)
 - #62532 (Some more cleanups to syntax::print)

Failed merges:

r? @ghost
2019-07-10 23:02:44 +00:00
bors
cd2cd4c962 Auto merge of #62564 - Mark-Simulacrum:azure-line-endings, r=pietroalbini
Ensure that checkout is with \n line endings

During installation of mingw, at least, the git directories change, so
we need to reset the core.autocrlf config to false.

Once we finish checking out submodules, check that the line endings are
\n and not \r\n.

Artifacts were built via the last try on #62545; I've manually confirmed that `install.sh` appears to no longer have `\r\n` line endings.

Fixes #62276.
2019-07-10 19:36:42 +00:00
Mazdak Farrokhzad
3c299a987c
Rollup merge of #62532 - Mark-Simulacrum:syntax-print-cleanup, r=petrochenkov
Some more cleanups to syntax::print

All of these changes should be functionally equivalent to previous code.

Each commit mostly stands alone and this PR is easiest to review by-commit.
2019-07-10 16:08:26 +02:00
Mazdak Farrokhzad
d0cec040de
Rollup merge of #62493 - Freyskeyd:valid_example_read-write_unaligned, r=rkruppe
#62357: doc(ptr): add example for {read,write}_unaligned

related to #62357

> With #62323 the only example (that had UB and was thus invalid) in std::ptr::read_unaligned and std::ptr::write_unaligned is removed.

> We should add a valid example of using the aforementioned functions.

Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
2019-07-10 16:08:24 +02:00
Mazdak Farrokhzad
ad21558b85
Rollup merge of #62481 - czipperz:iterator-last-nth-use-for_each, r=scottmcm
Use `fold` in `Iterator::last` default implementation

We already use it in all the other methods.  Consistency + potential perf is a pretty nice win!
2019-07-10 16:08:23 +02:00
Mazdak Farrokhzad
5760bc6e98
Rollup merge of #62465 - matthewjasper:never-type-storage, r=pnkfelix
Sometimes generate storage statements for temporaries with type `!`

Closes #62165
cc #42371
2019-07-10 16:08:21 +02:00
Mazdak Farrokhzad
a2cbae8ad3
Rollup merge of #62275 - eddyb:const-drop-replace, r=pnkfelix
rustc_mir: treat DropAndReplace as Drop + Assign in qualify_consts.

This slipped through the cracks and never got implemented (thankfully that just meant it was overly conservative and didn't allow assignments that don't *actually* drop the previous value).
Fixes #62273.

r? @oli-obk
2019-07-10 16:08:19 +02:00
Mark Rousskov
df725c28d6 Ensure that checkout is with \n line endings
During installation of mingw, at least, the git directories change, so
we need to reset the core.autocrlf config to false.

Once we finish checking out submodules, check that the line endings are
\n and not \r\n.
2019-07-10 09:56:47 -04:00
bors
c6a9e766f9 Auto merge of #62339 - pnkfelix:issue-61188-use-visitor-for-structural-match-check, r=nikomatsakis
use visitor for #[structural_match] check

This changes the code so that we recur down the structure of a type of a const (rather than just inspecting at a shallow one or two levels) when we are looking to see if it has an ADT that did not derive `PartialEq` and `Eq`.

Fix #61188

Fix #62307

Cc #62336
2019-07-10 12:26:44 +00:00
Mark Rousskov
56a9237b59 File is now short enough for tidy 2019-07-10 07:13:59 -04:00
Mark Rousskov
096cb4137d Remove writer function from PrintState 2019-07-10 07:13:57 -04:00
Mark Rousskov
73c1752b8e Use constant instead of magic number 2019-07-10 07:13:22 -04:00
Mark Rousskov
63fdf1a527 Remove needless indent arguments
We're always indenting by INDENT_UNIT anyway
2019-07-10 07:13:22 -04:00
Mark Rousskov
daf1b29f29 Properly case indent_unit constant 2019-07-10 07:13:22 -04:00
Mark Rousskov
cab453250a Move pp::Printer helpers to direct impl 2019-07-10 07:13:20 -04:00
Mark Rousskov
e91dbc5916 Rename is_bol -> is_beginning_of_line
Also moves it to pp::Printer from PrintState.
2019-07-10 07:12:29 -04:00
Mark Rousskov
39aa9bf730 Remove needless indirection in bclose 2019-07-10 07:12:29 -04:00
Mark Rousskov
04b80a5f5d Drop length from Token::String
It was always set to the string's length
2019-07-10 07:12:29 -04:00
Mark Rousskov
5879146392 Rename pretty_print_* to scan_* to follow naming in the paper
This is also easier to understand because the scan and print "tasks" are
separate, but previously were both called "print" or "pretty print."
2019-07-10 07:12:29 -04:00
Mark Rousskov
4783d9eaa5 Remove is_begin/is_end functions from PrintState
These are somewhat ambiguous (beginning/end of what?) so it's better to
inline their one use into the code.
2019-07-10 07:12:29 -04:00
Mark Rousskov
57cf7a2e57 Simplify print_end
Presumably the code was from an older age of Rust and can now be written
much simpler.
2019-07-10 07:12:29 -04:00
Mark Rousskov
55a6a761b9 Simplify check_stack implementation 2019-07-10 07:12:29 -04:00
Mark Rousskov
cd2d8326a5 Move BufEntry assignment into scan_push 2019-07-10 07:12:28 -04:00
Mark Rousskov
ccf279d9c3 Remove useless call to indent 2019-07-10 07:12:28 -04:00
Mark Rousskov
4c58fc32ae Fully privatize (vs. crate visibility) functions 2019-07-10 07:12:28 -04:00
Mark Rousskov
00ca508608 Move pp::Printer out field to owned String
This enforces that eof() must be called to get the String out, and
generally is better from an API perspective. No users of pretty printing
pre-allocate the buffer.
2019-07-10 07:12:28 -04:00
Mark Rousskov
e0ffa7c3d2 Inline State::new_from_input in pprust
This function took too many arguments and are simple on the inside;
inlining them makes complexity go down.

hir::print's copy is unfortunately used from librustc_driver so inlining
it is not as straightforward.
2019-07-10 07:12:28 -04:00
Mark Rousskov
e0db2e606c print_crate returns String instead of taking an out pointer 2019-07-10 07:12:28 -04:00
Mark Rousskov
7e3791469f Replace src: &mut dyn Read with String 2019-07-10 07:12:28 -04:00
Mark Rousskov
0eb2e566c1 Combine comment-handling logic into struct
This also permits sharing the underlying code between pprust and
hir::print.
2019-07-10 07:12:28 -04:00
Mark Rousskov
9b5e39723d Inline State::new
There was only one callsite for each and this removes the
unwrap_or_default's on the comments argument
2019-07-10 07:12:28 -04:00
Mark Rousskov
59b161c7c8 Stop Option-wrapping comments
We always check against the length before indexing anyway.
2019-07-10 07:12:28 -04:00
Mark Rousskov
a573d143a2 Remove unused boxes vector 2019-07-10 07:12:28 -04:00
Mark Rousskov
4483980285 Privatize and remove unused functions 2019-07-10 07:12:26 -04:00
Mark Rousskov
ae5ed9b729 Don't re-collect tokenstream twice to pretty print 2019-07-10 07:11:29 -04:00
Mark Rousskov
11d521676f Move lifetime_to_string to Display impl 2019-07-10 07:11:29 -04:00
Mark Rousskov
a440337e2b Remove unused arm_to_string 2019-07-10 07:11:29 -04:00
Mark Rousskov
0f10d114e4 Remove duplicate attr_to_string
attribute_to_string exists.
2019-07-10 07:11:29 -04:00
Mark Rousskov
9b0ebfa4e9 Move literal_to_string to fmt::Display 2019-07-10 07:11:29 -04:00
bors
d4e1565509 Auto merge of #62441 - RalfJung:place-ptr-normalization, r=oli-obk
Miri: Provide pointer forcing methods for MemPlace and Op

These are useful when one wants to to a lot of work with some place or operand and not to int-to-ptr casts all the time. In particular, this is needed to fix some test failures in Miri: we need to normalize before starting a visitor that walks a run-time value, so that we can later be sure (during the visitor walk) that we have a proper `Pointer`.

Also see the Miri side at https://github.com/rust-lang/miri/pull/830.

Cc @eddyb @oli-obk
2019-07-10 08:59:15 +00:00
bors
0324a2b309 Auto merge of #62555 - Centril:rollup-ti46adx, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #61853 (Emit warning when trying to use PGO in conjunction with unwinding on …)
 - #62278 (Add Iterator::partition_in_place() and is_partitioned())
 - #62283 (Target::arch can take more than listed options)
 - #62393 (Fix pretty-printing of `$crate` (take 4))
 - #62474 (Prepare for LLVM 9 update)

Failed merges:

r? @ghost
2019-07-10 05:21:43 +00:00
Chris Gregory
76a8bc2473 Use fold in Iterator::last
Replace last impl with fold
2019-07-09 21:26:49 -07:00
Mazdak Farrokhzad
6c0a406b1c
Rollup merge of #62474 - nikic:update-llvm, r=alexcrichton
Prepare for LLVM 9 update

Main changes:

 * In preparation for opaque pointer types, the `byval` attribute now takes a type. As such, the argument type needs to be threaded through to the function/callsite attribute application logic.
 * On ARM the `+fp-only-sp` and `+d16` features have become `-fp64` and `-d32`. I've switched the target definitions to use the new names, but also added bidirectional emulation so either can be used on any LLVM version for backwards compatibility.
 * The datalayout can now specify function pointer alignment. In particular on ARM `Fi8` is specified, which means that function pointer alignment is independent of function alignment. I've added this to our datalayouts to match LLVM (which is something we check) and strip the fnptr alignment for older LLVM versions.
 * The fmul/fadd reductions now always respect the accumulator (including for unordered reductions), so we should pass the identity instead of undef.

Open issues:

 * https://reviews.llvm.org/D62106 causes linker errors with ld.bdf due to https://sourceware.org/bugzilla/show_bug.cgi?id=24784. To avoid this I've enabled `RelaxELFRelocations`, which results in a GOTPCRELX relocation for `__tls_get_addr` and avoids the issue. However, this is likely not acceptable because relax relocations are not supported by older linker versions. We may need an LLVM option to keep using PLT for `__tls_get_addr` despite `RtLibUseGOT`.

The corresponding llvm-project PR is https://github.com/rust-lang/llvm-project/pull/19.

r? @ghost
2019-07-10 05:14:10 +02:00
Mazdak Farrokhzad
fe26fc9a1c
Rollup merge of #62393 - petrochenkov:notto-disu, r=Mark-Simulacrum
Fix pretty-printing of `$crate` (take 4)

Pretty-print `$crate` as `crate` or `crate_name` in unstructured tokens like `a $crate c` in `foo!(a $crate c)`, but only if those tokens are printed as a part of AST pretty-printing, rather than as a standalone token stream.

Fixes https://github.com/rust-lang/rust/issues/62325
Previous iterations - https://github.com/rust-lang/rust/pull/56647, https://github.com/rust-lang/rust/pull/57155, https://github.com/rust-lang/rust/pull/57915.
2019-07-10 05:14:09 +02:00
Mazdak Farrokhzad
1e48be948a
Rollup merge of #62283 - fintelia:patch-5, r=Mark-Simulacrum
Target::arch can take more than listed options

A list of options in a comment like this is almost guaranteed to become out of date: right now it is missing "riscv32" and "riscv64" and perhaps other architectures as well.
2019-07-10 05:14:07 +02:00
Mazdak Farrokhzad
b14b20c638
Rollup merge of #62278 - cuviper:iter-partition, r=alexcrichton
Add Iterator::partition_in_place() and is_partitioned()

`partition_in_place()` swaps `&mut T` items in-place to satisfy the
predicate, so all `true` items precede all `false` items. This requires
a `DoubleEndedIterator` so we can search from front and back for items
that need swapping.

`is_partitioned()` checks whether the predicate is already satisfied.
2019-07-10 05:14:06 +02:00
Mazdak Farrokhzad
3c3e3756b0
Rollup merge of #61853 - EricRahm:use_warning, r=varkor
Emit warning when trying to use PGO in conjunction with unwinding on …

…Windows.

This reduces the error introduced for #61002 to just a warning.
2019-07-10 05:14:04 +02:00
bors
3f435f622e Auto merge of #62548 - ehuss:update-cargo, r=alexcrichton
Update cargo

Update cargo

12 commits in 4c1fa54d10f58d69ac9ff55be68e1b1c25ecb816..677a180f4c8ca1dcef594f68dd0e63e4f08621f5
2019-06-24 11:24:18 +0000 to 2019-07-08 13:43:02 +0000
- Update dependencies (rust-lang/cargo#7106)
- Fix overwriting .d file for binary with dSYM on apple targets. (rust-lang/cargo#7057)
- Update changelog. (rust-lang/cargo#7102)
- Revert "Fix 'getting started' internal links" (rust-lang/cargo#7099)
- Bump to 0.39.0 (rust-lang/cargo#7100)
- Update dependency.rs (rust-lang/cargo#7098)
- Typo (rust-lang/cargo#7097)
- Fix 'getting started' internal links (rust-lang/cargo#7093)
- Fix misleading comment in testsuite (rust-lang/cargo#7090)
- improve uncommitted changes cargo-package message (rust-lang/cargo#7083)
- Clean environment when git-fetch-with-cli is used. (rust-lang/cargo#7082)
- Fix exponentiality in depend_on_deps_of_deps. (rust-lang/cargo#7062)
2019-07-10 01:53:04 +00:00
Eric Huss
03a4068152 Update cargo 2019-07-09 16:47:45 -07:00