]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAdd checking for no_mangle to unsafe_code lint
Wim Looman [Thu, 14 May 2020 15:31:06 +0000 (17:31 +0200)]
Add checking for no_mangle to unsafe_code lint

3 years agoAuto merge of #74862 - mark-i-m:mv-compiler, r=petrochenkov
bors [Sun, 30 Aug 2020 15:57:57 +0000 (15:57 +0000)]
Auto merge of #74862 - mark-i-m:mv-compiler, r=petrochenkov

Move almost all compiler crates to compiler/

This PR implements https://github.com/rust-lang/compiler-team/issues/336 and moves all `rustc_*` crates from `src` to the new `compiler` directory.

`librustc_foo` directories are renamed to `rustc_foo`.
`src` directories are introduced inside `rustc_*` directories to mirror the scheme already use for `library` crates.

3 years agomv compiler to compiler/
mark [Fri, 28 Aug 2020 03:58:48 +0000 (22:58 -0500)]
mv compiler to compiler/

3 years agoAuto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkov
bors [Sun, 30 Aug 2020 13:16:38 +0000 (13:16 +0000)]
Auto merge of #75176 - jyn514:impl-link, r=GuillaumeGomez,petrochenkov

Fix intra-doc links for cross-crate re-exports of default trait methods

The original fix for this was very simple: https://github.com/rust-lang/rust/pull/58972 ignored `extern_traits` because before https://github.com/rust-lang/rust/issues/65983 was fixed, they would always fail to resolve, giving spurious warnings. So the first commit just undoes that change, so extern traits are now seen by the `collect_intra_doc_links` pass. There are also some minor changes in `librustdoc/fold.rs` to avoid borrowing the `extern_traits` RefCell more than once at a time.

However, that brought up a much more thorny problem. `rustc_resolve` started giving 'error: cannot find a built-in macro with name `cfg`' when documenting `libproc_macro` (I still haven't been able to reproduce on anything smaller than the full standard library). The chain of events looked like this (thanks @eddyb for the help debugging!):

0. `x.py build --stage 1` builds the standard library and creates a sysroot
1. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above)
2. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros
3. `rustdoc` later tries to resolve some path in a doc link
4. suggestion logic fires and loads "extern prelude" crates by name
5. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros

`rustc_resolve` gives the error after step 5. However, `rustdoc` doesn't need suggestions at all - `resolve_str_path_error` completely discards the `ResolutionError`! The fix implemented in this PR is to skip the suggestion logic for `resolve_ast_path`: pass `record_used: false` and skip `lookup_import_candidates` when `record_used` isn't set.

It's possible that if/when https://github.com/rust-lang/rust/issues/74207 is implemented this will need a more in-depth fix which returns a `ResolutionError` from `compile_macro`, to allow rustdoc to reuse the suggestions from rustc_resolve. However, that's a much larger change and there's no need for it yet, so I haven't implemented it here.

Fixes https://github.com/rust-lang/rust/issues/73829.

r? @GuillaumeGomez

3 years agoresolve: Don't speculatively load crates if this is a speculative resolution
Joshua Nelson [Sat, 29 Aug 2020 13:47:39 +0000 (09:47 -0400)]
resolve: Don't speculatively load crates if this is a speculative resolution

This avoids a rare rustdoc bug where loading `core` twice caused a
'cannot find a built-in macro' error:

1. `x.py build --stage 1` builds the standard library and creates a sysroot
2. `cargo doc` does something like `cargo check` to create `rmeta`s for all the crates (unrelated to what was built above)
3. the `cargo check`-like `libcore-*.rmeta` is loaded as a transitive dependency *and claims ownership* of builtin macros
4. `rustdoc` later tries to resolve some path in a doc link
5. suggestion logic fires and loads "extern prelude" crates by name
6. the sysroot `libcore-*.rlib` is loaded and *fails to claim ownership* of builtin macros

This fixes step 5. by not running suggestion logic if this is a
speculative resolution. Additionally, it marks `resolve_ast_path` as a
speculative resolution.

3 years agorustdoc,metadata: Debugging
Joshua Nelson [Sun, 9 Aug 2020 03:47:07 +0000 (23:47 -0400)]
rustdoc,metadata: Debugging

3 years agoAuto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasper
bors [Sun, 30 Aug 2020 11:25:52 +0000 (11:25 +0000)]
Auto merge of #75867 - estebank:async-lt-sugg-fix, r=matthewjasper

Account for async functions when suggesting new named lifetime

Fix #75850.

3 years agoAuto merge of #75919 - rust-lang:jonas-schievink-patch-1, r=ehuss
bors [Sun, 30 Aug 2020 06:32:12 +0000 (06:32 +0000)]
Auto merge of #75919 - rust-lang:jonas-schievink-patch-1, r=ehuss

Fix typo (`thumbv8m.main-none-eabihf` is Mainline)

3 years agoAuto merge of #75901 - GuillaumeGomez:ayu-theme-button-hover-background-color, r...
bors [Sun, 30 Aug 2020 04:43:09 +0000 (04:43 +0000)]
Auto merge of #75901 - GuillaumeGomez:ayu-theme-button-hover-background-color, r=pickfire

Improve theme button hover background color

Fixes #75880.

