Commit graph

127730 commits

Author SHA1 Message Date
Mara Bos
45700a9d58 Drop use of Arc from Stdin and Stdout. 2020-09-24 19:09:33 +02:00
Mara Bos
e9b25f520b Add test to check stdout flushing during shutdown. 2020-09-24 18:22:21 +02:00
Mara Bos
bab15f773a Remove std::io::lazy::Lazy in favour of SyncOnceCell
The (internal) std::io::lazy::Lazy was used to lazily initialize the
stdout and stdin buffers (and mutexes). It uses atexit() to register a
destructor to flush the streams on exit, and mark the streams as
'closed'. Using the stream afterwards would result in a panic.

Stdout uses a LineWriter which contains a BufWriter that will flush the
buffer on drop. This one is important to be executed during shutdown,
to make sure no buffered output is lost. It also forbids access to
stdout afterwards, since the buffer is already flushed and gone.

Stdin uses a BufReader, which does not implement Drop. It simply forgets
any previously read data that was not read from the buffer yet. This
means that in the case of stdin, the atexit() function's only effect is
making stdin inaccessible to the program, such that later accesses
result in a panic. This is uncessary, as it'd have been safe to access
stdin during shutdown of the program.

---

This change removes the entire io::lazy module in favour of
SyncOnceCell. SyncOnceCell's fast path is much faster (a single atomic
operation) than locking a sys_common::Mutex on every access like Lazy
did.

However, SyncOnceCell does not use atexit() to drop the contained object
during shutdown.

As noted above, this is not a problem for stdin. It simply means stdin
is now usable during shutdown.

The atexit() call for stdout is moved to the stdio module. Unlike the
now-removed Lazy struct, SyncOnceCell does not have a 'gone and
unusable' state that panics. Instead of adding this again, this simply
replaces the buffer with one with zero capacity. This effectively
flushes the old buffer *and* makes any writes afterwards pass through
directly without touching a buffer, making print!() available during
shutdown without panicking.
2020-09-24 18:18:48 +02: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
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
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
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
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
Ralf Jung
9e2ebf31dd
Rollup merge of #76868 - poliorcetics:intra-doc-std-sync, r=jyn514
Finish moving to intra doc links for std::sync

Helps with #75080.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
2020-09-21 10:40:33 +02:00
Ralf Jung
5031242606
Rollup merge of #76867 - poliorcetics:intra-doc-core-iter, r=jyn514
Use intra-doc links in core/src/iter when possible

Helps with #75080.

I also updated lots of links to use `fn()` instead of `fn` when possible.

@rustbot modify labels: T-doc A-intra-doc-links

r? @jyn514
2020-09-21 10:40:32 +02:00
Ralf Jung
c2d9af68a0
Rollup merge of #76846 - botika:master, r=davidtwco
Avoiding unnecesary allocations at rustc_errors

Simplify the code avoiding allocations with easy alternative
2020-09-21 10:40:30 +02:00
Ralf Jung
8fa75a2b3a
Rollup merge of #76628 - jyn514:default-config-files, r=Mark-Simulacrum
Add sample defaults for config.toml

- Allow including defaults in `src/bootstrap/defaults` using `profile = "..."`.
- Add default config files, with a README noting they're experimental and asking you to open an issue if you run into trouble. The config files have comments explaining why the defaults are set.
- Combine config files using the `merge` dependency.

This introduces a new dependency on `merge` that hasn't yet been vetted.

I want to improve the output when `include = "x"` isn't found:

```
thread 'main' panicked at 'fs::read_to_string(&file) failed with No such file or directory (os error 2) ("configuration file did not exist")', src/bootstrap/config.rs:522:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to run: /home/joshua/rustc/build/bootstrap/debug/bootstrap test tidy
Build completed unsuccessfully in 0:00:00
```

However that seems like it could be fixed in a follow-up.

Closes #76619
2020-09-21 10:40:28 +02:00
Ralf Jung
c3abb82908
Rollup merge of #76135 - CDirkx:const-option, r=dtolnay,oli-obk
Stabilize some Option methods as const

Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

