]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix
bors [Sun, 1 Nov 2020 16:52:28 +0000 (16:52 +0000)]
Auto merge of #75534 - Aaron1011:feature/new-future-breakage, r=pnkfelix

Implement rustc side of report-future-incompat

cc https://github.com/rust-lang/rust/issues/71249

This is an alternative to `@pnkfelix's` initial implementation in https://github.com/pnkfelix/rust/commits/prototype-rustc-side-of-report-future-incompat (mainly because I started working before seeing that branch :smile: ).

My approach outputs the entire original `Diagnostic`, in a way that is compatible with incremental compilation. This is not yet integrated with compiletest, but can be used manually by passing `-Z emit-future-incompat-report` to `rustc`.

Several changes are made to support this feature:
* The `librustc_session/lint` module is moved to a new crate `librustc_lint_defs` (name bikesheddable). This allows accessing lint definitions from `librustc_errors`.
* The `Lint` struct is extended with an `Option<FutureBreakage>`. When present, it indicates that we should display a lint in the future-compat report. `FutureBreakage` contains additional information that we may want to display in the report (currently, a `date` field indicating when the crate will stop compiling).
* A new variant `rustc_error::Level::Allow` is added. This is used when constructing a diagnostic for a future-breakage lint that is marked as allowed (via `#[allow]` or `--cap-lints`). This allows us to capture any future-breakage diagnostics in one place, while still discarding them before they are passed to the `Emitter`.
* `DiagnosticId::Lint` is extended with a `has_future_breakage` field, indicating whether or not the `Lint` has future breakage information (and should therefore show up in the report).
* `Session` is given access to the `LintStore` via a new `SessionLintStore` trait (since `librustc_session` cannot directly reference `LintStore` without a cyclic dependency). We use this to turn a string `DiagnosticId::Lint` back into a `Lint`, to retrieve the `FutureBreakage` data.

Currently, `FutureBreakage.date` is always set to `None`. However, this could potentially be interpreted by Cargo in the future.

I've enabled the future-breakage report for the `ARRAY_INTO_ITER` lint, which can be used to test out this PR. The intent is to use the field to allow Cargo to determine the date of future breakage (as described in [RFC 2834](https://github.com/rust-lang/rfcs/blob/master/text/2834-cargo-report-future-incompat.md)) without needing to parse the diagnostic itself.

cc `@pnkfelix`

3 years agoAuto merge of #78553 - Nadrieril:fix-78549, r=varkor
bors [Sun, 1 Nov 2020 14:37:50 +0000 (14:37 +0000)]
Auto merge of #78553 - Nadrieril:fix-78549, r=varkor

Fix #78549

Before #78430, this worked because `specialize_constructor` didn't actually care too much which constructor was passed to it unless needed. That PR however handles `&str` as a special case, and I did not anticipate patterns for the `&str` type other than string literals.
I am not very confident there are not other similar oversights left, but hopefully only `&str` was different enough to break my assumptions.

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

3 years agoAuto merge of #78623 - m-ou-se:rollup-m6y5j0m, r=m-ou-se
bors [Sun, 1 Nov 2020 11:54:58 +0000 (11:54 +0000)]
Auto merge of #78623 - m-ou-se:rollup-m6y5j0m, r=m-ou-se

Rollup of 6 pull requests

Successful merges:

 - #78073 (Add #[inline] to some functions in core::str.)
 - #78596 (Fix doc links to std::fmt)
 - #78599 (Add note to process::arg[s] that args shouldn't be escaped or quoted)
 - #78602 (fix various aliasing issues in the standard library)
 - #78603 (expand: Tweak a comment in implementation of `macro_rules`)
 - #78621 (Inline Default::default() for atomics)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78621 - solson:inline, r=m-ou-se
Mara Bos [Sun, 1 Nov 2020 10:53:39 +0000 (11:53 +0100)]
Rollup merge of #78621 - solson:inline, r=m-ou-se

Inline Default::default() for atomics

