Commit graph

128128 commits

Author SHA1 Message Date
Aaron Hill
f5d71a9b3c
Don't use zip to compare iterators during pretty-print hack
If the right-hand iterator has exactly one more element than the
left-hand iterator, then both iterators will be fully consumed, but
the extra element will never be compared.
2020-09-21 15:11:59 -04:00
Aaron Hill
e734733a9e
Record tcx.def_span instead of item.span in crate metadata
This was missed in PR #75465. As a result, a few places have been using
the full body span of functions, instead of just the header span.
2020-09-21 15:10:16 -04:00
Guillaume Gomez
63195ecb45 Add explanation for E0756 2020-09-21 21:04:56 +02:00
Mara Bos
5d6f1a1e32 Move use align_of in atomic.rs into the places where it is used. 2020-09-21 20:44:45 +02:00
Mara Bos
7a04ff6c33 Gate Atomic::from_mut on cfg(target_has_atomic_equal_alignment).
Instead of a few hardcoded cfg(target_arch = ..) like before.
2020-09-21 20:43:44 +02:00
Mara Bos
668225d157 Revert "Revert adding Atomic::from_mut."
This reverts commit 5ef1db3622.
2020-09-21 20:43:44 +02:00
Mara Bos
54fdf54e06 Add feature gate ui test for cfg(target_has_atomic_equal_alignment). 2020-09-21 20:43:44 +02:00
Mara Bos
af56ad7633 Add feature gate ui test for cfg(target_has_atomic_load_store). 2020-09-21 20:43:44 +02:00
Mara Bos
9e3f94dabc Don't unwrap but report a fatal error for TargetDataLayout::parse. 2020-09-21 20:43:44 +02:00
James Whaley
9a1f1777d3
Remove cast to usize for BytePos and CharPos
The case shouldn't be necessary and implicitly truncating BytePos is not
desirable.
2020-09-21 19:42:43 +01:00
Mara Bos
db74e1f1e3 Add cfg(target_has_atomic_equal_alignment).
This is needed for Atomic::from_mut.
2020-09-21 20:42:25 +02:00
Bastian Kauschke
8fc782afc2 add test 2020-09-21 20:36:05 +02:00
Aleksei Latyshev
d4f158fa5c
Forbid redundant_pattern_matching triggering in macros
- remove ice-2636 test
2020-09-21 20:49:42 +03:00
bors
b01326ab03 Auto merge of #76680 - Julian-Wollersberger:nongeneric_ensure_sufficient_stack, r=jyn514
Make `ensure_sufficient_stack()` non-generic, using cargo-llvm-lines

