]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoUpdate cargo
Arlo Siemsen [Wed, 25 May 2022 17:31:30 +0000 (10:31 -0700)]
Update cargo

2 years agoAuto merge of #97388 - Dylan-DPC:rollup-tfuc4tf, r=Dylan-DPC
bors [Wed, 25 May 2022 11:17:34 +0000 (11:17 +0000)]
Auto merge of #97388 - Dylan-DPC:rollup-tfuc4tf, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95953 (Modify MIR building to drop repeat expressions with length zero)
 - #96913 (RFC3239: Implement `cfg(target)` - Part 2)
 - #97233 ([RFC 2011] Library code)
 - #97370 (Minor improvement on else-no-if diagnostic)
 - #97384 (Fix metadata stats.)

Failed merges:

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

2 years agoRollup merge of #97384 - nnethercote:fix-metadata-stats, r=bjorn3
Dylan DPC [Wed, 25 May 2022 08:48:31 +0000 (10:48 +0200)]
Rollup merge of #97384 - nnethercote:fix-metadata-stats, r=bjorn3

Fix metadata stats.

This commit:
- Counts some things that weren't being counted previously, and adds
  an assertion that ensure everything is counted.
- Reorders things so the `eprintln`s order matches the code order.
- Adds percentages, and makes clear that the zero bytes count is orthogonal to
  the other measurements.

Example of the new output:
```
55463779 metadata bytes, of which 18054531 bytes (32.6%) are zero
             preamble:       30 bytes ( 0.0%)
                  dep:        0 bytes ( 0.0%)
          lib feature:    17458 bytes ( 0.0%)
            lang item:      337 bytes ( 0.0%)
      diagnostic item:     1788 bytes ( 0.0%)
           native lib:        0 bytes ( 0.0%)
      foreign modules:     5113 bytes ( 0.0%)
       def-path table:   720180 bytes ( 1.3%)
               traits:      359 bytes ( 0.0%)
                impls:    64624 bytes ( 0.1%)
     incoherent_impls:      130 bytes ( 0.0%)
                  mir: 16137354 bytes (29.1%)
                 item: 23773099 bytes (42.9%)
interpret_alloc_index:      599 bytes ( 0.0%)
      proc-macro-data:        0 bytes ( 0.0%)
               tables: 10081135 bytes (18.2%)
 debugger visualizers:        0 bytes ( 0.0%)
     exported symbols:     5666 bytes ( 0.0%)
              hygiene:  1539390 bytes ( 2.8%)
      def-path hashes:  2752564 bytes ( 5.0%)
           source_map:   363540 bytes ( 0.7%)
                final:      413 bytes ( 0.0%)
```
r? `@bjorn3`

2 years agoRollup merge of #97370 - compiler-errors:else-no-if-2, r=Dylan-DPC
Dylan DPC [Wed, 25 May 2022 08:48:30 +0000 (10:48 +0200)]
Rollup merge of #97370 - compiler-errors:else-no-if-2, r=Dylan-DPC

Minor improvement on else-no-if diagnostic

Don't suggest wrapping in block since it's highly likely to be a missing `if` after `else`. Also rework message a bit (open to further suggestions).

cc: https://github.com/rust-lang/rust/pull/97298#discussion_r880933431

r? `@estebank`

2 years agoRollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm
Dylan DPC [Wed, 25 May 2022 08:48:29 +0000 (10:48 +0200)]
Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm

[RFC 2011] Library code

CC https://github.com/rust-lang/rust/pull/96496

Based on https://github.com/dtolnay/case-studies/tree/master/autoref-specialization.

Basically creates two traits with the same method name. One trait is generic over any `T` and the other is specialized to any `T: Printable`.

The compiler will then call the corresponding trait method through auto reference.

```rust
fn main() {
    let mut a = Capture::new();
    let mut b = Capture::new();

    (&Wrapper(&1i32)).try_capture(&mut a); // `try_capture` from `TryCapturePrintable`
    (&Wrapper(&vec![1i32])).try_capture(&mut b); // `try_capture` from `TryCaptureGeneric`

    assert_eq!(format!("{:?}", a), "1");
    assert_eq!(format!("{:?}", b), "N/A");
}
```

r? `@scottmcm`

2 years agoRollup merge of #96913 - Urgau:rfc3239-part2, r=petrochenkov
Dylan DPC [Wed, 25 May 2022 08:48:28 +0000 (10:48 +0200)]
Rollup merge of #96913 - Urgau:rfc3239-part2, r=petrochenkov

RFC3239: Implement `cfg(target)` - Part 2

