Commit graph

124418 commits

Author SHA1 Message Date
Yuki Okushi
2b4ae49f2e
Rollup merge of #74891 - lcnr:auto-trait-finder, r=varkor
handle ConstEquate in rustdoc

fixes #74882

r? @varkor cc @eddyb
2020-07-29 09:24:25 +09:00
Yuki Okushi
18bb8355df
Rollup merge of #74872 - JohnTitor:ping-risc-v, r=Mark-Simulacrum
Enable to ping RISC-V group via triagebot

We have the RISC-V group (https://github.com/rust-lang/team/blob/master/teams/risc-v.toml) but don't enable to ping on this repository (https://github.com/rust-lang/rust/pull/74813#issuecomment-664841177).
We don't have the instructions on the rustc-dev-guide yet but I'll create it soonish.
2020-07-29 09:24:24 +09:00
Yuki Okushi
1de0211d8e
Rollup merge of #74864 - lzutao:ayu-doccolor, r=GuillaumeGomez
ayu theme: Change doccomment color to `#a1ac88`

Before:
![image](https://user-images.githubusercontent.com/15225902/88621499-d1cbff80-d0ca-11ea-99c3-5e2632709274.png)

After:
![image](https://user-images.githubusercontent.com/15225902/88621471-bf51c600-d0ca-11ea-9455-9c297f50f15f.png)

Close #74788
2020-07-29 09:24:22 +09:00
Yuki Okushi
451ed88b8b
Rollup merge of #74859 - mark-i-m:patch-1, r=JohnTitor
Update outdated readme
2020-07-29 09:24:20 +09:00
Yuki Okushi
bd91877636
Rollup merge of #74814 - matklad:unwind-safe, r=KodrAus
Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy

I *think* we should implement those unconditionally with respect to `F`.

The user code can't observe the closure in any way, and we poison lazy if the closure itself panics.

But I've never fully wrapped my head around `UnwindSafe` traits, so 🤷‍♂️
2020-07-29 09:24:19 +09:00
Yuki Okushi
6968b75bd0
Rollup merge of #74707 - matklad:split_once, r=dtolnay
Add str::[r]split_once

This is useful for quick&dirty parsing of key: value config pairs. Used a bunch in Cargo and rust-analyzer:

* https://github.com/rust-lang/cargo/search?q=splitn%282&unscoped_q=splitn%282
* https://github.com/rust-analyzer/rust-analyzer/search?q=split_delim&unscoped_q=split_delim

In theory, once const-generics are done, this functionality could be achieved without a dedicated method with

```rust
match s.splitn(delimier, 2).collect_array::<2>() {
  Some([prefix, suffix]) => todo!(),
  None => todo!(),
}
```

Even in that world, having a dedicated method seems clearer on the intention.

I am not sure about naming -- this is something I've just came up with yesterday, I don't know off the top of my head analogs in other languages.

If T-libs thinks this is a reasonable API to have, I'll open a tracking issue and add more thorough tests.
2020-07-29 09:24:17 +09:00
Yuki Okushi
157975c6c4
Rollup merge of #74671 - rust-lang:const-generics-coerce-unsized, r=nikomatsakis
add const generics array coercion test
2020-07-29 09:24:15 +09:00
Yuki Okushi
1ed74eeef9
Rollup merge of #74266 - GuillaumeGomez:cleanup-e0720, r=Dylan-DPC
Clean up E0720 explanation

r? @Dylan-DPC
2020-07-29 09:24:13 +09:00
bors
4cca9505ea Auto merge of #74791 - tmiasko:raw-waker-inline, r=LukasKalbertodt
Add #[inline] to RawWaker::new

`RawWaker::new` is used when creating a new waker or cloning an existing one,
for example as in code below. The `RawWakerVTable::new` can be const evaluated,
but `RawWaker::new` itself cannot since waker pointer is not known at compile
time. Add `#[inline]` to avoid overhead of a function call.

```rust
unsafe fn clone_waker<W: Wake + Send + Sync + 'static>(waker: *const ()) -> RawWaker {
    unsafe { Arc::incr_strong_count(waker as *const W) };
    RawWaker::new(
        waker as *const (),
        &RawWakerVTable::new(clone_waker::<W>, wake::<W>, wake_by_ref::<W>, drop_waker::<W>),
    )
}
```
2020-07-28 23:45:05 +00:00
Alex Crichton
06d565c967 std: Switch from libbacktrace to gimli
This commit is a proof-of-concept for switching the standard library's
backtrace symbolication mechanism on most platforms from libbacktrace to
gimli. The standard library's support for `RUST_BACKTRACE=1` requires
in-process parsing of object files and DWARF debug information to
interpret it and print the filename/line number of stack frames as part
of a backtrace.

Historically this support in the standard library has come from a
library called "libbacktrace". The libbacktrace library seems to have
been extracted from gcc at some point and is written in C. We've had a
lot of issues with libbacktrace over time, unfortunately, though. The
library does not appear to be actively maintained since we've had
patches sit for months-to-years without comments. We have discovered a
good number of soundness issues with the library itself, both when
parsing valid DWARF as well as invalid DWARF. This is enough of an issue
that the libs team has previously decided that we cannot feed untrusted
inputs to libbacktrace. This also doesn't take into account the
portability of libbacktrace which has been difficult to manage and
maintain over time. While possible there are lots of exceptions and it's
the main C dependency of the standard library right now.

For years it's been the desire to switch over to a Rust-based solution
for symbolicating backtraces. It's been assumed that we'll be using the
Gimli family of crates for this purpose, which are targeted at safely
and efficiently parsing DWARF debug information. I've been working
recently to shore up the Gimli support in the `backtrace` crate. As of a
few weeks ago the `backtrace` crate, by default, uses Gimli when loaded
from crates.io. This transition has gone well enough that I figured it
was time to start talking seriously about this change to the standard
library.

This commit is a preview of what's probably the best way to integrate
the `backtrace` crate into the standard library with the Gimli feature
turned on. While today it's used as a crates.io dependency, this commit
switches the `backtrace` crate to a submodule of this repository which
will need to be updated manually. This is not done lightly, but is
thought to be the best solution. The primary reason for this is that the
`backtrace` crate needs to do some pretty nontrivial filesystem
interactions to locate debug information. Working without `std::fs` is
not an option, and while it might be possible to do some sort of
trait-based solution when prototyped it was found to be too unergonomic.
Using a submodule allows the `backtrace` crate to build as a submodule
of the `std` crate itself, enabling it to use `std::fs` and such.

Otherwise this adds new dependencies to the standard library. This step
requires extra attention because this means that these crates are now
going to be included with all Rust programs by default. It's important
to note, however, that we're already shipping libbacktrace with all Rust
programs by default and it has a bunch of C code implementing all of
this internally anyway, so we're basically already switching
already-shipping functionality to Rust from C.

* `object` - this crate is used to parse object file headers and
  contents. Very low-level support is used from this crate and almost
  all of it is disabled. Largely we're just using struct definitions as
  well as convenience methods internally to read bytes and such.

* `addr2line` - this is the main meat of the implementation for
  symbolication. This crate depends on `gimli` for DWARF parsing and
  then provides interfaces needed by the `backtrace` crate to turn an
  address into a filename / line number. This crate is actually pretty
  small (fits in a single file almost!) and mirrors most of what
  `dwarf.c` does for libbacktrace.

* `miniz_oxide` - the libbacktrace crate transparently handles
  compressed debug information which is compressed with zlib. This crate
  is used to decompress compressed debug sections.

* `gimli` - not actually used directly, but a dependency of `addr2line`.

* `adler32`- not used directly either, but a dependency of
  `miniz_oxide`.

The goal of this change is to improve the safety of backtrace
symbolication in the standard library, especially in the face of
possibly malformed DWARF debug information. Even to this day we're still
seeing segfaults in libbacktrace which could possibly become security
vulnerabilities. This change should almost entirely eliminate this
possibility whilc also paving the way forward to adding more features
like split debug information.

Some references for those interested are:

* Original addition of libbacktrace - #12602
* OOM with libbacktrace - #24231
* Backtrace failure due to use of uninitialized value - #28447
* Possibility to feed untrusted data to libbacktrace - #21889
* Soundness fix for libbacktrace - #33729
* Crash in libbacktrace - #39468
* Support for macOS, never merged - ianlancetaylor/libbacktrace#2
* Performance issues with libbacktrace - #29293, #37477
* Update procedure is quite complicated due to how many patches we
  need to carry - #50955
* Libbacktrace doesn't work on MinGW with dynamic libs - #71060
* Segfault in libbacktrace on macOS - #71397

Switching to Rust will not make us immune to all of these issues. The
crashes are expected to go away, but correctness and performance may
still have bugs arise. The gimli and `backtrace` crates, however, are
actively maintained unlike libbacktrace, so this should enable us to at
least efficiently apply fixes as situations come up.
2020-07-28 16:34:01 -07:00
Rich Kadel
20f55c193d Refactor MIR coverage instrumentation
Lays a better foundation for injecting more counters in each function.
2020-07-28 15:08:19 -07:00
Bastian Kauschke
2a16bb085e handle ConstEquate in rustdoc 2020-07-29 00:00:55 +02:00
bors
a7eff79135 Auto merge of #74861 - mark-i-m:mv-std-followup, r=Mark-Simulacrum
Re-enable linkcheck after moving std
2020-07-28 21:48:22 +00:00
Mark Rousskov
13ad2322ca Cache non-exhaustive separately from attributes 2020-07-28 16:26:38 -04:00
bors
2caf854f7a Auto merge of #74471 - da-x:string-type-diagnostic-item, r=petrochenkov
librustc_typeck: use diag item instead of string compare
2020-07-28 20:00:37 +00:00
Mark Rousskov
6726ca2b28 Collect library features from library/ 2020-07-28 13:03:59 -05:00
mark
856f68fa14 reenable tests after moving std 2020-07-28 13:03:59 -05:00
bors
98efae8760 Auto merge of #74482 - alexcrichton:update-stdarch, r=hanna-kruppe
Update stdarch submodule

This commit updates the src/stdarch submodule primarily to include
rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD
intrinsics and renamed WebAssembly atomics intrinsics. This is all
unstable surface area of the standard library so the changes should be
ok here. The SIMD updates also enable SIMD intrinsics to be used by any
program any any time, yay!

cc #74372, a tracking issue I've opened for the stabilization of SIMD
intrinsics
2020-07-28 17:39:39 +00:00
Oliver Scherer
7d67a1b871 Replace write-to-vec hack by introducing a display renderer for allocations 2020-07-28 19:16:09 +02:00
Alexis Bourget
90d00527d1 Add note to clearly mark the RFC as rejected 2020-07-28 18:53:35 +02:00
Alexis Bourget
dcce6cb511 Remove links to rejected errata 4406 for RFC 4291 2020-07-28 18:53:35 +02:00
Alex Crichton
83b493018a Update stdarch submodule
This commit updates the src/stdarch submodule primarily to include
rust-lang/stdarch#874 which updated and revamped WebAssembly SIMD
intrinsics and renamed WebAssembly atomics intrinsics. This is all
unstable surface area of the standard library so the changes should be
ok here. The SIMD updates also enable SIMD intrinsics to be used by any
program any any time, yay!

cc #74372, a tracking issue I've opened for the stabilization of SIMD
intrinsics
2020-07-28 09:41:09 -07:00
Oliver Scherer
5e96bb4593 Replace all uses of log::log_enabled with Debug printers 2020-07-28 16:15:40 +02:00
bors
7b3a781937 Auto merge of #73964 - jyn514:sane-defaults, r=Mark-Simulacrum
Improve defaults in x.py

- Make the default stage dependent on the subcommand
- Don't build stage1 rustc artifacts with x.py build --stage 1. If this is what you want, use x.py build --stage 2 instead, which gives you a working libstd.
- Change default debuginfo when debug = true from 2 to 1

I tried to fix CI to use `--stage 2` everywhere it currently has no stage, but I might have missed a spot.
This does not update much of the documentation - most of it is in https://github.com/rust-lang/rustc-dev-guide/ or https://github.com/rust-lang/rust-forge and will need a separate PR.

See individual commits for a detailed rationale of each change.
See also the MCP: https://github.com/rust-lang/compiler-team/issues/326

r? @Mark-Simulacrum , but anyone is free to give an opinion.
2020-07-28 13:56:32 +00:00
Joshua Nelson
da40cf81e6 Use --stage 2 in checktools
- Remove useless --stage 2 argument to checktools.sh
- Fix help text for expand-yaml-anchors (it had a typo)
2020-07-28 09:36:56 -04:00
Joshua Nelson
c4c6453b7b Fix bad rebase 2020-07-28 08:34:59 -04:00
Bastian Kauschke
4f28534138 symbol mangling: use ty::print::Print for consts 2020-07-28 14:34:18 +02:00
Yuki Okushi
b85dae00dc
Enable to ping RISC-V group via triagebot 2020-07-28 21:01:13 +09:00
David Sonder
b5d143b126
Enable docs on dist-x86_64-musl
Add the rust-docs component to toolchain x86_64-unknown-linux-musl, which allows
people using rustup on their musl-based linux distribution to download the
rust-docs.
2020-07-28 13:55:04 +02:00
bors
2c28244cf0 Auto merge of #74796 - infinity0:master, r=nikomatsakis
config.toml.example: Update remap-debuginfo doc to be more general & accurate

This makes it more obvious that the work-around to #74786 is actually correct, and a custom `--remap-path-prefix` isn't needed.

In fact the previous comment `/rustc/$hash/$crate` was wrong, it is not `$crate` but whatever path exists in the rustc source tree, so either `src/$crate` or `vendor/$crate`. I've fixed that as well to avoid future confusion.
2020-07-28 09:02:32 +00:00
Aleksey Kladov
6e9dc7d9ff Add str::[r]split_once
This is useful for quick&dirty parsing of key: value config pairs
2020-07-28 09:58:20 +02:00
Aleksey Kladov
ed1439cea4 Fix RefUnwindSafe & UnwinsSafe impls for lazy::SyncLazy
The logic here is the same as for Send&Sync impls.
2020-07-28 09:51:08 +02:00
Michal 'vorner' Vaner
ad6d63ef01
Don't use "weak count" around Weak::from_raw_ptr
As `Rc/Arc::weak_count` returns 0 when having no strong counts, this
could be confusing and it's better to avoid using that completely.

Closes #73840.
2020-07-28 08:30:32 +02:00
bors
1f5d69dacc Auto merge of #74855 - jyn514:separate-lints, r=Manishearth
Separate `missing_doc_code_examples` from intra-doc links

These two lints have no relation other than both being nightly-only.
This allows stabilizing intra-doc links without stabilizing `missing_doc_code_examples`.

Fixes one of the issues spotted by @ollie27 in https://github.com/rust-lang/rust/pull/74430#issuecomment-664693080.

r? @Manishearth
2020-07-28 05:49:59 +00:00
Lzu Tao
5faef5e00c ayu theme: Change doccomment color to #a1ac88
Co-authored-by: Cldfire <cldfire@3grid.net>
2020-07-28 05:12:12 +00:00
Ashley Mannix
9d4818c6f9 update stderr for polymorphic ui test 2020-07-28 14:37:31 +10:00
Tomasz Miąsko
0a51a9fb00 Add #[inline] to RawWaker::new 2020-07-28 06:14:52 +02:00
bors
1454bbd4fd Auto merge of #74841 - infinity0:fix-exec, r=Mark-Simulacrum
rustbuild: use Display for exit status instead of Debug, see #74832 for justification
2020-07-28 03:42:22 +00:00
Ashley Mannix
a99d2cbfe7 remove unstable const_type_id feature 2020-07-28 13:33:08 +10:00
Ashley Mannix
e3856616ee bump const type id stabilization to 1.46.0 2020-07-28 13:30:29 +10:00
Ashley Mannix
cac16c9793 stabilize const_type_id feature 2020-07-28 13:30:29 +10:00
Joshua Nelson
c3f5556c30 private_items_doc_tests -> doc_test_lints 2020-07-27 23:30:17 -04:00
Joshua Nelson
a5337d668c Use exhaustive match for assert 2020-07-27 23:19:43 -04:00
Joshua Nelson
7768eaa050 Add assert that tests happen with stage 2 in CI
- Use stage 2 for makefile
- Move assert to builder
- Don't add an assert for --help
- Allow --stage 0 if passed explicitly
- Don't assert defaults during tests

Otherwise it's impossible to test the defaults!
2020-07-27 23:19:31 -04:00
Joshua Nelson
4ee8d847e5 Use --stage 2 explicitly in CI
- expand yaml anchors
- don't use --stage 2 for dist; that's already the default
2020-07-27 23:19:16 -04:00
Joshua Nelson
cdca337547 Add tests for the new behavior
- Only set stage 2 in dist tests
- Add test for `x.py doc` without args
- Add test for `x.py build` without args
- Add test for `x.py build --stage 0`
2020-07-27 23:16:57 -04:00
Joshua Nelson
60c1729738 Move tests into a submodule 2020-07-27 23:16:01 -04:00
Joshua Nelson
74b373426a Fix most bootstrap tests
Uses --stage 2 for all the existing tests
2020-07-27 23:11:18 -04:00
Joshua Nelson
01c6256178 Change debuginfo to default to 1 if debug = true is set
From [a conversation in discord](https://discordapp.com/channels/442252698964721669/443151243398086667/719200989269327882):

> Linking seems to consume all available RAM, leading to the OS to swap memory to disk and slowing down everything in the process
Compiling itself doesn't seem to take up as much RAM, and I'm only looking to check whether a minimal testcase can be compiled by rustc, where the runtime performance isn't much of an issue

> do you have debug = true or debuginfo-level = 2 in config.toml?
> if so I think that results in over 2GB of debuginfo nowadays and is likely the culprit
> which might mean we're giving out bad advice :(

Anecdotally, this sped up my stage 1 build from 15 to 10 minutes.

This still adds line numbers, it only removes variable and type information.

- Improve wording for debuginfo description

Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
2020-07-27 23:11:18 -04:00
Joshua Nelson
f7dcfcd45b Don't build rustc without std
- Set rustc to build only when explicitly asked for

This allows building the stage2 rustc artifacts, which nothing depends
on.

Previously the behavior was as follows (where stageN <-> stage(N-1) artifacts, except for stage0 libstd):

- `x.py build --stage 0`:
  - stage0 libstd
  - stage1 rustc (but without putting rustc in stage0/)

This leaves you without any rustc at all except for the beta compiler
(https://github.com/rust-lang/rust/issues/73519). This is never what you want.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc
  - stage2 rustc

This leaves you with a broken stage2 rustc which doesn't even have
libcore and is effectively useless. Additionally, it compiles rustc
twice, which is not normally what you want.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 rustdoc and tools

This builds all tools in release mode. This is the correct usage for CI,
but takes far to long for development.

Now the behavior is as follows:

- `x.py build --stage 0`:
  - stage0 libstd

This is suitable for contributors only working on the standard library,
as it means rustc never has to be compiled.

- `x.py build --stage 1`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage1 rustdoc

This is suitable for contributors working on the compiler. It ensures
that you have a working rustc and libstd without having to pass
`src/libstd` in addition.

- `x.py build --stage 2`:
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc

This is suitable for debugging errors which only appear with the stage2
compiler.

- `x.py build --stage 2 src/libstd src/rustc`
  - stage0 libstd
  - stage1 rustc
  - stage1 libstd
  - stage2 rustc
  - stage2 libstd
  - stage2 rustdoc, tools, etc.
  - stage2 rustc artifacts ('stage3')

This is suitable for CI, which wants all tools in release mode.
However, most of the use cases for this should use `x.py dist` instead,
which builds all the tools without each having to be named individually.
2020-07-27 23:11:18 -04:00