]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #93353 - kellerkindt:saturating_int_assign_impl, r=joshtriplett
Matthias Krüger [Fri, 28 Jan 2022 14:20:26 +0000 (15:20 +0100)]
Rollup merge of #93353 - kellerkindt:saturating_int_assign_impl, r=joshtriplett

Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>

Tracking issue #92354

Analog to 9648b313cc8896970a12f45b3bb5c0593c3d510f #93208 reduce `saturating_int_assign_impl` (#93208) to:

```rust
let mut value = Saturating(2u8);
value += 3u8;
value -= 1u8;
value *= 2u8;
value /= 2u8;
value %= 2u8;
value ^= 255u8;
value |= 123u8;
value &= 2u8;
```

See https://github.com/rust-lang/rust/pull/93208#issuecomment-1022564429

2 years agoRollup merge of #93295 - ChrisDenton:tempdir-double-panic, r=dtolnay
Matthias Krüger [Fri, 28 Jan 2022 14:20:25 +0000 (15:20 +0100)]
Rollup merge of #93295 - ChrisDenton:tempdir-double-panic, r=dtolnay

Avoid double panics when using `TempDir` in tests

`TempDir` could panic on drop if `remove_dir_all` returns an error. If this happens while already panicking, the test process would abort and therefore not show the test results.

This PR tries to avoid such double panics.

2 years agoRollup merge of #93261 - bjorn3:cg_ssa_refactor6, r=cjgillot
Matthias Krüger [Fri, 28 Jan 2022 14:20:24 +0000 (15:20 +0100)]
Rollup merge of #93261 - bjorn3:cg_ssa_refactor6, r=cjgillot

Some unwinding related cg_ssa cleanups

These should make it a bit easier for alternative codegen backends to implement unwinding.

2 years agoRollup merge of #93239 - Thomasdezeeuw:socketaddr_creation, r=m-ou-se
Matthias Krüger [Fri, 28 Jan 2022 14:20:23 +0000 (15:20 +0100)]
Rollup merge of #93239 - Thomasdezeeuw:socketaddr_creation, r=m-ou-se

Add os::unix::net::SocketAddr::from_path

Creates a new SocketAddr from a path, supports both regular paths and
abstract namespaces.

Note that `SocketAddr::from_abstract_namespace` could be removed after this as `SocketAddr::unix` also supports abstract namespaces.

Updates #65275
Unblocks https://github.com/tokio-rs/mio/issues/1527

r? `@m-ou-se`

2 years agoRollup merge of #93158 - haraldh:wasi_sock_accept, r=dtolnay
Matthias Krüger [Fri, 28 Jan 2022 14:20:22 +0000 (15:20 +0100)]
Rollup merge of #93158 - haraldh:wasi_sock_accept, r=dtolnay

wasi: implement `sock_accept` and enable networking

With the addition of `sock_accept()` to snapshot1, simple networking via a passed `TcpListener` is possible. This PR implements the basics to make a simple server work.