This pull-request implements the compact `cfg(target(..))` part of [RFC 3239](https://github.com/rust-lang/rust/issues/96901).

I recommend reviewing this PR on a per commit basics, because of some moving parts.

cc `@GuillaumeGomez`
r? `@petrochenkov`

2 years agoRollup merge of #95953 - JakobDegen:repeat-leak, r=oli-obk
Dylan DPC [Wed, 25 May 2022 08:48:27 +0000 (10:48 +0200)]
Rollup merge of #95953 - JakobDegen:repeat-leak, r=oli-obk

Modify MIR building to drop repeat expressions with length zero

Closes #74836 .

Previously, when a user wrote `[foo; 0]` we used to simply leak `foo`. The goal is to fix that. This PR changes MIR building to make `[foo; 0]` equivalent to `{ drop(foo); [] }` in all cases. Of course, this is a breaking change (see below). A crater run did not indicate any regressions though, and given that the previous behavior was almost definitely not what any user wanted, it seems unlikely that anyone was relying on this.

Note that const generics are in general unaffected by this. Inserting the extra `drop` is only meaningful/necessary when `foo` is of a non-`Copy` type, and array repeat expressions with const generic repetition count must always be `Copy`.

Besides the obvious change to behavior associated with the additional drop, there are three categories of examples where this also changes observable behavior. In all of these cases, the new behavior is consistent with what you would get by replacing `[foo; 0]` with `{ drop(foo); [] }`. As such, none of these give the user new powers to express more things.

**No longer allowed in const (breaking)**:

```rust
const _: [String; 0] = [String::new(); 0];
```

This compiles on stable today. Because we now introduce the drop of `String`, this no longer compiles as `String` may not be dropped in a const context.

**Reduced dataflow (non-breaking)**:

```rust
let mut x: i32 = 0;
let r = &x;
let a = [r; 0];
x = 5;
let _b = a;
```

Borrowck rejects this code on stable because it believes there is dataflow between `a` and `r`, and so the lifetime of `r` has to extend to the last statement. This change removes the dataflow and the above code is allowed to compile.

**More const promotion (non-breaking)**:

```rust
let _v: &'static [String; 0] = &[String::new(); 0];
```

This does not compile today because `String` having drop glue keeps it from being const promoted (despite that drop glue never being executed). After this change, this is allowed to compile.

### Alternatives

A previous attempt at this tried to reduce breakage by various tricks. This is still a possibility, but given that crater showed no regressions it seems unclear why we would want to introduce this complexity.

Disallowing `[foo; 0]` completely is also an option, but obviously this is more of a breaking change. I do not know how often this is actually used though.

r? `@oli-obk`

2 years agoAuto merge of #97345 - lcnr:fast_reject, r=nnethercote
bors [Wed, 25 May 2022 08:36:46 +0000 (08:36 +0000)]
Auto merge of #97345 - lcnr:fast_reject, r=nnethercote

add a deep fast_reject routine

continues the work on #97136.

r? `@nnethercote`

Actually agree with you on the match structure :laughing: let's see how that impacted perf :sweat_smile:

2 years agoFix metadata stats.
Nicholas Nethercote [Wed, 25 May 2022 06:24:07 +0000 (16:24 +1000)]
Fix metadata stats.

This commit:
- Counts some things that weren't being counted previously, and adds
  an assertion that ensure everything is counted.
- Reorders things so the `eprintln`s order matches the code order.
- Adds percentages, and makes clear that the zero bytes count is orthogonal to
  the other measurements.

Example of the new output:
```
55463779 metadata bytes, of which 18054531 bytes (32.6%) are zero
             preamble:       30 bytes ( 0.0%)
                  dep:        0 bytes ( 0.0%)
          lib feature:    17458 bytes ( 0.0%)
            lang item:      337 bytes ( 0.0%)
      diagnostic item:     1788 bytes ( 0.0%)
           native lib:        0 bytes ( 0.0%)
      foreign modules:     5113 bytes ( 0.0%)
       def-path table:   720180 bytes ( 1.3%)
               traits:      359 bytes ( 0.0%)
                impls:    64624 bytes ( 0.1%)
     incoherent_impls:      130 bytes ( 0.0%)
                  mir: 16137354 bytes (29.1%)
                 item: 23773099 bytes (42.9%)
interpret_alloc_index:      599 bytes ( 0.0%)
      proc-macro-data:        0 bytes ( 0.0%)
               tables: 10081135 bytes (18.2%)
 debugger visualizers:        0 bytes ( 0.0%)
     exported symbols:     5666 bytes ( 0.0%)
              hygiene:  1539390 bytes ( 2.8%)
      def-path hashes:  2752564 bytes ( 5.0%)
           source_map:   363540 bytes ( 0.7%)
                final:      413 bytes ( 0.0%)
```

2 years agoAuto merge of #97382 - Dylan-DPC:rollup-2t4ov4z, r=Dylan-DPC
bors [Wed, 25 May 2022 06:14:15 +0000 (06:14 +0000)]
Auto merge of #97382 - Dylan-DPC:rollup-2t4ov4z, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93604 (Make llvm-libunwind a per-target option)
 - #97026 (Change orderings of `Debug` for the Atomic types to `Relaxed`.)
 - #97105 (Add tests for lint on type dependent on consts)
 - #97323 (Introduce stricter checks for might_permit_raw_init under a debug flag )
 - #97379 (Add aliases for `current_dir`)

Failed merges:

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

2 years agomove fast reject test out of `SelectionContext::match_impl`.
lcnr [Tue, 24 May 2022 07:22:24 +0000 (09:22 +0200)]
move fast reject test out of `SelectionContext::match_impl`.

`match_impl` has two call sites. For one of them (within `rematch_impl`)
the fast reject test isn't necessary, because any rejection would
represent a compiler bug.

This commit moves the fast reject test to the other `match_impl` call
site, in `assemble_candidates_from_impls`. This lets us move the fast
reject test outside the `probe` call in that function. This avoids the
taking of useless snapshots when the fast reject test succeeds, which
gives a performance win when compiling the `bitmaps` and `nalgebra`
crates.

Co-authored-by: name <n.nethercote@gmail.com>
2 years agoadd a deep fast_reject routine
lcnr [Tue, 24 May 2022 07:15:19 +0000 (09:15 +0200)]
add a deep fast_reject routine

2 years agoRollup merge of #97379 - ear7h:master, r=thomcc
Dylan DPC [Wed, 25 May 2022 05:31:45 +0000 (07:31 +0200)]
Rollup merge of #97379 - ear7h:master, r=thomcc

Add aliases for `current_dir`

Aliases were added for the equivalent C/C++ APIs for POSIX and Windows. Also, I added one for `pwd` which users may be more familiar with, from the command line.

2 years agoRollup merge of #97323 - 5225225:strict_init_checks, r=oli-obk
Dylan DPC [Wed, 25 May 2022 05:31:44 +0000 (07:31 +0200)]
Rollup merge of #97323 - 5225225:strict_init_checks, r=oli-obk

Introduce stricter checks for might_permit_raw_init under a debug flag

This is intended to be a version of the strict checks tried out in #79296, but also checking number validity (under the assumption that `let _ = std::mem::uninitialized::<u32>()` is UB, which seems to be what https://github.com/rust-lang/unsafe-code-guidelines/issues/71 is leaning towards.)

2 years agoRollup merge of #97105 - JulianKnodt:const_dep_gen_const_expr, r=lcnr
Dylan DPC [Wed, 25 May 2022 05:31:43 +0000 (07:31 +0200)]
Rollup merge of #97105 - JulianKnodt:const_dep_gen_const_expr, r=lcnr

Add tests for lint on type dependent on consts

r? `@lcnr`

2 years agoRollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm
Dylan DPC [Wed, 25 May 2022 05:31:42 +0000 (07:31 +0200)]
Rollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm

Change orderings of `Debug` for the Atomic types to `Relaxed`.

This reduces synchronization between threads when debugging the atomic types.  Reducing the synchronization means that executions with and without the debug calls will be more consistent, making it easier to debug.

We discussed this on the Rust Community Discord with `@ibraheemdev` before.

2 years agoRollup merge of #93604 - tmandry:libunwind-fuchsia-default, r=Mark-Simulacrum
Dylan DPC [Wed, 25 May 2022 05:31:41 +0000 (07:31 +0200)]
Rollup merge of #93604 - tmandry:libunwind-fuchsia-default, r=Mark-Simulacrum

Make llvm-libunwind a per-target option

Fuchsia doesn't ship libunwind in its SDK, so we must provide it statically.

2 years agoAuto merge of #97376 - compiler-errors:lazy-polymorphic, r=jackh726
bors [Wed, 25 May 2022 03:53:39 +0000 (03:53 +0000)]
Auto merge of #97376 - compiler-errors:lazy-polymorphic, r=jackh726

Make `Lazy*<T>` types in `rustc_metadata` not care about lifetimes until decode

This allows us to remove the `'tcx` lifetime from `CrateRoot`. This is necessary because of #97287, which makes the `'tcx` lifetime on `Ty` invariant instead of covariant, so [this hack](https://github.com/rust-lang/rust/blob/0a437b2ca081bc12425a3318cb66aade9824cbae/compiler/rustc_metadata/src/rmeta/decoder.rs#L89-92) no longer holds under that PR.

Introduces a trait called `ParameterizedOverTcx` which has a generic associated type that allows a type to be parameterized over that lifetime. This means we can decode, for example, `Lazy<Ty<'static>>` into any `Ty<'tcx>` depending on the `TyCtxt<'tcx>` we pass into the decode function.

2 years agoadd aliases for current_dir
julio [Wed, 25 May 2022 02:41:40 +0000 (19:41 -0700)]
add aliases for current_dir

2 years agoAuto merge of #97365 - klensy:rustdoc-vs-clippy, r=notriddle
bors [Wed, 25 May 2022 01:12:54 +0000 (01:12 +0000)]
Auto merge of #97365 - klensy:rustdoc-vs-clippy, r=notriddle

rustdoc: fix few clippy lints

Fix few clippy lints: second commit - perf ones, first - other ones.

2 years agoMake llvm-libunwind a per-target option
Tyler Mandry [Wed, 2 Feb 2022 22:48:09 +0000 (22:48 +0000)]
Make llvm-libunwind a per-target option

2 years agoMake Lazy not care about lifetimes until decode
Michael Goulet [Sun, 22 May 2022 19:34:34 +0000 (12:34 -0700)]
Make Lazy not care about lifetimes until decode

2 years agoAuto merge of #97372 - JohnTitor:rollup-6owv1v0, r=JohnTitor
bors [Tue, 24 May 2022 22:32:57 +0000 (22:32 +0000)]
Auto merge of #97372 - JohnTitor:rollup-6owv1v0, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #93966 (document expectations for Waker::wake)
 - #97266 (Make weird name lints trigger behind cfg_attr)
 - #97355 (Remove unused brush image)
 - #97358 (Update minifier-rs version to 0.1.0)
 - #97363 (Fix a small mistake in `SliceIndex`'s documentation)
 - #97364 (Fix weird indentation in continue_keyword docs)

Failed merges:

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

2 years agoMinor improvement on else-no-if diagnostic
Michael Goulet [Tue, 24 May 2022 21:14:41 +0000 (14:14 -0700)]
Minor improvement on else-no-if diagnostic

2 years agoRollup merge of #97364 - notriddle:continue-keyword, r=JohnTitor
Yuki Okushi [Tue, 24 May 2022 22:08:45 +0000 (07:08 +0900)]
Rollup merge of #97364 - notriddle:continue-keyword, r=JohnTitor

Fix weird indentation in continue_keyword docs

This format was causing every line in the code examples to have a space at the start.

2 years agoRollup merge of #97363 - wackbyte:sliceindex-doc-typo, r=JohnTitor
Yuki Okushi [Tue, 24 May 2022 22:08:44 +0000 (07:08 +0900)]
Rollup merge of #97363 - wackbyte:sliceindex-doc-typo, r=JohnTitor

Fix a small mistake in `SliceIndex`'s documentation

Originally, it said "`get_(mut_)unchecked`," but the method's actual name is `get_unchecked_mut`.

2 years agoRollup merge of #97358 - GuillaumeGomez:update-minifier, r=Dylan-DPC
Yuki Okushi [Tue, 24 May 2022 22:08:44 +0000 (07:08 +0900)]
Rollup merge of #97358 - GuillaumeGomez:update-minifier, r=Dylan-DPC

Update minifier-rs version to 0.1.0

It fixes a bug with regex parsing.

r? `@notriddle`

2 years agoRollup merge of #97355 - GuillaumeGomez:remove-brush, r=Dylan-DPC
Yuki Okushi [Tue, 24 May 2022 22:08:43 +0000 (07:08 +0900)]
Rollup merge of #97355 - GuillaumeGomez:remove-brush, r=Dylan-DPC

Remove unused brush image

r? `@notriddle`

2 years agoRollup merge of #97266 - est31:unknown_lints_cfg_attr, r=lcnr
Yuki Okushi [Tue, 24 May 2022 22:08:42 +0000 (07:08 +0900)]
Rollup merge of #97266 - est31:unknown_lints_cfg_attr, r=lcnr

Make weird name lints trigger behind cfg_attr

The weird name lints (`unknown_lints`, `renamed_and_removed_lints`), the lints that lint the linting, were previously not firing for lint level declarations behind `cfg_attr`, as they were only running before expansion.

Now, this will give a `unknown_lints` warning:

```Rust
#[cfg_attr(all(), allow(this_lint_does_not_exist))]
fn foo() {}
```

Lint level declarations behind a `cfg_attr` whose condition is not applying are still ignored. So this still won't give a warning:

```Rust
#[cfg_attr(any(), allow(this_lint_does_not_exist))]
fn foo() {}
```

Furthermore, this PR also makes the weird name lints respect level delcarations for *them* that were hidden by `cfg_attr`, making them consistent to other lints. So this will now not issue a warning:

```Rust
#[cfg_attr(all(), allow(unknown_lints))]
mod foo {
    #[allow(does_not_exist)]
    fn foo() {
    }
}
```

Fixes #97094

2 years agoRollup merge of #93966 - rkuhn:patch-1, r=tmandry
Yuki Okushi [Tue, 24 May 2022 22:08:41 +0000 (07:08 +0900)]
Rollup merge of #93966 - rkuhn:patch-1, r=tmandry

document expectations for Waker::wake

fixes #93961

Opened PR for a discussion on the precise wording.

2 years agoModify MIR building to drop `foo` in `[foo; 0]`
Jakob Degen [Wed, 13 Apr 2022 11:08:58 +0000 (07:08 -0400)]
Modify MIR building to drop `foo` in `[foo; 0]`

2 years agoAuto merge of #97360 - RalfJung:rustup, r=RalfJung
bors [Tue, 24 May 2022 19:05:20 +0000 (19:05 +0000)]
Auto merge of #97360 - RalfJung:rustup, r=RalfJung

update Miri

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

2 years agoFix weird indentation in continue_keyword docs
Michael Howell [Tue, 24 May 2022 18:09:24 +0000 (11:09 -0700)]
Fix weird indentation in continue_keyword docs

This format was causing every line in the code examples to have a space
at the start.

2 years agofix clippy perf lints
klensy [Tue, 24 May 2022 17:35:54 +0000 (13:35 -0400)]
fix clippy perf lints

2 years agoFix a mistake in `SliceIndex`'s documentation
wackbyte [Tue, 24 May 2022 17:22:41 +0000 (13:22 -0400)]
Fix a mistake in `SliceIndex`'s documentation

2 years agofix simple clippy lints
klensy [Sat, 21 May 2022 18:07:18 +0000 (14:07 -0400)]
fix simple clippy lints

2 years agoAuto merge of #97356 - Dylan-DPC:rollup-bhceawj, r=Dylan-DPC
bors [Tue, 24 May 2022 16:23:32 +0000 (16:23 +0000)]
Auto merge of #97356 - Dylan-DPC:rollup-bhceawj, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #97288 (Lifetime variance fixes for rustdoc)
 - #97298 (Parse expression after `else` as a condition if followed by `{`)
 - #97308 (Stabilize `cell_filter_map`)
 - #97321 (explain how to turn integers into fn ptrs)

Failed merges:

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

2 years agoupdate Miri
Ralf Jung [Tue, 24 May 2022 15:44:11 +0000 (17:44 +0200)]
update Miri

2 years agoEmit weird lint name lints after expansion
est31 [Sun, 22 May 2022 02:25:40 +0000 (04:25 +0200)]
Emit weird lint name lints after expansion

Previously, we were emitting weird name lints (for renamed or unknown lints)
before expansion, most importantly before cfg expansion.
This meant that the weird name lints would not fire
for lint attributes hidden inside cfg_attr. The same applied
for lint level specifications of those lints.

By moving the lints for the lint names to the post-expansion
phase, these issues are resolved.

2 years agoUpdate minifier-rs version to 0.1.0
Guillaume Gomez [Tue, 24 May 2022 14:55:29 +0000 (16:55 +0200)]
Update minifier-rs version to 0.1.0

2 years agoRollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC
Dylan DPC [Tue, 24 May 2022 13:58:26 +0000 (15:58 +0200)]
Rollup merge of #97321 - RalfJung:int-to-fnptr, r=Dylan-DPC

explain how to turn integers into fn ptrs

(with an intermediate raw ptr, not a direct transmute)
Direct int2ptr transmute, under the semantics I am imagining, will produce a ptr with "invalid" provenance that is invalid to deref or call. We cannot give it the same semantics as int2ptr casts since those do [something complicated](https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html).

To my great surprise, that is already what the example in the `transmute` docs does. :)  I still added a comment to say that that part is important, and I added a section explicitly talking about this to the `fn()` type docs.