Inspired by [this blog post](https://blog.mozilla.org/nnethercote/2020/08/05/how-to-speed-up-the-rust-compiler-some-more-in-2020/) from `@nnethercote,` I used [cargo-llvm-lines](https://github.com/dtolnay/cargo-llvm-lines/) on the rust compiler itself, to improve it's compile time. This PR contains only one low-hanging fruit, but I also want to share some measurements.

The function `ensure_sufficient_stack()` was monomorphized 1500 times, and with it the `stacker` and `psm` crates, for a total of 1.5% of all llvm IR lines. With some trickery I convert the generic closure into a dynamic one, and thus all that code is only monomorphized once.

# Measurements
Getting these numbers took some fiddling with CLI flags and I [modified](https://github.com/Julian-Wollersberger/cargo-llvm-lines/blob/master/src/main.rs#L115) cargo-llvm-lines to read from a folder instead of invoking cargo. Commands I used:
```
./x.py clean
RUSTFLAGS="--emit=llvm-ir -C link-args=-fuse-ld=lld -Z self-profile=profile" CARGOFLAGS_BOOTSTRAP="-Ztimings" RUSTC_BOOTSTRAP=1 ./x.py build -i --stage 1 library/std

# Then manually copy all .ll files into a folder I hardcoded in cargo-llvm-lines in main.rs#L115
cd ../cargo-llvm-lines
cargo run llvm-lines
```

The result is this list (see [first 500 lines](https://github.com/Julian-Wollersberger/cargo-llvm-lines/blob/master/llvm-lines-rustc-before.txt) ), before the change:
```
  Lines            Copies        Function name
  -----            ------        -------------
  16894211 (100%)  58417 (100%)  (TOTAL)
   2223855 (13.2%)   502 (0.9%)  rustc_query_system::query::plumbing::get_query_impl::{{closure}}
   1331918 (7.9%)   1287 (2.2%)  hashbrown::raw::RawTable<T>::reserve_rehash
    774434 (4.6%)  12043 (20.6%) core::ptr::drop_in_place
    294170 (1.7%)    499 (0.9%)  rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
    245410 (1.5%)   1552 (2.7%)  psm::on_stack::with_on_stack
    210311 (1.2%)      1 (0.0%)  rustc_target::spec::load_specific
    200962 (1.2%)    513 (0.9%)  rustc_query_system::query::plumbing::get_query_impl
    190704 (1.1%)      1 (0.0%)  rustc_middle::ty::query::<impl rustc_middle::ty::context::TyCtxt>::alloc_self_profile_query_strings
    180272 (1.1%)    468 (0.8%)  rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory
    177396 (1.1%)    114 (0.2%)  rustc_query_system::query::plumbing::force_query_impl
    161134 (1.0%)    445 (0.8%)  rustc_query_system::dep_graph::graph::DepGraph<K>::with_anon_task
    141551 (0.8%)    186 (0.3%)  rustc_query_system::query::plumbing::incremental_verify_ich
    110191 (0.7%)      7 (0.0%)  rustc_middle::ty::context::_DERIVE_rustc_serialize_Decodable_D_FOR_TypeckResults::<impl rustc_serialize::serialize::Decodable<__D> for rustc_middle::ty::context::TypeckResults>::decode::{{closure}}
    108590 (0.6%)    420 (0.7%)  core::ops::function::FnOnce::call_once
     88488 (0.5%)     21 (0.0%)  rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
     86368 (0.5%)      1 (0.0%)  rustc_middle::ty::query::stats::query_stats
     85654 (0.5%)   3973 (6.8%)  <&T as core::fmt::Debug>::fmt
     84475 (0.5%)      1 (0.0%)  rustc_middle::ty::query::Queries::try_collect_active_jobs
     81220 (0.5%)    862 (1.5%)  <hashbrown::raw::RawIterHash<T> as core::iter::traits::iterator::Iterator>::next
     77636 (0.5%)     54 (0.1%)  core::slice::sort::recurse
     66484 (0.4%)    461 (0.8%)  <hashbrown::raw::RawIter<T> as core::iter::traits::iterator::Iterator>::next
```

All `.ll` files together had 4.4GB. After my change they had 4.2GB. So a few percent less code LLVM has to process. Hurray!
Sadly, I couldn't measure an actual wall-time improvement. Watching YouTube while compiling added to much noise...

Here is the top of the list after the change:
```
  16460866 (100%)  58341 (100%)  (TOTAL)
   1903085 (11.6%)   504 (0.9%)  rustc_query_system::query::plumbing::get_query_impl::{{closure}}
   1331918 (8.1%)   1287 (2.2%)  hashbrown::raw::RawTable<T>::reserve_rehash
    777796 (4.7%)  12031 (20.6%) core::ptr::drop_in_place
    551462 (3.4%)   1519 (2.6%)  rustc_data_structures::stack::ensure_sufficient_stack::{{closure}}
```
Note that the total was reduced by 430 000 lines and `psm::on_stack::with_on_stack` has disappeared. Instead `rustc_data_structures::stack::ensure_sufficient_stack::{{closure}}` appeared. I'm confused about that one, but it seems to consist of inlined calls to `rustc_query_system::*` stuff.

Further note the other two big culprits in this list: `rustc_query_system` and `hashbrown`. These two are monomorphized many times, the query system summing to more than 20% of all lines, not even counting code that's probably inlined elsewhere.
Assuming compile times scale linearly with llvm-lines, that means a possible 20% compile time reduction.

Reducing eg. `get_query_impl` would probably need a major refactoring of the qery system though. _Everything_ in there is generic over multiple types, has associated types and passes generic Self arguments by value. Which means you can't simply make things `dyn`.

---------------------------------------
This PR is a small step to make rustc compile faster and thus make contributing to rustc less painful. Nonetheless I love Rust and I find the work around rustc fascinating :)
2020-09-21 17:32:57 +00:00
James Whaley
b4b4a2f092
Reduce boilerplate for BytePos and CharPos 2020-09-21 18:27:43 +01:00
Nicholas-Baron
ccd218d04c Added back the '// ignore-file-length' with an explanation 2020-09-21 09:16:55 -07:00
bors
4eff9b0b29 Auto merge of #77013 - RalfJung:rollup-84ut0xq, r=RalfJung
Rollup of 10 pull requests

Successful merges:

 - #76439 (Add error explanation for E0755)
 - #76521 (Fix segfault if pthread_getattr_np fails)
 - #76835 (make replace_prefix only take &str as arguments )
 - #76967 (Revert adding Atomic::from_mut.)
 - #76977 (Add a regression test for copy propagation miscompilation)
 - #76981 (liballoc bench use imported path Bencher)
 - #76983 (BTreeMap: extra testing & fixed comments)
 - #76996 (Fix typo in rustc_lexer docs)
 - #77009 (Dogfood total_cmp in the test crate)
 - #77012 (update Miri for another bugfix)

Failed merges:

 - #76489 (Add explanation for E0756)

r? `@ghost`
2020-09-21 15:06:20 +00:00
bors
78fbb04edb Auto merge of #6071 - ebroto:rustup, r=ebroto
Rustup

r? `@ghost`

changelog: none
2020-09-21 13:43:01 +00:00
Tomasz Miąsko
c7e887c64a DroplessArena: Allocate objects from the end of memory chunk
Allocating from the end of memory chunk simplifies the alignment code
and reduces the number of checked arithmetic operations.
2020-09-21 15:36:45 +02:00
Eduardo Broto
4117ae1175 Split redundant_pattern_matching tests
This is to avoid the 200 lines stderr file limit
2020-09-21 15:32:26 +02:00
Ralf Jung
6417eb0cff
Rollup merge of #77012 - RalfJung:miri, r=RalfJung
update Miri for another bugfix
2020-09-21 15:30:51 +02:00
Ralf Jung
fb3cb14af6
Rollup merge of #77009 - est31:dogfood_total_cmp, r=lcnr
Dogfood total_cmp in the test crate
2020-09-21 15:30:49 +02:00
Ralf Jung
48fc20cc47
Rollup merge of #76996 - LingMan:patch-1, r=ecstatic-morse
Fix typo in rustc_lexer docs

Also add an Oxford comma while we're editing that line.
2020-09-21 15:30:47 +02:00
Ralf Jung
4547ebb3fb
Rollup merge of #76983 - ssomers:btree_extra_test, r=Mark-Simulacrum
BTreeMap: extra testing & fixed comments

r? @Mark-Simulacrum
2020-09-21 15:30:46 +02:00
Ralf Jung
4b362bbbb6
Rollup merge of #76981 - pickfire:patch-5, r=Mark-Simulacrum
liballoc bench use imported path Bencher

test is already in scope, no need to use the full path
2020-09-21 15:30:44 +02:00
Ralf Jung
9c14ef572f
Rollup merge of #76977 - tmiasko:issue-76740, r=wesleywiser
Add a regression test for copy propagation miscompilation
2020-09-21 15:30:42 +02:00
Ralf Jung
b0c2eab66a
Rollup merge of #76967 - fusion-engineering-forks:revert-atomic-from-mut, r=kodrAus
Revert adding Atomic::from_mut.

This reverts #74532, which made too many assumptions about platforms, breaking some things.

Will need to be added later with a better way of gating on proper alignment, without hardcoding cfg(target_arch)s.

---

To be merged if fixing from_mut (#76965) takes too long.

r? @ghost
2020-09-21 15:30:41 +02:00
Ralf Jung
982c4a9c25
Rollup merge of #76835 - matthiaskrgr:replace_prefix, r=lcnr
make replace_prefix only take &str as arguments

included the clippy::manual strip commit to not run into merge conflicts later.

r? @lcnr
2020-09-21 15:30:39 +02:00
Ralf Jung
ae4b677aa8
Rollup merge of #76521 - tavianator:fix-pthread-getattr-destroy, r=Amanieu
Fix segfault if pthread_getattr_np fails

glibc [destroys][1] the passed pthread_attr_t if pthread_getattr_np()
fails.  Destroying it again leads to a segfault.  Fix it by only
destroying it on success for glibc.

[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_getattr_np.c;h=ce437205e41dc05653e435f6188768cccdd91c99;hb=HEAD#l205
2020-09-21 15:30:37 +02:00
Ralf Jung
670e204ace
Rollup merge of #76439 - GuillaumeGomez:add-error-explanation-e0755, r=pickfire,jyn514
Add error explanation for E0755

r? @pickfire
2020-09-21 15:30:34 +02:00
Ralf Jung
57baec7d43 update Miri for another bugfix 2020-09-21 15:26:50 +02:00
Eduardo Broto
6e07247578 Merge remote-tracking branch 'upstream/master' into rustup 2020-09-21 15:11:24 +02:00
Joshua Nelson
fe6fc555ac Add a changelog for x.py
- Add a changelog and instructions for updating it
- Use `changelog-seen` in `config.toml` and `VERSION` in bootstrap to determine whether the changelog has been read
- Nag people if they haven't read the x.py changelog
  + Print message twice to make sure it's seen
- Give different error messages depending on whether the version needs to be updated or added
2020-09-21 09:08:18 -04:00
bors
e0bf356f9e Auto merge of #74040 - lcnr:const-occurs-check, r=nikomatsakis
fix unification of const variables

r? `@nikomatsakis` `@varkor` `@eddyb` let's just ping everyone here 😅
2020-09-21 12:52:09 +00:00
Aleksey Kladov
60b102de06 Don't recommend ManuallyDrop to customize drop order
See
https://internals.rust-lang.org/t/need-for-controlling-drop-order-of-fields/12914/21
for the discussion.

TL;DR: ManuallyDrop is unsafe and footguny, but you can just ask the
compiler to do all the work for you by re-ordering declarations.
2020-09-21 14:00:04 +02:00
Ishi Tatsuyuki
f95e4f3ca9 Improve code and documentation clarity 2020-09-21 20:29:12 +09:00
Bastian Kauschke
2855b92eb4 add tests 2020-09-21 12:27:55 +02:00
Bastian Kauschke
073127a04f check for cycles when unifying const variables 2020-09-21 12:27:55 +02:00
bors
956e06c6c8 Auto merge of #77004 - RalfJung:rollup-usac4nv, r=RalfJung
Rollup of 13 pull requests

Successful merges:

 - #76135 (Stabilize some Option methods as const)
 - #76628 (Add sample defaults for config.toml )
 - #76846 (Avoiding unnecesary allocations at rustc_errors)
 - #76867 (Use intra-doc links in core/src/iter when possible)
 - #76868 (Finish moving to intra doc links for std::sync)
 - #76872 (Remove DeclareMethods)
 - #76936 (Add non-`unsafe` `.get_mut()` for `Unsafecell`)
 - #76958 (Replace manual as_nanos and as_secs_f64 reimplementations)
 - #76959 (Replace write_fmt with write!)
 - #76961 (Add test for issue #34634)
 - #76962 (Use const_cstr macro in consts.rs)
 - #76963 (Remove unused static_assert macro)
 - #77000 (update Miri)

Failed merges:

r? `@ghost`
2020-09-21 10:26:59 +00:00
est31
9172e277f8 Dogfood total_cmp in the test crate 2020-09-21 12:15:30 +02:00
Bastian Kauschke
39245400c5 fix InterpCx resolve 2020-09-21 12:09:08 +02:00
Oliver Scherer
c160bf3c3e Cache eval_to_allocation_raw on disk 2020-09-21 11:38:39 +02:00
Ralf Jung
d337074d09
Rollup merge of #77000 - RalfJung:miri, r=RalfJung
update Miri

I'd like to get https://github.com/rust-lang/miri/pull/1556 out there to avoid some backwards-incompatible changes.
r? @ghost Cc @rust-lang/miri
2020-09-21 10:40:49 +02:00
Ralf Jung
e177757a04
Rollup merge of #76963 - est31:remove_static_assert, r=oli-obk
Remove unused static_assert macro
2020-09-21 10:40:47 +02:00
Ralf Jung
9aba4962f5
Rollup merge of #76962 - est31:const_cstr, r=oli-obk
Use const_cstr macro in consts.rs
2020-09-21 10:40:45 +02:00
Ralf Jung
5760b081a6
Rollup merge of #76961 - bugadani:test-34634, r=Mark-Simulacrum
Add test for issue #34634

Closes #34634
2020-09-21 10:40:43 +02:00
Ralf Jung
f957aeef9f
Rollup merge of #76959 - est31:write, r=oli-obk
Replace write_fmt with write!

Latter is simpler
2020-09-21 10:40:41 +02:00
Ralf Jung
048866bd6b
Rollup merge of #76958 - est31:ns, r=oli-obk
Replace manual as_nanos and as_secs_f64 reimplementations
2020-09-21 10:40:39 +02:00
Ralf Jung
b670b86353
Rollup merge of #76936 - danielhenrymantilla:unsafecell_get_mut, r=RalfJung
Add non-`unsafe` `.get_mut()` for `Unsafecell`

  - Tracking issue: https://github.com/rust-lang/rust/issues/76943

As discussed in: https://internals.rust-lang.org/t/add-non-unsafe-get-mut-for-unsafecell/12407

  - ### [Rendered documentation](https://modest-dubinsky-1f9f47.netlify.app/core/cell/struct.unsafecell)

This PR tries to move the sound `&mut UnsafeCell<T> -> &mut T` projection that all the "downstream" constructions were already relying on, up to the root abstraction, where it rightfully belongs, and officially blessing it.

  - this **helps reduce the amount of `unsafe` snippets out there** (_c.f._, the second commit of this PR: 09503fd1b3)

The fact that this getter is now expose for `UnsafeCell<T>` itself, will also help convey the idea that **`UnsafeCell` is not magical _w.r.t._ `&mut` accesses**, contrary to what some people incorrectly think.

  - Even the standard library itself at some point had such a confusion, _c.f._ this comment where there is a mention of multi-threaded (and thus _shared_) access despite dealing with exclusive references over unique ownership: 59fb88d061/library/core/src/cell.rs (L498-L499)

r? @RalfJung
2020-09-21 10:40:37 +02:00
Ralf Jung
02d787bef8
Rollup merge of #76872 - khyperia:remove_declare_methods, r=eddyb
Remove DeclareMethods

Most of the `DeclareMethods` API was only used internally by rustc_codegen_llvm. As such, it makes no sense to require other backends to implement them.

(`get_declared_value` and `declare_cfn` were used, in one place, specific to the `main` symbol, which I've replaced with a more specialized function to allow more flexibility in implementation - the intent is that `declare_c_main` can go away once we do something more clever, e.g. @eddyb has ideas around having a MIR shim or somesuch we can explore in a follow-up PR)
2020-09-21 10:40:35 +02:00