]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #82350 - ehuss:test-chapter, r=jyn514
bors [Sun, 28 Feb 2021 09:18:27 +0000 (09:18 +0000)]
Auto merge of #82350 - ehuss:test-chapter, r=jyn514

Add a chapter on the test harness.

There isn't really any online documentation on the test harness, so this adds a chapter to the rustc book which provides information on how the harness works and details on the command-line options.

3 years agoAuto merge of #82605 - cuviper:issue81051, r=nikic
bors [Sun, 28 Feb 2021 06:37:18 +0000 (06:37 +0000)]
Auto merge of #82605 - cuviper:issue81051, r=nikic

Revert LLVM D81803 because it broke Windows 7

This submodule update reverts <https://reviews.llvm.org/D81803>.

While that change is meant to fix a real bug, [LLVM PR42623], it caused
new permission errors on Windows 7 that make it unable to build any
archives. This is probably the same root cause as [LLVM PR48378].

Fixes #81051. We'll file a new Rust issue to track the LLVM resolution.

[LLVM PR42623]: https://bugs.llvm.org/show_bug.cgi?id=42623
[LLVM PR48378]: https://bugs.llvm.org/show_bug.cgi?id=48378

3 years agoAuto merge of #82594 - nagisa:nagisa/remove-rumprun, r=petrochenkov
bors [Sun, 28 Feb 2021 03:56:16 +0000 (03:56 +0000)]
Auto merge of #82594 - nagisa:nagisa/remove-rumprun, r=petrochenkov

Remove the x86_64-rumprun-netbsd target

Herein we remove the target from the compiler and the code from libstd intended to support the now-defunct rumprun project.

Closes #81514

3 years agoAuto merge of #82611 - Dylan-DPC:rollup-l7xlpks, r=Dylan-DPC
bors [Sun, 28 Feb 2021 01:15:16 +0000 (01:15 +0000)]
Auto merge of #82611 - Dylan-DPC:rollup-l7xlpks, r=Dylan-DPC

Rollup of 11 pull requests

Successful merges:

 - #81856 (Suggest character encoding is incorrect when encountering random null bytes)
 - #82395 (Add missing "see its documentation for more" stdio)
 - #82401 (Remove a redundant macro)
 - #82498 (Use log level to control partitioning debug output)
 - #82534 (Link crtbegin/crtend on musl to terminate .eh_frame)
 - #82537 (Update measureme dependency to the latest version)
 - #82561 (doc: cube root, not cubic root)
 - #82563 (Fix intra-doc handling of `Self` in enum)
 - #82584 (Add ARIA role to sidebar toggle in Rustdoc)
 - #82596 (clarify RW lock's priority gotcha)
 - #82607 (Add a getter for Frame.loc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82607 - bjorn3:frame_loc_getter, r=RalfJung
Dylan DPC [Sat, 27 Feb 2021 20:56:25 +0000 (21:56 +0100)]
Rollup merge of #82607 - bjorn3:frame_loc_getter, r=RalfJung

Add a getter for Frame.loc

This is necessary for Priroda.

For context see https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Frame.3A.3Aloc.20no.20longer.20public/near/228070266 and oli-obk/priroda#27.

cc `@DJMcNab`

r? `@RalfJung`

3 years agoRollup merge of #82596 - matklad:rwlock, r=sfackler
Dylan DPC [Sat, 27 Feb 2021 20:56:24 +0000 (21:56 +0100)]
Rollup merge of #82596 - matklad:rwlock, r=sfackler

clarify RW lock's priority gotcha

In particular, the following program works on Linux, but deadlocks on
mac:

```rust
    use std::{
        sync::{Arc, RwLock},
        thread,
        time::Duration,
    };

    fn main() {
        let lock = Arc::new(RwLock::new(()));

        let r1 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r1/1");
                sleep(1000);

                let _rg = lock.read();
                eprintln!("r1/2");

                sleep(5000);
            }
        });
        sleep(100);
        let w = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _wg = lock.write();
                eprintln!("w");
            }
        });
        sleep(100);
        let r2 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r2");
                sleep(2000);
            }
        });

        r1.join().unwrap();
        r2.join().unwrap();
        w.join().unwrap();
    }

    fn sleep(ms: u64) {
        std::thread::sleep(Duration::from_millis(ms))
    }
```