With https://github.com/rust-lang/miri/pull/2151, Miri will start complaining about direct int-to-fnptr transmutes (in the sense that it is UB to call the resulting pointer).

2 years agoRollup merge of #97308 - JohnTitor:stabilize-cell-filter-map, r=Mark-Simulacrum
Dylan DPC [Tue, 24 May 2022 13:58:25 +0000 (15:58 +0200)]
Rollup merge of #97308 - JohnTitor:stabilize-cell-filter-map, r=Mark-Simulacrum

Stabilize `cell_filter_map`

FCP has been completed: https://github.com/rust-lang/rust/issues/81061#issuecomment-1081806326
Closes #81061

2 years agoRollup merge of #97298 - compiler-errors:if-else-stmt-braces, r=davidtwco
Dylan DPC [Tue, 24 May 2022 13:58:24 +0000 (15:58 +0200)]
Rollup merge of #97298 - compiler-errors:if-else-stmt-braces, r=davidtwco

Parse expression after `else` as a condition if followed by `{`

Fixes #49361.

Two things:
1. This wording needs help. I can never find a natural/intuitive phrasing when I write diagnostics :sweat_smile:
2. Do we even want to show the "wrap in braces" case? I would assume most of the time the "add an `if`" case is the right one.

2 years agoRollup merge of #97288 - compiler-errors:tcxify-rustdoc, r=Dylan-DPC
Dylan DPC [Tue, 24 May 2022 13:58:24 +0000 (15:58 +0200)]
Rollup merge of #97288 - compiler-errors:tcxify-rustdoc, r=Dylan-DPC

