Commit graph

124200 commits

Author SHA1 Message Date
bors
48036804d2 Auto merge of #74163 - cuviper:debian6, r=Mark-Simulacrum
ci: Update dist-{i686,x86_64}-linux to Debian 6

This increases the minimum `{i686,x86_64}-unknown-linux-gnu` platform
from RHEL/CentOS 5 (glibc 2.5 and kernel 2.6.18) to a slightly newer
Debian 6 `squeeze` (glibc 2.11 and kernel 2.6.32). While that release is
already EOL, it happens to match the minimum common versions of two
enterprise distros that do still need Rust support -- RHEL 6 (glibc 2.12
and kernel 2.6.32) and SLES 11 SP4 (glibc 2.11 and kernel 3.0).

Closes #62516.
2020-07-19 10:46:34 +00:00
Lzu Tao
5e5d816323 Add missing : after min-gdb-version 2020-07-19 09:29:11 +00:00
Lzu Tao
5aa33b11fc Use subslice pattern 2020-07-19 09:29:11 +00:00
Lzu Tao
75caee076d Extract closure to function 2020-07-19 09:29:11 +00:00
Lzu Tao
79d5cbbf86 Use Option::as_deref 2020-07-19 09:29:11 +00:00
Lzu Tao
07d56cba8f Fix panic as passing wrong format to extract_gdb_version 2020-07-19 09:29:11 +00:00
Lzu Tao
d778f326c3 compiletest: Rewrite extract_gdb_version function 2020-07-19 09:29:11 +00:00
Lzu Tao
cfa3a33014 compiletest: Rewrite extract_lldb_version function
This makes extract_lldb_version has the same version type like
extract_gdb_version.

This is technically a breaking change for rustc-dev users.
But note that rustc-dev is a nightly component.
2020-07-19 09:29:11 +00:00
Lzu Tao
0eff3d5d88 Ayu: use different background color to make Run button easy-to-spot
Co-authored-by: Cldfire <cldfire@3grid.net>
2020-07-19 09:09:06 +00:00
bors
47ea6d90b0 Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandry
Generating the coverage map

@tmandry @wesleywiser

rustc now generates the coverage map and can support (limited)
coverage report generation, at the function level.