Context: I was completely mystified by a my CI deadlocking on mac ([here](https://github.com/matklad/xshell/pull/7)), until ``@azdavis`` debugged the issue. See a stand-alone reproduciton here: https://github.com/matklad/xshell/pull/15

3 years agoRollup merge of #82584 - tazjin:rustdoc-aria, r=GuillaumeGomez
Dylan DPC [Sat, 27 Feb 2021 20:56:23 +0000 (21:56 +0100)]
Rollup merge of #82584 - tazjin:rustdoc-aria, r=GuillaumeGomez

Add ARIA role to sidebar toggle in Rustdoc

This indicates that the div is an interactive element, and makes the sidebar toggle "clickable" in assistive technologies.

Example of Vimium after this change has been applied (see the issue mentioned below for a screenshot of before):

![Screenshot of Vimium link hints on a Rustdoc page, indicating that the sidebar toggle is clickable](https://user-images.githubusercontent.com/1552853/109384961-ff935400-78f8-11eb-8199-1d35181aeff0.png)

Fixes #82582

3 years agoRollup merge of #82563 - lucas-deangelis:issue-82209-fix, r=jyn514
Dylan DPC [Sat, 27 Feb 2021 20:56:22 +0000 (21:56 +0100)]
Rollup merge of #82563 - lucas-deangelis:issue-82209-fix, r=jyn514

Fix intra-doc handling of `Self` in enum

Fixes #82209

3 years agoRollup merge of #82561 - tspiteri:cube-root, r=Dylan-DPC
Dylan DPC [Sat, 27 Feb 2021 20:56:21 +0000 (21:56 +0100)]
Rollup merge of #82561 - tspiteri:cube-root, r=Dylan-DPC

doc: cube root, not cubic root

Like we say square root, not quadratic root.

3 years agoRollup merge of #82537 - wesleywiser:update_measureme, r=oli-obk
Dylan DPC [Sat, 27 Feb 2021 20:56:20 +0000 (21:56 +0100)]
Rollup merge of #82537 - wesleywiser:update_measureme, r=oli-obk

Update measureme dependency to the latest version

This version adds the ability to use `rdpmc` hardware-based performance
counters instead of wall-clock time for measuring duration. This also
introduces a dependency on the `perf-event-open-sys` crate on Linux
which is used when using hardware counters.

r? ```@oli-obk```

3 years agoRollup merge of #82534 - nikic:musl-crtend, r=nagisa
Dylan DPC [Sat, 27 Feb 2021 20:56:19 +0000 (21:56 +0100)]
Rollup merge of #82534 - nikic:musl-crtend, r=nagisa

Link crtbegin/crtend on musl to terminate .eh_frame

For some targets, rustc uses a "CRT fallback", where it links CRT
object files it ships instead of letting the host compiler link
them.

On musl, rustc currently links crt1, crti and crtn (provided by
libc), but does not link crtbegin and crtend (provided by libgcc).
In particular, crtend is responsible for terminating the .eh_frame
section. Lack of terminator may result in segfaults during
unwinding, as reported in #47551 and encountered by the LLVM 12
update in #81451.

This patch links crtbegin and crtend for musl as well, following
the table at the top of crt_objects.rs.

r? ``@nagisa``

3 years agoRollup merge of #82498 - tmiasko:partitioning-debug, r=matthewjasper
Dylan DPC [Sat, 27 Feb 2021 20:56:18 +0000 (21:56 +0100)]
Rollup merge of #82498 - tmiasko:partitioning-debug, r=matthewjasper

Use log level to control partitioning debug output

3 years agoRollup merge of #82401 - osa1:remove_redundant_macro, r=matthewjasper
Dylan DPC [Sat, 27 Feb 2021 20:56:17 +0000 (21:56 +0100)]
Rollup merge of #82401 - osa1:remove_redundant_macro, r=matthewjasper

Remove a redundant macro

Turn the macro into a function. Also remove unused 'span' argument.

3 years agoRollup merge of #82395 - pickfire:see-more, r=GuillaumeGomez
Dylan DPC [Sat, 27 Feb 2021 20:56:16 +0000 (21:56 +0100)]
Rollup merge of #82395 - pickfire:see-more, r=GuillaumeGomez

Add missing "see its documentation for more" stdio

StdoutLock and StderrLock does not have example, it would be better
to leave "see its documentation for more" like iter docs.

3 years agoRollup merge of #81856 - Smittyvb:utf16-warn, r=matthewjasper
Dylan DPC [Sat, 27 Feb 2021 20:56:15 +0000 (21:56 +0100)]
Rollup merge of #81856 - Smittyvb:utf16-warn, r=matthewjasper

Suggest character encoding is incorrect when encountering random null bytes

This adds a note whenever null bytes are seen at the start of a token unexpectedly, since those tend to come from UTF-16 encoded files without a [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) (if a UTF-16 BOM appears it won't be valid UTF-8, but if there is no BOM it be both valid UTF-16 and valid but garbled UTF-8). This approach was suggested in https://github.com/rust-lang/rust/issues/73979#issuecomment-653976451.

Closes #73979.

3 years agoAdd a getter for Frame.loc
bjorn3 [Sat, 27 Feb 2021 20:01:02 +0000 (21:01 +0100)]
Add a getter for Frame.loc

This is necessary for Priroda.

3 years agoRevert LLVM D81803 because it broke Windows 7
Josh Stone [Sat, 27 Feb 2021 19:09:00 +0000 (11:09 -0800)]
Revert LLVM D81803 because it broke Windows 7

This submodule update reverts <https://reviews.llvm.org/D81803>.

While that change is meant to fix a real bug, [LLVM PR42623], it caused
new permission errors on Windows 7 that make it unable to build any
archives. This is probably the same root cause as [LLVM PR48378].

Fixes #81051. We'll file a new Rust issue to track the LLVM resolution.

[LLVM PR42623]: https://bugs.llvm.org/show_bug.cgi?id=42623
[LLVM PR48378]: https://bugs.llvm.org/show_bug.cgi?id=48378

3 years agoAuto merge of #80454 - JulianKnodt:ob_forest_op, r=matthewjasper
bors [Sat, 27 Feb 2021 17:35:35 +0000 (17:35 +0000)]
Auto merge of #80454 - JulianKnodt:ob_forest_op, r=matthewjasper

Skip Ty w/o infer ty/const in trait select

Remove some allocations & also add `skip_current_subtree` to skip subtrees with no inferred items.

r? `@eddyb` since marked in the FIXME

3 years agoUpdate library/std/src/sync/rwlock.rs
Aleksey Kladov [Sat, 27 Feb 2021 16:44:17 +0000 (19:44 +0300)]
Update library/std/src/sync/rwlock.rs

Co-authored-by: Steven Fackler <sfackler@gmail.com>
3 years agoclarify RW lock's priority gotcha
Aleksey Kladov [Sat, 27 Feb 2021 16:07:19 +0000 (19:07 +0300)]
clarify RW lock's priority gotcha

In particular, the following program works on Linux, but deadlocks on
mac:

    use std::{
        sync::{Arc, RwLock},
        thread,
        time::Duration,
    };

    fn main() {
        let lock = Arc::new(RwLock::new(()));

        let r1 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r1/1");
                sleep(1000);

                let _rg = lock.read();
                eprintln!("r1/2");

                sleep(5000);
            }
        });
        sleep(100);
        let w = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _wg = lock.write();
                eprintln!("w");
            }
        });
        sleep(100);
        let r2 = thread::spawn({
            let lock = Arc::clone(&lock);
            move || {
                let _rg = lock.read();
                eprintln!("r2");
                sleep(2000);
            }
        });

        r1.join().unwrap();
        r2.join().unwrap();
        w.join().unwrap();
    }

    fn sleep(ms: u64) {
        std::thread::sleep(Duration::from_millis(ms))
    }

3 years agoRemove the x86_64-rumprun-netbsd target
Simonas Kazlauskas [Sat, 27 Feb 2021 15:55:22 +0000 (17:55 +0200)]
Remove the x86_64-rumprun-netbsd target

Closes #81514

3 years agoAuto merge of #81874 - tesuji:spec_slice_fill, r=matthewjasper
bors [Sat, 27 Feb 2021 14:54:31 +0000 (14:54 +0000)]
Auto merge of #81874 - tesuji:spec_slice_fill, r=matthewjasper

Specialize slice::fill with Copy type and u8/i8/bool

I don't expect rustperf could measure any perf improvements with this changes
since `slice::fill` is newly added.

Godbolt link for this change: <https://rust.godbolt.org/z/r3fzee>.

r? `@matthewjasper` since this patch added new specialization.

3 years agoAdd ARIA role to sidebar toggle in Rustdoc
Vincent Ambo [Sat, 27 Feb 2021 10:37:05 +0000 (12:37 +0200)]
Add ARIA role to sidebar toggle in Rustdoc

This indicates that the div is an interactive element, and makes the
sidebar toggle "clickable" in assistive technologies.

Fixes #82582

3 years agoAuto merge of #82448 - Aaron1011:merge-hastokens-hasattrs, r=petrochenkov
bors [Sat, 27 Feb 2021 07:52:11 +0000 (07:52 +0000)]
Auto merge of #82448 - Aaron1011:merge-hastokens-hasattrs, r=petrochenkov

Combine HasAttrs and HasTokens into AstLike

When token-based attribute handling is implemeneted in #80689,
we will need to access tokens from `HasAttrs` (to perform
cfg-stripping), and we will to access attributes from `HasTokens` (to
construct a `PreexpTokenStream`).

This PR merges the `HasAttrs` and `HasTokens` traits into a new
`AstLike` trait. The previous `HasAttrs` impls from `Vec<Attribute>` and `AttrVec`
are removed - they aren't attribute targets, so the impls never really
made sense.

3 years agoCombine HasAttrs and HasTokens into AstLike
Aaron Hill [Tue, 23 Feb 2021 15:21:20 +0000 (10:21 -0500)]
Combine HasAttrs and HasTokens into AstLike

When token-based attribute handling is implemeneted in #80689,
we will need to access tokens from `HasAttrs` (to perform
cfg-stripping), and we will to access attributes from `HasTokens` (to
construct a `PreexpTokenStream`).

This PR merges the `HasAttrs` and `HasTokens` traits into a new
`AstLike` trait. The previous `HasAttrs` impls from `Vec<Attribute>` and `AttrVec`
are removed - they aren't attribute targets, so the impls never really
made sense.