Lifetime variance fixes for rustdoc

#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime.

This is doable, since everything is already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from #97287 so the rustdoc team can review independently.

2 years agoRemove unused brush image
Guillaume Gomez [Tue, 24 May 2022 13:55:01 +0000 (15:55 +0200)]
Remove unused brush image

2 years agoAuto merge of #97291 - compiler-errors:lazy-is-actually-3-types-in-a-trenchcoat,...
bors [Tue, 24 May 2022 13:42:33 +0000 (13:42 +0000)]
Auto merge of #97291 - compiler-errors:lazy-is-actually-3-types-in-a-trenchcoat, r=cjgillot

Split out the various responsibilities of `rustc_metadata::Lazy`

`Lazy<T>` actually acts like three different types -- a pointer in the crate metadata to a single value, a pointer to a list/array of values, and an indexable pointer of a list of values (a table).

We currently overload `Lazy<T>` to work differently than `Lazy<[T]>` and the same for `Lazy<Table<I, T>>`. All is well with some helper adapter traits such as [`LazyQueryDecodable`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/trait.LazyQueryDecodable.html) and [`EncodeContentsForLazy`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/encoder/trait.EncodeContentsForLazy.html).

Well, changes in #97287 that make `Lazy` work with the now invariant lifetime `'tcx` make these adapters fall apart because of coherence reasons. So we split out these three types and rework some of the helper traits so it's both 1. more clear to understand, and 2. compatible with the changes later in that PR.