These methods are currently const under the unstable feature `const_option` (tracking issue: #67441).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also:  [PR#75463](https://github.com/rust-lang/rust/pull/75463).

Related: #76225
2020-09-21 10:40:26 +02:00
bors
0433fdf93b Auto merge of #76843 - kornelski:longtypetofile, r=ecstatic-morse
Let user see the full type of type-length limit error

Seeing the full type of the error is sometimes essential to diagnosing the problem, but the type itself is too long to be displayed in the terminal in a useful fashion. This change solves this dilemma by writing the full offending type name to a file, and displays this filename as a note.

> note: the full type name been written to '$TEST_BUILD_DIR/issues/issue-22638/issue-22638.long-type.txt'

Closes #76777
2020-09-21 08:20:38 +00:00
Ralf Jung
fc4b21fb6b update Miri 2020-09-21 09:42:34 +02:00
bors
a409a233e0 Auto merge of #75974 - SkiFire13:peekmut-opt-sift, r=LukasKalbertodt
Avoid useless sift_down when std::collections::binary_heap::PeekMut is never mutably dereferenced

If `deref_mut` is never called then it's not possible for the element to be mutated without internal mutability, meaning there's no need to call `sift_down`.

This could be a little improvement in cases where you want to mutate the biggest element of the heap only if it satisfies a certain predicate that needs only read access to the element.
2020-09-21 05:31:01 +00:00
LingMan
fc20b7841c
Fix typo in rustc_lexer docs
Also add an Oxford comma while we're editing that line.
2020-09-21 05:43:39 +02:00
bors
70148d7b31 Auto merge of #76806 - jethrogb:jb/update-llvm, r=cuviper
Update LLVM

This (partially?) addresses rust-lang/rust#74632

r? `@cuviper`
2020-09-21 03:32:01 +00:00
bors
0f9f0b384a Auto merge of #76295 - mati865:remove-mmx, r=Amanieu,oli-obk
Remove MMX from Rust

Follow-up to https://github.com/rust-lang/stdarch/pull/890
This removes most of MMX from Rust (tests pass with small changes), keeping stable `is_x86_feature_detected!("mmx")` working.
2020-09-21 00:43:26 +00:00
Kornel Lesiński
34d3c7df80 Let user see the full type of type-length limit error 2020-09-21 00:39:58 +01:00
bors
7467d17bb9 Auto merge of #76544 - Mark-Simulacrum:less-python, r=alexcrichton
De-couple Python and bootstrap slightly

This revises rustbuild's entry points from Python to rely less on magic environment variables, preferring to use Cargo-provided environment variables where feasible.

Notably, BUILD_DIR and BOOTSTRAP_CONFIG are *not* moved, because both more-or-less have some non-trivial discovery logic and replicating it in rustbuild seems unfortunate; if it moved to Cargo that would be a different story.

Best reviewed by-commit.
2020-09-20 22:00:36 +00:00
Christiaan Dirkx
43cba349bd Remove can_suggest from Clippy.
Removes `can_suggest` from as it is no longer used.
Reverts rust-clippy#5724.
2020-09-21 00:00:33 +02:00
Christiaan Dirkx
e58d0627b8 Update Clippy testcases
Update the test `redundant_pattern_matching`: check if `is_some` and `is_none` are suggested within const contexts.
2020-09-20 23:59:34 +02:00
Christiaan Dirkx
4f859fbcfc Move const tests for Option to library\core
Part of #76268
2020-09-20 22:42:14 +02:00
CDirkx
9486f72879 Stabilize some Option methods as const
Stabilize the following methods of `Option` as const:
 - `is_some`
 - `is_none`
 - `as_ref`

Possible because of stabilization of #49146 (Allow if and match in constants).
2020-09-20 22:42:14 +02:00
Mark Rousskov
cf33aad8fd Specify output directory for bootstrap tests 2020-09-20 16:39:13 -04:00
Mark Rousskov
1aac99de25 Provide bootstrap tools with RUSTC in environment 2020-09-20 16:39:13 -04:00
Joshua Nelson
c9c8fb88cf Add sample defaults for config.toml
- Allow including defaults in `src/bootstrap/defaults` using `profile = "..."`
- Add default config files
- Combine config files using the merge dependency.
- Add comments to default config files
- Add a README asking to open an issue if the defaults are bad
- Give a loud error if trying to merge `.target`, since it's not
  currently supported
- Use an exhaustive match
- Use `<none>` in config.toml.example to avoid confusion
- Fix bugs in `Merge` derives

Previously, it would completely ignore the profile defaults if there
were any settings in `config.toml`. I sent an email to the `merge` maintainer
asking them to make the behavior in this commit the default.

This introduces a new dependency on `merge` that hasn't yet been vetted.

I want to improve the output when `include = "x"` isn't found:

```
thread 'main' panicked at 'fs::read_to_string(&file) failed with No such file or directory (os error 2) ("configuration file did not exist")', src/bootstrap/config.rs:522:28
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to run: /home/joshua/rustc/build/bootstrap/debug/bootstrap test tidy
Build completed unsuccessfully in 0:00:00
```

However that seems like it could be fixed in a follow-up.
2020-09-20 16:18:58 -04:00
Mark Rousskov
a625ab77e8 Discover Rust toolchain without Python 2020-09-20 16:18:58 -04:00