3 years agoAuto merge of #82511 - jsha:fix-bfcache2, r=GuillaumeGomez
bors [Sat, 27 Feb 2021 05:06:05 +0000 (05:06 +0000)]
Auto merge of #82511 - jsha:fix-bfcache2, r=GuillaumeGomez

Fix back-forward cache in rustdoc frontend

Rustdoc's frontend set a no-op unload handler, specifically to disable
Firefox's back-forward cache because it caused a bug. It's nice to
allow the back-forward cache because it permits faster navigations.

This change addresses the issues that were caused by back-forward cache.

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/1.5/Using_Firefox_1.5_caching
https://web.dev/bfcache/

Demo: https://jacob.hoffman-andrews.com/rust/fix-bfcache/std/string/struct.String.html

Related: #72272

3 years agoAuto merge of #82577 - Dylan-DPC:rollup-c3si8ju, r=Dylan-DPC
bors [Sat, 27 Feb 2021 02:18:11 +0000 (02:18 +0000)]
Auto merge of #82577 - Dylan-DPC:rollup-c3si8ju, r=Dylan-DPC

Rollup of 14 pull requests

Successful merges:

 - #81794 (update tracking issue for `relaxed_struct_unsize`)
 - #82057 (Replace const_cstr with cstr crate)
 - #82370 (Improve anonymous lifetime note to indicate the target span)
 - #82394 (:arrow_up: rust-analyzer)
 - #82396 (Add Future trait for doc_spotlight feature doc)
 - #82404 (Test hexagon-enum only when llvm target is present)
 - #82419 (expand: Preserve order of inert attributes during expansion)
 - #82420 (Enable API documentation for `std::os::wasi`.)
 - #82421 (Add a `size()` function to WASI's `MetadataExt`.)
 - #82442 (Skip emitting closure diagnostic when closure_kind_origins has no entry)
 - #82473 (Use libc::accept4 on Android instead of raw syscall.)
 - #82482 (Use small hash set in `mir_inliner_callees`)
 - #82490 (Update cargo)
 - #82494 (Substitute erased lifetimes on bad placeholder type)

Failed merges:

 - #82448 (Combine HasAttrs and HasTokens into AstLike)

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82494 - estebank:issue-82455, r=petrochenkov
Dylan DPC [Sat, 27 Feb 2021 01:34:35 +0000 (02:34 +0100)]
Rollup merge of #82494 - estebank:issue-82455, r=petrochenkov

Substitute erased lifetimes on bad placeholder type

Fix #82455.

3 years agoRollup merge of #82490 - ehuss:update-cargo, r=ehuss
Dylan DPC [Sat, 27 Feb 2021 01:34:33 +0000 (02:34 +0100)]
Rollup merge of #82490 - ehuss:update-cargo, r=ehuss

Update cargo