Split out from #97287 so it can be reviewed separately, since this PR stands on its own.

2 years agoAdd flag for stricter checks on uninit/zeroed
5225225 [Mon, 23 May 2022 15:44:05 +0000 (16:44 +0100)]
Add flag for stricter checks on uninit/zeroed

2 years agoRFC3239: Add tests for compact `cfg(target(..))`
Loïc BRANSTETT [Mon, 25 Apr 2022 10:07:21 +0000 (12:07 +0200)]
RFC3239: Add tests for compact `cfg(target(..))`

2 years agoRFC3239: Implement compact `cfg(target(..))`
Loïc BRANSTETT [Fri, 22 Apr 2022 14:34:56 +0000 (16:34 +0200)]
RFC3239: Implement compact `cfg(target(..))`

2 years agoClean up condition evaluation system
Loïc BRANSTETT [Fri, 22 Apr 2022 10:52:51 +0000 (12:52 +0200)]
Clean up condition evaluation system

2 years agoAuto merge of #97121 - pvdrz:do-subdiagnostics-later, r=davidtwco
bors [Tue, 24 May 2022 10:25:13 +0000 (10:25 +0000)]
Auto merge of #97121 - pvdrz:do-subdiagnostics-later, r=davidtwco

Avoid double binding of subdiagnostics inside `#[derive(SessionDiagnostic)]`

r? `@davidtwco`

2 years agoAuto merge of #96098 - JakobDegen:always-return-place, r=oli-obk
bors [Tue, 24 May 2022 07:13:26 +0000 (07:13 +0000)]
Auto merge of #96098 - JakobDegen:always-return-place, r=oli-obk

Refactor call terminator to always include destination place

In #71117 people seemed to agree that call terminators should always have a destination place, even if the call was guaranteed to diverge. This implements that. Unsurprisingly, the diff touches a lot of code, but thankfully I had to do almost nothing interesting. The only interesting thing came up in const prop, where the stack frame having no return place was also used to indicate that the layout could not be computed (or similar). I replaced this with a ZST allocation, which should continue to do the right things.

cc `@RalfJung` `@eddyb` who were involved in the original conversation

r? rust-lang/mir-opt

2 years agoCoalesce branches
kadmin [Thu, 19 May 2022 18:53:01 +0000 (18:53 +0000)]
Coalesce branches

Move a bunch of branches together into one if block, for easier reading.

Resolve comments

Attempt to make some branches unreachable [tmp]

Revert unreachable branches

2 years agoAuto merge of #97342 - JohnTitor:rollup-zqxctaw, r=JohnTitor
bors [Tue, 24 May 2022 04:32:42 +0000 (04:32 +0000)]
Auto merge of #97342 - JohnTitor:rollup-zqxctaw, r=JohnTitor

Rollup of 5 pull requests

Successful merges:

 - #97240 (Typo suggestion for a variable with a name similar to struct fields)
 - #97289 (Lifetime variance fixes for clippy)
 - #97290 (Turn on `fast_submodules` unconditionally)
 - #97336 (typo)
 - #97337 (Fix stabilization version of `Ipv6Addr::to_ipv4_mapped`)

Failed merges:

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

2 years agoParse expression after `else` as a condition if followed by `{`
Michael Goulet [Sun, 22 May 2022 23:06:36 +0000 (16:06 -0700)]
Parse expression after `else` as a condition if followed by `{`

2 years agoRollup merge of #97337 - tbu-:pr_fix_stabilization_ipv4_mapped, r=Mark-Simulacrum
Yuki Okushi [Tue, 24 May 2022 03:18:34 +0000 (12:18 +0900)]
Rollup merge of #97337 - tbu-:pr_fix_stabilization_ipv4_mapped, r=Mark-Simulacrum

Fix stabilization version of `Ipv6Addr::to_ipv4_mapped`

2 years agoRollup merge of #97336 - tshepang:typo, r=cjgillot
Yuki Okushi [Tue, 24 May 2022 03:18:33 +0000 (12:18 +0900)]
Rollup merge of #97336 - tshepang:typo, r=cjgillot

typo

2 years agoRollup merge of #97290 - jyn514:fast-submodules, r=Mark-Simulacrum
Yuki Okushi [Tue, 24 May 2022 03:18:32 +0000 (12:18 +0900)]
Rollup merge of #97290 - jyn514:fast-submodules, r=Mark-Simulacrum

Turn on `fast_submodules` unconditionally

I don't know why anyone would turn this off; doing so makes builds much slower (nearly a 60x slowdown according to #49057).
Remove the option to do so, which makes bootstrap a little easier to maintain.

Bootstrap continues to allow you to manage submodules manually by setting `submodules = false`.

2 years agoRollup merge of #97289 - compiler-errors:tcxify-clippy, r=Mark-Simulacrum
Yuki Okushi [Tue, 24 May 2022 03:18:31 +0000 (12:18 +0900)]
Rollup merge of #97289 - compiler-errors:tcxify-clippy, r=Mark-Simulacrum

Lifetime variance fixes for clippy

#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be shortened to some common lifetime.

This is doable, since everything is already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from #97287 so the clippy team can review independently.

2 years agoRollup merge of #97240 - TaKO8Ki:improve-errors-about-typos-on-variables, r=compiler...
Yuki Okushi [Tue, 24 May 2022 03:18:30 +0000 (12:18 +0900)]
Rollup merge of #97240 - TaKO8Ki:improve-errors-about-typos-on-variables, r=compiler-errors

Typo suggestion for a variable with a name similar to struct fields

closes #97133

2 years agoFix iterator implementation, add some inlines
Michael Goulet [Tue, 24 May 2022 02:50:29 +0000 (19:50 -0700)]
Fix iterator implementation, add some inlines