![Screenshot from 2020-08-25 13-44-01](https://user-images.githubusercontent.com/3050060/91170922-e60b1880-e6d9-11ea-9eb1-61a44cdc28d9.png)
![Screenshot from 2020-08-25 13-43-43](https://user-images.githubusercontent.com/3050060/91170924-e73c4580-e6d9-11ea-969e-616bf4130975.png)

r? @pickfire

3 years agoAuto merge of #76093 - jyn514:prim-assoc-items, r=Manishearth
bors [Sun, 30 Aug 2020 02:36:48 +0000 (02:36 +0000)]
Auto merge of #76093 - jyn514:prim-assoc-items, r=Manishearth

Fix intra-doc links for associated constants

Previously, only associated functions would be resolved. Fixes the issues in https://github.com/rust-lang/rust/pull/75969#discussion_r477898003.

I'm a little uncomfortable hard-coding the string constants, but it looks like that's how it's done elsewhere. I might make a follow-up PR at some point putting it in one place.

Not sure how to test associated types, since AFAIK there aren't any on primitives.

r? @Manishearth

3 years agoFix intra-doc links for associated constants
Joshua Nelson [Sun, 30 Aug 2020 01:21:23 +0000 (21:21 -0400)]
Fix intra-doc links for associated constants

Previously, only associated functions would be resolved.

3 years agoAuto merge of #76090 - Dylan-DPC:rollup-eksndcr, r=Dylan-DPC
bors [Sun, 30 Aug 2020 00:47:37 +0000 (00:47 +0000)]
Auto merge of #76090 - Dylan-DPC:rollup-eksndcr, r=Dylan-DPC

Rollup of 14 pull requests

Successful merges:

 - #75832 (Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…)
 - #75852 (Switch to intra-doc links in `core::hash`)
 - #75874 (Shorten liballoc doc intra link while readable)
 - #75881 (Expand rustdoc theme chooser x padding)
 - #75885 (Fix another clashing_extern_declarations false positive.)
 - #75892 (Fix typo in TLS Model in Unstable Book)
 - #75910 (Add test for issue #27130)
 - #75917 (Move to intra doc links for core::ptr::non_null)
 - #75975 (Allow --bess ing expect-tests in tools)
 - #75990 (Add __fastfail for Windows on arm/aarch64)
 - #76015 (Fix loading pretty-printers in rust-lldb script)
 - #76022 (Clean up rustdoc front-end source code)
 - #76029 (Move to intra-doc links for library/core/src/sync/atomic.rs)
 - #76057 (Move retokenize hack to save_analysis)

Failed merges:

r? @ghost

3 years agoRollup merge of #76057 - matklad:remove-retokenize, r=petrochenkov
Dylan DPC [Sat, 29 Aug 2020 23:44:01 +0000 (01:44 +0200)]
Rollup merge of #76057 - matklad:remove-retokenize, r=petrochenkov

Move retokenize hack to save_analysis

closes #76046

3 years agoRollup merge of #76029 - denisvasilik:intra-doc-links-core-atomic, r=kennytm
Dylan DPC [Sat, 29 Aug 2020 23:43:59 +0000 (01:43 +0200)]
Rollup merge of #76029 - denisvasilik:intra-doc-links-core-atomic, r=kennytm

Move to intra-doc links for library/core/src/sync/atomic.rs

Helps with #75080.

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

Known issues:

* Link from core to std:

    [`Arc`]
[`std::thread::yield_now`]
[`std::thread::sleep`]
[`std::sync::Mutex`]

3 years agoRollup merge of #76022 - GuillaumeGomez:cleanup-rustdoc-front, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:57 +0000 (01:43 +0200)]
Rollup merge of #76022 - GuillaumeGomez:cleanup-rustdoc-front, r=jyn514

Clean up rustdoc front-end source code

r? @jyn514

3 years agoRollup merge of #76015 - ortem:fix-lldb-script, r=Mark-Simulacrum
Dylan DPC [Sat, 29 Aug 2020 23:43:55 +0000 (01:43 +0200)]
Rollup merge of #76015 - ortem:fix-lldb-script, r=Mark-Simulacrum

Fix loading pretty-printers in rust-lldb script

Pretty-printers loading in `rust-lldb` script was broken in https://github.com/rust-lang/rust/pull/72357

This fixes https://github.com/rust-lang/rust/issues/76006

3 years agoRollup merge of #75990 - rylev:arm-fastfail, r=alexcrichton
Dylan DPC [Sat, 29 Aug 2020 23:43:54 +0000 (01:43 +0200)]
Rollup merge of #75990 - rylev:arm-fastfail, r=alexcrichton

Add __fastfail for Windows on arm/aarch64

Fixes #73215

3 years agoRollup merge of #75975 - matklad:snapshot-tests, r=Mark-Simulacrum
Dylan DPC [Sat, 29 Aug 2020 23:43:52 +0000 (01:43 +0200)]
Rollup merge of #75975 - matklad:snapshot-tests, r=Mark-Simulacrum

Allow --bess ing expect-tests in tools

I haven't tried this, but I think this should do the trick, as `RustdocCrate` is a special step in bootstrap, which uses `tool_caro`

r? @ghost

3 years agoRollup merge of #75917 - poliorcetics:intra-doc-core-nonnull, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:50 +0000 (01:43 +0200)]
Rollup merge of #75917 - poliorcetics:intra-doc-core-nonnull, r=jyn514

Move to intra doc links for core::ptr::non_null

Helps with #75080.

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

r? @jyn514

3 years agoRollup merge of #75910 - bugadani:testcase, r=oli-obk
Dylan DPC [Sat, 29 Aug 2020 23:43:48 +0000 (01:43 +0200)]
Rollup merge of #75910 - bugadani:testcase, r=oli-obk

Add test for issue #27130

#27130 seems to be fixed by the llvm 11 update. The issue is marked with needs-test, so here it is. As some historical context, the generated code was fine until 1.38, and remained unoptimized from 1.38 up until the current nightly.

I've also added a pattern matching version that was fine on 1.45.2.

3 years agoRollup merge of #75892 - ArekPiekarz:unstable_book_tls_model_typo, r=petrochenkov
Dylan DPC [Sat, 29 Aug 2020 23:43:46 +0000 (01:43 +0200)]
Rollup merge of #75892 - ArekPiekarz:unstable_book_tls_model_typo, r=petrochenkov

Fix typo in TLS Model in Unstable Book

3 years agoRollup merge of #75885 - jumbatm:issue75739-clashing-extern-declarations-transparent...
Dylan DPC [Sat, 29 Aug 2020 23:43:44 +0000 (01:43 +0200)]
Rollup merge of #75885 - jumbatm:issue75739-clashing-extern-declarations-transparent-nonzero, r=lcnr

Fix another clashing_extern_declarations false positive.

Fixes #75739.

Fix another clashing_extern_declarations false positive, this time for transparent newtype with a non-zero member.

r? @lcnr

3 years agoRollup merge of #75881 - pickfire:patch-5, r=GuillaumeGomez
Dylan DPC [Sat, 29 Aug 2020 23:43:42 +0000 (01:43 +0200)]
Rollup merge of #75881 - pickfire:patch-5, r=GuillaumeGomez

Expand rustdoc theme chooser x padding

![image](https://user-images.githubusercontent.com/4687791/91057476-d0eea500-e659-11ea-8c9a-e44db937da89.png)
![image](https://user-images.githubusercontent.com/4687791/91057530-e368de80-e659-11ea-9298-fbb00006d91f.png)

But I still think there is room for improvement considering mdbook.

![image](https://user-images.githubusercontent.com/4687791/91057583-f7acdb80-e659-11ea-9dc5-317caed92bc5.png)

CC @GuillaumeGomez @jyn514

3 years agoRollup merge of #75874 - pickfire:patch-3, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:41 +0000 (01:43 +0200)]
Rollup merge of #75874 - pickfire:patch-3, r=jyn514

Shorten liballoc doc intra link while readable

r? @jyn514

Do you want to reviews these sort of pull requests in the future? I might send a few of them while reading vec code.

3 years agoRollup merge of #75852 - camelid:patch-3, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:39 +0000 (01:43 +0200)]
Rollup merge of #75852 - camelid:patch-3, r=jyn514

Switch to intra-doc links in `core::hash`

Part of #75080.

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

3 years agoRollup merge of #75832 - kofls:intradoc-fix, r=jyn514
Dylan DPC [Sat, 29 Aug 2020 23:43:37 +0000 (01:43 +0200)]
Rollup merge of #75832 - kofls:intradoc-fix, r=jyn514

Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs…

…, primitive_docs.rs & poison.rs

Partial fix for #75080

r? @jyn514

3 years agoAuto merge of #75775 - matklad:rustc-lexer-rustdoc-highlight, r=GuillaumeGomez
bors [Sat, 29 Aug 2020 22:42:08 +0000 (22:42 +0000)]
Auto merge of #75775 - matklad:rustc-lexer-rustdoc-highlight, r=GuillaumeGomez

Use rustc_lexer for rustdoc syntax highlighting

r? @ghost

3 years agorustdoc: Fix intra-doc links for cross-crate re-exports of traits
Joshua Nelson [Wed, 5 Aug 2020 04:11:57 +0000 (00:11 -0400)]
rustdoc: Fix intra-doc links for cross-crate re-exports of traits

 #58972 ignored extern_traits because before #65983 was fixed, they
would always fail to resolve, giving spurious warnings.
This undoes that change, so extern traits are now seen by the
`collect_intra_doc_links` pass. There are also some minor changes in
librustdoc/fold.rs to avoid borrowing the extern_traits RefCell more
than once at a time.

3 years agoAuto merge of #76016 - RalfJung:miri, r=RalfJung
bors [Sat, 29 Aug 2020 20:54:25 +0000 (20:54 +0000)]
Auto merge of #76016 - RalfJung:miri, r=RalfJung

bump Miri

Fixes https://github.com/rust-lang/rust/issues/75970
Cc @rust-lang/miri r? @ghost

3 years agobump Miri
Ralf Jung [Fri, 28 Aug 2020 08:06:15 +0000 (10:06 +0200)]
bump Miri

3 years agoAuto merge of #75713 - mati865:netbsd_zlib, r=Mark-Simulacrum
bors [Sat, 29 Aug 2020 19:04:26 +0000 (19:04 +0000)]
Auto merge of #75713 - mati865:netbsd_zlib, r=Mark-Simulacrum

Enable zlib for NetBSD

NetBSD Docker dist job passed locally.

3 years agoAuto merge of #75754 - joshtriplett:wip-perf-snappy, r=Mark-Simulacrum
bors [Sat, 29 Aug 2020 16:59:39 +0000 (16:59 +0000)]
Auto merge of #75754 - joshtriplett:wip-perf-snappy, r=Mark-Simulacrum

Switch to Snappy compression for metadata

3 years agoAuto merge of #76034 - flip1995:clippyup, r=Manishearth
bors [Sat, 29 Aug 2020 14:36:46 +0000 (14:36 +0000)]
Auto merge of #76034 - flip1995:clippyup, r=Manishearth

Update Clippy

Bi-weekly Clippy update, as per the [new policy](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#syncing-back-changes-in-clippy-to-rust-langrust).

r? @Manishearth

3 years agoAuto merge of #75370 - simonvandel:optimize-if-condition-on-int-to-switch, r=oli-obk
bors [Sat, 29 Aug 2020 12:31:56 +0000 (12:31 +0000)]
Auto merge of #75370 - simonvandel:optimize-if-condition-on-int-to-switch, r=oli-obk

New pass to optimize `if`conditions on integrals to switches on the integer

Fixes #75144

 Pass to convert `if` conditions on integrals into switches on the integral.
 For an example, it turns something like

 ```
 _3 = Eq(move _4, const 43i32);
 StorageDead(_4);
 switchInt(_3) -> [false: bb2, otherwise: bb3];
 ```

 into:

 ```
 switchInt(_4) -> [43i32: bb3, otherwise: bb2];
 ```

3 years agoNew pass to optimize `if`conditions on integrals to switches on the integer
Simon Vandel Sillesen [Mon, 10 Aug 2020 18:27:41 +0000 (20:27 +0200)]
New pass to optimize `if`conditions on integrals to switches on the integer
Fixes #75144

3 years agoAllow --bess ing expect-tests in tools
Aleksey Kladov [Thu, 27 Aug 2020 11:12:40 +0000 (13:12 +0200)]
Allow --bess ing expect-tests in tools

See #75773 and #75775

3 years agoUse an id instead of a function
Guillaume Gomez [Sat, 29 Aug 2020 10:38:50 +0000 (12:38 +0200)]
Use an id instead of a function

3 years agoExplicitly look for 'thumb-mode' before using __fastfail on 'arm'
Ryan Levick [Sat, 29 Aug 2020 10:30:49 +0000 (12:30 +0200)]
Explicitly look for 'thumb-mode' before using __fastfail on 'arm'

3 years agoMove retokenize hack to save_analysis
Aleksey Kladov [Sat, 29 Aug 2020 09:38:15 +0000 (11:38 +0200)]
Move retokenize hack to save_analysis

3 years agoAuto merge of #75985 - csmoe:issue-61076-1, r=estebank
bors [Sat, 29 Aug 2020 10:07:05 +0000 (10:07 +0000)]
Auto merge of #75985 - csmoe:issue-61076-1, r=estebank

Should not apply field accessing on enum

Closes #75977
But I'm surprised that `x.py test --stage 1` and CI didn't catch this with existing testcase.
r? @estebank

3 years agoAuto merge of #75916 - jyn514:unify-error-reporting, r=euclio
bors [Sat, 29 Aug 2020 07:52:53 +0000 (07:52 +0000)]
Auto merge of #75916 - jyn514:unify-error-reporting, r=euclio

 Unify error reporting for intra-doc links

- Give a suggestion even if there is no span available
- Give a more accurate description of the change than 'use the
disambiguator'
- Write much less code

Closes #75836.
r? @euclio
cc @pickfire - this gets rid of 'disambiguator' like you suggested in https://github.com/rust-lang/rust/pull/75079#discussion_r464464195.

3 years agoAuto merge of #74922 - joshtriplett:ninja-by-default, r=Mark-Simulacrum
bors [Sat, 29 Aug 2020 06:08:37 +0000 (06:08 +0000)]
Auto merge of #74922 - joshtriplett:ninja-by-default, r=Mark-Simulacrum

Set ninja=true by default

Ninja substantially improves LLVM build time. On a 96-way system, using
Make took 248s, and using Ninja took 161s, a 35% improvement.

We already require a variety of tools to build Rust. If someone wants to
build without Ninja (for instance, to minimize the set of packages
required to bootstrap a new target), they can easily set `ninja=false`
in `config.toml`.  Our defaults should help people build Rust (and LLVM)
faster, to speed up development.

3 years agoAuto merge of #75939 - Amanieu:fix_asm2, r=nagisa
bors [Sat, 29 Aug 2020 04:18:22 +0000 (04:18 +0000)]
Auto merge of #75939 - Amanieu:fix_asm2, r=nagisa

Fix a typo in #75781

3 years agoAuto merge of #75877 - vigoux:master, r=Amanieu
bors [Sat, 29 Aug 2020 01:48:40 +0000 (01:48 +0000)]
Auto merge of #75877 - vigoux:master, r=Amanieu

Update compiler-builtins

Update the compiler-builtins dependency to include latest changes.

This allows for `aarch64-unknown-linux-musl` to pass all tests.

Fixes #57820 and fixes #46651

3 years agoAuto merge of #72808 - Lucretiel:line-writer-reimpl, r=Amanieu
bors [Fri, 28 Aug 2020 23:41:57 +0000 (23:41 +0000)]
Auto merge of #72808 - Lucretiel:line-writer-reimpl, r=Amanieu

Substantial refactor to the design of LineWriter

# Preamble

This is the first in a series of pull requests designed to move forward with https://github.com/rust-lang/rust/issues/60673 (and the related [5 year old FIXME](https://github.com/rust-lang/rust/blob/ea7181b5f7a888c2cf969ae86de7207fa5fb40aa/src/libstd/io/stdio.rs#L459-L461)), which calls for an update to `Stdout` such that it can be block-buffered rather than line-buffered under certain circumstances (such as a `tty`, or a user setting the mode with a function call). This pull request refactors the logic `LineWriter` into a `LineWriterShim`, which operates on a `BufWriter` by mutable reference, such that it is easy to invoke the line-writing logic on an existing `BufWriter` without having to construct a new `LineWriter`.

Additionally, fixes #72721

## A note on flushing

Because the word **flush** tends to be pretty overloaded in this discussion, I'm going to use the word **unbuffered** to refer to a `BufWriter` sending its data to the wrapped writer via `write`, without calling `flush` on it, and I'll be using **flushed** when referring to sending data via flush, which recursively writes the data all the way to the final sink.

For example, given a `T = BufWriter<BufWriter<File>>`, saying that `T` **unbuffers** its data means that it is sent to the inner `BufWriter`, but not necessarily to the `File`, whereas saying that `T` **flushes** its data means that causes it (via `Write::flush`) to be delivered all the way to `File`.

# Goals

Once it became clear (for reasons described below) that the best way to approach this would involve refactoring `LineWriter` to work more directly on `BufWriter`'s internals, I established the following design goals for the refactor:

- Do not duplicate logic with `BufWriter`. It's great at buffering and then unbuffering data, so use the existing logic as much as possible.
- Minimize superfluous copying of data into `BufWriter`'s buffer.
- Eliminate calls to `BufWriter::flush` and instead do the same thing as `BufWriter::write`, which is to only write to the wrapped writer (rather than flushing all the way down to the final data sink).
- Uphold the "at-most 1 write of new data" convention of `Write::write`
- Minimize or eliminate dropping errors (that is, eliminate the parts of the old design that threw away errors because `write` *must* report if any bytes were written)
- As much as possible, attempt to fully flush completed lines, and *not* flush partial lines. One of the advantages of this design is that, so long as we don't encounter lines larger than the `BufWriter`'s capacity, partial lines will never be unbuffered, while completed lines will *always* be unbuffered (with subsequent calls to `LineWriter::write` retrying failed writes before processing new data.

# Design

There are two major & related parts of the design.

First, a new internal stuct, `LineWriterShim`, is added. This struct implements all of the actual logic of line-writing in a `Write` implementation, but it only operates on an `&mut BufWriter`. This means that this shim can be constructed on-the-fly to apply line writing logic to an existing `BufWriter`. This is in fact how `LineWriter` has been updated to operate, and it is also how `Stdout` is being updated in my [development branch](https://github.com/Lucretiel/rust/tree/stdout-block-buffer) to switch which mode it wants to use at runtime.

[An example of how this looks in practice](https://github.com/Lucretiel/rust/blob/f24f272df674dc7fa8941b97b45f41ad08b2199b/src/libstd/io/stdio.rs#L479-L484
)

The second major part of the design that the line-buffering logic, implemented in `LineWriterShim`, has been updated to work slightly more directly on the internals of `BufWriter`. Mostly it makes us of the public interface—particularly `buffer()` and `get_mut()`—but it also controls the flushing of the buffer with `flush_buf` rather than `flush`, and it writes to the buffer infallibly with a new `write_to_buffer` method. This has several advantages:

- Data no longer has to round trip through the `BufWriter`'s buffer. If the user provides a complete line, that line is written directly to the inner writer (after ensuring the existing buffer is flushed).
- The conventional contract of `write`—that at-most 1 attempt to write new data is made—is much more cleanly upheld, because we don't have to perform fallible flushes and perform semi-complicated logic of trying to pretend errors at different stages didn't happen. Instead, after attempting to write lines directly to the buffer, we can infallibly add trailing data to the buffer without allowing any attempts to continue writing it to the `inner` writer.
- Perhaps most importantly, `LineWriter` *no longer performs a full flush on every line.* This makes its behavior much more consistent with `BufWriter`, which unbuffers data to its inner writer, without trying to flush it all the way to the final device. Previously, `LineWriter` had no choice but to use `flush` to ensure that the lines were unbuffered, but by writing directly to `inner` via `get_mut()` (when appropriate), we can use a more correct behavior.

## New(ish) line buffering logic

The logic for line writing has been cleaned up, as described above. It now follows this algorithm for `write`, with minor adjustments for `write_all` and `write_vectored`:

- Does our input data contain a newline?
    - If no:
        - simply use the regular `BufWriter::write` to write it; this will append it to the buffer and/or flush it as necessary based on how full the buffer is and how much input data there is.
        - additionally, if the current buffer ends with `'\n'`, attempt to immediately flush it with `flush_buf` before calling `BufWriter::write` This reproduces the old `needs_flush` behavior and ensures completed lines are flushed as soon as possible. The reason we only check if the buffer *ends* with `'\n'` is discussed later.
    - If yes:
        - First, `flush_buf`
        - Then use `bufwriter.get_mut().write()` to write the input data directly to the underlying writer, up to the last newline. Make at most one attempt at this.
        - If it errors, return the error
        - If it succeeds with a full write, add the remaining data (between the last newline and the end of the input) to the buffer. In order to uphold the "at-most 1 attempt to write new data" convention, no attempts are made to write this data to the inner writer (though obviously a subsequent write may immediately flush it, e.g., if it totally filled the buffer's capacity.
        - If it only partially succeeds, buffer the data only up to the last newline. We do this to try to avoid writing partial lines to the inner writer where possible (that is, whenever the lines are shorter than the total buffer capacity).

While it was not my intention for this behavior to diverge from this existing `LineWriter` algorithm, this updated design emerged very naturally once `LineWriter` wasn't burdened with having to only operate via `BufWriter::flush`. There essentially two main changes to observable behavior:

- `flush` is no longer used to unbuffer lines. The are only written to the writer wrapped by `LineWriter`; this inner writer might do its own buffering. This change makes `LineWriter` consistent with the behavior of `BufWriter`. This is probably the most obvious user-visible change; it's the one I most expect to provoke issue reports, if any are provoked.
- Unless a line exceeds the capacity of the buffer, partial lines are not unbuffered (without the user manually calling flush). This is a less surprising behavior, and is enabled because `LineWriter` now has more precise control of what data is buffered and when it is unbuffered. I'd be surprised if anyone is relying on `LineWriter` unbuffering or flushing *partial* lines that are shorter than the capacity, so I'm not worried about this one.

None of these changes are inconsistent with any published documentation of `LineWriter`. Nonetheless, like all changes with user-facing behavior changes, this design will obviously have to be very carefully scrutinized.

# Alternative designs and design rationalle

The initial goal of this project was to provide a way for the `LineWriter` logic to be operable directly on a `BufWriter`, so that the updated `Stdout` doesn't need to do something convoluted like `enum { BufWriter, LineWriter }` (which ends up being ~~impossible~~ difficult to transition between states after being constructed). The design went through several iterations before arriving at the current draft.

The major first version simply involved adding methods like `write_line_buffered` to `BufWriter`; these would contain the actual logic of line-buffered writing, and would additionally have the advantages (described above) of operating directly on the internals of `BufWriter`. The idea was that `LineWriter` would simply call these methods, and the updated `Stdout` would use either `BufWriter::write` or `BufWriter::write_line_buffered`, depending on what mode it was in.

The major issue with this design is that it loses the ability to take advantage of the `io::Write` trait, which provides several useful default implementations of the various io methods, such as `write_fmt` and `write_all`, just using the core methods. For this reason, the `write_line_buffered` design was retained, but moved into a separate struct called `LineWriterShim` which operates on an `&mut LineWriter`. As part of this move, the logic was lightly retooled to not touch the innards of `BufWriter` directly, but instead to make use of the unexported helper methods like `flush_buf`.

The other design evolutions were mostly related to answering questions like "how much data should be buffered", "how should partial line writes be handled", etc. As much as possible I tried to answer these by emulating the current `LineWriter` logic (which, for example, retries partial line writes on subsequent calls to `write`) while still meeting the refactor design goals.

# Next steps

~Currently, this design fails a few `LineWriter` tests, mostly because they expect `LineWriter` to *fully* flush its content. There are also some changes to the way that `LineWriter` buffers data *after* writing completed lines, aimed at ensuring that partial lines are not unbuffered prematurely. I want to make sure I fully understand the intent behind these tests before I either update the test or update this design so that they pass.~

However, in the meantime I wanted to get this published so that feedback could start to accumulate on it. There's a lot of errata around how I arrived at this design that didn't really fit in this overlong document, so please ask questions about anything that confusing or unclear and hopefully I can explain more of the rationale that led to it.

# Test updates

This design required some tests to be updated; I've research the intent behind these tests (mostly via `git blame`) and updated them appropriately. Those changes are cataloged here.

- `test_line_buffer_fail_flush`: This test was added as a regression test for #32085, and is intended to assure that an errors from `flush` aren't propagated when preceded by a successful `write`. Because type of issue is no longer possible, because `write` calls `buffer.get_mut().write()` instead of `buffer.write(); buffer.flush();`, I'm simply removing this test entirely. Other, similar error invariants related to errors during write-retrying are handled in other test cases.
- `erroneous_flush_retried`: This test was added as a regression test for #37807, and was intended to ensure that flush-retrying (via `needs_flush`) and error-ignoring were being handled correctly (ironically, this issue was caused by the flush-error-ignoring, above). Half of that issue is not possible by design with this refactor, because we no longer make fallible i/o calls that might produce errors we have to ignore after unbuffering lines. The `should_flush` behavior is captured by checking for a trailing newline in the `LineWriter` buffer; this test now checks that behavior.
- `line_vectored`: changes here were pretty minor, mostly related to when partial lines are or aren't written. The old implementation of `write_vectored` used very complicated logic to precisely determine the location of the last newline and precisely write up to that point; this required doing several consecutive fallible writes, with all the complex error handling or ignoring issues that come with it. The updated design does at-most one write of a subset of total buffers (that is, it doesn't split in the middle of a buffer), even if that means writing partial lines. One of the major advantages of the new design is that the underlying vectored write operation on the device can be taken advantage of, even with small writes, so long as they include a newline; previously these were unconditionally buffered then written.
- `line_vectored_partial_and_errors`: Pretty similiar to `line_vectored`, above; this test is for basic error recovery in `write_vectored` for vectored writes. As previously discussed, the mocked behavior being tested for (errors ignored under certain circumstances) no occurs, so I've simplified the test while doing my best to retain its spirit.

3 years agoAuto merge of #76035 - tiagolam:master, r=pietroalbini
bors [Fri, 28 Aug 2020 20:58:49 +0000 (20:58 +0000)]
Auto merge of #76035 - tiagolam:master, r=pietroalbini

Build dist-x86_64-musl with --enable-profiler.

Trying to build a Rust project with `-Zprofile` for target
x86_64-unknown-linux-musl using rustc 1.46.0-nightly (346aec9b0
2020-07-11), installed with rustup, results in the following error.
```
        export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"export CARGO_INCREMENTAL=0$ cargo build --target=x86_64-unknown-linux-muslCompiling hello_world v0.1.0 (…)error[E0463]: can't find crate for `profiler_builtins`
        |
         = note: the compiler may have been built without the profiler runtime

        error: aborting due to previous error

        For more information about this error, try `rustc --explain E0463`.error: could not compile `hello_world`.

        To learn more, run the command again with --verbose.
```

`-Zprofile` is required here to enable grcov profiling.

This is similar in nature to issue
https://github.com/rust-lang/rust/issues/57257, which has been fixed in
asimilar way at https://github.com/rust-lang/rust/pull/60476 .

A fix for Android has also landed not long ago:
https://github.com/rust-lang/rust/pull/70054 .

Signed-off-by: Tiago Lam <tiagol@hadean.com>
3 years agoFix test
Amanieu d'Antras [Fri, 28 Aug 2020 17:53:09 +0000 (18:53 +0100)]
Fix test

3 years agoBuild dist-x86_64-musl with --enable-profiler.
Tiago Lam [Fri, 28 Aug 2020 17:23:20 +0000 (18:23 +0100)]
Build dist-x86_64-musl with --enable-profiler.

Trying to build a Rust project with `-Zprofile` for target
x86_64-unknown-linux-musl using rustc 1.46.0-nightly (346aec9b0
2020-07-11), installed with rustup, results in the following error.
```
        export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"export CARGO_INCREMENTAL=0$ cargo build --target=x86_64-unknown-linux-muslCompiling hello_world v0.1.0 (…)error[E0463]: can't find crate for `profiler_builtins`
        |
         = note: the compiler may have been built without the profiler runtime

        error: aborting due to previous error

        For more information about this error, try `rustc --explain E0463`.error: could not compile `hello_world`.

        To learn more, run the command again with --verbose.
```

`-Zprofile` is required here to enable grcov profiling.

This is similar in nature to issue
https://github.com/rust-lang/rust/issues/57257, which has been fixed in
asimilar way at https://github.com/rust-lang/rust/pull/60476 .

A fix for Android has also landed not long ago:
https://github.com/rust-lang/rust/pull/70054 .

Signed-off-by: Tiago Lam <tiagol@hadean.com>
3 years agoAuto merge of #76018 - pietroalbini:ci-left-fallible-finish-2, r=Mark-Simulacrum
bors [Fri, 28 Aug 2020 17:14:04 +0000 (17:14 +0000)]
Auto merge of #76018 - pietroalbini:ci-left-fallible-finish-2, r=Mark-Simulacrum

Run cancel-outdated-builds after fully setting up the env

This PR fixes #75995 not working as expected.

Due to GitHub Actions limitations the environment variables set in the build matrix definition are not added by the GHA runner, but by the `setup-environment.sh` script. Before this PR the `cancel-outdated-builds` action was started before that script, so it was never able to detect the "suppression" variable added in #75995. This PR reorders the jobs to make sure `setup-environment.sh` runs before the action.

r? @Mark-Simulacrum

3 years agoUpdate Cargo.lock
flip1995 [Fri, 28 Aug 2020 16:43:41 +0000 (18:43 +0200)]
Update Cargo.lock

3 years agoMerge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup
flip1995 [Fri, 28 Aug 2020 14:10:16 +0000 (16:10 +0200)]
Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup

3 years agoBack to opcode for 32 bit ARM __fastfail
Ryan Levick [Fri, 28 Aug 2020 15:40:56 +0000 (17:40 +0200)]
Back to opcode for 32 bit ARM __fastfail

3 years agoUse intra-doc links for bool
Denis Vasilik [Fri, 28 Aug 2020 15:30:05 +0000 (17:30 +0200)]
Use intra-doc links for bool

3 years agoUse intra-doc links
Denis Vasilik [Fri, 28 Aug 2020 15:24:47 +0000 (17:24 +0200)]
Use intra-doc links

3 years agoDisable ninja on the dry-run builder
Josh Triplett [Fri, 28 Aug 2020 14:20:50 +0000 (07:20 -0700)]
Disable ninja on the dry-run builder

3 years agoAuto merge of #5774 - ThibsG:FixNewRetNoSelf, r=ebroto
bors [Fri, 28 Aug 2020 11:54:07 +0000 (11:54 +0000)]
Auto merge of #5774 - ThibsG:FixNewRetNoSelf, r=ebroto

Fix FP in `new_ret_no_self`: trigger in trait def instead of impl block

Lint in trait def instead of impl block.

Fixes: #5435
changelog: none

3 years agoClean up rustdoc front-end source code
Guillaume Gomez [Fri, 28 Aug 2020 11:30:21 +0000 (13:30 +0200)]
Clean up rustdoc front-end source code

3 years agoAuto merge of #76019 - pietroalbini:rollup-1tkgdnd, r=pietroalbini
bors [Fri, 28 Aug 2020 10:16:03 +0000 (10:16 +0000)]
Auto merge of #76019 - pietroalbini:rollup-1tkgdnd, r=pietroalbini

Rollup of 12 pull requests

Successful merges:

 - #75330 (Improve rendering of crate features via doc(cfg))
 - #75927 (Use intra-doc links in `core::macros`)
 - #75941 (Clean up E0761 explanation)
 - #75943 (Fix potential UB in align_offset doc examples)
 - #75946 (Error use explicit intra-doc link and fix text)
 - #75955 (Use intra-doc links in `core::future::future` and `core::num::dec2flt`)
 - #75967 (Fix typo in `std::hint::black_box` docs)
 - #75972 (Fix ICE due to carriage return w/ multibyte char)
 - #75989 (Rename rustdoc/test -> rustdoc/doctest)
 - #75996 (fix wording in release notes)
 - #75998 (Add InstrProfilingPlatformFuchsia.c to profiler_builtins)
 - #76000 (Adds --bless support to test/run-make-fulldeps)

Failed merges:

r? @ghost

3 years agoSwitch to asm! macro and use brk instruction on ARM
Ryan Levick [Fri, 28 Aug 2020 09:22:16 +0000 (11:22 +0200)]
Switch to asm! macro and use brk instruction on ARM

3 years agoRollup merge of #76000 - richkadel:llvm-coverage-map-gen-6b.2, r=wesleywiser
Pietro Albini [Fri, 28 Aug 2020 08:24:12 +0000 (10:24 +0200)]
Rollup merge of #76000 - richkadel:llvm-coverage-map-gen-6b.2, r=wesleywiser

Adds --bless support to test/run-make-fulldeps

The ability to "bless" output for some of these tests is critical to
making it practical to adapt tests to unrelated changes.

This is needed for new coverage tests, as shown in PR #76004 .

r? @tmandry
FYI: @wesleywiser

3 years agoRollup merge of #75998 - richkadel:llvm-coverage-map-gen-6b.1, r=wesleywiser
Pietro Albini [Fri, 28 Aug 2020 08:24:11 +0000 (10:24 +0200)]
Rollup merge of #75998 - richkadel:llvm-coverage-map-gen-6b.1, r=wesleywiser

Add InstrProfilingPlatformFuchsia.c to profiler_builtins

All other Platform files included in `llvm-project/compiler-rt` were
present, except Fuchsia.

Now that there is a functional end-to-end version of
`-Zinstrument-coverage`, I need to start building and testing
coverage-enabled Rust programs on Fuchsia, and this file is required.

r? @tmandry
FYI, @wesleywiser

3 years agoRollup merge of #75996 - tinaun:patch-2, r=jonas-schievink
Pietro Albini [Fri, 28 Aug 2020 08:24:09 +0000 (10:24 +0200)]
Rollup merge of #75996 - tinaun:patch-2, r=jonas-schievink

fix wording in release notes

C-like enums are still allowed to impl drop, you just can't cast them to numbers

3 years agoRollup merge of #75989 - matklad:renamerustdoctest, r=GuillaumeGomez
Pietro Albini [Fri, 28 Aug 2020 08:24:07 +0000 (10:24 +0200)]
Rollup merge of #75989 - matklad:renamerustdoctest, r=GuillaumeGomez

Rename rustdoc/test -> rustdoc/doctest

This modules contains the implementation of doctests, and not the
tests of rustdoc itself. This name is confusing, so let's rename it to
doctest for clarity.

3 years agoRollup merge of #75972 - JulianKnodt:i70381, r=rollup
Pietro Albini [Fri, 28 Aug 2020 08:24:06 +0000 (10:24 +0200)]
Rollup merge of #75972 - JulianKnodt:i70381, r=rollup

Fix ICE due to carriage return w/ multibyte char

Based off of this [commit](https://github.com/kfitch/rust/commit/972560b83f80e1219b5735ff3d751c034115b08e)

Fixes #70381

CC: @Dylan-DPC
3 years agoRollup merge of #75967 - aticu:blackbox_typo, r=Dylan-DPC
Pietro Albini [Fri, 28 Aug 2020 08:24:04 +0000 (10:24 +0200)]
Rollup merge of #75967 - aticu:blackbox_typo, r=Dylan-DPC

Fix typo in `std::hint::black_box` docs

3 years agoRollup merge of #75955 - camelid:intra-doc-links-for-future-and-dec2flt, r=jyn514
Pietro Albini [Fri, 28 Aug 2020 08:24:02 +0000 (10:24 +0200)]
Rollup merge of #75955 - camelid:intra-doc-links-for-future-and-dec2flt, r=jyn514

Use intra-doc links in `core::future::future` and `core::num::dec2flt`

Part of #75080.

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

3 years agoRollup merge of #75946 - pickfire:patch-8, r=jyn514
Pietro Albini [Fri, 28 Aug 2020 08:24:00 +0000 (10:24 +0200)]
Rollup merge of #75946 - pickfire:patch-8, r=jyn514

Error use explicit intra-doc link and fix text

Follow up of https://github.com/rust-lang/rust/pull/75629

r? @jyn514

3 years agoRollup merge of #75943 - elichai:2020-align_offset-docs, r=RalfJung
Pietro Albini [Fri, 28 Aug 2020 08:23:59 +0000 (10:23 +0200)]
Rollup merge of #75943 - elichai:2020-align_offset-docs, r=RalfJung

Fix potential UB in align_offset doc examples

Currently it takes a pointer only to the first element in the array, this changes the code to take a pointer to the whole array.
miri can't catch this right now because it later calls `x.len()` which re-tags the pointer for the whole array.

https://github.com/rust-lang/miri/issues/1526#issuecomment-680897144

3 years agoRollup merge of #75941 - GuillaumeGomez:cleanup-e0761, r=Dylan-DPC
Pietro Albini [Fri, 28 Aug 2020 08:23:57 +0000 (10:23 +0200)]
Rollup merge of #75941 - GuillaumeGomez:cleanup-e0761, r=Dylan-DPC

Clean up E0761 explanation

r? @Dylan-DPC

3 years agoRollup merge of #75927 - camelid:intra-doc-links-for-core-macros, r=jyn514
Pietro Albini [Fri, 28 Aug 2020 08:23:55 +0000 (10:23 +0200)]
Rollup merge of #75927 - camelid:intra-doc-links-for-core-macros, r=jyn514

Use intra-doc links in `core::macros`

Part of #75080.

Also cleaned up some things.

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

3 years agoRollup merge of #75330 - Nemo157:improve-doc-cfg-features, r=GuillaumeGomez
Pietro Albini [Fri, 28 Aug 2020 08:23:53 +0000 (10:23 +0200)]
Rollup merge of #75330 - Nemo157:improve-doc-cfg-features, r=GuillaumeGomez

Improve rendering of crate features via doc(cfg)

The current rendering of crate features with `doc(cfg(feature = ".."))` is verbose and unwieldy for users, `doc(cfg(target_feature = ".."))` is special-cased to make it render nicely, and a similar rendering can be applied to `doc(cfg(feature))` to make it easier for users to read.

I also added special casing of `all`/`any` cfgs consisting of just `feature`/`target-feature` to remove the repetitive "target/crate feature" prefix.

The downside of this current rendering is that there is no distinction between `feature` and `target_feature` in the shorthand display. IMO this is ok, or if anything `target_feature` should have a more verbose shorthand, because `doc(cfg(feature = ".."))` usage is going to vastly outstrip `doc(cfg(target_feature = ".."))` usage in non-stdlib crates when it eventually stabilizes (or even before that given the number of crates using `cfg_attr(docsrs)` like constructs).

## Previously

<img width="259" alt="Screenshot 2020-08-09 at 13 32 42" src="https://user-images.githubusercontent.com/81079/89731110-d090c000-da44-11ea-96fa-56adc6339123.png">
<img width="438" alt="image" src="https://user-images.githubusercontent.com/81079/89731116-d7b7ce00-da44-11ea-87c6-022d192d6eca.png">
<img width="765" alt="image" src="https://user-images.githubusercontent.com/81079/89731152-24030e00-da45-11ea-9552-1c270bff2729.png">
<img width="671" alt="image" src="https://user-images.githubusercontent.com/81079/89731158-28c7c200-da45-11ea-8acb-97d8a4ce00eb.png">

## Now

<img width="216" alt="image" src="https://user-images.githubusercontent.com/81079/89731123-e1d9cc80-da44-11ea-82a8-5900bd9448a5.png">
<img width="433" alt="image" src="https://user-images.githubusercontent.com/81079/89731127-e8684400-da44-11ea-9d18-572fd810f19f.png">
<img width="606" alt="image" src="https://user-images.githubusercontent.com/81079/89731162-2feed000-da45-11ea-98d2-8a88c364d903.png">
<img width="669" alt="image" src="https://user-images.githubusercontent.com/81079/89731991-ccb46c00-da4b-11ea-9416-cd20a3193826.png">

cc #43781

3 years agoci: run cancel-outdated-builds after fully setting up the env
Pietro Albini [Fri, 28 Aug 2020 08:09:08 +0000 (10:09 +0200)]
ci: run cancel-outdated-builds after fully setting up the env

3 years agoUpdate clippy_lints/src/methods/mod.rs
Thibaud [Fri, 28 Aug 2020 07:33:05 +0000 (09:33 +0200)]
Update clippy_lints/src/methods/mod.rs

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
3 years agoUpdate clippy_lints/src/utils/mod.rs
Thibaud [Fri, 28 Aug 2020 07:31:29 +0000 (09:31 +0200)]
Update clippy_lints/src/utils/mod.rs

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
3 years agoUpdate clippy_lints/src/utils/mod.rs
Thibaud [Fri, 28 Aug 2020 07:31:12 +0000 (09:31 +0200)]
Update clippy_lints/src/utils/mod.rs

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
3 years agoUpdate compiler-builtins
Thomas Vigouroux [Mon, 24 Aug 2020 13:44:13 +0000 (15:44 +0200)]
Update compiler-builtins

Fixes #57820 and #46651

3 years agoFix loading pretty-printers in rust-lldb script
ortem [Fri, 28 Aug 2020 06:29:45 +0000 (09:29 +0300)]
Fix loading pretty-printers in rust-lldb script

3 years agoOnce again, x.py tidy
Nathan West [Fri, 28 Aug 2020 02:55:58 +0000 (22:55 -0400)]
Once again, x.py tidy

3 years agoTypo fixes
Nathan West [Fri, 28 Aug 2020 02:49:16 +0000 (22:49 -0400)]
Typo fixes

3 years agoRemove unnecessary intra-doc link
Camelid [Fri, 28 Aug 2020 02:42:23 +0000 (19:42 -0700)]
Remove unnecessary intra-doc link

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoImprovements to `LineWriter::write_all`
Nathan West [Fri, 28 Aug 2020 02:32:28 +0000 (22:32 -0400)]
Improvements to `LineWriter::write_all`

`LineWriter::write_all` now only emits a single write when writing a
newline when there's already buffered data.

3 years agoAuto merge of #70212 - Amanieu:catch_foreign, r=Mark-Simulacrum
bors [Fri, 28 Aug 2020 01:20:17 +0000 (01:20 +0000)]
Auto merge of #70212 - Amanieu:catch_foreign, r=Mark-Simulacrum

Abort when foreign exceptions are caught by catch_unwind

Prior to this PR, foreign exceptions were not caught by catch_unwind, and instead passed through invisibly. This represented a painful soundness hole in some libraries ([take_mut](https://github.com/Sgeo/take_mut/blob/master/src/lib.rs#L37)), which relied on `catch_unwind` to handle all possible exit paths from a closure.

With this PR, foreign exceptions are now caught by `catch_unwind` and will trigger an abort since catching foreign exceptions is currently UB according to the latest proposals by the FFI unwind project group.

cc @rust-lang/wg-ffi-unwind

3 years agoAuto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto
bors [Thu, 27 Aug 2020 23:26:52 +0000 (23:26 +0000)]
Auto merge of #5971 - giraffate:fix_fp_in_to_string_in_display, r=ebroto

Fix FP in `to_string_in_display`

Don't emit a lint when `.to_string()` on anything that is not `self`

Fix #5967

changelog: Fix FP in `to_string_in_display` when calling `.to_string()` on anything that is not `self`

3 years agoAuto merge of #75995 - pietroalbini:ci-let-fallible-finish, r=Mark-Simulacrum
bors [Thu, 27 Aug 2020 23:22:34 +0000 (23:22 +0000)]
Auto merge of #75995 - pietroalbini:ci-let-fallible-finish, r=Mark-Simulacrum

Disable cancel-outdated-builds for auto-fallible

`cancel-outdated-builds` doesn't need to be enabled on fallible jobs, and it's actually making it harder for us to see if https://github.com/rust-lang/rust/issues/71988 is fixed. This adds some temporary code to avoid `auto-fallible` jobs from being cancelled by our tooling.

r? @Mark-Simulacrum

3 years agoMake sure the functions don't get merged
Dániel Buga [Thu, 27 Aug 2020 23:16:20 +0000 (01:16 +0200)]
Make sure the functions don't get merged

3 years agoAuto merge of #75976 - GuillaumeGomez:help-popup, r=jyn514
bors [Thu, 27 Aug 2020 21:30:32 +0000 (21:30 +0000)]
Auto merge of #75976 - GuillaumeGomez:help-popup, r=jyn514

Improve help popup

Fixes #75623.

The second commit is just a slight improvement: the help popup won't be created until someone presses "?" or ESC. Not a big improvement in itself but considering the low amount of code required, I think it was worth the shot.

r? @jyn514

3 years agoAbort when catch_unwind catches a foreign exception
Amanieu d'Antras [Sat, 21 Mar 2020 07:50:38 +0000 (07:50 +0000)]
Abort when catch_unwind catches a foreign exception

3 years agoAdds --bless support to test/run-make-fulldeps
Rich Kadel [Thu, 27 Aug 2020 19:27:18 +0000 (12:27 -0700)]
Adds --bless support to test/run-make-fulldeps

The ability to "bless" output for some of these tests is critical to
making it practical to adapt tests to unrelated changes.

This is needed for new coverage tests, as shown in PR #75828 (or its
derivative).

3 years agoSwitch to intra-doc links in `core::hash`
Camelid [Sun, 23 Aug 2020 21:48:37 +0000 (14:48 -0700)]
Switch to intra-doc links in `core::hash`

3 years agoAdd InstrProfilingPlatformFuchsia.c to profiler_builtins
Rich Kadel [Thu, 27 Aug 2020 18:52:36 +0000 (11:52 -0700)]
Add InstrProfilingPlatformFuchsia.c to profiler_builtins

All other Platform files included in `llvm-project/compiler-rt` were
present, except Fuchsia.

Now that there is a functional end-to-end version of
`-Zinstrument-coverage`, I need to start building and testing
coverage-enabled Rust programs on Fuchsia, and this file is required.

3 years agofix wording in release notes
tinaun [Thu, 27 Aug 2020 18:41:18 +0000 (14:41 -0400)]
fix wording in release notes

C-like enums are still allowed to impl drop, you just can't cast them to numbers

3 years agoUse intra-doc links in `core::num::dec2flt`
Camelid [Wed, 26 Aug 2020 19:26:26 +0000 (12:26 -0700)]
Use intra-doc links in `core::num::dec2flt`

3 years agoUse intra-doc links in `core::future::future`
Camelid [Wed, 26 Aug 2020 19:25:19 +0000 (12:25 -0700)]
Use intra-doc links in `core::future::future`

3 years agoci: disable cancel-outdated-builds for auto-fallible
Pietro Albini [Thu, 27 Aug 2020 18:07:06 +0000 (20:07 +0200)]
ci: disable cancel-outdated-builds for auto-fallible

3 years agoAuto merge of #75933 - Aaron1011:feature/closure-move-err, r=oli-obk
bors [Thu, 27 Aug 2020 17:48:23 +0000 (17:48 +0000)]
Auto merge of #75933 - Aaron1011:feature/closure-move-err, r=oli-obk

Point to a move-related span when pointing to closure upvars

Fixes #75904

When emitting move/borrow errors, we may point into a closure to
indicate why an upvar is used in the closure. However, we use the
'upvar span', which is just an arbitrary usage of the upvar. If the
upvar is used in multiple places (e.g. a borrow and a move), we may end
up pointing to the borrow. If the overall error is a move error, this
can be confusing.

This PR tracks the span that caused an upvar to become captured by-value
instead of by-ref (assuming that it's not a `move` closure). We use this
span instead of the 'upvar' span when we need to point to an upvar usage
during borrow checking.

3 years agoAdd __fastfail for Windows on arm/aarch64
Ryan Levick [Thu, 27 Aug 2020 17:11:48 +0000 (19:11 +0200)]
Add __fastfail for Windows on arm/aarch64

3 years agoAdd expect test for rustdoc html highlighting
Aleksey Kladov [Thu, 27 Aug 2020 10:50:28 +0000 (12:50 +0200)]
Add expect test for rustdoc html highlighting

It's a unit-test in a sense that it only checks syntax highlighting.
However, the resulting HTML is written to disk and can be easily
inspected in the browser.

To update the test, run with `--bless` argument or set
`UPDATE_EXPEC=1` env var

3 years agoMerge logic of looking for `Self` type
ThibsG [Thu, 27 Aug 2020 16:24:59 +0000 (18:24 +0200)]
Merge logic of looking for `Self` type

3 years agoRemove expansion restriction + fix doc and tests naming
ThibsG [Tue, 25 Aug 2020 07:16:08 +0000 (09:16 +0200)]
Remove expansion restriction + fix doc and tests naming

3 years agoFix FP in `new_ret_no_self`: trigger in trait def instead of impl block
ThibsG [Tue, 7 Jul 2020 20:47:32 +0000 (22:47 +0200)]
Fix FP in `new_ret_no_self`: trigger in trait def instead of impl block