See also:
* [wasmtime tracking issue](https://github.com/bytecodealliance/wasmtime/issues/3730)
* [wasmtime PR](https://github.com/bytecodealliance/wasmtime/pull/3711)

TODO:
* [ ] Discussion of `SocketAddr` return value for `::accept()`

```rust
        Ok((
            TcpStream::from_inner(unsafe { Socket::from_raw_fd(fd as _) }),
            // WASI has no concept of SocketAddr yet
            // return an unspecified IPv4Addr
            SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0),
        ))
```

2 years agoRollup merge of #92611 - Amanieu:asm-reference, r=m-ou-se
Matthias Krüger [Fri, 28 Jan 2022 14:20:21 +0000 (15:20 +0100)]
Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-se

Add links to the reference and rust by example for asm! docs and lints

These were previously removed in #91728 due to broken links.

cc ``@ehuss`` since this updates the rust-by-example submodule

2 years agoUpdate tracking issue for unix_socket_creation
Thomas de Zeeuw [Fri, 28 Jan 2022 14:00:17 +0000 (15:00 +0100)]
Update tracking issue for unix_socket_creation

2 years agowasi: enable TcpListener and TcpStream
Harald Hoyer [Fri, 21 Jan 2022 13:19:48 +0000 (14:19 +0100)]
wasi: enable TcpListener and TcpStream

With the addition of `sock_accept()` to snapshot1, simple networking via
a passed `TcpListener` is possible. This patch implements the basics to
make a simple server work.

Signed-off-by: Harald Hoyer <harald@profian.com>
2 years agowasi: update to wasi 0.11.0
Harald Hoyer [Fri, 21 Jan 2022 13:19:13 +0000 (14:19 +0100)]
wasi: update to wasi 0.11.0

To make use of `sock_accept()`, update the wasi crate to `0.11.0`.

Signed-off-by: Harald Hoyer <harald@profian.com>
2 years agoAuto merge of #90677 - bobrippling:suggest-tuple-parens, r=camelid
bors [Fri, 28 Jan 2022 09:46:22 +0000 (09:46 +0000)]
Auto merge of #90677 - bobrippling:suggest-tuple-parens, r=camelid

Suggest tuple-parentheses for enum variants

This follows on from #86493 / #86481, making the parentheses suggestion. To summarise, given the following code:

```rust
fn f() -> Option<(i32, i8)> {
    Some(1, 2)
}
```

The current output is:

```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
 --> b.rs:2:5
  |
2 |     Some(1, 2)
  |     ^^^^ -  - supplied 2 arguments
  |     |
  |     expected 1 argument

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.
```

With this change, `rustc` will now suggest parentheses when:
- The callee is expecting a single tuple argument
- The number of arguments passed matches the element count in the above tuple
- The arguments' types match the tuple's fields

```
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied
 --> b.rs:2:5
  |
2 |     Some(1, 2)
  |     ^^^^ -  - supplied 2 arguments
  |
help: use parentheses to construct a tuple
  |
2 |     Some((1, 2))
  |          +    +
```

2 years agoAuto merge of #93343 - lqd:attrs, r=spastorino
bors [Fri, 28 Jan 2022 06:28:08 +0000 (06:28 +0000)]
Auto merge of #93343 - lqd:attrs, r=spastorino

Only traverse attrs once while checking for coherence override attributes

In coherence, while checking for negative impls override attributes: only traverse the `DefId`s' attributes once.

This PR is an easy way to get back some of the small perf loss in #93175

2 years agoAuto merge of #93376 - flip1995:clippyup, r=Manishearth
bors [Fri, 28 Jan 2022 01:33:00 +0000 (01:33 +0000)]
Auto merge of #93376 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoAuto merge of #93390 - matthiaskrgr:rollup-4xeki5w, r=matthiaskrgr
bors [Thu, 27 Jan 2022 22:34:34 +0000 (22:34 +0000)]
Auto merge of #93390 - matthiaskrgr:rollup-4xeki5w, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #91641 (Define c_char using cfg_if rather than repeating 40-line cfg)
 - #92899 (Mention std::iter::zip in Iterator::zip docs)
 - #93193 (Add test for stable hash uniqueness of adjacent field values)
 - #93325 (Introduce a limit to Levenshtein distance computation)
 - #93339 (rustdoc: add test case for multiple traits and erased names)
 - #93357 (Clarify the `usage-of-qualified-ty` error message.)
 - #93363 (`#[rustc_pass_by_value]` cleanup)
 - #93365 (More arena cleanups)

Failed merges:

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

2 years agoRollup merge of #93365 - nnethercote:more-arena-cleanups, r=oli-obk
Matthias Krüger [Thu, 27 Jan 2022 21:32:30 +0000 (22:32 +0100)]
Rollup merge of #93365 - nnethercote:more-arena-cleanups, r=oli-obk

More arena cleanups

A sequel to #90990.

r? `@oli-obk`

2 years agoRollup merge of #93363 - lcnr:pass-by-value, r=petrochenkov
Matthias Krüger [Thu, 27 Jan 2022 21:32:29 +0000 (22:32 +0100)]
Rollup merge of #93363 - lcnr:pass-by-value, r=petrochenkov

`#[rustc_pass_by_value]` cleanup

2 years agoRollup merge of #93357 - nnethercote:clarify-usage-of-qualified-ty, r=lcnr
Matthias Krüger [Thu, 27 Jan 2022 21:32:28 +0000 (22:32 +0100)]
Rollup merge of #93357 - nnethercote:clarify-usage-of-qualified-ty, r=lcnr

Clarify the `usage-of-qualified-ty` error message.

I found this message confusing when I encountered it. This commit makes
it clearer that you have to import the unqualified type yourself.

r? `@lcnr`

2 years agoRollup merge of #93339 - notriddle:notriddle/test-generics-multi-trait, r=GuillaumeGomez
Matthias Krüger [Thu, 27 Jan 2022 21:32:27 +0000 (22:32 +0100)]
Rollup merge of #93339 - notriddle:notriddle/test-generics-multi-trait, r=GuillaumeGomez

rustdoc: add test case for multiple traits and erased names

https://github.com/rust-lang/rust/pull/92339#discussion_r792805289

2 years agoRollup merge of #93325 - tmiasko:lev, r=davidtwco
Matthias Krüger [Thu, 27 Jan 2022 21:32:26 +0000 (22:32 +0100)]
Rollup merge of #93325 - tmiasko:lev, r=davidtwco

Introduce a limit to Levenshtein distance computation

Incorporate distance limit from `find_best_match_for_name` directly into
Levenshtein distance computation.

Use the string size difference as a lower bound on the distance and exit
early when it exceeds the specified limit.

After finding a candidate within a limit, lower the limit further to
restrict the search space.

2 years agoRollup merge of #93193 - Kobzol:stable-hash-permutation-test, r=the8472
Matthias Krüger [Thu, 27 Jan 2022 21:32:24 +0000 (22:32 +0100)]
Rollup merge of #93193 - Kobzol:stable-hash-permutation-test, r=the8472

Add test for stable hash uniqueness of adjacent field values

This PR adds a simple test to check that stable hash will produce a different hash if the order of two values that have the same combined bit pattern changes.

r? `@the8472`

2 years agoRollup merge of #92899 - cameron1024:zip-docs, r=dtolnay
Matthias Krüger [Thu, 27 Jan 2022 21:32:23 +0000 (22:32 +0100)]
Rollup merge of #92899 - cameron1024:zip-docs, r=dtolnay

Mention std::iter::zip in Iterator::zip docs

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

I'm not sure about the wording. I think it's alright, but happy to change.

2 years agoRollup merge of #91641 - dtolnay:cchar-if, r=Mark-Simulacrum
Matthias Krüger [Thu, 27 Jan 2022 21:32:23 +0000 (22:32 +0100)]
Rollup merge of #91641 - dtolnay:cchar-if, r=Mark-Simulacrum

Define c_char using cfg_if rather than repeating 40-line cfg

Libstd has a 40-line cfg that defines the targets on which `c_char` is unsigned, and then repeats the same cfg with `not(…)` for the targets on which `c_char` is signed.

This PR replaces it with a `cfg_if!` in which an `else` takes care of the signed case.

I confirmed that `x.py doc library/std` inlines the type alias because c_char_definition is not a publicly accessible path:

![Screenshot from 2021-12-07 13-42-07](https://user-images.githubusercontent.com/1940490/145110596-f1058406-9f32-44ff-9a81-1dfd19b4a24f.png)

2 years agoTouch up PR 92899 Iterator::zip docs
David Tolnay [Thu, 27 Jan 2022 20:41:03 +0000 (12:41 -0800)]
Touch up PR 92899 Iterator::zip docs

2 years agoClarify `ArenaAllocatable`'s second parameter.
Nicholas Nethercote [Tue, 25 Jan 2022 23:46:40 +0000 (10:46 +1100)]
Clarify `ArenaAllocatable`'s second parameter.

It's simply a binary thing to allow different behaviour for `Copy` vs
`!Copy` types. The new code makes this much clearer; I was scratching my
head over the old code for some time.

2 years agoAdd some comments.
Nicholas Nethercote [Tue, 25 Jan 2022 23:33:41 +0000 (10:33 +1100)]
Add some comments.

2 years agoMerge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup
flip1995 [Thu, 27 Jan 2022 14:12:45 +0000 (15:12 +0100)]
Merge commit 'a98e7ab8b94485be6bd03e0c6b8682ecab5b52e6' into clippyup

2 years agoAuto merge of #8359 - flip1995:rustup, r=flip1995
bors [Thu, 27 Jan 2022 13:48:23 +0000 (13:48 +0000)]
Auto merge of #8359 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2022-01-27
flip1995 [Thu, 27 Jan 2022 13:23:42 +0000 (14:23 +0100)]
Bump nightly version -> 2022-01-27

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 27 Jan 2022 13:23:31 +0000 (14:23 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agotry apply `rustc_pass_by_value` to `Span`
lcnr [Thu, 27 Jan 2022 07:17:13 +0000 (08:17 +0100)]
try apply `rustc_pass_by_value` to `Span`

2 years agoUse sockaddr_un in unix SocketAddr::from_path
Thomas de Zeeuw [Thu, 27 Jan 2022 08:54:28 +0000 (09:54 +0100)]
Use sockaddr_un in unix SocketAddr::from_path

2 years agoMake sockaddr_un safe and use copy_nonoverlapping
Thomas de Zeeuw [Thu, 27 Jan 2022 08:52:59 +0000 (09:52 +0100)]
Make sockaddr_un safe and use copy_nonoverlapping

The creation of libc::sockaddr_un is a safe operation, no need for it to
be unsafe.

This also uses the more performant copy_nonoverlapping instead of an
iterator.

2 years agoupdate pass_by_value
lcnr [Thu, 27 Jan 2022 06:58:33 +0000 (07:58 +0100)]
update pass_by_value

2 years agomention std::iter::zip in Iterator::zip docs
cameron [Thu, 27 Jan 2022 06:47:52 +0000 (06:47 +0000)]
mention std::iter::zip in Iterator::zip docs

2 years agoClarify the `usage-of-qualified-ty` error message.
Nicholas Nethercote [Thu, 27 Jan 2022 00:10:37 +0000 (11:10 +1100)]
Clarify the `usage-of-qualified-ty` error message.

I found this message confusing when I encountered it. This commit makes
it clearer that you have to import the unqualified type yourself.

2 years agoAuto merge of #92889 - tmiasko:unbounded-recursion, r=ecstatic-morse
bors [Thu, 27 Jan 2022 06:21:53 +0000 (06:21 +0000)]
Auto merge of #92889 - tmiasko:unbounded-recursion, r=ecstatic-morse

Ignore unwinding edges when checking for unconditional recursion

The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.

The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function `f` because a
call to `g` might unwind. It also wouldn't lint function `h` because an
overflow check preceding the self-recursive call might unwind:

```rust
pub fn f() {
    g();
    f();
}

pub fn g() { /* ... */ }

pub fn h(a: usize) {
  h(a + 1);
}
```

To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.

Fixes #78474.

2 years agoAuto merge of #93081 - nikic:aarch64-fix, r=cuviper
bors [Thu, 27 Jan 2022 01:53:24 +0000 (01:53 +0000)]
Auto merge of #93081 - nikic:aarch64-fix, r=cuviper

Update LLVM submodule

Update LLVM to fix #92786.

2 years agoAuto merge of #93352 - matthiaskrgr:rollup-5peret4, r=matthiaskrgr
bors [Wed, 26 Jan 2022 22:54:26 +0000 (22:54 +0000)]
Auto merge of #93352 - matthiaskrgr:rollup-5peret4, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #90247 (Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa)
 - #91861 (Replace iterator-based construction of collections by `Into<T>`)
 - #92098 (add OpenBSD platform-support page)
 - #92134 (Add x86_64-pc-windows-msvc linker-plugin-lto instructions)
 - #92256 (Improve selection errors for `~const` trait bounds)
 - #92778 (fs: Use readdir() instead of readdir_r() on Linux and Android)
 - #93338 (Update minifier crate version to 0.0.42)

Failed merges:

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

2 years agoUnimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>
Michael Watzko [Wed, 26 Jan 2022 21:00:26 +0000 (22:00 +0100)]
Unimpl {Add,Sub,Mul,Div,Rem,BitXor,BitOr,BitAnd}<$t> for Saturating<$t>

Analog to 9648b313cc8896970a12f45b3bb5c0593c3d510f #93208

2 years agoRollup merge of #93338 - GuillaumeGomez:update-minifier, r=notriddle
Matthias Krüger [Wed, 26 Jan 2022 22:45:24 +0000 (23:45 +0100)]
Rollup merge of #93338 - GuillaumeGomez:update-minifier, r=notriddle

Update minifier crate version to 0.0.42

Some issues on the CSS minification.

r? `@notriddle`

2 years agoRollup merge of #92778 - tavianator:linux-readdir-no-r, r=joshtriplett
Matthias Krüger [Wed, 26 Jan 2022 22:45:23 +0000 (23:45 +0100)]
Rollup merge of #92778 - tavianator:linux-readdir-no-r, r=joshtriplett

fs: Use readdir() instead of readdir_r() on Linux and Android

See #40021 for more details.  Fixes #86649.  Fixes #34668.

2 years agoRollup merge of #92256 - fee1-dead:improve-selection-err, r=oli-obk
Matthias Krüger [Wed, 26 Jan 2022 22:45:22 +0000 (23:45 +0100)]
Rollup merge of #92256 - fee1-dead:improve-selection-err, r=oli-obk

Improve selection errors for `~const` trait bounds

2 years agoRollup merge of #92134 - nico-abram:patch-1, r=michaelwoerister
Matthias Krüger [Wed, 26 Jan 2022 22:45:21 +0000 (23:45 +0100)]
Rollup merge of #92134 - nico-abram:patch-1, r=michaelwoerister

Add x86_64-pc-windows-msvc linker-plugin-lto instructions

I had some trouble getting cross language LTO working for this target, in part because the very few links of documentation I could find were linux-centric and because of a few very specific errors I ran into. I'm not sure if this is the correct place to document this, but this is one of the first links I found when looking for documentation so it might be the best place for it.

2 years agoRollup merge of #92098 - semarie:openbsd-platform, r=pietroalbini
Matthias Krüger [Wed, 26 Jan 2022 22:45:20 +0000 (23:45 +0100)]
Rollup merge of #92098 - semarie:openbsd-platform, r=pietroalbini

add OpenBSD platform-support page

It mentions x86_64, i686, aarch64 and sparc64 which are actively maintained and used on OpenBSD (binaries provided by standard package distribution on OpenBSD).

I volontary kept `powerpc-unknown-openbsd` unmentioned as it was added by `@Yn0ga` in #82733, and I am unaware if it is functional or not (I doubt as I added libc support only few days ago, and std `c_char` signess was wrong). `@Yn0ga` maybe you comment on your `powerpc-unknown-openbsd` usage ?

2 years agoRollup merge of #91861 - juniorbassani:use-from-array-in-collections-examples, r...
Matthias Krüger [Wed, 26 Jan 2022 22:45:19 +0000 (23:45 +0100)]
Rollup merge of #91861 - juniorbassani:use-from-array-in-collections-examples, r=yaahc

Replace iterator-based construction of collections by `Into<T>`

Just a few quality of life improvements in the doc examples. I also removed some `Vec`s in favor of arrays.

2 years agoRollup merge of #90247 - newpavlov:duration_float_fract, r=nagisa
Matthias Krüger [Wed, 26 Jan 2022 22:45:18 +0000 (23:45 +0100)]
Rollup merge of #90247 - newpavlov:duration_float_fract, r=nagisa

Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa

Closes: #90225
The methods now implement direct processing of exponent and mantissa, which should result in the best possible conversion accuracy (modulo truncation, i.e. float value of 19.995 ns will be represented as 19 ns).

2 years agorustdoc: add test case for multiple traits and erased names
Michael Howell [Wed, 26 Jan 2022 16:24:36 +0000 (09:24 -0700)]
rustdoc: add test case for multiple traits and erased names

https://github.com/rust-lang/rust/pull/92339#discussion_r792805289

2 years agoAuto merge of #93301 - spastorino:perf-test-1, r=oli-obk
bors [Wed, 26 Jan 2022 19:45:09 +0000 (19:45 +0000)]
Auto merge of #93301 - spastorino:perf-test-1, r=oli-obk

Store hir_id_to_def_id in OwnerInfo.

This is for perf test purposes only. Related to #89278

2 years agoAuto merge of #8350 - dswij:8331, r=Manishearth
bors [Wed, 26 Jan 2022 19:19:28 +0000 (19:19 +0000)]
Auto merge of #8350 - dswij:8331, r=Manishearth

fix bad suggestion on `numeric_literal`

closes #8331

changelog: [`numeric_literal`]  fix suggestion not showing sign

2 years agoOnly traverse attrs once while checking for coherence override
Rémy Rakic [Wed, 26 Jan 2022 17:32:02 +0000 (18:32 +0100)]
Only traverse attrs once while checking for coherence override

2 years agoUpdate minifier crate version to 0.0.42
Guillaume Gomez [Wed, 26 Jan 2022 16:24:34 +0000 (17:24 +0100)]
Update minifier crate version to 0.0.42

2 years agoFilter out local_id == 0, those are already considered on the call site
Santiago Pastorino [Wed, 26 Jan 2022 12:53:17 +0000 (09:53 -0300)]
Filter out local_id == 0, those are already considered on the call site

2 years agoBless incremental tests.
Camille GILLOT [Sun, 26 Sep 2021 12:37:23 +0000 (14:37 +0200)]
Bless incremental tests.

2 years agoImprove Duration::try_from_secs_f32/64 accuracy by directly processing exponent and...
Артём Павлов [Artyom Pavlov] [Wed, 26 Jan 2022 15:14:25 +0000 (18:14 +0300)]
Improve Duration::try_from_secs_f32/64 accuracy by directly processing exponent and mantissa

2 years agoIgnore unwinding edges when checking for unconditional recursion
Tomasz Miąsko [Fri, 14 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Ignore unwinding edges when checking for unconditional recursion

The unconditional recursion lint determines if all execution paths
eventually lead to a self-recursive call.

The implementation always follows unwinding edges which limits its
practical utility. For example, it would not lint function `f` because a
call to `g` might unwind. It also wouldn't lint function `h` because an
overflow check preceding the self-recursive call might unwind:

```rust
pub fn f() {
    g();
    f();
}

pub fn g() { /* ... */ }

pub fn h(a: usize) {
  h(a + 1);
}
```

To avoid the issue, assume that terminators that might continue
execution along non-unwinding edges do so.

2 years agoAuto merge of #91840 - JakobDegen:fix_early_otherwise, r=oli-obk
bors [Wed, 26 Jan 2022 12:10:54 +0000 (12:10 +0000)]
Auto merge of #91840 - JakobDegen:fix_early_otherwise, r=oli-obk

Fix the unsoundness in the `early_otherwise_branch` mir opt pass

Closes #78496 .

This change is a significant rewrite of much of the pass. Exactly what it does is documented in the source file (with ascii art!), and all the changes that are made to the MIR that are not trivially sound are carefully documented. That being said, this is my first time touching MIR, so there are probably some invariants I did not know about that I broke.

This version of the optimization is also somewhat more flexible than the original; for example, we do not care how or where the value on which the parent is switching is computed. There is no requirement that any types be the same. This could be made even more flexible in the future by allowing a wider range of statements in the bodies of `BBC, BBD` (as long as they are all the same of course). This should be a good first step though.

Probably needs a perf run.

r? `@oli-obk` who reviewed things the last time this was touched

2 years agoIntroduce a limit to Levenshtein distance computation
Tomasz Miąsko [Thu, 20 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Introduce a limit to Levenshtein distance computation

Incorporate distance limit from `find_best_match_for_name` directly into
Levenshtein distance computation.

Use the string size difference as a lower bound on the distance and exit
early when it exceeds the specified limit.

After finding a candidate within a limit, lower the limit further to
restrict the search space.

2 years agoCheck namespace before computing the Levenshtein distance
Tomasz Miąsko [Mon, 17 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Check namespace before computing the Levenshtein distance

2 years agoHoist `to_uppercase` out of the loop
Tomasz Miąsko [Mon, 17 Jan 2022 00:00:00 +0000 (00:00 +0000)]
Hoist `to_uppercase` out of the loop

2 years agoAuto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomez
bors [Wed, 26 Jan 2022 09:10:27 +0000 (09:10 +0000)]
Auto merge of #88679 - petrochenkov:doctrscope, r=GuillaumeGomez

rustdoc: Pre-calculate traits that are in scope for doc links

This eliminates one more late use of resolver (part of #83761).
At early doc link resolution time we go through parent modules of items from the current crate, reexports of items from other crates, trait items, and impl items collected by `collect-intra-doc-links` pass, determine traits that are in scope in each such module, and put those traits into a map used by later rustdoc passes.
r? `@jyn514`

2 years agoUpdate LLVM submodule
Nikita Popov [Wed, 19 Jan 2022 16:08:09 +0000 (17:08 +0100)]
Update LLVM submodule

2 years agofix bad suggestion on `numeric_literal`
Dharma Saputra Wijaya [Tue, 25 Jan 2022 14:19:19 +0000 (22:19 +0800)]
fix bad suggestion on `numeric_literal`

2 years agoAuto merge of #93314 - ehuss:update-cargo, r=ehuss
bors [Wed, 26 Jan 2022 01:47:08 +0000 (01:47 +0000)]
Auto merge of #93314 - ehuss:update-cargo, r=ehuss

Update cargo

9 commits in 95bb3c92bf516017e812e7f1c14c2dea3845b30e..1c034752de0df744fcd7788fcbca158830b8bf85
2022-01-18 17:39:35 +0000 to 2022-01-25 22:36:53 +0000
- Sync toml_edit versions (rust-lang/cargo#10329)
- Check --config for dotted keys only (rust-lang/cargo#10176)
- Remove deprecated --host arg for search and publish cmds (rust-lang/cargo#10327)
- doc: it's valid to use OUT_DIR for intermediate artifacts (rust-lang/cargo#10326)
- Use local git info for version. (rust-lang/cargo#10323)
- Fix documenting with undocumented dependencies. (rust-lang/cargo#10324)
- do not compile test for bins flagged as `test = false` (rust-lang/cargo#10305)
- Port cargo from toml-rs to toml_edit (rust-lang/cargo#10086)
- Fix new::git_default_branch with different default (rust-lang/cargo#10306)

2 years agoUpdate cargo
Eric Huss [Wed, 26 Jan 2022 00:24:21 +0000 (16:24 -0800)]
Update cargo

2 years agoUpdate src/doc/rustc/src/linker-plugin-lto.md
Nicolas Abram [Tue, 25 Jan 2022 23:19:43 +0000 (20:19 -0300)]
Update src/doc/rustc/src/linker-plugin-lto.md

Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2 years agoRemove 1-tuple unreachable case
Rob Pilling [Sun, 16 Jan 2022 22:47:33 +0000 (22:47 +0000)]
Remove 1-tuple unreachable case

2 years agoHandle generics with ParamEnv
Rob Pilling [Sun, 16 Jan 2022 21:47:44 +0000 (21:47 +0000)]
Handle generics with ParamEnv

2 years agoCompare tuple element & arg types before suggesting a tuple
Rob Pilling [Sun, 5 Dec 2021 21:41:33 +0000 (21:41 +0000)]
Compare tuple element & arg types before suggesting a tuple

2 years agoTest tuple suggestions, including tuple-as-function-argument
Rob Pilling [Tue, 9 Nov 2021 23:20:26 +0000 (23:20 +0000)]
Test tuple suggestions, including tuple-as-function-argument

2 years agoSuggest tuple-parentheses when passing N arguments to an N-tuple argument
Rob Pilling [Sun, 7 Nov 2021 22:41:35 +0000 (22:41 +0000)]
Suggest tuple-parentheses when passing N arguments to an N-tuple argument

2 years agoAuto merge of #93308 - matthiaskrgr:rollup-9tc73ft, r=matthiaskrgr
bors [Tue, 25 Jan 2022 22:30:07 +0000 (22:30 +0000)]
Auto merge of #93308 - matthiaskrgr:rollup-9tc73ft, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #93250 (Remove deduplication of early lints)
 - #93286 (Add white-space: nowrap to links in the sidebar)
 - #93291 (minor fix for #93231)
 - #93300 (make Windows abort_internal Miri-compatible)
 - #93303 (Fix ICE when parsing bad turbofish with lifetime argument)

Failed merges:

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

2 years agoRollup merge of #93303 - compiler-errors:issue-93282, r=wesleywiser
Matthias Krüger [Tue, 25 Jan 2022 22:06:04 +0000 (23:06 +0100)]
Rollup merge of #93303 - compiler-errors:issue-93282, r=wesleywiser

Fix ICE when parsing bad turbofish with lifetime argument

Generalize conditions where we suggest adding the turbofish operator, so we don't ICE during code like

```rust
fn foo() {
  A<'a,>
}
```

but instead suggest adding a turbofish.

Fixes #93282

2 years agoRollup merge of #93300 - RalfJung:win-abort-miri, r=Amanieu
Matthias Krüger [Tue, 25 Jan 2022 22:06:03 +0000 (23:06 +0100)]
Rollup merge of #93300 - RalfJung:win-abort-miri, r=Amanieu

make Windows abort_internal Miri-compatible

https://github.com/rust-lang/rust/pull/92828 started calling `abort_internal` on double-panics, uncovering that on Windows this function does not work in Miri because of its use of inline assembly.

Cc `@Amanieu`

2 years agoRollup merge of #93291 - conradludgate:minor-fix-93231, r=GuillaumeGomez
Matthias Krüger [Tue, 25 Jan 2022 22:06:02 +0000 (23:06 +0100)]
Rollup merge of #93291 - conradludgate:minor-fix-93231, r=GuillaumeGomez

minor fix for #93231

In #93231 I introduced the new sidebar colours to make the contrast more balanced and easier to read, but it seems I made a copy-paste error in the light theme, resulting in functions appearing green.

This one line change replaces that colour with it's corrected orange/brown colour.

I have double checked the rest of the colours and they seem ok. Sorry for the inconvenience

2 years agoRollup merge of #93286 - jsha:sidebar-nowrap, r=GuillaumeGomez
Matthias Krüger [Tue, 25 Jan 2022 22:06:01 +0000 (23:06 +0100)]
Rollup merge of #93286 - jsha:sidebar-nowrap, r=GuillaumeGomez

Add white-space: nowrap to links in the sidebar

We already have overflow: hidden on these links, but if there is a possibility to wrap, they will wrap. This happens in particular for trait implementations because the punctuation (`<>, `) introduces opportunities for breaks. That produces inconsistent UI. Fix it by forcing them not to wrap.

Demo: https://rustdoc.crud.net/jsha/sidebar-nowrap/std/string/struct.String.html

To see the effect, scroll down to the "Trait Implementations" portion of the sidebar and look at IndexMut. Compare vs:

https://doc.rust-lang.org/std/string/struct.String.html
https://doc.rust-lang.org/nightly/std/string/struct.String.html

r? `@camelid`

2 years agoRollup merge of #93250 - Aaron1011:remove-early-dedup, r=oli-obk
Matthias Krüger [Tue, 25 Jan 2022 22:06:00 +0000 (23:06 +0100)]
Rollup merge of #93250 - Aaron1011:remove-early-dedup, r=oli-obk

Remove deduplication of early lints

We already have a general mechanism for deduplicating reported
lints, so there's no need to have an additional one for early lints
specifically. This allows us to remove some `PartialEq` impls.

2 years agodelay the bug once again, generalize turbofish suggestion
Michael Goulet [Tue, 25 Jan 2022 19:08:37 +0000 (11:08 -0800)]
delay the bug once again, generalize turbofish suggestion

2 years agoAuto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
bors [Tue, 25 Jan 2022 18:53:45 +0000 (18:53 +0000)]
Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot

Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`

2 years agoAuto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
bors [Tue, 25 Jan 2022 18:53:45 +0000 (18:53 +0000)]
Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot

Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`

2 years agoRemove delayed bug when encountering label in bad turbofish
Michael Goulet [Tue, 25 Jan 2022 18:47:10 +0000 (10:47 -0800)]
Remove delayed bug when encountering label in bad turbofish

2 years agoStore hir_id_to_def_id in OwnerInfo.
Camille GILLOT [Sun, 21 Nov 2021 18:04:47 +0000 (19:04 +0100)]
Store hir_id_to_def_id in OwnerInfo.

2 years agomake Windows abort_internal Miri-compatible
Ralf Jung [Tue, 25 Jan 2022 17:41:26 +0000 (12:41 -0500)]
make Windows abort_internal Miri-compatible

2 years agoAuto merge of #92353 - Kobzol:doc-attr-lists-gat, r=GuillaumeGomez
bors [Tue, 25 Jan 2022 15:43:29 +0000 (15:43 +0000)]
Auto merge of #92353 - Kobzol:doc-attr-lists-gat, r=GuillaumeGomez

Rustdoc: remove ListAttributesIter and use impl Iterator instead

This is a continuation of https://github.com/rust-lang/rust/pull/92227.

I found that `ListAttributesIter` did not optimize well and replacing it with a simple `impl Iterator` resulted in 1-3 % instruction count wins locally.

Because I needed to use `impl Iterator` on a slice of AST attributes, I had to implement it using GAT + impl trait. I also have a version without GAT [here](https://github.com/Kobzol/rust/commit/5470e2a65cbd3086d19f0847f44ca9cbbc049689), if GATs are not welcome in rustdoc :D Locally it resulted in equal performance numbers.

Can I ask for a perf. run? Thanks.

r? rust-lang/rustdoc

2 years agoRename `TypedArenaChunk` as `ArenaChunk`.
Nicholas Nethercote [Tue, 25 Jan 2022 14:35:52 +0000 (01:35 +1100)]
Rename `TypedArenaChunk` as `ArenaChunk`.

Because it's used within both `TypedArena` and `DroplessArena`.

The commit also makes `<u8>` the default parameter.

2 years agoAdd a minimal working `append_const_msg` argument
Deadbeef [Sat, 15 Jan 2022 18:44:57 +0000 (02:44 +0800)]
Add a minimal working `append_const_msg` argument

2 years agoImprove selection errors for `~const` trait bounds
Deadbeef [Fri, 24 Dec 2021 14:50:44 +0000 (22:50 +0800)]
Improve selection errors for `~const` trait bounds

2 years agorustdoc: Pre-calculate traits that are in scope for doc links
Vadim Petrochenkov [Sun, 29 Aug 2021 18:41:46 +0000 (21:41 +0300)]
rustdoc: Pre-calculate traits that are in scope for doc links

This eliminates one more late use of resolver

2 years agoAuto merge of #8343 - robjtede:patch-1, r=giraffate
bors [Tue, 25 Jan 2022 13:08:10 +0000 (13:08 +0000)]
Auto merge of #8343 - robjtede:patch-1, r=giraffate

Autofocus search input

changelog: autofocus filter input on Clippy Lints page

2 years agoAvoid double panics when using `TempDir` in tests
Chris Denton [Tue, 25 Jan 2022 10:36:10 +0000 (10:36 +0000)]
Avoid double panics when using `TempDir` in tests

2 years agoAuto merge of #93089 - pierwill:rm-outlivesconstraint-ord, r=michaelwoerister
bors [Tue, 25 Jan 2022 08:18:25 +0000 (08:18 +0000)]
Auto merge of #93089 - pierwill:rm-outlivesconstraint-ord, r=michaelwoerister

Remove ordering traits from `OutlivesConstraint`

In two cases where this ordering was used, I've replaced the sorting to use a key that does not rely on `DefId` being `Ord`. This is part of #90317. If I understand correctly, whether this is correct depends on whether the `RegionVid`s are tracked during incremental compilation. But I might be mistaken in this approach. cc `@cjgillot`

2 years agogive light-theme fns the correct orange-brown colour
Conrad Ludgate [Tue, 25 Jan 2022 08:00:34 +0000 (08:00 +0000)]
give light-theme fns the correct orange-brown colour

2 years agoAuto merge of #93288 - matthiaskrgr:rollup-uu4uwd1, r=matthiaskrgr
bors [Tue, 25 Jan 2022 05:15:21 +0000 (05:15 +0000)]
Auto merge of #93288 - matthiaskrgr:rollup-uu4uwd1, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #88794 (Add a `try_clone()` function to `OwnedFd`.)
 - #93064 (Properly track `DepNode`s in trait evaluation provisional cache)
 - #93118 (Move param count error emission to end of `check_argument_types`)
 - #93144 (Work around missing code coverage data causing llvm-cov failures)
 - #93169 (Fix inconsistency of local blanket impls)
 - #93175 (Implement stable overlap check considering negative traits)
 - #93251 (rustdoc settings: use radio buttons for theme)
 - #93269 (Use error-on-mismatch policy for PAuth module flags.)

Failed merges:

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

2 years agoRollup merge of #93269 - jacobbramley:dev/pauth-option-1, r=petrochenkov
Matthias Krüger [Tue, 25 Jan 2022 04:51:14 +0000 (05:51 +0100)]
Rollup merge of #93269 - jacobbramley:dev/pauth-option-1, r=petrochenkov

Use error-on-mismatch policy for PAuth module flags.

This agrees with Clang, and avoids an error when using LTO with mixed
C/Rust. LLVM considers different behaviour flags to be a mismatch,
even when the flag value itself is the same.

This also makes the flag setting explicit for all uses of
LLVMRustAddModuleFlag.

----

I believe that this fixes #92885, but have only reproduced it locally on Linux hosts so cannot confirm that it fixes the issue as reported.

I have not included a test for this because it is covered by an existing test (`src/test/run-make-fulldeps/cross-lang-lto-clang`). It is not without its problems, though:
* The test requires Clang and `--run-clang-based-tests-with=...` to run, and this is not the case on the CI.
   * Any test I add would have a similar requirement.
* With this patch applied, the test gets further, but it still fails (for other reasons). I don't think that affects #92885.

2 years agoRollup merge of #93251 - jsha:theme-radio, r=GuillaumeGomez
Matthias Krüger [Tue, 25 Jan 2022 04:51:13 +0000 (05:51 +0100)]
Rollup merge of #93251 - jsha:theme-radio, r=GuillaumeGomez

rustdoc settings: use radio buttons for theme

This reduces the number of clicks required to change theme.

Also, simplify the UI a bit (remove setting grouping), and add a "Back" link close to the settings icon.

Demo: https://rustdoc.crud.net/jsha/theme-radio/settings.html

r? ``@GuillaumeGomez``

New:

![image](https://user-images.githubusercontent.com/220205/150702647-4826d525-54fa-439a-b24c-6d5bca6f95bf.png)

Old:

![image](https://user-images.githubusercontent.com/220205/150702669-6a4214ed-1dab-4fee-b1aa-59acfce3dbca.png)

2 years agoRollup merge of #93175 - spastorino:negative-traits-coherence-new, r=nikomatsakis
Matthias Krüger [Tue, 25 Jan 2022 04:51:12 +0000 (05:51 +0100)]
Rollup merge of #93175 - spastorino:negative-traits-coherence-new, r=nikomatsakis

Implement stable overlap check considering negative traits

This PR implement the new disjointness rules for overlap check described in https://rust-lang.github.io/negative-impls-initiative/explainer/coherence-check.html#new-disjointness-rules

r? ``@nikomatsakis``

2 years agoRollup merge of #93169 - CraftSpider:rustdoc-clean-inconsistency, r=GuillaumeGomez
Matthias Krüger [Tue, 25 Jan 2022 04:51:12 +0000 (05:51 +0100)]
Rollup merge of #93169 - CraftSpider:rustdoc-clean-inconsistency, r=GuillaumeGomez

Fix inconsistency of local blanket impls

When a blanket impl is local, go through HIR instead of middle. This fixes inconsistencies with data detected during JSON generation.

Expected this change to take longer. I also tried doing the whole item through existing clean architecture, but it didn't work out trivially, and felt like it would have added more complexity than it removed.

Properly fixes #83718

2 years agoRollup merge of #93144 - wesleywiser:uninhabited_type_code_cov2, r=tmandry
Matthias Krüger [Tue, 25 Jan 2022 04:51:11 +0000 (05:51 +0100)]
Rollup merge of #93144 - wesleywiser:uninhabited_type_code_cov2, r=tmandry

Work around missing code coverage data causing llvm-cov failures

If we do not add code coverage instrumentation to the `Body` of a
function, then when we go to generate the function record for it, we
won't write any data and this later causes llvm-cov to fail when
processing data for the entire coverage report.

I've identified two main cases where we do not currently add code
coverage instrumentation to the `Body` of a function:

  1. If the function has a single `BasicBlock` and it ends with a
     `TerminatorKind::Unreachable`.

  2. If the function is created using a proc macro of some kind.

For case 1, this is typically not important as this most often occurs as
a result of function definitions that take or return uninhabited
types. These kinds of functions, by definition, cannot even be called so
they logically should not be counted in code coverage statistics.

For case 2, I haven't looked into this very much but I've noticed while
testing this patch that (other than functions which are covered by case
1) the skipped function coverage debug message is occasionally triggered
in large crate graphs by functions generated from a proc macro. This may
have something to do with weird spans being generated by the proc macro
but this is just a guess.

I think it's reasonable to land this change since currently, we fail to
generate *any* results from llvm-cov when a function has no coverage
instrumentation applied to it. With this change, we get coverage data
for all functions other than the two cases discussed above.

Fixes #93054 which occurs because of uncallable functions which shouldn't
have code coverage anyway.

I will open an issue for missing code coverage of proc macro generated
functions and leave a link here once I have a more minimal repro.

r? ``@tmandry``
cc ``@richkadel``

2 years agoRollup merge of #93118 - jackh726:param-heuristics-3, r=estebank
Matthias Krüger [Tue, 25 Jan 2022 04:51:10 +0000 (05:51 +0100)]
Rollup merge of #93118 - jackh726:param-heuristics-3, r=estebank

Move param count error emission to end of `check_argument_types`

The error emission here isn't exactly what is done in #92364, but replicating that is hard . The general move should make for a smaller diff.

Also included the `(usize, Ty, Ty)` to -> `Option<(Ty, Ty)>` commit.

r? ``@estebank``

2 years agoRollup merge of #93064 - Aaron1011:provisional-dep-node, r=michaelwoerister
Matthias Krüger [Tue, 25 Jan 2022 04:51:10 +0000 (05:51 +0100)]
Rollup merge of #93064 - Aaron1011:provisional-dep-node, r=michaelwoerister

Properly track `DepNode`s in trait evaluation provisional cache

Fixes #92987

During evaluation of an auto trait predicate, we may encounter a cycle.
This causes us to store the evaluation result in a special 'provisional
cache;. If we later end up determining that the type can legitimately
implement the auto trait despite the cycle, we remove the entry from
the provisional cache, and insert it into the evaluation cache.

Additionally, trait evaluation creates a special anonymous `DepNode`.
All queries invoked during the predicate evaluation are added as
outoging dependency edges from the `DepNode`. This `DepNode` is then
store in the evaluation cache - if a different query ends up reading
from the cache entry, it will also perform a read of the stored
`DepNode`. As a result, the cached evaluation will still end up
(transitively) incurring all of the same dependencies that it would
if it actually performed the uncached evaluation (e.g. a call to
`type_of` to determine constituent types).

Previously, we did not correctly handle the interaction between the
provisional cache and the created `DepNode`. Storing an evaluation
result in the provisional cache would cause us to lose the `DepNode`
created during the evaluation. If we later moved the entry from the
provisional cache to the evaluation cache, we would use the `DepNode`
associated with the evaluation that caused us to 'complete' the cycle,
not the evaluatoon where we first discovered the cycle. As a result,
future reads from the evaluation cache would miss some incremental
compilation dependencies that would have otherwise been added if the
evaluation was *not* cached.

Under the right circumstances, this could lead to us trying to force
a query with a no-longer-existing `DefPathHash`, since we were missing
the (red) dependency edge that would have caused us to bail out before
attempting forcing.

This commit makes the provisional cache store the `DepNode` create
during the provisional evaluation. When we move an entry from the
provisional cache to the evaluation cache, we create a *new* `DepNode`
that has dependencies going to *both* of the evaluation `DepNodes` we
have available. This ensures that cached reads will incur all of
the necessary dependency edges.

2 years agoRollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplett
Matthias Krüger [Tue, 25 Jan 2022 04:51:09 +0000 (05:51 +0100)]
Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtriplett

Add a `try_clone()` function to `OwnedFd`.

As suggested in #88564. This adds a `try_clone()` to `OwnedFd` by
refactoring the code out of the existing `File`/`Socket` code.

r? ``@joshtriplett``

2 years agoAdd white-space: nowrap to links in the sidebar
Jacob Hoffman-Andrews [Tue, 25 Jan 2022 04:19:09 +0000 (20:19 -0800)]
Add white-space: nowrap to links in the sidebar

We already have overflow: hidden on these links, but if there is a
possibility to wrap, they will wrap. This happens in particular for trait
implementations because the punctuation (`<>, `) introduces opportunities
for breaks. That produces inconsistent UI. Fix it by forcing them not to
wrap.