2 years agorefine comments, disambiguate len for array and tables
Michael Goulet [Sun, 22 May 2022 23:46:23 +0000 (16:46 -0700)]
refine comments, disambiguate len for array and tables

2 years agosplit out the various responsibilities of Lazy
Michael Goulet [Sun, 22 May 2022 18:16:14 +0000 (11:16 -0700)]
split out the various responsibilities of Lazy

2 years agoTurn on `fast_submodules` unconditionally
Joshua Nelson [Sun, 22 May 2022 20:51:15 +0000 (15:51 -0500)]
Turn on `fast_submodules` unconditionally

I don't know why anyone would turn this off; doing so makes builds much slower (nearly a 60x slowdown according to #49057).
Remove the option to do so, which makes bootstrap a little easier to maintain.

Bootstrap continues to allow you to manage submodules manually by setting `submodules = false`.

2 years agoAuto merge of #97272 - jackh726:ban-compare-mode-nll, r=Mark-Simulacrum
bors [Tue, 24 May 2022 01:52:00 +0000 (01:52 +0000)]
Auto merge of #97272 - jackh726:ban-compare-mode-nll, r=Mark-Simulacrum

Disallow compare-mode=nll test differences

This ensures that new tests don't get added not as revisions if they have nll output. This will make stabilization PR easier.

r? `@Mark-Simulacrum`

2 years agoFix stabilization version of `Ipv6Addr::to_ipv4_mapped`
Tobias Bucher [Mon, 23 May 2022 23:05:06 +0000 (01:05 +0200)]
Fix stabilization version of `Ipv6Addr::to_ipv4_mapped`

2 years agoRefactor call terminator to always hold a destination place
Jakob Degen [Sat, 16 Apr 2022 13:27:54 +0000 (09:27 -0400)]
Refactor call terminator to always hold a destination place

2 years agotypo
Tshepang Lekhonkhobe [Mon, 23 May 2022 20:51:34 +0000 (22:51 +0200)]
typo

2 years agoAuto merge of #97120 - Kobzol:rustc-pgo-expansion, r=Mark-Simulacrum
bors [Mon, 23 May 2022 20:50:23 +0000 (20:50 +0000)]
Auto merge of #97120 - Kobzol:rustc-pgo-expansion, r=Mark-Simulacrum

Update `rustc` PGO benchmark list

I noticed that the `rustc` PGO crates do not contain any crate that would stress the trait system. I tried adding and removing various crates to the PGO benchmark list here. Here's what I found:

