]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-se
Yuki Okushi [Mon, 2 Aug 2021 02:03:15 +0000 (11:03 +0900)]
Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-se

Change environment variable getters to error recoverably

This PR changes the standard library environment variable getter functions to error recoverably (i.e. not panic) when given an invalid value.

On some platforms, it is invalid for environment variable names to contain `'\0'` or `'='`, or for their values to contain `'\0'`. Currently, the standard library panics when manipulating environment variables with names or values that violate these invariants. However, this behavior doesn't make a lot of sense, at least in the case of getters. If the environment variable is missing, the standard library just returns an error value, rather than panicking. It doesn't make sense to treat the case where the variable is invalid any differently from that. See the [internals thread](https://internals.rust-lang.org/t/why-should-std-var-panic/14847) for discussion. Thus, this PR changes the functions to error recoverably in this case as well.

If desired, I could change the functions that manipulate environment variables in other ways as well. I didn't do that here because it wasn't entirely clear what to change them to. Should they error silently or do something else? If someone tells me how to change them, I'm happy to implement the changes.

This fixes #86082, an ICE that arises from the current behavior. It also adds a regression test to make sure the ICE does not occur again in the future.

`@rustbot` label +T-libs
r? `@joshtriplett`

2 years agoAuto merge of #86031 - ssomers:btree_lazy_iterator, r=Mark-Simulacrum
bors [Sun, 1 Aug 2021 21:45:30 +0000 (21:45 +0000)]
Auto merge of #86031 - ssomers:btree_lazy_iterator, r=Mark-Simulacrum

BTree: lazily locate leaves in rangeless iterators

BTree iterators always locate both the first and last leaf edge and often only need either one, i.e., whenever they are traversed in a single direction, like in for-loops and in the common use of `iter().next()` or `iter().next_back()` to retrieve the first or last key/value-pair (#62924). It's fairly easy to avoid because the iterators with this disadvantage already are quite separate from other iterators.

r? `@Mark-Simulacrum`

2 years agoAuto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrum
bors [Sun, 1 Aug 2021 19:04:37 +0000 (19:04 +0000)]
Auto merge of #87622 - pietroalbini:bump-bootstrap, r=Mark-Simulacrum

Bump bootstrap compiler to 1.55

Changing the cfgs for stdarch is missing, but my understanding is that we don't need to do it as part of this PR?

r? `@Mark-Simulacrum`

2 years agoAuto merge of #81825 - voidc:pidfd, r=joshtriplett
bors [Sun, 1 Aug 2021 16:45:47 +0000 (16:45 +0000)]
Auto merge of #81825 - voidc:pidfd, r=joshtriplett

Add Linux-specific pidfd process extensions (take 2)

Continuation of #77168.
I addressed the following concerns from the original PR:

- make `CommandExt` and `ChildExt` sealed traits
- wrap file descriptors in `PidFd` struct representing ownership over the fd
- add `take_pidfd` to take the fd out of `Child`
- close fd when dropped

Tracking Issue: #82971

2 years agobump bootstrap compiler to 1.55
Pietro Albini [Fri, 30 Jul 2021 12:46:56 +0000 (14:46 +0200)]
bump bootstrap compiler to 1.55

2 years agoAuto merge of #87664 - devnexen:netbsd_sanitizers_support, r=nagisa
bors [Sun, 1 Aug 2021 14:16:37 +0000 (14:16 +0000)]
Auto merge of #87664 - devnexen:netbsd_sanitizers_support, r=nagisa

netbsd x86_64 arch enable supported sanitizers.

2 years agoAuto merge of #87546 - rusticstuff:issue87450-take-two, r=davidtwco
bors [Sun, 1 Aug 2021 11:56:02 +0000 (11:56 +0000)]
Auto merge of #87546 - rusticstuff:issue87450-take-two, r=davidtwco

Bail on any found recursion when expanding opaque types

Fixes #87450. More of a bandaid because it does not fix the exponential complexity of the type folding used for opaque type expansion.

2 years agoAuto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
bors [Sun, 1 Aug 2021 09:15:15 +0000 (09:15 +0000)]
Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa

more clippy::complexity fixes

(also a couple of clippy::perf fixes)

2 years agoCheck whether clone3 syscall exists in pidfd test
Dominik Stolz [Sat, 10 Jul 2021 10:58:30 +0000 (12:58 +0200)]
Check whether clone3 syscall exists in pidfd test

2 years agoAdd dummy FileDesc struct for doc target
Dominik Stolz [Thu, 1 Jul 2021 14:50:14 +0000 (16:50 +0200)]
Add dummy FileDesc struct for doc target

2 years agoDo not call getpid wrapper after fork in tests
Dominik Stolz [Thu, 25 Mar 2021 21:46:37 +0000 (22:46 +0100)]
Do not call getpid wrapper after fork in tests

The test calls libc::getpid() in the pre_exec hook and asserts that the returned value is different from the PID of the parent.
However, libc::getpid() returns the wrong value.
Before version 2.25, glibc caches the PID of the current process with the goal of avoiding additional syscalls.
The cached value is only updated when the wrapper functions for fork or clone are called.
In PR #81825 we switch to directly using the clone3 syscall.
Thus, the cache is not updated and getpid returns the PID of the parent.
source: https://man7.org/linux/man-pages/man2/getpid.2.html#NOTES

2 years agoAuto merge of #84662 - dtolnay:unwindsafe, r=Amanieu
bors [Sun, 1 Aug 2021 02:53:13 +0000 (02:53 +0000)]
Auto merge of #84662 - dtolnay:unwindsafe, r=Amanieu

Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core

They were previously only available in std::panic, not core::panic.

- https://doc.rust-lang.org/1.51.0/std/panic/trait.UnwindSafe.html
- https://doc.rust-lang.org/1.51.0/std/panic/trait.RefUnwindSafe.html
- https://doc.rust-lang.org/1.51.0/std/panic/struct.AssertUnwindSafe.html

Where this is relevant: trait objects! Inside a `#![no_std]` library it's otherwise impossible to have a struct holding a trait object, and at the same time can be used from downstream std crates in a way that doesn't interfere with catch_unwind.

```rust
// common library

#![no_std]

pub struct Thing {
    pub(crate) x: &'static (dyn SomeTrait + Send + Sync),
}

pub(crate) trait SomeTrait {...}
```

```rust
// downstream application

fn main() {
    let thing: library::Thing = ...;
    let _ = std::panic::catch_unwind(|| { let _ = thing; });  // does not work :(
}
```

See https://github.com/dtolnay/colorous/blob/a4131708e2f05d2377964981896ff62dbc9b027b/src/gradient.rs#L7-L15 for a real life example of needing to work around this problem. In particular that workaround would not even be viable if implementors of the trait were provided externally by a caller, as the `feature = "std"` would become non-additive in that case.

What happens without the UnwindSafe constraints:

```rust
fn main() {
    let gradient = colorous::VIRIDIS;
    let _ = std::panic::catch_unwind(|| { let _ = gradient; });
}
```

```console
error[E0277]: the type `(dyn colorous::gradient::EvalGradient + Send + Sync + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
   --> src/main.rs:3:13
    |
3   |     let _ = std::panic::catch_unwind(|| { let _ = gradient; });
    |             ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn colorous::gradient::EvalGradient + Send + Sync + 'static)` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
    |
   ::: .rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:430:40
    |
430 | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
    |                                        ---------- required by this bound in `catch_unwind`
    |
    = help: within `Gradient`, the trait `RefUnwindSafe` is not implemented for `(dyn colorous::gradient::EvalGradient + Send + Sync + 'static)`
    = note: required because it appears within the type `&'static (dyn colorous::gradient::EvalGradient + Send + Sync + 'static)`
    = note: required because it appears within the type `Gradient`
    = note: required because of the requirements on the impl of `UnwindSafe` for `&Gradient`
    = note: required because it appears within the type `[closure@src/main.rs:3:38: 3:62]`
```

2 years agoFix unused sync::atomic import on targets without atomics
David Tolnay [Sun, 1 Aug 2021 00:26:55 +0000 (17:26 -0700)]
Fix unused sync::atomic import on targets without atomics

2 years agoAuto merge of #85782 - badboy:build-ios-sim-target, r=Mark-Simulacrum
bors [Sun, 1 Aug 2021 00:12:18 +0000 (00:12 +0000)]
Auto merge of #85782 - badboy:build-ios-sim-target, r=Mark-Simulacrum

Build aarch64-apple-ios-sim as part of the full macOS build

Part of the [MCP 428](https://github.com/rust-lang/compiler-team/issues/428) to promote this target to Tier 2.

This adds the aarch64-apple-ios-sim target as a tier 2 target, currently cross-compiled from our x86_64 apple builders. The compiler team has approved the addition per the MCP noted above, and the infrastructure team has not raised concerns with this addition at this time (as the CI time impact is expected to be minimal; this is only building std).

2 years agoAuto merge of #87662 - FabianWolff:rb-string, r=estebank
bors [Sat, 31 Jul 2021 20:20:18 +0000 (20:20 +0000)]
Auto merge of #87662 - FabianWolff:rb-string, r=estebank

Suggest `br` if the unknown string prefix `rb` is found

Currently, for the following code:
```rust
fn main() {
    rb"abc";
}
```
we issue the following suggestion:
```
help: consider inserting whitespace here
  |
2 |     rb "abc";
  |       --
```
With my changes (only in edition 2021, where unknown prefixes became an error), I get:
```
help: use `br` for a raw byte string
  |
2 |     br"abc";
  |     ^^
```

2 years agoAuto merge of #87610 - Aaron1011:bump-llvm-bugfix, r=cuviper
bors [Sat, 31 Jul 2021 17:09:02 +0000 (17:09 +0000)]
Auto merge of #87610 - Aaron1011:bump-llvm-bugfix, r=cuviper

Bump LLVM for RegAllocFast bugfix

Fixes #83854

cc `@cuviper`

2 years agonetbsd x86_64 arch enable supported sanitizers.
David Carlier [Sat, 31 Jul 2021 14:26:55 +0000 (15:26 +0100)]
netbsd x86_64 arch enable supported sanitizers.

2 years agoAuto merge of #87607 - JohnTitor:help-to-unused-must-use-op, r=estebank
bors [Sat, 31 Jul 2021 13:47:25 +0000 (13:47 +0000)]
Auto merge of #87607 - JohnTitor:help-to-unused-must-use-op, r=estebank

Add a hint that the expressions produce a value

Fixes #85913
The second commit is semi-_unrelated_ but it allows us to run the related tests just on `src/test/ui/lint`.

2 years agoSuggest `br` if the unknown string prefix `rb` is found
Fabian Wolff [Sat, 31 Jul 2021 13:37:36 +0000 (15:37 +0200)]
Suggest `br` if the unknown string prefix `rb` is found

2 years agoRelocate Arc and Rc UnwindSafe impls
David Tolnay [Sat, 31 Jul 2021 10:57:49 +0000 (03:57 -0700)]
Relocate Arc and Rc UnwindSafe impls

2 years agoAuto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakis
bors [Sat, 31 Jul 2021 07:46:14 +0000 (07:46 +0000)]
Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakis

Trait upcasting coercion (part1)

This revives the first part of earlier PR #60900 .

It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details.

This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part.
(I hope i have dealt with the `ExistentialTraitRef` values correctly...)

The next part will be implementing the pointer casting.

2 years agoAuto merge of #87387 - the8472:slice-iter-advance_by, r=scottmcm
bors [Sat, 31 Jul 2021 05:22:13 +0000 (05:22 +0000)]
Auto merge of #87387 - the8472:slice-iter-advance_by, r=scottmcm

Implement advance_by, advance_back_by for slice::{Iter, IterMut}

Part of #77404.

Picking up where #77633 was closed.

I have addressed https://github.com/rust-lang/rust/pull/77633#issuecomment-771842599 by restoring `nth` and `nth_back`. So according to that comment this should already be r=m-ou-se, but it has been sitting for a while.

2 years agoAuto merge of #87488 - kornelski:track-remove, r=dtolnay
bors [Sat, 31 Jul 2021 03:00:20 +0000 (03:00 +0000)]
Auto merge of #87488 - kornelski:track-remove, r=dtolnay

Track caller of Vec::remove()

`vec.remove(invalid)` doesn't print a helpful source position:

> thread 'main' panicked at 'removal index (is 99) should be < len (is 1)', **library/alloc/src/vec/mod.rs:1379:13**

2 years agoAdd more tests to cover more corner cases of type-checking.
Charles Lew [Fri, 30 Jul 2021 16:46:43 +0000 (00:46 +0800)]
Add more tests to cover more corner cases of type-checking.

2 years agoAuto merge of #86754 - estebank:use-multispans-more, r=varkor
bors [Fri, 30 Jul 2021 23:18:12 +0000 (23:18 +0000)]
Auto merge of #86754 - estebank:use-multispans-more, r=varkor

Use `multipart_suggestions` more

Built on top of #86532

2 years agoApply review suggestion
Yuki Okushi [Fri, 30 Jul 2021 21:21:52 +0000 (06:21 +0900)]
Apply review suggestion

2 years agoMove the `unused` dir to `lint`s subdir
Yuki Okushi [Thu, 29 Jul 2021 20:41:10 +0000 (05:41 +0900)]
Move the `unused` dir to `lint`s subdir

2 years agoAdd a hint that the expressions produce a value
Yuki Okushi [Thu, 29 Jul 2021 20:35:03 +0000 (05:35 +0900)]
Add a hint that the expressions produce a value

2 years agoAuto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitor
bors [Fri, 30 Jul 2021 19:45:55 +0000 (19:45 +0000)]
Auto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #86072 (Cross compiling rustc_llvm on Darwin requires zlib.)
 - #87385 (Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default)
 - #87547 (Add missing examples for NonNull)
 - #87557 (Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic)
 - #87559 (Tweak borrowing suggestion in `for` loop)
 - #87596 (Add warning when whitespace is not skipped after an escaped newline)
 - #87606 (Add some TAIT-related regression tests)
 - #87609 (Add docs about performance and `Iterator::map` to `[T; N]::map`)
 - #87616 (Fix missing word in rustdoc book)

Failed merges:

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

2 years agoRollup merge of #87616 - Wilfred:patch-1, r=jyn514
Yuki Okushi [Fri, 30 Jul 2021 19:09:34 +0000 (04:09 +0900)]
Rollup merge of #87616 - Wilfred:patch-1, r=jyn514

Fix missing word in rustdoc book

2 years agoRollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se
Yuki Okushi [Fri, 30 Jul 2021 19:09:33 +0000 (04:09 +0900)]
Rollup merge of #87609 - LukasKalbertodt:improve-array-map-docs, r=m-ou-se

Add docs about performance and `Iterator::map` to `[T; N]::map`

This suboptimal code gen for some usages of array::map got a bit of
attention by multiple people throughout the community. Some cases:

- https://github.com/rust-lang/rust/issues/75243#issuecomment-866051086
- https://github.com/rust-lang/rust/issues/75243#issuecomment-874732134
- https://www.reddit.com/r/rust/comments/oeqqf7/unexpected_high_stack_usage/

My *guess* is that this gets the attention it gets because in JavaScript
(and potentially other languages), a `map` function on arrays is very
commonly used since in those languages, arrays basically take the role
of Rust's iterator. I considered explicitly naming JavaScript in the
first paragraph I added, but I couldn't find precedence of mentioning
other languages in standard library doc, so I didn't add it.

When array::map was stabilized, we still wanted to add docs, but that
somehow did not happen in time. So here we are. Not sure if this sounds
crazy but maybe it is worth considering beta backporting this? Only if
it's not a lot of work, of course! But yeah, stabilized array::map is
already in beta and if this problem is really as big as it sometimes seems,
might be worth having the docs in place when 1.55 is released.

CC ``@CryZe``

r? ``@m-ou-se`` (since you were involved in that discussion and the stabilization)

2 years agoRollup merge of #87606 - JohnTitor:tait-tests, r=oli-obk
Yuki Okushi [Fri, 30 Jul 2021 19:09:32 +0000 (04:09 +0900)]
Rollup merge of #87606 - JohnTitor:tait-tests, r=oli-obk

Add some TAIT-related regression tests

Closes #74280, closes #77179.
r? ``@oli-obk``

2 years agoRollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebank
Yuki Okushi [Fri, 30 Jul 2021 19:09:31 +0000 (04:09 +0900)]
Rollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebank

Add warning when whitespace is not skipped after an escaped newline

Fixes issue #87318, also simplifies issue #87319.

* Add support to the lexer to emit warnings as well as errors.
* Emit a warning when a string literal contains an escaped newline, but when (some of) the whitespace on the next line is not skipped due to it being non-ASCII.

2 years agoRollup merge of #87559 - estebank:consider-borrowing, r=oli-obk
Yuki Okushi [Fri, 30 Jul 2021 19:09:30 +0000 (04:09 +0900)]
Rollup merge of #87559 - estebank:consider-borrowing, r=oli-obk

Tweak borrowing suggestion in `for` loop

2 years agoRollup merge of #87557 - rylev:fix-invalid-prelude-collision-error, r=nikomatsakis
Yuki Okushi [Fri, 30 Jul 2021 19:09:29 +0000 (04:09 +0900)]
Rollup merge of #87557 - rylev:fix-invalid-prelude-collision-error, r=nikomatsakis

Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic

Fixes #86940

The test cases and associated issue should make it clear what specifically this is meant to fix. The fix is slightly hacky in that we check against the literal source code of the call site for the presence of `<` in order to determine if the user has included the generics for the struct (meaning we don't need to include them for them).

r? ``@nikomatsakis``

2 years agoRollup merge of #87547 - GuillaumeGomez:nonnull-examples, r=kennytm
Yuki Okushi [Fri, 30 Jul 2021 19:09:26 +0000 (04:09 +0900)]
Rollup merge of #87547 - GuillaumeGomez:nonnull-examples, r=kennytm

Add missing examples for NonNull

2 years agoRollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov
Yuki Okushi [Fri, 30 Jul 2021 19:09:20 +0000 (04:09 +0900)]
Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkov

Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default

This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default.

To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon.

In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.

2 years agoRollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisa
Yuki Okushi [Fri, 30 Jul 2021 19:09:19 +0000 (04:09 +0900)]
Rollup merge of #86072 - MarcusCalhoun-Lopez:llvm_cross, r=nagisa

Cross compiling rustc_llvm on Darwin requires zlib.

2 years agoAdd regression test for issue #87450.
Hans Kratz [Fri, 30 Jul 2021 18:32:22 +0000 (18:32 +0000)]
Add regression test for issue #87450.

2 years agoFix some broken rustdoc links in core::panic documentation
David Tolnay [Wed, 28 Apr 2021 17:34:22 +0000 (10:34 -0700)]
Fix some broken rustdoc links in core::panic documentation

2 years agoFix comment referring to formerly-above code
David Tolnay [Wed, 28 Apr 2021 17:08:29 +0000 (10:08 -0700)]
Fix comment referring to formerly-above code

2 years agoFix undocumented unsafe in AssertUnwindSafe impls
David Tolnay [Wed, 28 Apr 2021 15:47:09 +0000 (08:47 -0700)]
Fix undocumented unsafe in AssertUnwindSafe impls

2 years agoMove UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core
David Tolnay [Wed, 28 Apr 2021 15:39:23 +0000 (08:39 -0700)]
Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to core

2 years agoFix separation of public vs internal parts of Location
David Tolnay [Wed, 28 Apr 2021 15:35:21 +0000 (08:35 -0700)]
Fix separation of public vs internal parts of Location

2 years agoSplit core::panic module to subdirectory
David Tolnay [Wed, 28 Apr 2021 15:31:33 +0000 (08:31 -0700)]
Split core::panic module to subdirectory

2 years agoAuto merge of #87421 - estebank:perf-run, r=oli-obk
bors [Fri, 30 Jul 2021 17:18:50 +0000 (17:18 +0000)]
Auto merge of #87421 - estebank:perf-run, r=oli-obk

Do not discard `?Sized` type params and suggest their removal

2 years agoImplement trait upcasting coercion type-checking.
Charles Lew [Sun, 25 Jul 2021 10:43:48 +0000 (18:43 +0800)]
Implement trait upcasting coercion type-checking.

2 years agoAdd feature gate tests.
Charles Lew [Sun, 13 Jun 2021 10:42:11 +0000 (18:42 +0800)]
Add feature gate tests.

2 years agoAdded feature gate.
Alexander Regueiro [Thu, 31 Oct 2019 02:52:05 +0000 (10:52 +0800)]
Added feature gate.

2 years agoUse multispan suggestions more often
Esteban Küber [Mon, 28 Jun 2021 18:22:47 +0000 (11:22 -0700)]
Use multispan suggestions more often

* Use more accurate span for `async move` suggestion
* Use more accurate span for deref suggestion
* Use `multipart_suggestion` more often

2 years agoTweak borrowing suggestion in `for` loop
Esteban Küber [Wed, 28 Jul 2021 17:08:39 +0000 (10:08 -0700)]
Tweak borrowing suggestion in `for` loop

2 years agoDo not discard `?Sized` type params and suggest their removal
Esteban Küber [Sat, 24 Jul 2021 01:47:53 +0000 (18:47 -0700)]
Do not discard `?Sized` type params and suggest their removal

2 years agoFix error with suggestion for how to disambiguate associated function when struct...
Ryan Levick [Wed, 28 Jul 2021 16:34:19 +0000 (18:34 +0200)]
Fix error with suggestion for how to disambiguate associated function when struct is generic

2 years agoAuto merge of #85971 - FabianWolff:issue-85586, r=davidtwco
bors [Fri, 30 Jul 2021 14:38:00 +0000 (14:38 +0000)]
Auto merge of #85971 - FabianWolff:issue-85586, r=davidtwco

Use more precise span for E0282 in cast expressions

This pull request fixes #85586. The example code given there:
```rust
fn main() {
    let a = [1, 2, 3].iter().sum();
    let b = (a + 1) as usize;
}
```
currently produces
```
error[E0282]: type annotations needed
 --> issue-85586.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

error: aborting due to previous error
```
even though the type of the entire cast expression quite clearly should be `usize`. The error is in the cast's left-hand side, which is made explicit by the changes in this PR:
```
error[E0282]: type annotations needed
 --> issue-85586.rs:3:13
  |
3 |     let b = (a + 1) as usize;
  |             ^^^^^^^ cannot infer type
  |
  = note: type must be known at this point

error: aborting due to previous error
```

2 years agoAdd warning when whitespace is not skipped after an escaped newline.
Anton Golov [Fri, 30 Jul 2021 14:09:33 +0000 (16:09 +0200)]
Add warning when whitespace is not skipped after an escaped newline.

2 years agoAuto merge of #87237 - jonas-schievink:const-for-and-try, r=oli-obk
bors [Fri, 30 Jul 2021 12:05:48 +0000 (12:05 +0000)]
Auto merge of #87237 - jonas-schievink:const-for-and-try, r=oli-obk

Add feature gates for `for` and `?` in consts

These operations seems *relatively* straightforward to support, and only seem to be blocked on `impl const Trait`.

I have included a working test for `const_try`, but `const_for` is currently unusable without reimplementing *every single* defaulted `Iterator` method, so I didn't do that.

(both features still need tracking issues before this is merged)

2 years agoAuto merge of #87615 - JohnTitor:rollup-t5jpmrg, r=JohnTitor
bors [Fri, 30 Jul 2021 09:43:32 +0000 (09:43 +0000)]
Auto merge of #87615 - JohnTitor:rollup-t5jpmrg, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #87052 (Optimize fmt::PadAdapter::wrap)
 - #87522 (Fix assert in diy_float)
 - #87553 (Fix typo in rustc_driver::version)
 - #87554 (2229: Discr should be read when PatKind is Range)
 - #87564 (min_type_alias_impl_trait is going to be removed in 1.56)
 - #87574 (Update the examples in `String` and `VecDeque::retain`)
 - #87583 (Refactor compression cache in v0 symbol mangler)
 - #87585 (Add missing links for core::char types)
 - #87594 (fs File get_path procfs usage for netbsd same as linux.)
 - #87602 ([backtraces]: look for the `begin` symbol only after seeing `end`)

Failed merges:

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

2 years agoAdd missing examples for NonNull
Guillaume Gomez [Wed, 28 Jul 2021 12:24:23 +0000 (14:24 +0200)]
Add missing examples for NonNull

2 years agoFix missing word in comment
Wilfred Hughes [Fri, 30 Jul 2021 07:58:48 +0000 (00:58 -0700)]
Fix missing word in comment

2 years agoRollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized...
Yuki Okushi [Fri, 30 Jul 2021 07:27:01 +0000 (16:27 +0900)]
Rollup merge of #87602 - wesleywiser:partially_fix_short_backtraces_windows_optimized, r=dtolnay

[backtraces]: look for the `begin` symbol only after seeing `end`

On `x86_64-pc-windows-msvc`, we often get backtraces which look like
    this:

    ```
    10:     0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook
    11:     0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
    12:     0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae
    13:     0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805
    14:     0x7ff77e0e108c - d
    15:     0x7ff77e0e1069 - c
    16:     0x7ff77e0e1059 - b
    17:     0x7ff77e0e1049 - a
    18:     0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81
    19:     0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
    20:     0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3
    ```

Notice that `__rust_begin_short_backtrace` appears on frame 11 before
    `__rust_end_short_backtrace` on frame 12. This is because in typical
    release binaries without debug symbols, dbghelp.dll, which we use to walk
    and symbolize the stack, does not know where CGU internal functions
    start or end and so the closure invoked by `__rust_end_short_backtrace`
    is incorrectly described as `__rust_begin_short_backtrace` because it
    happens to be near that symbol.

While that can obviously change, this has been happening quite
    consistently since #75048. Since this is a very small change to the std
    and the change makes sense by itself, I think this is worth doing.

This doesn't completely resolve the situation for release binaries on
    Windows, since without debug symbols, the stack printed can still show
    incorrect symbol names (this is why the test uses `#[no_mangle]`) but it
    does slightly improve the situation in that you see the same backtrace
    you would see with `RUST_BACKTRACE=full` or in a debugger (without the
    uninteresting bits at the top and bottom).

Fixes part of #87481

2 years agoRollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett
Yuki Okushi [Fri, 30 Jul 2021 07:27:00 +0000 (16:27 +0900)]
Rollup merge of #87594 - devnexen:netbsd_fs_getfiledescriptor_path, r=joshtriplett

fs File get_path procfs usage for netbsd same as linux.

2 years agoRollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett
Yuki Okushi [Fri, 30 Jul 2021 07:26:59 +0000 (16:26 +0900)]
Rollup merge of #87585 - GuillaumeGomez:char-types-doc, r=joshtriplett

Add missing links for core::char types

2 years agoRollup merge of #87583 - tmiasko:compression-cache, r=wesleywiser
Yuki Okushi [Fri, 30 Jul 2021 07:26:58 +0000 (16:26 +0900)]
Rollup merge of #87583 - tmiasko:compression-cache, r=wesleywiser

Refactor compression cache in v0 symbol mangler

* Remove redundant option around compression caches (they are always present).
* Flatten compression caches into symbol mangler to avoid dynamic memory allocation.
* Implement printer for `&mut SymbolMangler` instead of `SymbolMangler` to avoid passing now slightly larger symbol mangler by value.

2 years agoRollup merge of #87574 - cuviper:retain-examples, r=joshtriplett
Yuki Okushi [Fri, 30 Jul 2021 07:26:57 +0000 (16:26 +0900)]
Rollup merge of #87574 - cuviper:retain-examples, r=joshtriplett

Update the examples in `String` and `VecDeque::retain`

The examples added in #60396 used a "clever" post-increment hack,
unrelated to the actual point of the examples. That hack was found
[confusing] in the users forum, and #81811 already changed the `Vec`
example to use a more direct iterator. This commit changes `String` and
`VecDeque` in the same way for consistency.

[confusing]: https://users.rust-lang.org/t/help-understand-strange-expression/62858

2 years agoRollup merge of #87564 - spastorino:adjust-min-tait-removed-version, r=jackh726
Yuki Okushi [Fri, 30 Jul 2021 07:26:56 +0000 (16:26 +0900)]
Rollup merge of #87564 - spastorino:adjust-min-tait-removed-version, r=jackh726

min_type_alias_impl_trait is going to be removed in 1.56

#87501 removed `min_type_alias_impl_trait` but meanwhile that PR was approved in homu queue, a new beta was cut so we need to bump the version because it won't be removed in 1.55.

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

```@bors``` rollup=always

2 years agoRollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakis
Yuki Okushi [Fri, 30 Jul 2021 07:26:55 +0000 (16:26 +0900)]
Rollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakis

2229: Discr should be read when PatKind is Range

This PR fixes an issue related to pattern matching in closures when Edition 2021 is enabled.

- If any of the patterns the discr is being matched on is `PatKind::Range` then the discr should be read

r? ```@nikomatsakis```

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

2 years agoRollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesleywiser
Yuki Okushi [Fri, 30 Jul 2021 07:26:54 +0000 (16:26 +0900)]
Rollup merge of #87553 - bjorn3:fix_hotplug_codegen_version, r=wesleywiser

Fix typo in rustc_driver::version

This caused rustc `-Zcodegen-backend=foo.so -vV` to look for `oo.so` instead of `foo.so`

2 years agoRollup merge of #87522 - frogtd:patch-1, r=yaahc
Yuki Okushi [Fri, 30 Jul 2021 07:26:53 +0000 (16:26 +0900)]
Rollup merge of #87522 - frogtd:patch-1, r=yaahc

Fix assert in diy_float

The shifting should have gone the other way, the current incarnation is always true.

2 years agoRollup merge of #87052 - phlopsi:patch-1, r=jyn514
Yuki Okushi [Fri, 30 Jul 2021 07:26:52 +0000 (16:26 +0900)]
Rollup merge of #87052 - phlopsi:patch-1, r=jyn514

Optimize fmt::PadAdapter::wrap

After adding the first `write!` usage to my project and printing the result to the console, I noticed, that my binary contains the strings "called `Option::unwrap()` on a `None` value`" and more importantly "C:\Users\Patrick Fischer\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\fmt\builders.rs", with my release build being configured as follows:
```
[profile.release]
panic = "abort"
codegen-units = 1
strip = "symbols" # the important bit
lto = true
```
I am in a no_std environment and my custom panic handler is a simple `loop {}`. I did not expect the above information to be preserved. I heavily suspect the edited function to be the culprit. It contains the only direct use of `Option::unwrap` in the entire file and I tracked the symbols in the assembly to be used from the section `_ZN68_$LT$core..fmt..builders..PadAdapter$u20$as$u20$core..fmt..Write$GT$9write_str17ha1d5e5efe167202aE`.

Aside from me suspecting this function to be the culprit, the replaced code performs the same operation as `Option::insert`, but without the `unreachable_unchecked` optimization `Option::insert` provides. Therefore, it makes sense to me to use the more optimized version, instead.

As I don't change any semantics, I hope a simple pull request suffices.

2 years agoAuto merge of #87483 - oli-obk:tait_ice, r=lqd
bors [Fri, 30 Jul 2021 07:02:34 +0000 (07:02 +0000)]
Auto merge of #87483 - oli-obk:tait_ice, r=lqd

Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution

Fixes #87455

This situation was unreachable before #87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After #87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).

2 years agoAuto merge of #87445 - amalik18:issue-83584-fix, r=kennytm
bors [Fri, 30 Jul 2021 04:34:13 +0000 (04:34 +0000)]
Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytm

Fix may not to appropriate might not or must not

I went through and changed occurrences of `may not` to be more explicit with `might not` and `must not`.

2 years agoBump LLVM for RegAllocFast bugfix
Aaron Hill [Fri, 30 Jul 2021 00:22:59 +0000 (19:22 -0500)]
Bump LLVM for RegAllocFast bugfix

Fixes #83854

2 years agoAuto merge of #87285 - GuillaumeGomez:intra-doc-span, r=estebank
bors [Thu, 29 Jul 2021 23:33:18 +0000 (23:33 +0000)]
Auto merge of #87285 - GuillaumeGomez:intra-doc-span, r=estebank

Improve intra doc errors display

#87169

`@jyn514` This is what I had in mind to avoid having duplicated backticks. I also gave a try to simply updating the span for the suggestion/help messages but I think this current one is better because less "noisy". Anyway, that allows you to see the result. ;)

2 years agoUpdate error code description
Jonas Schievink [Thu, 29 Jul 2021 22:33:30 +0000 (00:33 +0200)]
Update error code description

2 years agoAdd docs about performance and `Iterator::map` to `[T; N]::map`
Lukas Kalbertodt [Thu, 29 Jul 2021 22:08:48 +0000 (00:08 +0200)]
Add docs about performance and `Iterator::map` to `[T; N]::map`

2 years agoUpdate tests
Jonas Schievink [Thu, 29 Jul 2021 21:15:53 +0000 (23:15 +0200)]
Update tests

2 years agoAdd tracking issues
Jonas Schievink [Thu, 29 Jul 2021 01:00:52 +0000 (03:00 +0200)]
Add tracking issues

2 years agoAdd `const_for` test
Jonas Schievink [Thu, 29 Jul 2021 00:56:03 +0000 (02:56 +0200)]
Add `const_for` test

2 years agoAdd feature gates for `for` and `?` in consts
Jonas Schievink [Sun, 18 Jul 2021 01:34:50 +0000 (03:34 +0200)]
Add feature gates for `for` and `?` in consts

2 years agoAuto merge of #85901 - ijackson:bufwriter-tweaks, r=joshtriplett
bors [Thu, 29 Jul 2021 20:52:34 +0000 (20:52 +0000)]
Auto merge of #85901 - ijackson:bufwriter-tweaks, r=joshtriplett

Bufwriter disassembly tweaks

In #80690 `@BurntSushi` observed that `WriterPanicked` was erroneously not exported, and suggested renaming `into_raw_parts` to `into_parts`. (More info in my commit messages.)

r? `@BurntSushi`

2 years agoAdd some TAIT-related regression tests
Yuki Okushi [Thu, 29 Jul 2021 19:49:08 +0000 (04:49 +0900)]
Add some TAIT-related regression tests

2 years ago[backtraces]: look for the `begin` symbol only after seeing `end`
Wesley Wiser [Thu, 29 Jul 2021 17:06:37 +0000 (13:06 -0400)]
[backtraces]: look for the `begin` symbol only after seeing `end`

On `x86_64-pc-windows-msvc`, we often get backtraces which look like
this:

```
10:     0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook
11:     0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
12:     0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae
13:     0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805
14:     0x7ff77e0e108c - d
15:     0x7ff77e0e1069 - c
16:     0x7ff77e0e1059 - b
17:     0x7ff77e0e1049 - a
18:     0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81
19:     0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c
20:     0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3
```

Notice that `__rust_begin_short_backtrace` appears on frame 11 before
`__rust_end_short_backtrace` on frame 12. This is because in typical
release binaries without debug symbols, dbghelp.dll, which we use to walk
and symbolize the stack, does not know where CGU internal functions
start or end and so the closure invoked by `__rust_end_short_backtrace`
is incorrectly described as `__rust_begin_short_backtrace` because it
happens to be near that symbol.

While that can obviously change, this has been happening quite
consistently since #75048. Since this is a very small change to the std
and the change makes sense by itself, I think this is worth doing.

This doesn't completely resolve the situation for release binaries on
Windows, since without debug symbols, the stack printed can still show
incorrect symbol names (this is why the test uses `#[no_mangle]`) but it
does slightly improve the situation in that you see the same backtrace
you would see with `RUST_BACKTRACE=full` or in a debugger (without the
uninteresting bits at the top and bottom).

2 years agoAdd regression test
Wesley Wiser [Wed, 28 Jul 2021 15:40:53 +0000 (11:40 -0400)]
Add regression test

2 years agofs File get_path procfs usage for netbsd same as linux.
David Carlier [Thu, 29 Jul 2021 16:49:48 +0000 (17:49 +0100)]
fs File get_path procfs usage for netbsd same as linux.

2 years agoAuto merge of #87579 - flip1995:clippyup, r=Manishearth
bors [Thu, 29 Jul 2021 15:36:52 +0000 (15:36 +0000)]
Auto merge of #87579 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoUpdate rustdoc-ui tests for intra-doc links errors
Guillaume Gomez [Mon, 19 Jul 2021 15:00:35 +0000 (17:00 +0200)]
Update rustdoc-ui tests for intra-doc links errors

2 years agoRemove unnecessary trailing semicolons from clippy tests
Aaron Hill [Thu, 29 Jul 2021 14:52:35 +0000 (09:52 -0500)]
Remove unnecessary trailing semicolons from clippy tests

2 years agoRename feature gate bufwriter_into_parts from bufwriter_into_raw_parts
Ian Jackson [Mon, 19 Jul 2021 16:33:55 +0000 (17:33 +0100)]
Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts

As requested
  https://github.com/rust-lang/rust/pull/85901#pullrequestreview-698404772

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoBufWriter: rename `into_parts` from `into_raw_parts`
Ian Jackson [Tue, 1 Jun 2021 15:47:26 +0000 (16:47 +0100)]
BufWriter: rename `into_parts` from `into_raw_parts`

I looked in stdlib and as @BurntSushi thought, `raw` is generally
used for raw pointers, or other hazardous kinds of thing.  stdlib does
not have `into_parts` apart from the one I added to `IntoInnerError`.

I did an ad-hoc search of the rustdocs for my current game project
Otter, which includes quite a large number of dependencies.
`into_parts` seems heavily used for things quite like this.

So change this name.

Suggested-by: Andrew Gallant <jamslam@gmail.com>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoBufWriter: actually export WriterPanicked error
Ian Jackson [Tue, 1 Jun 2021 15:30:13 +0000 (16:30 +0100)]
BufWriter: actually export WriterPanicked error

I didn't notice the submodule, which means I failed to re-export this
to make it actually-public.

Reported-by: Andrew Gallant <jamslam@gmail.com>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2 years agoAdd missing links for core::char types
Guillaume Gomez [Thu, 29 Jul 2021 12:13:41 +0000 (14:13 +0200)]
Add missing links for core::char types

2 years agoChange span for intra-doc links errors
Guillaume Gomez [Mon, 19 Jul 2021 15:00:21 +0000 (17:00 +0200)]
Change span for intra-doc links errors

2 years agoImplement `Printer` for `&mut SymbolMangler`
Tomasz Miąsko [Thu, 29 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Implement `Printer` for `&mut SymbolMangler`

to avoid passing the symbol mangler by value.

2 years agoFlatten compression caches into symbol mangler
Tomasz Miąsko [Thu, 29 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Flatten compression caches into symbol mangler

The compression caches currently don't have any dedicated functionality
that would benefit from being separated. Incorporating caches directly
into the symbol manger also avoids dynamic memory allocation.

The symbol mangler, which is often passed by value, is now slightly
larger. This aspect will be addressed by a follow-up commit.

2 years agoRemove redundant option around compression caches
Tomasz Miąsko [Tue, 27 Jul 2021 00:00:00 +0000 (00:00 +0000)]
Remove redundant option around compression caches

Compression caches are always present. Remove unnecessary option.

2 years agoUpdate Cargo.lock (Clippy version bump)
flip1995 [Thu, 29 Jul 2021 10:17:29 +0000 (12:17 +0200)]
Update Cargo.lock (Clippy version bump)

2 years agoMerge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyup
flip1995 [Thu, 29 Jul 2021 10:16:06 +0000 (12:16 +0200)]
Merge commit '0cce3f643bfcbb92d5a1bb71858c9cbaff749d6b' into clippyup

2 years agoAuto merge of #7504 - flip1995:rename-lints, r=flip1995
bors [Thu, 29 Jul 2021 10:14:31 +0000 (10:14 +0000)]
Auto merge of #7504 - flip1995:rename-lints, r=flip1995

Rename two lints to comply with our lint naming convention

self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain

We don't need to `register_renamed` those lints, since I'll backport them to beta, so the old names won't hit stable.

changelog: none
(I'll adapt the changelog before merging #7498)

2 years agoRename two lints to comply with our lint naming convention
flip1995 [Thu, 29 Jul 2021 10:10:18 +0000 (12:10 +0200)]
Rename two lints to comply with our lint naming convention

self_named_constructor -> self_named_constructors
append_instead_of_extend -> extend_with_drain

2 years agoUse strip_prefix
bjorn3 [Thu, 29 Jul 2021 09:54:39 +0000 (11:54 +0200)]
Use strip_prefix