Example commands to generate a coverage report:
```shell
$ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu
$ $BUILD/stage1/bin/rustc -Zinstrument-coverage \
$HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs
$ LLVM_PROFILE_FILE="main.profraw" ./main
called
$ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata
$ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main
```
![rust coverage report only 20200706](https://user-images.githubusercontent.com/3827298/86697299-1cbe8f80-bfc3-11ea-8955-451b48626991.png)

r? @wesleywiser

Rust compiler MCP rust-lang/compiler-team#278
Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
2020-07-19 07:25:18 +00:00
Jarek Samic
dec70767e5 Fix search input focus in ayu theme 2020-07-19 02:00:10 -04:00
Manish Goregaokar
ec966ae13d primitive impls are weird 2020-07-18 22:42:11 -07:00
Manish Goregaokar
ea70cc0ae6 Clarify the literal string 2020-07-18 22:42:11 -07:00
Manish Goregaokar
8d470b5796
Update src/libstd/io/mod.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-07-18 22:31:35 -07:00
Manish Goregaokar
4a324b8117
Update src/tools/linkchecker/main.rs
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-07-18 22:30:25 -07:00
Lokathor
ec9c8d81f6 remove unused imports 2020-07-18 23:01:01 -06:00
Lzu Tao
174abeb6cb Add an border around the Run button 2020-07-19 04:31:01 +00:00
bors
0701419e96 Auto merge of #74493 - Manishearth:rollup-ust7yr4, r=Manishearth
Rollup of 7 pull requests

Successful merges:

 - #70817 (Add core::task::ready! macro)
 - #73762 (Document the trait keyword)
 - #74021 (impl Index<RangeFrom> for CStr)
 - #74071 (rustc_metadata: Make crate loading fully speculative)
 - #74445 (add test for #62878)
 - #74459 (Make unreachable_unchecked a const fn)
 - #74478 (Revert "Use an UTF-8 locale for the linker.")

Failed merges:

r? @ghost
2020-07-19 04:03:54 +00:00
Lokathor
4c8e62b433 Resolve https://github.com/rust-lang/rust/pull/74419#issuecomment-660518936 2020-07-18 21:57:37 -06:00
Manish Goregaokar
a83e294f77
Rollup merge of #74478 - rust-lang:revert-74416-linker-locale-utf8, r=Mark-Simulacrum
Revert "Use an UTF-8 locale for the linker."

Reverts rust-lang/rust#74416

This is suspected to have caused significant compile time regressions: https://perf.rust-lang.org/compare.html?start=39d5a61f2e4e237123837f5162cc275c2fd7e625&end=d3df8512d2c2afc6d2e7d8b5b951dd7f2ad77b02&stat=instructions:u
2020-07-18 16:51:01 -07:00
Manish Goregaokar
2fad396368
Rollup merge of #74459 - canova:const-unreachable-unchecked, r=oli-obk
Make unreachable_unchecked a const fn

This PR makes `std::hint::unreachable_unchecked` a const fn so we can use it inside a const function.
r? @RalfJung
Fixes #53188.
2020-07-18 16:50:59 -07:00
Manish Goregaokar
1a54b61e39
Rollup merge of #74445 - lcnr:const-generic-ty-decl, r=Dylan-DPC
add test for #62878

forgot to push this as part of #74159

r? @Dylan-DPC
2020-07-18 16:50:57 -07:00
Manish Goregaokar
43ba8409d7
Rollup merge of #74071 - petrochenkov:cload3, r=matthewjasper
rustc_metadata: Make crate loading fully speculative

Instead of reporting `span_err`s on the spot crate loading errors are now wrapped into the `CrateError` enum and returned, so they are reported only at the top level `resolve_crate` call, and not reported at all if we are resolving speculatively with `maybe_resolve_crate`.

As a result we can attempt loading crates for error recovery (e.g. import suggestions) without any risk of producing extra errors.
Also, this means better separation between error reporting and actual logic.

Fixes https://github.com/rust-lang/rust/issues/55103
Fixes https://github.com/rust-lang/rust/issues/56590
2020-07-18 16:50:56 -07:00
Manish Goregaokar
f305b200df
Rollup merge of #74021 - 1011X:master, r=dtolnay
impl Index<RangeFrom> for CStr

This change implements (partial) slicing for `CStr`.

Since a `CStr` must end in a null byte, it's not possible to trim from the right and still have a valid `CStr`. But, it *is* possible to trim from the left. This lets us be a bit more flexible and treat them more like strings.

```rust
let string = CStr::from_bytes_with_nul(b"Hello World!\0");
let result = CStr::from_bytes_with_nul(b"World!\0");
assert_eq!(&string[6..], result);
```
2020-07-18 16:50:54 -07:00
Manish Goregaokar
a6266e2d60
Rollup merge of #73762 - poliorcetics:trait-keyword, r=KodrAus
Document the trait keyword

Partial fix of #34601.

This document the trait keyword. To avoid doing too much and forcing more updates as functionalities evolve, I put two links to the reference, especially for trait objects. This mainly documents the "big" parts, not so much the small details that might trip someone experimenting.

@rustbot modify labels: T-doc,C-enhancement
2020-07-18 16:50:52 -07:00
Manish Goregaokar
479c8ad17c
Rollup merge of #70817 - yoshuawuyts:task-ready, r=dtolnay
Add core::task::ready! macro

This PR adds `ready!` as a top-level macro to `libcore` following the implementation of `futures_core::ready`, tracking issue https://github.com/rust-lang/rust/issues/70922. This macro is commonly used when implementing `Future`, `AsyncRead`, `AsyncWrite` and `Stream`. And being only 5 lines, it seems like a useful and straight forward addition to std.

## Example

```rust
use core::task::{Context, Poll};
use core::future::Future;
use core::pin::Pin;

async fn get_num() -> usize {
    42
}

pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> {
    let mut f = get_num();
    let f = unsafe { Pin::new_unchecked(&mut f) };

    let num = ready!(f.poll(cx));
    // ... use num

    Poll::Ready(())
}
```

## Naming

In `async-std` we chose to nest the macro under the `task` module instead of having the macro at the top-level. This is a pattern that currently does not occur in std, mostly due to this not being possible prior to Rust 2018.

This PR proposes to add the `ready` macro as `core::ready`. But another option would be to introduce it as `core::task::ready` since it's really only useful when used in conjunction with `task::{Context, Poll}`.

## Implementation questions

I tried rendering the documentation locally but the macro didn't show up under `core`. I'm not sure if I quite got this right. I used the [`todo!` macro PR](https://github.com/rust-lang/rust/pull/56348/files) as a reference, and our approaches look similar.

## References

- [`futures::ready`](https://docs.rs/futures/0.3.4/futures/macro.ready.html)
- [`async_std::task::ready`](https://docs.rs/async-std/1.5.0/async_std/task/index.html)
- [`futures_core::ready`](https://docs.rs/futures-core/0.3.4/futures_core/macro.ready.html)
2020-07-18 16:50:50 -07:00
Manish Goregaokar
a9680938d0 Add explicit exception list to linkchecker 2020-07-18 16:13:04 -07:00
Manish Goregaokar
9392a5ed94 Use intra-doc links on HashSet 2020-07-18 16:13:04 -07:00
Manish Goregaokar
e53fea7e06 Use intra-doc links on HashMap 2020-07-18 16:13:04 -07:00
Manish Goregaokar
26ba0e12e8 Use intra-doc links in std::io 2020-07-18 16:13:04 -07:00
Jane Lusby
397c82bae1 remove trailing semi 2020-07-18 15:57:57 -07:00
Jane Lusby
8561b67b6f add a Backtrace::disabled function 2020-07-18 15:51:44 -07:00
CAD97
1821e3d75c re-add Layout::for_value_raw
This was accidentally removed in rust-lang/rust#70362
56cbf2f22a
2020-07-18 18:27:39 -04:00
Alexis Bourget
d88cce2423 Add a link to read in the read_exact doc about the guarantees 2020-07-18 23:20:58 +02:00
David Tolnay
30b8835d1d
Update stability attribute for CStr indexing 2020-07-18 12:16:25 -07:00
1011X
f08aae6a2b
impl Index<RangeFrom<usize>> for CStr 2020-07-18 12:14:32 -07:00
Manish Goregaokar
4c48ac3e88 Use intra-doc links in BTreeMap 2020-07-18 11:41:41 -07:00
Manish Goregaokar
3168b7d6c0 Use more intra-doc links in BTreeSet 2020-07-18 11:21:22 -07:00
Manish Goregaokar
d6d48b4ca9 Use intra-doc links in alloc::String 2020-07-18 11:03:44 -07:00
Bastian Kauschke
e8d16fdf9f add note to opt_const_param_of 2020-07-18 19:23:35 +02:00
Manish Goregaokar
a594603f50 More links in std::str 2020-07-18 09:43:39 -07:00
bors
1fa54ad968 Auto merge of #73441 - alexcrichton:backtrace-gimli, r=Mark-Simulacrum
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.

---

I want to note that my purpose for creating a PR here is to start a conversation about this. I think that all the various pieces are in place that this is compelling enough that I think this transition should be talked about seriously. There are a number of items which still need to be addressed before actually merging this PR, however:

* [ ] `gimli` needs to be published to crates.io
* [ ] `addr2line` needs a publish
* [ ] `miniz_oxide` needs a publish
* [ ] Tests probably shouldn't recommend the `gimli` crate's traits for implementing
* [ ] The `backtrace` crate's branch changes need to be merged to the master branch (https://github.com/rust-lang/backtrace-rs/pull/349)
* [ ] The support for `libbacktrace` on some platforms needs to be audited to see if we should support more strategies in the gimli implementation - https://github.com/rust-lang/backtrace-rs/issues/325, https://github.com/rust-lang/backtrace-rs/issues/326, https://github.com/rust-lang/backtrace-rs/issues/350, https://github.com/rust-lang/backtrace-rs/issues/351

Most of the merging/publishing I'm not actively pushing on right now. It's a bit wonky for crates to support libstd so I'm holding off on pulling the trigger everywhere until there's a bit more discussion about how to go through with this. Namely https://github.com/rust-lang/backtrace-rs/pull/349 I'm going to hold off merging until we decide to go through with the submodule strategy.

In any case this is a pretty major change, so I suspect that the compiler team is likely going to be interested in this. I don't mean to force changes by dumping a bunch of code by any means. Integration of external crates into the standard library is so difficult I wanted to have a proof-of-concept to review while talking about whether to do this at all (hence the PR), but I'm more than happy to follow any processes needed to merge this. I must admit though that I'm not entirely sure myself at this time what the process would be to decide to merge this, so I'm hoping others can help me figure that out!
2020-07-18 16:08:23 +00:00
Jonas Schievink
09240a4b4b
Revert "Use an UTF-8 locale for the linker." 2020-07-18 16:59:16 +02:00
bors
8cf4219c16 Auto merge of #5815 - JarredAllen:redundant_pattern_bugfix, r=flip1995
Redundant pattern bugfix

changelog: Fixes the bug reported #5766
2020-07-18 14:43:36 +00:00
bors
799eef6919 Auto merge of #5818 - flip1995:rustup, r=flip1995
Rename TypeckTables to TypeckResults.

r? @ghost

changelog: none
2020-07-18 13:11:03 +00:00
flip1995
0f501ac1db
Merge remote-tracking branch 'upstream/master' into rustup 2020-07-18 15:09:58 +02:00
bors
7d31ffc1ac Auto merge of #74468 - Manishearth:rollup-5nhvz80, r=Manishearth
Rollup of 11 pull requests

Successful merges:

 - #72414 ( Add lazy initialization primitives to std)
 - #74069 (Compare tagged/niche-filling layout and pick the best one)
 - #74418 (ci: Set `shell: bash` as a default, remove duplicates)
 - #74441 (bootstrap.py: patch RPATH on NixOS to handle the new zlib dependency.)
 - #74444 (Add regression test for #69414)
 - #74448 (improper_ctypes_definitions: allow `Box`)
 - #74449 (Test codegen of compare_exchange operations)
 - #74450 (Fix `Safety` docs for `from_raw_parts_mut`)
 - #74453 (Use intra-doc links in `str` and `BTreeSet`)
 - #74457 (rustbuild: drop tool::should_install)
 - #74464 (Use pathdiff crate)

Failed merges:

r? @ghost
2020-07-18 13:00:50 +00:00
Vadim Petrochenkov
0a4217d09f rustc_metadata: Make crate loading fully speculative 2020-07-18 14:06:04 +04:00
Vadim Petrochenkov
4044cbc559 rustc_metadata: Refactor away CrateLocator::(dy,static)libname 2020-07-18 14:06:04 +04:00
Vadim Petrochenkov
926ac5a2fd rustc_metadata: Remove some extra diagnostics for legacy plugins
They are deprecated so doing extra work for error recovery doesn't make sense
2020-07-18 14:04:41 +04:00