- Removing [`externs` and `match-stress`](https://perf.rust-lang.org/compare.html?start=c0672870491e84362f76ddecd50fa229f9b06dff&end=b056963e0324fa76c721d79f12658a64cfa4cb5e&stat=instructions:u) regresses these two benchmarks by up to 15 % and removing them doesn't improve anything else, so we should keep them.
- Adding [`keccak`](https://perf.rust-lang.org/compare.html?start=52cc7795245347500ddf6dc959cf58a7abe2d935&end=6fd27b23fd7860c79752479173b4a1b877cba490) regresses `diesel`, otherwise it doesn't do much.
- Adding [`tt-muncher`](https://perf.rust-lang.org/compare.html?start=c0672870491e84362f76ddecd50fa229f9b06dff&end=2ab5994d9cdfb098344895f7d8d5aee3cf3d6eff&stat=instructions:u) improves it very slightly, not worth it to include it IMO.
- Adding just [`diesel`](https://perf.rust-lang.org/compare.html?start=00755e4ca68f12ed200e921276788ab19975e85f&end=cd37706ad459ee8ddfda4631be71120cb7eda19d) improves it by up to 1.5 % and others crate slightly, but regresses `bitmaps`.
- Adding [`bitmaps`](https://perf.rust-lang.org/compare.html?start=67a9bcb31b85e87cc8bb327022632e48a0ca64a8&end=0cd80ba74425e6614cd52c4ea2bf6b0191c6dbc4&stat=instructions:u) improves both it and diesel, no other regressions.
- Adding [both](https://perf.rust-lang.org/compare.html?start=77972d2d0134fb597249b3b64dcf9510a790c34e&end=f968d7af511d750db96cfdc04f844fb017c079ce) `bitmaps` and `diesel` produces quite nice improvements and almost no regressions.
- Adding [ucd](https://perf.rust-lang.org/compare.html?start=b5caa5a8421f84cb7664f999b7635801bcf3f96a&end=327cc09917311f65cf427e6c0bf5f7424af9fd05&stat=instructions:u) did not have a large effect on primary benchmarks.

r? `@lqd`

2 years agoAuto merge of #94053 - GuillaumeGomez:fields-stripped, r=notriddle
bors [Mon, 23 May 2022 18:26:42 +0000 (18:26 +0000)]
Auto merge of #94053 - GuillaumeGomez:fields-stripped, r=notriddle

rustdoc: Remove fields_stripped fields (and equivalents)

Fixes #90588.

r? `@camelid`

2 years agosync primitive_docs
Ralf Jung [Mon, 23 May 2022 17:09:23 +0000 (19:09 +0200)]
sync primitive_docs

2 years agoexplain how to turn integers into fn ptrs
Ralf Jung [Mon, 23 May 2022 16:47:05 +0000 (18:47 +0200)]
explain how to turn integers into fn ptrs

(with an intermediate raw ptr, not a direct transmute)

2 years agoLifetime variance fixes for clippy
Michael Goulet [Mon, 23 May 2022 15:48:17 +0000 (08:48 -0700)]
Lifetime variance fixes for clippy

2 years agoAdd bitmaps and diesel to `rustc` PGO benchmarks
Jakub Beránek [Mon, 23 May 2022 15:55:50 +0000 (17:55 +0200)]
Add bitmaps and diesel to `rustc` PGO benchmarks

2 years agoAuto merge of #97315 - Dylan-DPC:rollup-2wee2oz, r=Dylan-DPC
bors [Mon, 23 May 2022 15:45:44 +0000 (15:45 +0000)]
Auto merge of #97315 - Dylan-DPC:rollup-2wee2oz, r=Dylan-DPC

Rollup of 4 pull requests

Successful merges:

 - #96129 (Document rounding for floating-point primitive operations and string parsing)
 - #97286 (Add new eslint rule to prevent whitespace before function call paren)
 - #97292 (Lifetime variance fixes for rustc)
 - #97309 (Add some regression tests for #90400)

Failed merges:

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

2 years agoRollup merge of #97309 - JohnTitor:issue-90400, r=compiler-errors
Dylan DPC [Mon, 23 May 2022 13:11:05 +0000 (15:11 +0200)]
Rollup merge of #97309 - JohnTitor:issue-90400, r=compiler-errors

Add some regression tests for #90400

This adds two regression tests taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836.
Note that we cannot close the issue right now as the [original code](https://github.com/rust-lang/rust/issues/90400#issue-1039577786) still triggers an ICE.

r? `@compiler-errors`

2 years agoRollup merge of #97292 - compiler-errors:tcxify-rustc, r=davidtwco
Dylan DPC [Mon, 23 May 2022 13:11:04 +0000 (15:11 +0200)]
Rollup merge of #97292 - compiler-errors:tcxify-rustc, r=davidtwco

Lifetime variance fixes for rustc

#97287 migrates rustc to a `Ty` type that is invariant over its lifetime `'tcx`, so I need to fix a bunch of places that assume that `Ty<'a>` and `Ty<'b>` can be unified by shortening both to some common lifetime.

This is doable, since many lifetimes are already `'tcx`, so all this PR does is be a bit more explicit that elided lifetimes are actually `'tcx`.

Split out from #97287 so the compiler team can review independently.

2 years agoRollup merge of #97286 - GuillaumeGomez:eslint-check-fn, r=notriddle
Dylan DPC [Mon, 23 May 2022 13:11:03 +0000 (15:11 +0200)]
Rollup merge of #97286 - GuillaumeGomez:eslint-check-fn, r=notriddle

Add new eslint rule to prevent whitespace before function call paren

It prevents `foo ()` basically. :)

r? `@notriddle`

2 years agoRollup merge of #96129 - mattheww:2022-04_float_rounding, r=Dylan-DPC
Dylan DPC [Mon, 23 May 2022 13:11:02 +0000 (15:11 +0200)]
Rollup merge of #96129 - mattheww:2022-04_float_rounding, r=Dylan-DPC

Document rounding for floating-point primitive operations and string parsing

The docs for floating point don't have much to say at present about either the precision of their results or rounding behaviour.

As I understand it[^1][^2], Rust doesn't support operating with non-default rounding directions, so we need only describe roundTiesToEven.

[^1]: https://github.com/rust-lang/rust/issues/41753#issuecomment-299322887
[^2]: https://github.com/llvm/llvm-project/issues/8472#issuecomment-980888781

This PR makes a start by documenting that for primitive operations and `from_str()`.

2 years agoAuto merge of #92461 - rust-lang:const_tls_local_panic_count, r=Mark-Simulacrum
bors [Mon, 23 May 2022 13:04:59 +0000 (13:04 +0000)]
Auto merge of #92461 - rust-lang:const_tls_local_panic_count, r=Mark-Simulacrum

Use const initializer for LOCAL_PANIC_COUNT

This reduces the size of the __getit function for LOCAL_PANIC_COUNT and should speed up accesses of LOCAL_PANIC_COUNT a bit.

2 years agoFix typo
est31 [Sat, 21 May 2022 18:59:51 +0000 (20:59 +0200)]
Fix typo

2 years agoGreatly extend explanations on strip_hidden items
Guillaume Gomez [Mon, 23 May 2022 12:02:10 +0000 (14:02 +0200)]
Greatly extend explanations on strip_hidden items

Co-authored-by: Michael Howell <michael@notriddle.com>
2 years agoadd typo suggestions for all `AssocSuggestion` variants
Takayuki Maeda [Mon, 23 May 2022 10:58:20 +0000 (19:58 +0900)]
add typo suggestions for all `AssocSuggestion` variants

2 years agoAuto merge of #97195 - notriddle:notriddle/cleanup, r=GuillaumeGomez
bors [Mon, 23 May 2022 10:46:50 +0000 (10:46 +0000)]
Auto merge of #97195 - notriddle:notriddle/cleanup, r=GuillaumeGomez

rustdoc: shrink GenericArgs/PathSegment with boxed slices

This PR also contains a few cleanup bits and pieces, but one of them is a broken intra-doc link, and the other is removing an unused Hash impl. The last commit is the one that matters.

2 years agoAdd some regression tests for #90400
Yuki Okushi [Mon, 23 May 2022 09:23:38 +0000 (18:23 +0900)]
Add some regression tests for #90400

2 years agoStabilize `cell_filter_map`
Yuki Okushi [Mon, 23 May 2022 09:04:53 +0000 (18:04 +0900)]
Stabilize `cell_filter_map`

2 years agoAuto merge of #97304 - Dylan-DPC:rollup-qxrfddc, r=Dylan-DPC
bors [Mon, 23 May 2022 07:57:15 +0000 (07:57 +0000)]
Auto merge of #97304 - Dylan-DPC:rollup-qxrfddc, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97087 (Clarify slice and Vec iteration order)
 - #97254 (Remove feature: `crate` visibility modifier)
 - #97271 (Add regression test for #91949)
 - #97294 (std::time : fix variable name in the doc)
 - #97303 (Fix some typos in arg checking algorithm)

Failed merges:

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

2 years agoRollup merge of #97303 - compiler-errors:arg-typos, r=jackh726
Dylan DPC [Mon, 23 May 2022 05:43:52 +0000 (07:43 +0200)]
Rollup merge of #97303 - compiler-errors:arg-typos, r=jackh726

Fix some typos in arg checking algorithm

Fixes #97197

Also fixes a typo where if we're missing args A, B, C, we actually say A, B, B

2 years agoRollup merge of #97294 - jersou:patch-1, r=Dylan-DPC
Dylan DPC [Mon, 23 May 2022 05:43:51 +0000 (07:43 +0200)]
Rollup merge of #97294 - jersou:patch-1, r=Dylan-DPC

std::time : fix variable name in the doc

2 years agoRollup merge of #97271 - JohnTitor:issue-91949, r=compiler-errors
Dylan DPC [Mon, 23 May 2022 05:43:50 +0000 (07:43 +0200)]
Rollup merge of #97271 - JohnTitor:issue-91949, r=compiler-errors

Add regression test for #91949

Closes #91949
This needs `build-fail` because the original bug only appeared with `cargo build`.
r? `@compiler-errors`

2 years agoRollup merge of #97254 - jhpratt:remove-crate-vis, r=cjgillot
Dylan DPC [Mon, 23 May 2022 05:43:50 +0000 (07:43 +0200)]
Rollup merge of #97254 - jhpratt:remove-crate-vis, r=cjgillot

Remove feature: `crate` visibility modifier

FCP completed in #53120.

2 years agoRollup merge of #97087 - Nilstrieb:clarify-slice-iteration-order, r=dtolnay
Dylan DPC [Mon, 23 May 2022 05:43:49 +0000 (07:43 +0200)]
Rollup merge of #97087 - Nilstrieb:clarify-slice-iteration-order, r=dtolnay

Clarify slice and Vec iteration order

While already being inferable from the doc examples, it wasn't fully specified. This is the only logical way to do a slice iterator, so I think this should be uncontroversial. It also improves the `Vec::into_iter` example to better show the order and that the iterator returns owned values.

2 years agoAuto merge of #96100 - Raekye:master, r=dtolnay
bors [Mon, 23 May 2022 05:32:04 +0000 (05:32 +0000)]
Auto merge of #96100 - Raekye:master, r=dtolnay

Change `NonNull::as_uninit_*` to take self by value (as opposed to reference), matching primitive pointers.

Copied from my comment on [#75402](https://github.com/rust-lang/rust/issues/75402#issuecomment-1100496823):

> I noticed that `as_uninit_*` on pointers take `self` by value (and pointers are `Copy`), e.g. see [`as_uninit_mut`](https://doc.rust-lang.org/core/primitive.pointer.html#method.as_uninit_mut).
>
> However, on `NonNull`, these functions take `self` by reference, e.g. see the function with the same name by for `NonNull`: [`as_uninit_mut`](https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.as_uninit_mut) takes `self` by mutable reference. Even more inconsistent, [`as_uninit_slice_mut`](https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.as_uninit_slice_mut) returns a mutable reference, but takes `self` by immutable reference.
>
> I think these methods should take `self` by value for consistency. The returned lifetime is unbounded anyways and not tied to the pointer/NonNull value anyways

I realized the change is trivial (if desired) so here I am creating my first PR. I think it's not a breaking change since (it's on nightly and) `NonNull` is `Copy`; all previous usages of these methods taking `self` by reference should continue to compile. However, it might cause warnings to appear on usages of `NonNull::as_uninit_mut`, which used to require the the `NonNull` variable be declared `mut`, but now it's not necessary.

2 years agoFix some typos in arg checking algorithm
Michael Goulet [Mon, 23 May 2022 05:06:27 +0000 (22:06 -0700)]
Fix some typos in arg checking algorithm

2 years agoDisallow non-same compare-mode-nll
Jack Huey [Sun, 22 May 2022 07:04:12 +0000 (03:04 -0400)]
Disallow non-same compare-mode-nll

2 years agoAuto merge of #96455 - dtolnay:writetmp, r=m-ou-se
bors [Mon, 23 May 2022 02:50:50 +0000 (02:50 +0000)]
Auto merge of #96455 - dtolnay:writetmp, r=m-ou-se

Make write/print macros eagerly drop temporaries

This PR fixes the 2 regressions in #96434 (`println` and `eprintln`) and changes all the other similar macros (`write`, `writeln`, `print`, `eprint`) to match the old pre-#94868 behavior of `println` and `eprintln`.

argument position | before #94868 | after #94868 | after this PR
--- |:---:|:---:|:---:
`write!($tmp, "…", …)` | :rage: | :rage: | :smiley_cat:
`write!(…, "…", $tmp)` | :rage: | :rage: | :smiley_cat:
`writeln!($tmp, "…", …)` | :rage: | :rage: | :smiley_cat:
`writeln!(…, "…", $tmp)` | :rage: | :rage: | :smiley_cat:
`print!("…", $tmp)` | :rage: | :rage: | :smiley_cat:
`println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat:
`eprint!("…", $tmp)` | :rage: | :rage: | :smiley_cat:
`eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat:
`panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:

Example of code that is affected by this change:

```rust
use std::sync::Mutex;

fn main() {
    let mutex = Mutex::new(0);
    print!("{}", mutex.lock().unwrap()) /* no semicolon */
}
```

You can see several real-world examples like this in the Crater links at the top of #96434. This code failed to compile prior to this PR as follows, but works after this PR.

```console
error[E0597]: `mutex` does not live long enough
 --> src/main.rs:5:18
  |
5 |     print!("{}", mutex.lock().unwrap()) /* no semicolon */
  |                  ^^^^^^^^^^^^---------
  |                  |
  |                  borrowed value does not live long enough
  |                  a temporary with access to the borrow is created here ...
6 | }
  | -
  | |
  | `mutex` dropped here while still borrowed
  | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard`
```

2 years agoFix clippy explicit_write lint for new writeln implementation
David Tolnay [Mon, 23 May 2022 00:39:44 +0000 (17:39 -0700)]
Fix clippy explicit_write lint for new writeln implementation

2 years agoAuto merge of #96906 - tbu-:pr_stabilize_to_ipv4_mapped, r=dtolnay
bors [Mon, 23 May 2022 00:10:07 +0000 (00:10 +0000)]
Auto merge of #96906 - tbu-:pr_stabilize_to_ipv4_mapped, r=dtolnay

Stabilize `Ipv6Addr::to_ipv4_mapped`

CC https://github.com/rust-lang/rust/issues/27709 (tracking issue for the `ip` feature which contains more
functions)

The function `Ipv6Addr::to_ipv4` is bad because it also returns an IPv4
address for the IPv6 loopback address `::1`. Stabilize
`Ipv6Addr::to_ipv4_mapped` so we can recommend that function instead.

2 years agoMake write/print macros eagerly drop temporaries
David Tolnay [Tue, 26 Apr 2022 22:16:23 +0000 (15:16 -0700)]
Make write/print macros eagerly drop temporaries

2 years agoAdd test of temporaries inside format_args of core/std macros
David Tolnay [Tue, 26 Apr 2022 22:00:36 +0000 (15:00 -0700)]
Add test of temporaries inside format_args of core/std macros