Functions like `AtomicUsize::default()` are not cross-crate inlineable before this PR ([see assembly output here](https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=e353321766418f759c69fb141d3732f8)), which can lead to unexpected performance issues when initializing a large array using this function, e.g. as seen [here](https://github.com/spacejam/sled/blob/d513996a85875be8c813fd0e30a548b89682289a/src/histogram.rs#L53) which should turn into a simple loop writing zeroes but doesn't.

r? @m-ou-se

3 years agoRollup merge of #78603 - petrochenkov:fourdigits, r=matthewjasper
Mara Bos [Sun, 1 Nov 2020 10:53:37 +0000 (11:53 +0100)]
Rollup merge of #78603 - petrochenkov:fourdigits, r=matthewjasper

expand: Tweak a comment in implementation of `macro_rules`

The answer to the removed FIXME is that we don't apply mark to the span `sp` just because that span is no longer used. We could apply it, but that would just be unnecessary extra work.

The comments in code tell why the span is unused, it's a span of `$var` literally, which is lost for `tt` variables because their tokens are outputted directly, but kept for other variables which are outputted as [groups](https://doc.rust-lang.org/nightly/proc_macro/struct.Group.html) and `sp` is kept as the group's span.

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

3 years agoRollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-se
Mara Bos [Sun, 1 Nov 2020 10:53:36 +0000 (11:53 +0100)]
Rollup merge of #78602 - RalfJung:raw-ptr-aliasing-issues, r=m-ou-se

fix various aliasing issues in the standard library

This fixes various cases where the standard library either used raw pointers after they were already invalidated by using the original reference again, or created raw pointers for one element of a slice and used it to access neighboring elements.

3 years agoRollup merge of #78599 - panstromek:master, r=m-ou-se
Mara Bos [Sun, 1 Nov 2020 10:53:34 +0000 (11:53 +0100)]
Rollup merge of #78599 - panstromek:master, r=m-ou-se

Add note to process::arg[s] that args shouldn't be escaped or quoted

This came out of discussion on [forum](https://users.rust-lang.org/t/how-to-get-full-output-from-command/50626), where I recently asked a question and it turned out that the problem was redundant quotation:

```rust
 Command::new("rg")
        .arg("\"pattern\"") // this will look for "pattern" with quotes included
```

This is something that has bitten me few times already (in multiple languages actually), so It'd be grateful to have it in the docs, even though it's not sctrictly Rust specific problem. Other users also agreed.

This can be really annoying to debug, because in many cases (inluding mine), quotes can be legal part of the argument, so the command doesn't fail, it just behaves unexpectedly. Not everybody (including me) knows that quotes around arguments are part of the shell and not part of the called program. Coincidentally, somoene had the same problem [yesterday](https://www.reddit.com/r/rust/comments/jkxelc/going_crazy_over_running_a_curl_process_from_rust/) on reddit.

I am not a native speaker, so I welcome any corrections or better formulation, I don't expect this to be merged as is. I was also reminded that this is platform/shell specific behaviour, but I didn't find a good way to formulate that briefly, any ideas welcome.

 It's also my first PR here, so I am not sure I did everything correctly, I did this just from Github UI.

3 years agoRollup merge of #78596 - pavlukivan:master, r=m-ou-se
Mara Bos [Sun, 1 Nov 2020 10:53:33 +0000 (11:53 +0100)]
Rollup merge of #78596 - pavlukivan:master, r=m-ou-se

Fix doc links to std::fmt

`std::format` and `core::write` macros' docs linked to `core::fmt` for format string reference, even though only `std::fmt` has format string documentation (and the link titles were `std::fmt`)

3 years agoRollup merge of #78073 - fusion-engineering-forks:inline, r=eddyb
Mara Bos [Sun, 1 Nov 2020 10:53:29 +0000 (11:53 +0100)]
Rollup merge of #78073 - fusion-engineering-forks:inline, r=eddyb

Add #[inline] to some functions in core::str.

Almost all str functions already had #[inline].

3 years agoAuto merge of #78531 - cuviper:unwrap-metadata, r=tmandry
bors [Sun, 1 Nov 2020 09:30:11 +0000 (09:30 +0000)]
Auto merge of #78531 - cuviper:unwrap-metadata, r=tmandry

rustc_llvm: unwrap LLVMMetadataRef before casting

Directly casting the opaque pointer was [reported] to cause an
"incomplete type" error with GCC 9.3:

```
llvm-wrapper/RustWrapper.cpp:939:31:   required from here
/usr/include/c++/9.3/type_traits:1301:12: error: invalid use of incomplete type 'struct LLVMOpaqueMetadata'
 1301 |     struct is_base_of
      |            ^~~~~~~~~~
In file included from [...]/rust/src/llvm-project/llvm/include/llvm-c/BitReader.h:23,
                 from llvm-wrapper/LLVMWrapper.h:1,
                 from llvm-wrapper/RustWrapper.cpp:1:
[...]/rust/src/llvm-project/llvm/include/llvm-c/Types.h:89:16: note: forward declaration of 'struct LLVMOpaqueMetadata'
   89 | typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
      |                ^~~~~~~~~~~~~~~~~~
```

[reported]: https://zulip-archive.rust-lang.org/182449tcompilerhelp/12215halprustcllvmbuildfail.html#214915124

A simple `unwrap` fixes the issue.

r? `@eddyb`

3 years agoAuto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkov
bors [Sun, 1 Nov 2020 06:49:16 +0000 (06:49 +0000)]
Auto merge of #78420 - estebank:suggest-assoc-fn, r=petrochenkov

Suggest calling associated `fn` inside `trait`s

When calling a function that doesn't exist inside of a trait's
associated `fn`, and another associated `fn` in that trait has that
name, suggest calling it with the appropriate fully-qualified path.

Expand the label to be more descriptive.

Prompted by the following user experience:
https://users.rust-lang.org/t/cannot-find-function/50663

3 years agoInline Default::default() for atomics
Scott Olson [Sun, 1 Nov 2020 04:38:41 +0000 (04:38 +0000)]
Inline Default::default() for atomics

3 years agoThe need for `Single` to cover `Unlistable` was a hack
Nadrieril [Sun, 1 Nov 2020 02:04:11 +0000 (02:04 +0000)]
The need for `Single` to cover `Unlistable` was a hack

It is now unneeded, since we handle `&str` patterns in a consistent way.

3 years agoFix #78549
Nadrieril [Sun, 1 Nov 2020 01:58:48 +0000 (01:58 +0000)]
Fix #78549

Before #78430, string literals worked because `specialize_constructor`
didn't actually care too much which constructor was passed to it unless
needed. Since then, string literals are special cased and a bit hacky. I
did not anticipate patterns for the `&str` type other than string
literals, hence this bug. This makes string literals less hacky.

3 years agoAuto merge of #78147 - tmiasko:validate-storage, r=jonas-schievink
bors [Sun, 1 Nov 2020 01:27:15 +0000 (01:27 +0000)]
Auto merge of #78147 - tmiasko:validate-storage, r=jonas-schievink

Assert that locals have storage when used

The validator in visit_local asserts that local has a stroage when used,
but visit_local is never called so validation is ineffective.

Use super_statement and super_terminator to ensure that locals are visited.

3 years agoAssert that locals have storage when used
Tomasz Miąsko [Sun, 25 Oct 2020 00:00:00 +0000 (00:00 +0000)]
Assert that locals have storage when used

The validator in visit_local asserts that local has a stroage when used,
but visit_local is never called so validation is ineffective.

Use super_statement and super_terminator to ensure that locals are visited.

3 years agoAuto merge of #78594 - m-ou-se:rollup-h5c8frs, r=m-ou-se
bors [Sat, 31 Oct 2020 17:09:38 +0000 (17:09 +0000)]
Auto merge of #78594 - m-ou-se:rollup-h5c8frs, r=m-ou-se

Rollup of 7 pull requests

Successful merges:

 - #74622 (Add std::panic::panic_any.)
 - #77099 (make exp_m1 and ln_1p examples more representative of use)
 - #78526 (Strip tokens from trait and impl items before printing AST JSON)
 - #78550 (x.py setup: Create config.toml in the current directory, not the top-level directory)
 - #78577 (validator: Extend aliasing check to a call terminator)
 - #78581 (Constantify more BTreeMap and BTreeSet functions)
 - #78587 (parser: Cleanup `LazyTokenStream` and avoid some clones)

Failed merges:

r? `@ghost`

3 years agoApply suggestions from code review
Matyáš Racek [Sat, 31 Oct 2020 16:28:44 +0000 (17:28 +0100)]
Apply suggestions from code review

Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
3 years agofix aliasing issues in SipHasher
Ralf Jung [Wed, 28 Oct 2020 13:01:04 +0000 (14:01 +0100)]
fix aliasing issues in SipHasher

3 years agofix aliasing issue in binary_heap
Ralf Jung [Sat, 31 Oct 2020 15:22:24 +0000 (16:22 +0100)]
fix aliasing issue in binary_heap

3 years agofix aliasing issue in unix sleep function
Ralf Jung [Sat, 31 Oct 2020 15:16:54 +0000 (16:16 +0100)]
fix aliasing issue in unix sleep function

3 years agofix aliasing issues in u128 formatting code
Ralf Jung [Sat, 31 Oct 2020 15:13:33 +0000 (16:13 +0100)]
fix aliasing issues in u128 formatting code

3 years agoexpand: Tweak a comment in implementation of `macro_rules`
Vadim Petrochenkov [Sat, 31 Oct 2020 15:09:21 +0000 (18:09 +0300)]
expand: Tweak a comment in implementation of `macro_rules`

3 years agoAdd note to process::arg[s] that args shouldn't be escaped or quoted
Matyáš Racek [Sat, 31 Oct 2020 13:40:36 +0000 (14:40 +0100)]
Add note to process::arg[s] that args shouldn't be escaped or quoted

3 years agoFix doc links to std::fmt
Ivan Pavluk [Sat, 31 Oct 2020 10:50:08 +0000 (17:50 +0700)]
Fix doc links to std::fmt

std::format and core::write macros' docs linked to core::fmt for format string reference, even though only std::fmt has format string documentation and the link titles were std::fmt.

3 years agoRollup merge of #78587 - petrochenkov:lazytok, r=Aaron1011
Mara Bos [Sat, 31 Oct 2020 08:49:41 +0000 (09:49 +0100)]
Rollup merge of #78587 - petrochenkov:lazytok, r=Aaron1011

parser: Cleanup `LazyTokenStream` and avoid some clones

by using a named struct instead of a closure.

r? @Aaron1011

3 years agoRollup merge of #78581 - a1phyr:const_btree_more, r=dtolnay
Mara Bos [Sat, 31 Oct 2020 08:49:39 +0000 (09:49 +0100)]
Rollup merge of #78581 - a1phyr:const_btree_more, r=dtolnay

Constantify more BTreeMap and BTreeSet functions

Just because we can:

- `BTreeMap::len`
- `BTreeMap::is_empty`
- `BTreeSet::len`
- `BTreeSet::is_empty`

Note that I put the `const` under `const_btree_new`, because I don't think their is a need to create another feature flag for that.

cc #71835

3 years agoRollup merge of #78577 - tmiasko:validate-aliasing, r=jonas-schievink
Mara Bos [Sat, 31 Oct 2020 08:49:38 +0000 (09:49 +0100)]
Rollup merge of #78577 - tmiasko:validate-aliasing, r=jonas-schievink

validator: Extend aliasing check to a call terminator

3 years agoRollup merge of #78550 - jyn514:setup, r=Mark-Simulacrum
Mara Bos [Sat, 31 Oct 2020 08:49:36 +0000 (09:49 +0100)]
Rollup merge of #78550 - jyn514:setup, r=Mark-Simulacrum

x.py setup: Create config.toml in the current directory, not the top-level directory

See https://github.com/rust-lang/rust/issues/78509 for discussion.

r? @pnkfelix
cc @cuviper @Mark-Simulacrum

3 years agoRollup merge of #78526 - Aaron1011:fix/assoc-tokens, r=estebank
Mara Bos [Sat, 31 Oct 2020 08:49:34 +0000 (09:49 +0100)]
Rollup merge of #78526 - Aaron1011:fix/assoc-tokens, r=estebank

Strip tokens from trait and impl items before printing AST JSON

Fixes #78510

3 years agoRollup merge of #77099 - tspiteri:exp_m1-examples, r=m-ou-se
Mara Bos [Sat, 31 Oct 2020 08:49:32 +0000 (09:49 +0100)]
Rollup merge of #77099 - tspiteri:exp_m1-examples, r=m-ou-se

make exp_m1 and ln_1p examples more representative of use

With this PR, the examples for `exp_m1` would fail if `x.exp() - 1.0` is used instead of `x.exp_m1()`, and the examples for `ln_1p` would fail if `(x + 1.0).ln()` is used instead of `x.ln_1p()`.

3 years agoRollup merge of #74622 - fusion-engineering-forks:panic-box, r=KodrAus
Mara Bos [Sat, 31 Oct 2020 08:49:28 +0000 (09:49 +0100)]
Rollup merge of #74622 - fusion-engineering-forks:panic-box, r=KodrAus

Add std::panic::panic_any.

The discussion of #67984 lead to the conclusion that there should be a macro or function separate from `std::panic!()` for throwing arbitrary payloads, to make it possible to deprecate or disallow (in edition 2021) `std::panic!(arbitrary_payload)`.

Alternative names:

- `panic_with!(..)`
- ~~`start_unwind(..)`~~ (panicking doesn't always unwind)
- `throw!(..)`
- `panic_throwing!(..)`
- `panic_with_value(..)`
- `panic_value(..)`
- `panic_with(..)`
- `panic_box(..)`
- `panic(..)`

The equivalent (private, unstable) function in `libstd` is called `std::panicking::begin_panic`.

I suggest `panic_any`, because it allows for any (`Any + Send`) type.

_Tracking issue: #78500_

3 years agoUpdate Clippy path to `Lint`
Aaron Hill [Sat, 31 Oct 2020 01:41:16 +0000 (21:41 -0400)]
Update Clippy path to `Lint`

3 years agoAuto merge of #76257 - JulianKnodt:i75777, r=Dylan-DPC
bors [Sat, 31 Oct 2020 01:34:49 +0000 (01:34 +0000)]
Auto merge of #76257 - JulianKnodt:i75777, r=Dylan-DPC

Add regression test

This adds a regression test for #75777, effectively closing it since it is solved on nightly and beta.

Closes #75777

3 years agoFix test
Aaron Hill [Tue, 20 Oct 2020 11:57:24 +0000 (07:57 -0400)]
Fix test

3 years agoAlways pass `-Z future-incompat-report` to UI tests
Aaron Hill [Mon, 19 Oct 2020 15:55:35 +0000 (11:55 -0400)]
Always pass `-Z future-incompat-report` to UI tests

3 years agoDon't display empty future-compat report
Aaron Hill [Mon, 19 Oct 2020 15:54:09 +0000 (11:54 -0400)]
Don't display empty future-compat report

3 years agoUpdate into-iter-on-arrays test to check future-incompat-report
Aaron Hill [Mon, 19 Oct 2020 15:50:36 +0000 (11:50 -0400)]
Update into-iter-on-arrays test to check future-incompat-report

3 years agoOnly error on unfixed diagnostics
Aaron Hill [Mon, 19 Oct 2020 15:49:07 +0000 (11:49 -0400)]
Only error on unfixed diagnostics

3 years agoStrip out non-diagnostic lines from rustfix input
Aaron Hill [Mon, 19 Oct 2020 15:43:38 +0000 (11:43 -0400)]
Strip out non-diagnostic lines from rustfix input

3 years agoPrint future breakage report
Aaron Hill [Mon, 19 Oct 2020 15:19:37 +0000 (11:19 -0400)]
Print future breakage report

3 years agoSome work
Aaron Hill [Sun, 18 Oct 2020 19:28:23 +0000 (15:28 -0400)]
Some work

3 years agoImplement rustc side of report-future-incompat
Aaron Hill [Thu, 13 Aug 2020 19:41:52 +0000 (15:41 -0400)]
Implement rustc side of report-future-incompat

3 years agoparser: Cleanup `LazyTokenStream` and avoid some clones
Vadim Petrochenkov [Fri, 30 Oct 2020 21:40:41 +0000 (00:40 +0300)]
parser: Cleanup `LazyTokenStream` and avoid some clones

by using a named struct instead of a closure.

3 years agoAuto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk
bors [Fri, 30 Oct 2020 22:53:55 +0000 (22:53 +0000)]
Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obk

TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

Implements MCP rust-lang/compiler-team#374.

Blocked on FCP in rust-lang/compiler-team#374.
r? `@lcnr` cc `@jonas-schievink`

3 years agoConstantify more BTreeMap and BTreeSet functions
Benoît du Garreau [Fri, 30 Oct 2020 18:24:08 +0000 (19:24 +0100)]
Constantify more BTreeMap and BTreeSet functions

- BTreeMap::len
- BTreeMap::is_empty
- BTreeSet::len
- BTreeSet::is_empty

3 years agoAuto merge of #78424 - jyn514:THE-PAPERCLIP-COMETH, r=davidtwco
bors [Fri, 30 Oct 2020 14:24:02 +0000 (14:24 +0000)]
Auto merge of #78424 - jyn514:THE-PAPERCLIP-COMETH, r=davidtwco

Fix some more clippy warnings

Found while working on https://github.com/rust-lang/rust/pull/77351. It turns out that `x.py clippy --fix` does work on that branch as long as you pass `CARGOFLAGS=--lib`.

3 years agoAdd back missing comments
Joshua Nelson [Tue, 27 Oct 2020 14:55:26 +0000 (10:55 -0400)]
Add back missing comments

3 years agoFix even more clippy warnings
Joshua Nelson [Tue, 27 Oct 2020 01:02:48 +0000 (21:02 -0400)]
Fix even more clippy warnings

3 years agoFix some more clippy warnings
Joshua Nelson [Tue, 27 Oct 2020 00:02:06 +0000 (20:02 -0400)]
Fix some more clippy warnings

3 years agoRemove implicit `Continue` type
LeSeulArtichaut [Sun, 25 Oct 2020 10:50:56 +0000 (11:50 +0100)]
Remove implicit `Continue` type

3 years agoUse `ControlFlow::is{break,continue}`
LeSeulArtichaut [Thu, 22 Oct 2020 08:20:24 +0000 (10:20 +0200)]
Use `ControlFlow::is{break,continue}`

3 years agoTypeVisitor: use `ControlFlow` in clippy
LeSeulArtichaut [Wed, 21 Oct 2020 12:27:32 +0000 (14:27 +0200)]
TypeVisitor: use `ControlFlow` in clippy

3 years agoTypeVisitor: use `ControlFlow` in rustc_{mir,privacy,traits,typeck}
LeSeulArtichaut [Wed, 21 Oct 2020 12:26:34 +0000 (14:26 +0200)]
TypeVisitor: use `ControlFlow` in rustc_{mir,privacy,traits,typeck}

3 years agoTypeVisitor: use `ControlFlow` in rustc_{infer,lint,trait_selection}
LeSeulArtichaut [Wed, 21 Oct 2020 12:24:35 +0000 (14:24 +0200)]
TypeVisitor: use `ControlFlow` in rustc_{infer,lint,trait_selection}

3 years agoTypeVisitor: use `std::ops::ControlFlow` instead of `bool`
LeSeulArtichaut [Wed, 21 Oct 2020 12:22:44 +0000 (14:22 +0200)]
TypeVisitor: use `std::ops::ControlFlow` instead of `bool`

3 years agoAuto merge of #78562 - JohnTitor:rollup-otg906u, r=JohnTitor
bors [Fri, 30 Oct 2020 10:01:49 +0000 (10:01 +0000)]
Auto merge of #78562 - JohnTitor:rollup-otg906u, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #77334 (Reorder benches const variable)
 - #77888 (Simplify a nested bool match)
 - #77921 (f64: Refactor collapsible_if)
 - #78523 (Revert invalid `fn` return type parsing change)
 - #78524 (Avoid BorrowMutError with RUSTC_LOG=debug)
 - #78545 (Make anonymous binders start at 0)
 - #78554 (Improve wording of `core::ptr::drop_in_place` docs)
 - #78556 (Link to pass docs from NRVO module docs)

Failed merges:

 - #78424 (Fix some more clippy warnings)

r? `@ghost`

3 years agoRollup merge of #78556 - camelid:mir-opt-nrvo-docs, r=jyn514
Yuki Okushi [Fri, 30 Oct 2020 09:00:58 +0000 (18:00 +0900)]
Rollup merge of #78556 - camelid:mir-opt-nrvo-docs, r=jyn514

Link to pass docs from NRVO module docs

It can be easy to miss that this is documented on the pass's struct if you are
looking at the module docs.

Cc https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/what.20is.20NRVO.3F

3 years agoRollup merge of #78554 - camelid:improve-drop_in_place-docs-wording, r=jyn514
Yuki Okushi [Fri, 30 Oct 2020 09:00:58 +0000 (18:00 +0900)]
Rollup merge of #78554 - camelid:improve-drop_in_place-docs-wording, r=jyn514

Improve wording of `core::ptr::drop_in_place` docs

And two small intra-doc link conversions in `std::{f32, f64}`.

3 years agoRollup merge of #78545 - jackh726:anonymous, r=oli-obk
Yuki Okushi [Fri, 30 Oct 2020 09:00:56 +0000 (18:00 +0900)]
Rollup merge of #78545 - jackh726:anonymous, r=oli-obk

Make anonymous binders start at 0

A few changes to some test outputs, but these actually look *more* correct to me.

3 years agoRollup merge of #78524 - tmiasko:source-files-borrow, r=Aaron1011
Yuki Okushi [Fri, 30 Oct 2020 09:00:54 +0000 (18:00 +0900)]
Rollup merge of #78524 - tmiasko:source-files-borrow, r=Aaron1011

Avoid BorrowMutError with RUSTC_LOG=debug

```console
$ touch empty.rs
$ env RUSTC_LOG=debug rustc +stage1 --crate-type=lib empty.rs
```

Fails with a `BorrowMutError` because source map files are already
borrowed while `features_query` attempts to format a log message
containing a span.

Release the borrow before the query to avoid the issue.

3 years agoRollup merge of #78523 - estebank:fix-return-type-parse-regression, r=dtolnay
Yuki Okushi [Fri, 30 Oct 2020 09:00:53 +0000 (18:00 +0900)]
Rollup merge of #78523 - estebank:fix-return-type-parse-regression, r=dtolnay

Revert invalid `fn` return type parsing change

Revert one of the changes in #78379.

Fix #78507.

3 years agoRollup merge of #77921 - wcampbell0x2a:f64-collapsible-if, r=jyn514
Yuki Okushi [Fri, 30 Oct 2020 09:00:49 +0000 (18:00 +0900)]
Rollup merge of #77921 - wcampbell0x2a:f64-collapsible-if, r=jyn514

f64: Refactor collapsible_if

3 years agoRollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514
Yuki Okushi [Fri, 30 Oct 2020 09:00:45 +0000 (18:00 +0900)]
Rollup merge of #77888 - LingMan:ast_pretty_tt_prepend_space, r=jyn514

Simplify a nested bool match

Logically this first eliminates the innermost match by merging the patterns.
Then, in a second step, turns the newly innermost match into a `matches!` call.

3 years agoRollup merge of #77334 - pickfire:patch-4, r=jyn514
Yuki Okushi [Fri, 30 Oct 2020 09:00:41 +0000 (18:00 +0900)]
Rollup merge of #77334 - pickfire:patch-4, r=jyn514

Reorder benches const variable

Move LEN so it is is read in order.

3 years agoAdd regression test
kadmin [Wed, 2 Sep 2020 19:19:43 +0000 (19:19 +0000)]
Add regression test

3 years agoAuto merge of #78393 - SNCPlay42:match-if-guard, r=tmandry
bors [Fri, 30 Oct 2020 07:05:57 +0000 (07:05 +0000)]
Auto merge of #78393 - SNCPlay42:match-if-guard, r=tmandry

Always record reference to binding in match if guards

When encountering a binding from a `match` pattern in its `if` guard when computing a generator's interior types, we must always record the type of a reference to the binding because of how `if` guards are lowered to MIR. This was missed in #75213 because the binding in that test case was autorefed and we recorded that adjusted type anyway.

Fixes #78366

3 years agoLink to pass docs from NRVO module docs
Camelid [Fri, 30 Oct 2020 06:05:45 +0000 (23:05 -0700)]
Link to pass docs from NRVO module docs

3 years agoImprove wording of `core::ptr::drop_in_place` docs
Camelid [Fri, 30 Oct 2020 03:09:29 +0000 (20:09 -0700)]
Improve wording of `core::ptr::drop_in_place` docs

And two small intra-doc link conversions in `std::{f32, f64}`.

3 years agoAuto merge of #78432 - sexxi-goose:fix-77993-take3, r=nikomatsakis
bors [Fri, 30 Oct 2020 03:00:13 +0000 (03:00 +0000)]
Auto merge of #78432 - sexxi-goose:fix-77993-take3, r=nikomatsakis

Handle type errors in closure/generator upvar_tys

Fixes #77993

3 years agoCreate config.toml in the current directory, not the top-level directory
Joshua Nelson [Fri, 30 Oct 2020 01:23:55 +0000 (21:23 -0400)]
Create config.toml in the current directory, not the top-level directory

See https://github.com/rust-lang/rust/issues/78509 for discussion.

3 years agoAuto merge of #78540 - RalfJung:miri, r=RalfJung
bors [Fri, 30 Oct 2020 00:28:32 +0000 (00:28 +0000)]
Auto merge of #78540 - RalfJung:miri, r=RalfJung

update Miri

Cc `@rust-lang/miri` r? `@ghost`

3 years agovalidator: Extend aliasing check to a call terminator
Tomasz Miąsko [Fri, 30 Oct 2020 00:00:00 +0000 (00:00 +0000)]
validator: Extend aliasing check to a call terminator

3 years agoMake anonymous binders start at 0
Jack Huey [Thu, 29 Oct 2020 22:42:31 +0000 (18:42 -0400)]
Make anonymous binders start at 0

3 years agoAuto merge of #78528 - jonas-schievink:rollup-e70g9zk, r=jonas-schievink
bors [Thu, 29 Oct 2020 20:56:25 +0000 (20:56 +0000)]
Auto merge of #78528 - jonas-schievink:rollup-e70g9zk, r=jonas-schievink

Rollup of 11 pull requests

Successful merges:

 - #75078 (Improve documentation for slice strip_* functions)
 - #76138 (Explain fully qualified syntax for `Rc` and `Arc`)
 - #78244 (Dogfood {exclusive,half-open} ranges in compiler (nfc))
 - #78422 (Do not ICE on invalid input)
 - #78423 (rustc_span: improve bounds checks in byte_pos_to_line_and_col)
 - #78431 (Prefer new associated numeric consts in float error messages)
 - #78462 (Use unwrapDIPtr because the Scope may be null.)
 - #78493 (Update cargo)
 - #78499 (Prevent String::retain from creating non-utf8 strings when abusing panic)
 - #78505 (Update Clippy - temporary_cstring_as_ptr deprecation)
 - #78527 (Fix some more typos)

Failed merges:

r? `@ghost`

3 years agoupdate Miri
Ralf Jung [Thu, 29 Oct 2020 20:33:37 +0000 (21:33 +0100)]
update Miri

3 years agoAuto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkov
bors [Thu, 29 Oct 2020 18:34:59 +0000 (18:34 +0000)]
Auto merge of #78508 - wesleywiser:optimize_visit_scopes, r=petrochenkov

[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot path

This improves the performance of the `resolve_crate` function by 30% for
a very large single file crate with auto-generated C bindings.

cc `@rylev`

3 years agorustc_llvm: unwrap LLVMMetadataRef before casting
Josh Stone [Thu, 29 Oct 2020 16:45:15 +0000 (09:45 -0700)]
rustc_llvm: unwrap LLVMMetadataRef before casting

Directly casting the opaque pointer was [reported] to cause an
"incomplete type" error with GCC 9.3:

```
llvm-wrapper/RustWrapper.cpp:939:31:   required from here
/usr/include/c++/9.3/type_traits:1301:12: error: invalid use of incomplete type 'struct LLVMOpaqueMetadata'
 1301 |     struct is_base_of
      |            ^~~~~~~~~~
In file included from [...]/rust/src/llvm-project/llvm/include/llvm-c/BitReader.h:23,
                 from llvm-wrapper/LLVMWrapper.h:1,
                 from llvm-wrapper/RustWrapper.cpp:1:
[...]/rust/src/llvm-project/llvm/include/llvm-c/Types.h:89:16: note: forward declaration of 'struct LLVMOpaqueMetadata'
   89 | typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
      |                ^~~~~~~~~~~~~~~~~~
```

[reported]: https://zulip-archive.rust-lang.org/182449tcompilerhelp/12215halprustcllvmbuildfail.html#214915124

A simple `unwrap` fixes the issue.

3 years agoRollup merge of #78527 - bugadani:typo3, r=jonas-schievink
Jonas Schievink [Thu, 29 Oct 2020 16:05:31 +0000 (17:05 +0100)]
Rollup merge of #78527 - bugadani:typo3, r=jonas-schievink

Fix some more typos

3 years agoRollup merge of #78505 - ebroto:clippyup, r=oli-obk
Jonas Schievink [Thu, 29 Oct 2020 16:05:30 +0000 (17:05 +0100)]
Rollup merge of #78505 - ebroto:clippyup, r=oli-obk

Update Clippy - temporary_cstring_as_ptr deprecation

In #75671 `clippy::temporary_cstr_as_ptr` was removed instead of being deprecated. This will trigger an error (unknown lint) for users that refer to that lint to e.g. allow it, instead of a more informative warning.

This update should fix that for nightly users.

r? @oli-obk

3 years agoRollup merge of #78499 - SkiFire13:fix-string-retain, r=m-ou-se
Jonas Schievink [Thu, 29 Oct 2020 16:05:28 +0000 (17:05 +0100)]
Rollup merge of #78499 - SkiFire13:fix-string-retain, r=m-ou-se

Prevent String::retain from creating non-utf8 strings when abusing panic

Fixes #78498

The idea is the same as `Vec::drain`, set the len to 0 so that nobody can observe the broken invariant if it escapes the function (in this case if `f` panics)

3 years agoRollup merge of #78493 - ehuss:update-cargo, r=ehuss
Jonas Schievink [Thu, 29 Oct 2020 16:05:26 +0000 (17:05 +0100)]
Rollup merge of #78493 - ehuss:update-cargo, r=ehuss

Update cargo

8 commits in dd83ae55c871d94f060524656abab62ec40b4c40..becb4c282b8f37469efb8f5beda45a5501f9d367
2020-10-20 19:31:26 +0000 to 2020-10-28 16:41:55 +0000
- List available packages if providing `--package` with an empty value (rust-lang/cargo#8808)
- Add a future-compatibility warning on allowed feature name characters. (rust-lang/cargo#8814)
- New namespaced features implementation. (rust-lang/cargo#8799)
- Remove redundant "For example, " (rust-lang/cargo#8810)
- Document platform-specific build-dependencies (rust-lang/cargo#8809)
- Remove some unused code. (rust-lang/cargo#8807)
- Some minor clippy fixes. (rust-lang/cargo#8804)
- Update TOML website links. (rust-lang/cargo#8803)

3 years agoRollup merge of #78462 - danielframpton:fixnullisa, r=nagisa
Jonas Schievink [Thu, 29 Oct 2020 16:05:23 +0000 (17:05 +0100)]
Rollup merge of #78462 - danielframpton:fixnullisa, r=nagisa

Use unwrapDIPtr because the Scope may be null.

I ran into an assertion when using debug information on Windows with LLVM assertions enabled.

It seems like we are using unwrap here (which in turn calls isa and requires the pointer to be non-null) but we expect the value to be null because that is what we are passing from rustc.

This change uses unwrapDIPtr which explicitly allows nullptr.

The FFI prototype for this method on the rust side has the `LLVMMetadataRef` parameter as `Scope: Option<&'a DIScope>`, and we always pass `None` when `msvc_like_names` is true.

3 years agoRollup merge of #78431 - Rustin-Liu:rustin-patch-lint, r=estebank
Jonas Schievink [Thu, 29 Oct 2020 16:05:21 +0000 (17:05 +0100)]
Rollup merge of #78431 - Rustin-Liu:rustin-patch-lint, r=estebank

Prefer new associated numeric consts in float error messages

Fix https://github.com/rust-lang/rust/issues/78382

3 years agoRollup merge of #78423 - tgnottingham:caching_source_map_bounds_check, r=oli-obk
Jonas Schievink [Thu, 29 Oct 2020 16:05:17 +0000 (17:05 +0100)]
Rollup merge of #78423 - tgnottingham:caching_source_map_bounds_check, r=oli-obk

rustc_span: improve bounds checks in byte_pos_to_line_and_col

The effect of this change is to consider edge-case spans that start or
end at the position one past the end of a file to be valid during span
hashing and encoding. This change means that these spans will be
preserved across incremental compilation sessions when they are part of
a serialized query result, instead of causing the dummy span to be used.

3 years agoRollup merge of #78422 - estebank:fix-78372, r=pnkfelix
Jonas Schievink [Thu, 29 Oct 2020 16:05:14 +0000 (17:05 +0100)]
Rollup merge of #78422 - estebank:fix-78372, r=pnkfelix

Do not ICE on invalid input

Fix #78372.

3 years agoRollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkor
Jonas Schievink [Thu, 29 Oct 2020 16:05:11 +0000 (17:05 +0100)]
Rollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkor

Dogfood {exclusive,half-open} ranges in compiler (nfc)

In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.

3 years agoRollup merge of #76138 - camelid:rc-fully-qualified-syntax, r=steveklabnik
Jonas Schievink [Thu, 29 Oct 2020 16:05:08 +0000 (17:05 +0100)]
Rollup merge of #76138 - camelid:rc-fully-qualified-syntax, r=steveklabnik

Explain fully qualified syntax for `Rc` and `Arc`

Also cleaned up some other small things.

@rustbot modify labels: T-doc

3 years agoRollup merge of #75078 - ijackson:slice-strip, r=steveklabnik
Jonas Schievink [Thu, 29 Oct 2020 16:05:00 +0000 (17:05 +0100)]
Rollup merge of #75078 - ijackson:slice-strip, r=steveklabnik

Improve documentation for slice strip_* functions

Prompted by the stabilisation tracking issue #73413 I looked at the docs for `strip_prefix` and `strip_suffix` for both `str` and `slice`, and I felt they could be slightly improved.

Thanks for your attention.

3 years agoFix typos
Dániel Buga [Thu, 29 Oct 2020 15:51:46 +0000 (16:51 +0100)]
Fix typos

3 years agoStrip tokens from trait and impl items before printing AST JSON
Aaron Hill [Thu, 29 Oct 2020 15:37:55 +0000 (11:37 -0400)]
Strip tokens from trait and impl items before printing AST JSON

Fixes #78510

3 years agoAdd regression test
Esteban Küber [Thu, 29 Oct 2020 15:32:13 +0000 (08:32 -0700)]
Add regression test

3 years agoRevert invalid `fn` return type parsing change
Esteban Küber [Thu, 29 Oct 2020 15:26:42 +0000 (08:26 -0700)]
Revert invalid `fn` return type parsing change

Fix #78507.

3 years agoAuto merge of #78446 - RalfJung:box, r=Amanieu
bors [Thu, 29 Oct 2020 12:08:16 +0000 (12:08 +0000)]
Auto merge of #78446 - RalfJung:box, r=Amanieu

fix Box::into_unique

https://github.com/rust-lang/rust/pull/77187/ broke Stacked Borrows pointer tagging around `Box::into_unique` (this is caused by `Box` being a special case in the type system, which box-internal code needs to account for). This PR fixes that.

r? `@Amanieu` Cc `@TimDiekmann`

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

3 years agoAdded test for issue #78498
Giacomo Stevanato [Thu, 29 Oct 2020 10:48:56 +0000 (11:48 +0100)]
Added test for issue #78498

3 years agoPrevent String::retain from creating non-utf8 strings when abusing panic
Giacomo Stevanato [Wed, 28 Oct 2020 17:52:45 +0000 (18:52 +0100)]
Prevent String::retain from creating non-utf8 strings when abusing panic

3 years agoAuto merge of #78506 - cuviper:ubuntu-lts, r=pietroalbini
bors [Thu, 29 Oct 2020 09:27:08 +0000 (09:27 +0000)]
Auto merge of #78506 - cuviper:ubuntu-lts, r=pietroalbini

ci: update x86_64-gnu and x86_64-gnu-debug to ubuntu:20.04

The former `ubuntu:19.10` reached EOL in July, 2020, whereas
`ubuntu:20.04` is an LTS release supported until 2025.

These are non-dist CI images, so the impact should be low.

3 years agoAuto merge of #78486 - pietroalbini:manifest-artifacts, r=Mark-Simulacrum
bors [Thu, 29 Oct 2020 06:18:12 +0000 (06:18 +0000)]
Auto merge of #78486 - pietroalbini:manifest-artifacts, r=Mark-Simulacrum

Include non-rustup artifacts in the manifest

This PR fixes https://github.com/rust-lang/promote-release/issues/22 by including all the files we ship in the generated manifests, even the ones that are not installable through rustup. In practice this adds the following "artifacts":

* `source-code`: the tarball containing the full source code used to build the release (`rustc-{channel}-src.tar.xz`)
* `installer-msi`: the MSI installer for Windows systems (`rust-{channel}-{target}.msi`)
* `installer-pkg`: the PKG installer for macOS systems (`rust-{channel}-{target}.pkg`)

These files are included in a new `artifacts` table of the manifest, like so:

```toml
[[artifacts.installer-msi.target.aarch64-pc-windows-msvc]]
url = "https://example.com/2020-10-28/rust-nightly-aarch64-pc-windows-msvc.msi"
hash-sha256 = "6b41d5b829d20834c5d93628d008ec618f8914ee79303363bd13a86fd5f305dd"

[[artifacts.installer-msi.target.i686-pc-windows-gnu]]
url = "https://example.com/2020-10-28/rust-nightly-i686-pc-windows-gnu.msi"
hash-sha256 = "83f020de6e180c155add9fce1cea2ac6e5f744edbd6dc1581e24de8f56b2ca7a"

[[artifacts.installer-msi.target.i686-pc-windows-msvc]]
url = "https://example.com/2020-10-28/rust-nightly-i686-pc-windows-msvc.msi"
hash-sha256 = "dbc80c24e9d5df01616c6f216114b4351f51a94218e2368b5cebe4165b270702"

[[artifacts.installer-msi.target.x86_64-pc-windows-gnu]]
url = "https://example.com/2020-10-28/rust-nightly-x86_64-pc-windows-gnu.msi"
hash-sha256 = "8196eca3f02d72d4c8776ad4fcc72897125e2cf6404ae933e31c07e197e3c9fa"

[[artifacts.installer-msi.target.x86_64-pc-windows-msvc]]
url = "https://example.com/2020-10-28/rust-nightly-x86_64-pc-windows-msvc.msi"
hash-sha256 = "b2e7fd6463790732fcf9c726b9448068712341943199cb40fc11d1138b8a207b"

[[artifacts.installer-pkg.target.aarch64-apple-darwin]]
url = "https://example.com/2020-10-28/rust-nightly-aarch64-apple-darwin.pkg"
hash-sha256 = "70421c191752fb33886f8033b029e634bcc993b72308cef52a38405840e91f5c"

[[artifacts.installer-pkg.target.x86_64-apple-darwin]]
url = "https://example.com/2020-10-28/rust-nightly-x86_64-apple-darwin.pkg"
hash-sha256 = "ebd7a5acb61e82d85e855146cc9bd856f32228ee7f40dd94c659b00614ed4f1f"

[[artifacts.source-code.target."*"]]
url = "https://example.com/2020-10-28/rustc-nightly-src.tar.gz"
hash-sha256 = "5fcc487ee4c15c689de8ddf7daac7ff6a65c80498197b9aea58622dc2b3bca10"

[[artifacts.source-code.target."*"]]
url = "https://example.com/2020-10-28/rustc-nightly-src.tar.xz"
hash-sha256 = "0c618ef0ec5f64da1801e9d0df6c755f6ed1a8780ec5c8ee75e55614be51d42c"

```

Each artifact can be available for multiple targets, and each target can have multiple versions of the same file (for example, a `gz`-compressed one and a `xz`-compressed one). In the future rustup might add functionality to let users retrieve the artifacts, but that's not needed to land this PR, and whether to do the implementation is up to the rustup maintainers.

r? `@kinnison`
cc `@Mark-Simulacrum`

3 years agoAuto merge of #78512 - JohnTitor:rollup-a7qwjah, r=JohnTitor
bors [Thu, 29 Oct 2020 03:57:54 +0000 (03:57 +0000)]
Auto merge of #78512 - JohnTitor:rollup-a7qwjah, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #77213 (rustdoc options to set default theme (and other settings))
 - #78224 (min_const_generics: allow ty param in repeat expr)
 - #78428 (MinConstGenerics UI test for invalid values for bool & char)
 - #78460 (Adjust turbofish help message for const generics)
 - #78470 (Clean up intra-doc links in `std::path`)
 - #78475 (fix a comment in validity check)
 - #78478 (Add const generics tests for supertraits + dyn traits.)
 - #78487 (Fix typo "compiltest")
 - #78491 (Inline NonZeroN::from(n))
 - #78492 (Update books)
 - #78494 (Fix typos)

Failed merges:

r? `@ghost`

3 years agoDogfood {exclusive,half-open} ranges in compiler (nfc)
Jubilee Young [Thu, 22 Oct 2020 18:42:44 +0000 (11:42 -0700)]
Dogfood {exclusive,half-open} ranges in compiler (nfc)

In particular, this allows us to write more explicit matches that
avoid the pitfalls of using a fully general fall-through case, yet
remain fairly ergonomic. Less logic is in guard cases, more is in
the actual exhaustive case analysis.

No functional changes.