11 commits in bf5a5d5e5d3ae842a63bfce6d070dfd438cf6070..572e201536dc2e4920346e28037b63c0f4d88b3c
2021-02-18 15:49:14 +0000 to 2021-02-24 16:51:20 +0000
- Pass the error message format to rustdoc (rust-lang/cargo#9128)
- Fix test target_in_environment_contains_lower_case (rust-lang/cargo#9203)
- Fix hang on broken stderr. (rust-lang/cargo#9201)
- Make it more clear which module is being tested when running cargo test (rust-lang/cargo#9195)
- Updates to edition handling. (rust-lang/cargo#9184)
- Add --cfg and --rustc-cfg flags to output compiler configuration (rust-lang/cargo#9002)
- Run rustdoc doctests relative to the workspace (rust-lang/cargo#9105)
- Add support for [env] section in .cargo/config.toml (rust-lang/cargo#9175)
- Add schema field and `features2` to the index. (rust-lang/cargo#9161)
- Document the default location where cargo install emitting build artifacts (rust-lang/cargo#9189)
- Do not exit prematurely if anything failed installing. (rust-lang/cargo#9185)

3 years agoRollup merge of #82482 - tmiasko:small-cycles, r=varkor
Dylan DPC [Sat, 27 Feb 2021 01:34:32 +0000 (02:34 +0100)]
Rollup merge of #82482 - tmiasko:small-cycles, r=varkor

Use small hash set in `mir_inliner_callees`

Use small hash set in `mir_inliner_callees` to avoid temporary
allocation when possible and quadratic behaviour for large number of
callees.

3 years agoRollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-se
Dylan DPC [Sat, 27 Feb 2021 01:34:31 +0000 (02:34 +0100)]
Rollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-se

Use libc::accept4 on Android instead of raw syscall.

This PR replaces the use of a raw `accept4` syscall with `libc::accept4`. This was originally added (by me) because `std` couldn't update to the latest `libc` with `accept4` support for android. By now, libc is already on 0.2.85, so the workaround can be removed.

`@rustbot` label +O-android +T-libs-impl

3 years agoRollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewjasper
Dylan DPC [Sat, 27 Feb 2021 01:34:30 +0000 (02:34 +0100)]
Rollup merge of #82442 - Aaron1011:fix/closure-mut-crash, r=matthewjasper

Skip emitting closure diagnostic when closure_kind_origins has no entry

Fixes #82438

This map is not guarnateed to have an entry for a closure.

3 years agoRollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichton
Dylan DPC [Sat, 27 Feb 2021 01:34:28 +0000 (02:34 +0100)]
Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichton

Add a `size()` function to WASI's `MetadataExt`.

WASI's `filestat` type includes a size field, so expose it in
`MetadataExt` via a `size()` function, similar to the corresponding Unix
function.

r? ``````@alexcrichton``````

3 years agoRollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichton
Dylan DPC [Sat, 27 Feb 2021 01:34:27 +0000 (02:34 +0100)]
Rollup merge of #82420 - sunfishcode:wasi-docs, r=alexcrichton

Enable API documentation for `std::os::wasi`.

This adds API documentation support for `std::os::wasi` modeled after
how `std::os::unix` works, so that WASI can be documented [here] along
with the other platforms.

[here]: https://doc.rust-lang.org/stable/std/os/index.html

Two changes of particular interest:

 - This changes the `AsRawFd` for `io::Stdin` for WASI to return
   `libc::STDIN_FILENO` instead of `sys::stdio::Stdin.as_raw_fd()` (and
   similar for `Stdout` and `Stderr`), which matches how the `unix`
   version works. `STDIN_FILENO` etc. may not always be explicitly
   reserved at the WASI level, but as long as we have Rust's `std` and
   `libc`, I think it's reasonable to guarantee that we'll always use
   `libc::STDIN_FILENO` for stdin.

 - This duplicates the `osstr2str` utility function, rather than
   trying to share it across all the configurations that need it.

r? ```@alexcrichton```

3 years agoRollup merge of #82419 - petrochenkov:inertord, r=Aaron1011
Dylan DPC [Sat, 27 Feb 2021 01:34:26 +0000 (02:34 +0100)]
Rollup merge of #82419 - petrochenkov:inertord, r=Aaron1011

expand: Preserve order of inert attributes during expansion

Fixes https://github.com/rust-lang/rust/issues/67839
Fixes https://github.com/rust-lang/rust/issues/81871
r? `````@Aaron1011`````

3 years agoRollup merge of #82404 - nagisa:nagisa/hexagon-enums-llvm-comps, r=petrochenkov
Dylan DPC [Sat, 27 Feb 2021 01:34:25 +0000 (02:34 +0100)]
Rollup merge of #82404 - nagisa:nagisa/hexagon-enums-llvm-comps, r=petrochenkov

Test hexagon-enum only when llvm target is present

See https://github.com/rust-lang/rust/pull/82379#issuecomment-783439754

r? ``````@petrochenkov``````

``````@bors`````` rollup

3 years agoRollup merge of #82396 - pickfire:patch-5, r=GuillaumeGomez
Dylan DPC [Sat, 27 Feb 2021 01:34:24 +0000 (02:34 +0100)]
Rollup merge of #82396 - pickfire:patch-5, r=GuillaumeGomez

Add Future trait for doc_spotlight feature doc

3 years agoRollup merge of #82394 - lnicola:rust-analyzer-2021-02-22, r=jonas-schievink
Dylan DPC [Sat, 27 Feb 2021 01:34:23 +0000 (02:34 +0100)]
Rollup merge of #82394 - lnicola:rust-analyzer-2021-02-22, r=jonas-schievink

:arrow_up: rust-analyzer

3 years agoRollup merge of #82370 - 0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank
Dylan DPC [Sat, 27 Feb 2021 01:34:22 +0000 (02:34 +0100)]
Rollup merge of #82370 - 0yoyoyo:update-issue-81650-point-anonymous-lifetime, r=estebank

Improve anonymous lifetime note to indicate the target span

Improvement for  #81650
Cc #81995

Message after this improvement:
(Improve note in the middle)

```
error[E0311]: the parameter type `T` may not live long enough
  --> src/main.rs:25:11
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |              -- help: consider adding an explicit lifetime bound...: `T: 'a +`
25 |     scope.spawn(move |_| {
   |           ^^^^^
   |
note: the parameter type `T` must be valid for the anonymous lifetime defined on the function body at 24:40...
  --> src/main.rs:24:40
   |
24 | fn play_with<T: Animal + Send>(scope: &Scope, animal: T) {
   |                                        ^^^^^
note: ...so that the type `[closure@src/main.rs:25:17: 27:6]` will meet its required lifetime bounds
  --> src/main.rs:25:11
   |
25 |     scope.spawn(move |_| {
   |           ^^^^^
```

r? ``````@estebank``````

3 years agoRollup merge of #82057 - upsuper-forks:cstr, r=davidtwco,wesleywiser
Dylan DPC [Sat, 27 Feb 2021 01:34:21 +0000 (02:34 +0100)]
Rollup merge of #82057 - upsuper-forks:cstr, r=davidtwco,wesleywiser

Replace const_cstr with cstr crate

This PR replaces the `const_cstr` macro inside `rustc_data_structures` with `cstr` macro from [cstr](https://crates.io/crates/cstr) crate.

The two macros basically serve the same purpose, which is to generate `&'static CStr` from a string literal. `cstr` is better because it validates the literal at compile time, while the existing `const_cstr` does it at runtime when `debug_assertions` is enabled. In addition, the value `cstr` generates can be used in constant context (which is seemingly not needed anywhere currently, though).

3 years agoRollup merge of #81794 - lcnr:relaxed_adt_unsize-tracking-issue, r=camelid
Dylan DPC [Sat, 27 Feb 2021 01:34:20 +0000 (02:34 +0100)]
Rollup merge of #81794 - lcnr:relaxed_adt_unsize-tracking-issue, r=camelid

update tracking issue for `relaxed_struct_unsize`

forgot to do this before #80726 got merged. The tracking issue is #81793

3 years agoMove test file, add test of generated link
Lucas De Angelis [Sat, 27 Feb 2021 00:08:05 +0000 (01:08 +0100)]
Move test file, add test of generated link

3 years agoUpdate src/librustdoc/passes/collect_intra_doc_links.rs
Lucas De Angelis [Fri, 26 Feb 2021 22:48:45 +0000 (23:48 +0100)]
Update src/librustdoc/passes/collect_intra_doc_links.rs

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agoAuto merge of #82559 - tmiasko:inlined, r=petrochenkov
bors [Fri, 26 Feb 2021 21:58:58 +0000 (21:58 +0000)]
Auto merge of #82559 - tmiasko:inlined, r=petrochenkov

Miscellaneous inlining improvements

Inline a few small and hot functions.

3 years agoFix formatting
Lucas De Angelis [Fri, 26 Feb 2021 21:48:53 +0000 (22:48 +0100)]
Fix formatting

3 years agoFix intra-doc handling of `Self` in enum
Lucas De Angelis [Fri, 26 Feb 2021 21:09:39 +0000 (22:09 +0100)]
Fix intra-doc handling of `Self` in enum

Fixes #82209

3 years agoAuto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomez
bors [Fri, 26 Feb 2021 19:17:00 +0000 (19:17 +0000)]
Auto merge of #82552 - GuillaumeGomez:rollup-8dn1ztn, r=GuillaumeGomez

Rollup of 8 pull requests

Successful merges:

 - #81940 (Stabilize str_split_once)
 - #82165 (Reword labels on E0308 involving async fn return type)
 - #82456 (Replaced some unwrap_or and map_or with lazy variants)
 - #82491 (Consider inexpensive inlining criteria first)
 - #82506 (Properly account for non-shorthand pattern field in unused variable lint)
 - #82535 (Set codegen thread names)
 - #82545 (rustdoc: add optional woff2 versions of FiraSans.)
 - #82549 (Revert "Update normalize.css to 8.0.1")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agodoc: cube root, not cubic root
Trevor Spiteri [Fri, 26 Feb 2021 18:03:44 +0000 (19:03 +0100)]
doc: cube root, not cubic root

Like we say square root, not quadratic root.

3 years agoAdd for example word to spotlight doc
Ivan Tham [Fri, 26 Feb 2021 17:29:56 +0000 (01:29 +0800)]
Add for example word to spotlight doc

As suggested by GuillaumeGomez

3 years agoRollup merge of #82549 - rust-lang:revert-82313-update-normalize-css, r=apiraino
Guillaume Gomez [Fri, 26 Feb 2021 14:52:37 +0000 (15:52 +0100)]
Rollup merge of #82549 - rust-lang:revert-82313-update-normalize-css, r=apiraino

Revert "Update normalize.css to 8.0.1"

Reverts rust-lang/rust#82313

Fixes #82548
Fixes #82542

``@jsha:`` I'm reverting until we can come up with a new version which is fully working.

r? ``@jyn514``

3 years agoRollup merge of #82545 - jsha:woff2, r=GuillaumeGomez
Guillaume Gomez [Fri, 26 Feb 2021 14:52:36 +0000 (15:52 +0100)]
Rollup merge of #82545 - jsha:woff2, r=GuillaumeGomez

rustdoc: add optional woff2 versions of FiraSans.

For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.

If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.

3 years agoRollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa
Guillaume Gomez [Fri, 26 Feb 2021 14:52:35 +0000 (15:52 +0100)]
Rollup merge of #82535 - wesleywiser:wip_codegen_thread_names, r=nagisa

Set codegen thread names

Set names on threads spawned during codegen. Various debugging and profiling tools can take advantage of this to show a more useful identifier for threads.

For example, gdb will show thread names in `info threads`:

```
(gdb) info threads
  Id   Target Id                                          Frame
  1    Thread 0x7fffefa7ec40 (LWP 2905) "rustc"           __pthread_clockjoin_ex (threadid=140737214134016, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>)
    at pthread_join_common.c:145
  2    Thread 0x7fffefa7b700 (LWP 2957) "rustc"           0x00007ffff125eaa8 in llvm::X86_MC::initLLVMToSEHAndCVRegMapping(llvm::MCRegisterInfo*) ()
   from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so
  3    Thread 0x7fffeef0f700 (LWP 3116) "rustc"           futex_wait_cancelable (private=0, expected=0, futex_word=0x7fffe8602ac8) at ../sysdeps/nptl/futex-internal.h:183
* 4    Thread 0x7fffeed0e700 (LWP 3123) "rustc"           rustc_codegen_ssa::back::write::spawn_work (cgcx=..., work=...) at /home/wesley/code/rust/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1573
  6    Thread 0x7fffe113b700 (LWP 3150) "opt foof.7rcbfp" 0x00007ffff2940e62 in llvm::CallGraph::populateCallGraphNode(llvm::CallGraphNode*) ()
   from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so
  8    Thread 0x7fffe0d39700 (LWP 3158) "opt foof.7rcbfp" 0x00007fffefe8998e in malloc_consolidate (av=av@entry=0x7ffe2c000020) at malloc.c:4492
  9    Thread 0x7fffe0f3a700 (LWP 3162) "opt foof.7rcbfp" 0x00007fffefef27c4 in __libc_open64 (file=0x7fffe0f38608 "foof.foof.7rcbfp3g-cgu.6.rcgu.o", oflag=524865) at ../sysdeps/unix/sysv/linux/open64.c:48
(gdb)
```

and Windows Performance Analyzer will also show this information when profiling:

![image](https://user-images.githubusercontent.com/831192/109231017-d311f780-7793-11eb-8072-ab836a830e90.png)

3 years agoRollup merge of #82506 - estebank:unused_variable_lint, r=lcnr
Guillaume Gomez [Fri, 26 Feb 2021 14:52:33 +0000 (15:52 +0100)]
Rollup merge of #82506 - estebank:unused_variable_lint, r=lcnr

Properly account for non-shorthand pattern field in unused variable lint

Fix #82488

3 years agoRollup merge of #82491 - tmiasko:i, r=lcnr
Guillaume Gomez [Fri, 26 Feb 2021 14:52:32 +0000 (15:52 +0100)]
Rollup merge of #82491 - tmiasko:i, r=lcnr

Consider inexpensive inlining criteria first

Refactor inlining decisions so that inexpensive criteria are considered first:

1. Based on code generation attributes.
2. Based on MIR availability (examines call graph).
3. Based on MIR body.

3 years agoRollup merge of #82456 - klensy:or-else, r=estebank
Guillaume Gomez [Fri, 26 Feb 2021 14:52:31 +0000 (15:52 +0100)]
Rollup merge of #82456 - klensy:or-else, r=estebank

Replaced some unwrap_or and map_or with lazy variants

Replaced some `unwrap_or` and `map_or` with `unwrap_or_else` and `map_or_else`.

3 years agoRollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebank
Guillaume Gomez [Fri, 26 Feb 2021 14:52:30 +0000 (15:52 +0100)]
Rollup merge of #82165 - nellshamrell:nell/fix-80658-B, r=estebank

Reword labels on E0308 involving async fn return type

Fix for #80658.

When someone writes code like this:

```rust
fn foo() -> u8 {
    async fn async_fn() -> () {}

    async_fn()
}
```

And they try to compile it, they will see an error that looks like this:

```bash
error[E0308]: mismatched types
 --> test.rs:4:5
  |
1 | fn foo() -> u8 {
  |             -- expected `u8` because of return type
2 |     async fn async_fn() -> () {}
  |                            -- checked the `Output` of this `async fn`, found opaque type
3 |
4 |     async_fn()
  |     ^^^^^^^^^^ expected `u8`, found opaque type
  |
  = note: while checking the return type of this `async fn`
  = note:     expected type `u8`
          found opaque type `impl Future`
```

3 years agoRollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se
Guillaume Gomez [Fri, 26 Feb 2021 14:52:29 +0000 (15:52 +0100)]
Rollup merge of #81940 - jhpratt:stabilize-str_split_once, r=m-ou-se

Stabilize str_split_once

Closes #74773

3 years agoRevert "Update normalize.css to 8.0.1"
Guillaume Gomez [Fri, 26 Feb 2021 13:59:24 +0000 (14:59 +0100)]
Revert "Update normalize.css to 8.0.1"

3 years agoAuto merge of #81458 - estebank:match-stmt-remove-semi, r=oli-obk
bors [Fri, 26 Feb 2021 12:03:38 +0000 (12:03 +0000)]
Auto merge of #81458 - estebank:match-stmt-remove-semi, r=oli-obk

Detect match statement intended to be tail expression

CC #24157

3 years agoLink crtbegin/crtend on musl to terminate .eh_frame
Nikita Popov [Fri, 26 Feb 2021 10:01:23 +0000 (11:01 +0100)]
Link crtbegin/crtend on musl to terminate .eh_frame

For some targets, rustc uses a "CRT fallback", where it links CRT
object files it ships instead of letting the host compiler link
them.

On musl, rustc currently links crt1, crti and crtn (provided by
libc), but does not link crtbegin and crtend (provided by libgcc).
In particular, crtend is responsible for terminating the .eh_frame
section. Lack of terminator may result in segfaults during
unwinding, as reported in #47551 and encountered by the LLVM 12
update in #81451.

This patch links crtbegin and crtend for musl as well, following
the table at the top of crt_objects.rs.

3 years agoEmbed woff2 files in rustdoc binary.
Jacob Hoffman-Andrews [Fri, 26 Feb 2021 08:38:05 +0000 (00:38 -0800)]
Embed woff2 files in rustdoc binary.

3 years agoAdd optional woff2 versions of FiraSans.
Jacob Hoffman-Andrews [Fri, 26 Feb 2021 08:02:11 +0000 (00:02 -0800)]
Add optional woff2 versions of FiraSans.

For browsers that support woff2 (most modern ones:
https://caniuse.com/woff2), this offers a reduction in download size
for these two fonts from 362k to 257k (32% reduction). It decreases the
total page size for `struct.String.html` (counting all subresources) by
about 2.5%.

If this is interesting, I'm happy to apply the same treatment to the
other fonts, but these two are the biggest.

3 years agoupdate tracking issue for `relaxed_struct_unsize`
lcnr [Fri, 26 Feb 2021 07:32:38 +0000 (08:32 +0100)]
update tracking issue for `relaxed_struct_unsize`

3 years agoAuto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514
bors [Fri, 26 Feb 2021 00:17:22 +0000 (00:17 +0000)]
Auto merge of #78429 - casey:doctest-attribute-splitting, r=jyn514

[librustdoc] Only split lang string on `,`, ` `, and `\t`

Split markdown lang strings into tokens on `,`.

The previous behavior was to split lang strings into tokens on any
character that wasn't a `_`, `_`, or alphanumeric.

This is a potentially breaking change, so please scrutinize! See discussion in #78344.

I noticed some test cases that made me wonder if there might have been some reason for the original behavior:

```
t("{.no_run .example}", false, true, Ignore::None, true, false, false, false, v(), None);
t("{.sh .should_panic}", true, false, Ignore::None, false, false, false, false, v(), None);
t("{.example .rust}", false, false, Ignore::None, true, false, false, false, v(), None);
t("{.test_harness .rust}", false, false, Ignore::None, true, true, false, false, v(), None);
```

It seemed pretty peculiar to specifically test lang strings in braces, with all the tokens prefixed by `.`.

I did some digging, and it looks like the test cases were added way back in [this commit from 2014](https://github.com/rust-lang/rust/commit/3fef7a74ca9a) by `@skade.`

It looks like they were added just to make sure that the splitting was permissive, and aren't testing that those strings in particular are accepted.

Closes https://github.com/rust-lang/rust/issues/78344.

3 years agoMiscellaneous inlining improvements
Tomasz Miąsko [Fri, 26 Feb 2021 00:00:00 +0000 (00:00 +0000)]
Miscellaneous inlining improvements

Inline a few small and hot functions.

3 years agoSet codegen thread names
Wesley Wiser [Thu, 18 Feb 2021 19:27:37 +0000 (14:27 -0500)]
Set codegen thread names

For example, gdb:

```
(gdb) info threads
  Id   Target Id                                          Frame
  1    Thread 0x7fffefa7ec40 (LWP 2905) "rustc"           __pthread_clockjoin_ex (threadid=140737214134016, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>)
    at pthread_join_common.c:145
  2    Thread 0x7fffefa7b700 (LWP 2957) "rustc"           0x00007ffff125eaa8 in llvm::X86_MC::initLLVMToSEHAndCVRegMapping(llvm::MCRegisterInfo*) ()
   from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so
  3    Thread 0x7fffeef0f700 (LWP 3116) "rustc"           futex_wait_cancelable (private=0, expected=0, futex_word=0x7fffe8602ac8) at ../sysdeps/nptl/futex-internal.h:183
* 4    Thread 0x7fffeed0e700 (LWP 3123) "rustc"           rustc_codegen_ssa::back::write::spawn_work (cgcx=..., work=...) at /home/wesley/code/rust/rust/compiler/rustc_codegen_ssa/src/back/write.rs:1573
  6    Thread 0x7fffe113b700 (LWP 3150) "opt foof.7rcbfp" 0x00007ffff2940e62 in llvm::CallGraph::populateCallGraphNode(llvm::CallGraphNode*) ()
   from /home/wesley/.rustup/toolchains/stage1/lib/librustc_driver-f866439e29074957.so
  8    Thread 0x7fffe0d39700 (LWP 3158) "opt foof.7rcbfp" 0x00007fffefe8998e in malloc_consolidate (av=av@entry=0x7ffe2c000020) at malloc.c:4492
  9    Thread 0x7fffe0f3a700 (LWP 3162) "opt foof.7rcbfp" 0x00007fffefef27c4 in __libc_open64 (file=0x7fffe0f38608 "foof.foof.7rcbfp3g-cgu.6.rcgu.o", oflag=524865) at ../sysdeps/unix/sysv/linux/open64.c:48
(gdb)
```

3 years agoUpdate measureme dependency to the latest version
Wesley Wiser [Thu, 25 Feb 2021 23:25:38 +0000 (18:25 -0500)]
Update measureme dependency to the latest version

This version adds the ability to use `rdpmc` hardware-based performance
counters instead of wall-clock time for measuring duration. This also
introduces a dependency on the `perf-event-open-sys` crate on Linux
which is used when using hardware counters.

3 years agoAuto merge of #82530 - Aaron1011:rollup-aalwq15, r=Aaron1011
bors [Thu, 25 Feb 2021 21:34:55 +0000 (21:34 +0000)]
Auto merge of #82530 - Aaron1011:rollup-aalwq15, r=Aaron1011

Rollup of 11 pull requests

Successful merges:

 - #82269 (Cleanup `PpMode` and friends)
 - #82431 (Set RUST_BACKTRACE=0 when running `treat-err-as-bug` tests)
 - #82441 (Fix typo in sanitizer flag in unstable book.)
 - #82463 (panic_bounds_checks should be panic_bounds_check)
 - #82464 (Update outdated comment in unix Command.)
 - #82467 (library: Normalize safety-for-unsafe-block comments)
 - #82468 (Move pick_by_value_method docs above function header)
 - #82484 (rustdoc: Remove duplicate "List of all items")
 - #82502 (Only look for HTML `tidy` when running rustdoc tests)
 - #82503 (fix typo in `pre-commit.sh`)
 - #82510 (Fix typo in `param_env_reveal_all_normalized`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82510 - jyn514:fix-typo, r=Dylan-DPC
Aaron Hill [Thu, 25 Feb 2021 21:06:26 +0000 (16:06 -0500)]
Rollup merge of #82510 - jyn514:fix-typo, r=Dylan-DPC

Fix typo in `param_env_reveal_all_normalized`

This made the generated docs look strange: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.param_env_reveal_all_normalized

3 years agoRollup merge of #82503 - cratelyn:patch-1, r=Mark-Simulacrum
Aaron Hill [Thu, 25 Feb 2021 21:06:25 +0000 (16:06 -0500)]
Rollup merge of #82503 - cratelyn:patch-1, r=Mark-Simulacrum

fix typo in `pre-commit.sh`

This updates a small typo I found, no more no less :slightly_smiling_face:

3 years agoRollup merge of #82502 - jyn514:tidy, r=petrochenkov
Aaron Hill [Thu, 25 Feb 2021 21:06:24 +0000 (16:06 -0500)]
Rollup merge of #82502 - jyn514:tidy, r=petrochenkov

Only look for HTML `tidy` when running rustdoc tests

This avoids printing lots of unnecessary errors, as well as making the
test suite slightly faster. This doesn't fix the windows bug tracked by https://github.com/rust-lang/rust/issues/82501, though.

r? `@petrochenkov`

3 years agoRollup merge of #82484 - bugadani:docfix, r=jyn514
Aaron Hill [Thu, 25 Feb 2021 21:06:23 +0000 (16:06 -0500)]
Rollup merge of #82484 - bugadani:docfix, r=jyn514

rustdoc: Remove duplicate "List of all items"

Closes #82477

r? `@jyn514`

3 years agoRollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkov
Aaron Hill [Thu, 25 Feb 2021 21:06:22 +0000 (16:06 -0500)]
Rollup merge of #82468 - osa1:pick_by_value_method_docs, r=petrochenkov

Move pick_by_value_method docs above function header

- Currently style triggers #81183 so we can't add `#[instrument]` to
  this function.

- Having docs above the header is more consistent with the rest of the
  code base.

3 years agoRollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytm
Aaron Hill [Thu, 25 Feb 2021 21:06:21 +0000 (16:06 -0500)]
Rollup merge of #82467 - ojeda:tidy-normalize-safety-comments, r=kennytm

library: Normalize safety-for-unsafe-block comments

Almost all safety comments are of the form `// SAFETY:`,
so normalize the rest and fix a few of them that should
have been a `/// # Safety` section instead.

Furthermore, make `tidy` only allow the uppercase form. While
currently `tidy` only checks `core`, it is a good idea to prevent
`core` from drifting to non-uppercase comments, so that later
we can start checking `alloc` etc. too.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
3 years agoRollup merge of #82464 - ehuss:unix-command-comment, r=kennytm
Aaron Hill [Thu, 25 Feb 2021 21:06:20 +0000 (16:06 -0500)]
Rollup merge of #82464 - ehuss:unix-command-comment, r=kennytm

Update outdated comment in unix Command.

The big comment in the `Command` struct has been incorrect for some time (at least since #46789 which removed `envp`). Rather than try to remove the allocations, this PR just updates the comment to reflect reality. There is an explanation for the reasoning at https://github.com/rust-lang/rust/pull/31409#issuecomment-182122895, discussing the potential of being able to call `Command::exec` after `libc::fork`.  That can still be done in the future, but I think for now it would be good to just correct the comment.

3 years agoRollup merge of #82463 - jrmuizel:patch-1, r=steveklabnik
Aaron Hill [Thu, 25 Feb 2021 21:06:19 +0000 (16:06 -0500)]
Rollup merge of #82463 - jrmuizel:patch-1, r=steveklabnik

panic_bounds_checks should be panic_bounds_check

3 years agoRollup merge of #82441 - frewsxcv:frewsxcv-docs, r=GuillaumeGomez
Aaron Hill [Thu, 25 Feb 2021 21:06:18 +0000 (16:06 -0500)]
Rollup merge of #82441 - frewsxcv:frewsxcv-docs, r=GuillaumeGomez

Fix typo in sanitizer flag in unstable book.

3 years agoRollup merge of #82431 - Aaron1011:fix/bug-env, r=jyn514
Aaron Hill [Thu, 25 Feb 2021 21:06:17 +0000 (16:06 -0500)]
Rollup merge of #82431 - Aaron1011:fix/bug-env, r=jyn514

Set RUST_BACKTRACE=0 when running `treat-err-as-bug` tests

These ensure that these tests pass regardless of what RUST_BACKTRACE is
set to in the user's shell.

3 years agoRollup merge of #82269 - LeSeulArtichaut:cleanup-ppmode, r=spastorino
Aaron Hill [Thu, 25 Feb 2021 21:06:16 +0000 (16:06 -0500)]
Rollup merge of #82269 - LeSeulArtichaut:cleanup-ppmode, r=spastorino

Cleanup `PpMode` and friends

This PR:
 - Separates `PpSourceMode` and `PpHirMode` to remove invalid states
 - Renames the variant to remove the redundant `Ppm` prefix
 - Adds basic documentation for the different pretty-print modes
 - Cleanups some code to make it more idiomatic

Not sure if this is actually useful, but it looks cleaner to me.

3 years agoAuto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obk
bors [Thu, 25 Feb 2021 18:14:50 +0000 (18:14 +0000)]
Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obk

Add #[rustc_legacy_const_generics]

This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead.

This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`.

```rust
#[rustc_legacy_const_generics(1)]
pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] {
    [x, Y, z]
}

fn main() {
    assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]);
    assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]);
}
```

r? `@oli-obk`

3 years agoDetect match statement intended to be tail expression
Esteban Küber [Thu, 28 Jan 2021 02:27:13 +0000 (18:27 -0800)]
Detect match statement intended to be tail expression

CC #24157

3 years agoAuto merge of #82517 - Dylan-DPC:rollup-a1958gb, r=Dylan-DPC
bors [Thu, 25 Feb 2021 15:15:59 +0000 (15:15 +0000)]
Auto merge of #82517 - Dylan-DPC:rollup-a1958gb, r=Dylan-DPC

Rollup of 16 pull requests

Successful merges:

 - #75807 (Convert core/num/mod.rs to intra-doc links)
 - #80534 (Use #[doc = include_str!()] in std)
 - #80553 (Add an impl of Error on `Arc<impl Error>`.)
 - #81167 (Make ptr::write const)
 - #81575 (rustdoc: Name fields of `ResolutionFailure::WrongNamespace`)
 - #81713 (Account for associated consts in the "unstable assoc item name colission" lint)
 - #82078 (Make char and u8 methods const)
 - #82087 (Fix ICE caused by suggestion with no code substitutions)
 - #82090 (Do not consider using a semicolon inside of a different-crate macro)
 - #82213 (Slices for vecs)
 - #82214 (Remove redundant to_string calls)
 - #82220 (fix the false 'defined here' messages)
 - #82313 (Update normalize.css to 8.0.1)
 - #82321 (AST: Remove some unnecessary boxes)
 - #82364 (Improve error msgs when found type is deref of expected)
 - #82514 (Update Clippy)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #82514 - flip1995:clippyup, r=Manishearth
Dylan DPC [Thu, 25 Feb 2021 13:34:05 +0000 (14:34 +0100)]
Rollup merge of #82514 - flip1995:clippyup, r=Manishearth

Update Clippy

Bi-weekly Clippy update.

This updates `Cargo.lock`, so probably needs rollup=never. (https://github.com/rust-lang/rust/commit/0046d7c33e944e87a5cabc940f21bacdce5af307)

https://github.com/rust-lang/rust/commit/a6dd9b96068800fd548a72b3aa7ac4712d1d0c49 fixes things in Clippy, so that it can be build and tested. This needs proper fixing in Clippy, but I didn't want this to block the sync.

r? `@Manishearth`

3 years agoRollup merge of #82364 - osa1:issue82361, r=estebank
Dylan DPC [Thu, 25 Feb 2021 13:34:04 +0000 (14:34 +0100)]
Rollup merge of #82364 - osa1:issue82361, r=estebank

Improve error msgs when found type is deref of expected

This improves help messages in two cases:

- When expected type is `T` and found type is `&T`, we now look through blocks
  and suggest dereferencing the expression of the block, rather than the whole
  block.

- In the above case, if the expression is an `&`, we not suggest removing the
  `&` instead of adding `*`.

Both of these are demonstrated in the regression test. Before this patch the
first error in the test would be:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^ expected `usize`, found `&usize`
    9 | |     };
      | |_____- `if` and `else` have incompatible types
      |
    help: consider dereferencing the borrow
      |
    7 |     } else *{
    8 |         b
    9 |     };
      |

Now:

    error[E0308]: `if` and `else` have incompatible types
     --> test.rs:8:9
      |
    5 | /     if true {
    6 | |         a
      | |         - expected because of this
    7 | |     } else {
    8 | |         b
      | |         ^
      | |         |
      | |         expected `usize`, found `&usize`
      | |         help: consider dereferencing the borrow: `*b`
    9 | |     };
      | |_____- `if` and `else` have incompatible types

The second error:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^^ expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types
       |
    help: consider dereferencing the borrow
       |
    13 |     } else *{
    14 |         &1
    15 |     };
       |

now:

    error[E0308]: `if` and `else` have incompatible types
      --> test.rs:14:9
       |
    11 | /     if true {
    12 | |         1
       | |         - expected because of this
    13 | |     } else {
    14 | |         &1
       | |         ^-
       | |         ||
       | |         |help: consider removing the `&`: `1`
       | |         expected integer, found `&{integer}`
    15 | |     };
       | |_____- `if` and `else` have incompatible types

Fixes #82361

---

r? ````@estebank````

3 years agoRollup merge of #82321 - bugadani:ast3, r=varkor
Dylan DPC [Thu, 25 Feb 2021 13:34:03 +0000 (14:34 +0100)]
Rollup merge of #82321 - bugadani:ast3, r=varkor

AST: Remove some unnecessary boxes

3 years agoRollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez
Dylan DPC [Thu, 25 Feb 2021 13:34:02 +0000 (14:34 +0100)]
Rollup merge of #82313 - jsha:update-normalize-css, r=GuillaumeGomez

Update normalize.css to 8.0.1

From From https://github.com/necolas/normalize.css/releases/tag/8.0.1.

The old version was 3.0.0, from 2014. The new version is from 2018.

I noticed when looking at frontend performance for rustdoc that this file was out of date. The URL in the 3.0.0 license header now resolves to an incorrect destination. And generally it seems good to be up-to-date.

Before-and-after images, plus diff, under details. TL;DR: Nothing changes except a slight adjustment to line height.

<details>

![with-normalize-8 0 1](https://user-images.githubusercontent.com/220205/108581849-bd5c8800-72e4-11eb-9150-78c8d67ca37a.png)

![with-normalize-3 0 0](https://user-images.githubusercontent.com/220205/108581848-bcc3f180-72e4-11eb-8b45-0cd1415a51e5.png)

![diff](https://user-images.githubusercontent.com/220205/108581890-dfeea100-72e4-11eb-93c5-6284492f54a9.png)

</details>

3 years agoRollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor
Dylan DPC [Thu, 25 Feb 2021 13:34:00 +0000 (14:34 +0100)]
Rollup merge of #82220 - henryboisdequin:fixes-80853, r=varkor

fix the false 'defined here' messages

Closes #80853.

Take this code:

```rust
struct S;

fn repro_ref(thing: S) {
    thing();
}
```

Previously, the error message would be this:

```
error[E0618]: expected function, found `S`
 --> src/lib.rs:4:5
  |
3 | fn repro_ref(thing: S) {
  |              ----- `S` defined here
4 |     thing();
  |     ^^^^^--
  |     |
  |     call expression requires function

error: aborting due to previous error
```

This is incorrect as `S` is not defined in the function arguments, `thing` is defined there. With this change, the following is emitted:

```
error[E0618]: expected function, found `S`
  --> $DIR/80853.rs:4:5
   |
LL | fn repro_ref(thing: S) {
   |              ----- is of type `S`
LL |     thing();
   |     ^^^^^--
   |     |
   |     call expression requires function
   |
   = note: local variable `S` is not a function

error: aborting due to previous error
```

As you can see, this error message points out that `thing` is of type `S` and later in a note, that `S` is not a function. This change does seem like a downside for some error messages. Take this example:

```
LL | struct Empty2;
   | -------------- is of type `Empty2`
```

As you can see, the error message shows that the definition of `Empty2` is of type `Empty2`. Although this isn't wrong, it would be more helpful if it would say something like this (which was there previously):

```
LL | struct Empty2;
   | -------------- `Empty2` defined here
```

If there is a better way of doing this, where the `Empty2` example would stay the same as without this change, please inform me.

**Update: This is now fixed**

CC `@camelid`

3 years agoRollup merge of #82214 - est31:no_to_string, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:59 +0000 (14:33 +0100)]
Rollup merge of #82214 - est31:no_to_string, r=oli-obk

Remove redundant to_string calls

3 years agoRollup merge of #82213 - est31:slices_for_vecs, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:58 +0000 (14:33 +0100)]
Rollup merge of #82213 - est31:slices_for_vecs, r=jyn514

Slices for vecs

3 years agoRollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank
Dylan DPC [Thu, 25 Feb 2021 13:33:57 +0000 (14:33 +0100)]
Rollup merge of #82090 - notriddle:consider-using-a-semicolon-here, r=estebank

Do not consider using a semicolon inside of a different-crate macro

Fixes #81943

3 years agoRollup merge of #82087 - estebank:abolish-ice, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:56 +0000 (14:33 +0100)]
Rollup merge of #82087 - estebank:abolish-ice, r=oli-obk

Fix ICE caused by suggestion with no code substitutions

Change suggestion logic to filter and checking _before_ creating
specific resolution suggestion.

Assert earlier that suggestions contain code substitions to make it
easier in the future to debug invalid uses. If we find this becomes too
noisy in the wild, we can always make the emitter resilient to these
cases and remove the assertions.

Fix #78651.

3 years agoRollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se
Dylan DPC [Thu, 25 Feb 2021 13:33:55 +0000 (14:33 +0100)]
Rollup merge of #82078 - lopopolo:char-u8-const-fn, r=m-ou-se

Make char and u8 methods const

char methods `len_utf8`, `len_utf16`, `to_ascii_lowercase`, `eq_ignore_ascii_case` can be made const.

`u8` methods `to_ascii_lowercase`, `to_ascii_uppercase` are required to be const as well.

`u8::eq_ignore_ascii_case` was additionally made const.

Rebase of https://github.com/rust-lang/rust/pull/79549 originally authored by ``@YenForYang.`` Changes from that PR:

- Squashed all commits from #79549.
- rebased to latest upstream master.
- Removed const attributes for `char::escape_unicode` and `char::escape_default`.
- Updated `since` attributes for `const` stabilization to 1.52.0.

cc ``@m-ou-se.``

3 years agoRollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:53 +0000 (14:33 +0100)]
Rollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obk

Account for associated consts in the "unstable assoc item name colission" lint

Fix #81663.

3 years agoRollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:52 +0000 (14:33 +0100)]
Rollup merge of #81575 - camelid:rustdoc-wrongnamespace-cleanup, r=jyn514

rustdoc: Name fields of `ResolutionFailure::WrongNamespace`

It makes it clearer that the `Namespace` is the one requested by the
disambiguator, rather than the actual namespace of the item. It said
that in the docs before, but now you can tell in the code so it reduces
the potential for confusion.

3 years agoRollup merge of #81167 - usbalbin:const_write, r=oli-obk
Dylan DPC [Thu, 25 Feb 2021 13:33:51 +0000 (14:33 +0100)]
Rollup merge of #81167 - usbalbin:const_write, r=oli-obk

Make ptr::write const

~~The code in this PR as of right now is not much more than an experiment.~~

~~This should, if I am not mistaken, in theory compile and pass the tests once the bootstraping compiler is updated. Thus the PR is blocked on that which should happen some time after the February the 9th. Also we might want to wait for #79989 to avoid regressing performance due to using `mem::forget` over `intrinsics::forget`~~.

3 years agoRollup merge of #80553 - derekdreery:arc_error, r=m-ou-se
Dylan DPC [Thu, 25 Feb 2021 13:33:50 +0000 (14:33 +0100)]
Rollup merge of #80553 - derekdreery:arc_error, r=m-ou-se

Add an impl of Error on `Arc<impl Error>`.

`Display` already exists so this should be a non-controversial change (famous last words).

Would have to be insta-stable.

3 years agoRollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514
Dylan DPC [Thu, 25 Feb 2021 13:33:47 +0000 (14:33 +0100)]
Rollup merge of #80534 - LeSeulArtichaut:doc-include, r=jyn514

Use #[doc = include_str!()] in std

cc https://github.com/rust-lang/rust/issues/78835#issuecomment-742531894
r? `````@jyn514`````

3 years agoRollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics
Dylan DPC [Thu, 25 Feb 2021 13:33:44 +0000 (14:33 +0100)]
Rollup merge of #75807 - jyn514:num-intra-link, r=poliorcetics

Convert core/num/mod.rs to intra-doc links

Helps with #75080.
This can't convert the associated constants `MAX` and `MIN` until #74489 is merged.

r? `@poliorcetics`

3 years agoAuto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514
bors [Thu, 25 Feb 2021 12:33:21 +0000 (12:33 +0000)]
Auto merge of #82265 - GuillaumeGomez:cleanup-attrs-twice, r=jyn514

Prevent to compute Item attributes twice

I came across this case when working on another part of rustdoc. Not a game changer but a nice little improvement.

cc `@camelid`

r? `@jyn514`

3 years agoadd helpful error notes and fix the false 'defined here' messages
Henry Boisdequin [Wed, 17 Feb 2021 14:50:59 +0000 (20:20 +0530)]
add helpful error notes and fix the false 'defined here' messages