]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoBTreeMap: avoid aliasing while handling underfull nodes
Stein Somers [Thu, 22 Oct 2020 18:57:11 +0000 (20:57 +0200)]
BTreeMap: avoid aliasing while handling underfull nodes

3 years agoAuto merge of #78965 - jryans:emscripten-threads-libc, r=kennytm
bors [Thu, 12 Nov 2020 05:52:17 +0000 (05:52 +0000)]
Auto merge of #78965 - jryans:emscripten-threads-libc, r=kennytm

Update thread and futex APIs to work with Emscripten

This updates the thread and futex APIs in `std` to match the APIs exposed by
Emscripten. This allows threads to run on `wasm32-unknown-emscripten` and the
thread parker to compile without errors related to the missing `futex` module.

To make use of this, Rust code must be compiled with `-C target-feature=atomics`
and Emscripten must link with `-pthread`.

I have confirmed this works well locally when building multithreaded crates.
Attempting to enable `std` thread tests currently fails for seemingly obscure
reasons and Emscripten is currently disabled in CI, so further work is needed to
have proper test coverage here.

3 years agoFix timeout conversion
J. Ryan Stinnett [Thu, 12 Nov 2020 03:40:15 +0000 (03:40 +0000)]
Fix timeout conversion

3 years agoUpdate thread and futex APIs to work with Emscripten
J. Ryan Stinnett [Wed, 11 Nov 2020 22:25:48 +0000 (22:25 +0000)]
Update thread and futex APIs to work with Emscripten

This updates the thread and futex APIs in `std` to match the APIs exposed by
Emscripten. This allows threads to run on `wasm32-unknown-emscripten` and the
thread parker to compile without errors related to the missing `futex` module.

To make use of this, Rust code must be compiled with `-C target-feature=atomics`
and Emscripten must link with `-pthread`.

I have confirmed this works well locally when building multithreaded crates.
Attempting to enable `std` thread tests currently fails for seemingly obscure
reasons and Emscripten is currently disabled in CI, so further work is needed to
have proper test coverage here.

3 years agoAuto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011
bors [Thu, 12 Nov 2020 00:33:55 +0000 (00:33 +0000)]
Auto merge of #78782 - petrochenkov:nodoctok, r=Aaron1011

Do not collect tokens for doc comments

Doc comment is a single token and AST has all the information to re-create it precisely.
Doc comments are also responsible for majority of calls to `collect_tokens` (with `num_calls == 1` and `num_calls == 0`, cc https://github.com/rust-lang/rust/pull/78736).

(I also moved token collection into `fn parse_attribute` to deduplicate code a bit.)

r? `@Aaron1011`

3 years agoAuto merge of #78956 - jonas-schievink:rollup-r53giob, r=jonas-schievink
bors [Wed, 11 Nov 2020 22:20:07 +0000 (22:20 +0000)]
Auto merge of #78956 - jonas-schievink:rollup-r53giob, r=jonas-schievink

Rollup of 11 pull requests

Successful merges:

 - #78216 (Duration::zero() -> Duration::ZERO)
 - #78354 (Support enable/disable sanitizers/profiler per target)
 - #78417 (BTreeMap: split off most code of append)
 - #78832 (look at assoc ct, check the type of nodes)
 - #78873 (Add flags customizing behaviour of MIR inlining)
 - #78899 (Support inlining diverging function calls)
 - #78923 (Cleanup and comment intra-doc link pass)
 - #78929 (rustc_target: Move target env "gnu" from `linux_base` to `linux_gnu_base`)
 - #78930 (rustc_taret: Remove `TargetOptions::is_like_android`)
 - #78942 (Fix typo in comment)
 - #78947 (Ship llvm-cov through llvm-tools)

Failed merges:

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

3 years agoRollup merge of #78947 - dalance:llvm_cov, r=Mark-Simulacrum
Jonas Schievink [Wed, 11 Nov 2020 19:59:14 +0000 (20:59 +0100)]
Rollup merge of #78947 - dalance:llvm_cov, r=Mark-Simulacrum

Ship llvm-cov through llvm-tools

`llvm-cov` is used to generate coverage report with LLVM InstrProf-based code coverage #34701.
So if `llvm-cov` is shipped through llvm-tools, users can try it easily accorging to the instruction of [The Rust Unstable Book](https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/source-based-code-coverage.html).

3 years agoRollup merge of #78942 - eltociear:patch-1, r=jonas-schievink
Jonas Schievink [Wed, 11 Nov 2020 19:59:12 +0000 (20:59 +0100)]
Rollup merge of #78942 - eltociear:patch-1, r=jonas-schievink

Fix typo in comment

occurences -> occurrences

3 years agoRollup merge of #78930 - petrochenkov:notlikeandroid, r=Mark-Simulacrum
Jonas Schievink [Wed, 11 Nov 2020 19:59:10 +0000 (20:59 +0100)]
Rollup merge of #78930 - petrochenkov:notlikeandroid, r=Mark-Simulacrum

rustc_taret: Remove `TargetOptions::is_like_android`

This option was replaced by more specific options and is no longer used by the compiler.

3 years agoRollup merge of #78929 - petrochenkov:linuxbase, r=joshtriplett
Jonas Schievink [Wed, 11 Nov 2020 19:59:09 +0000 (20:59 +0100)]
Rollup merge of #78929 - petrochenkov:linuxbase, r=joshtriplett

rustc_target: Move target env "gnu" from `linux_base` to `linux_gnu_base`

Follow up to https://github.com/rust-lang/rust/pull/77729.

Changes the target spec hierarchy for Linux from
```
linux_base
├── linux_musl_base
└── linux_uclibc_base
```
where `linux_base` is really `linux_gnu_base` and the inheriting targets replace target env "gnu" with "musl"/"uclibc" to
```
linux_base
├── linux_gnu_base
├── linux_musl_base
└── linux_uclibc_base
```
which is slightly less confusing (I think).

3 years agoRollup merge of #78923 - jyn514:intra-doc-comments, r=Manishearth
Jonas Schievink [Wed, 11 Nov 2020 19:59:07 +0000 (20:59 +0100)]
Rollup merge of #78923 - jyn514:intra-doc-comments, r=Manishearth

Cleanup and comment intra-doc link pass

r? ```@Manishearth```
cc ```@seeplusplus```

3 years agoRollup merge of #78899 - tmiasko:inline-diverging, r=oli-obk
Jonas Schievink [Wed, 11 Nov 2020 19:59:05 +0000 (20:59 +0100)]
Rollup merge of #78899 - tmiasko:inline-diverging, r=oli-obk

Support inlining diverging function calls

The existing heuristic does penalize diverging calls to some degree, but since
it never inlined them previously it might need some further modifications.

Additionally introduce storage markers for all temporaries created by
the inliner. The temporary introduced for destination rebrorrow, didn't
use them previously.

3 years agoRollup merge of #78873 - tmiasko:inline-opts, r=oli-obk
Jonas Schievink [Wed, 11 Nov 2020 19:59:03 +0000 (20:59 +0100)]
Rollup merge of #78873 - tmiasko:inline-opts, r=oli-obk

Add flags customizing behaviour of MIR inlining

* `-Zinline-mir-threshold` to change the default threshold.
* `-Zinline-mir-hint-threshold` to change the threshold used by
  functions with inline hint.

Having those as configurable flags makes it possible to experiment with with
different inlining thresholds and substantially increase test coverage of MIR
inlining when used with increased thresholds (for example, necessary to test
#78844).

3 years agoRollup merge of #78832 - lcnr:const-evaluatable-unevaluated, r=oli-obk
Jonas Schievink [Wed, 11 Nov 2020 19:59:02 +0000 (20:59 +0100)]
Rollup merge of #78832 - lcnr:const-evaluatable-unevaluated, r=oli-obk

look at assoc ct, check the type of nodes

an example where types matter are function objects, see the added test which previously passed.

Now does a shallow comparison of unevaluated constants.

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

3 years agoRollup merge of #78417 - ssomers:btree_chop_up_2, r=Mark-Simulacrum
Jonas Schievink [Wed, 11 Nov 2020 19:59:00 +0000 (20:59 +0100)]
Rollup merge of #78417 - ssomers:btree_chop_up_2, r=Mark-Simulacrum

BTreeMap: split off most code of append

To complete #78056, move the last single-purpose pieces of code out of map.rs into a separate module. Also, tweaked documentation and safeness - I doubt think this code would be safe if the iterators passed in wouldn't be as sorted as the method says they should be - and bounds on MergeIterInner.

r? ```@Mark-Simulacrum```

3 years agoRollup merge of #78354 - 12101111:rustbuild_profiler, r=Mark-Simulacrum
Jonas Schievink [Wed, 11 Nov 2020 19:58:56 +0000 (20:58 +0100)]
Rollup merge of #78354 - 12101111:rustbuild_profiler, r=Mark-Simulacrum

Support enable/disable sanitizers/profiler per target

This PR add options under `[target.*]` of `config.toml` which can enable or disable sanitizers/profiler runtime for corresponding target.
If these options are empty, the global options under `[build]` will take effect.

Fix #78329

3 years agoRollup merge of #78216 - workingjubilee:duration-zero, r=m-ou-se
Jonas Schievink [Wed, 11 Nov 2020 19:58:52 +0000 (20:58 +0100)]
Rollup merge of #78216 - workingjubilee:duration-zero, r=m-ou-se

Duration::zero() -> Duration::ZERO

In review for #72790, whether or not a constant or a function should be favored for `#![feature(duration_zero)]` was seen as an open question. In https://github.com/rust-lang/rust/issues/73544#issuecomment-691701670 an invitation was opened to either stabilize the methods or propose a switch to the constant value, supplemented with reasoning. Followup comments suggested community preference leans towards the const ZERO, which would be reason enough.

ZERO also "makes sense" beside existing associated consts for Duration. It is ever so slightly awkward to have a series of constants specifying 1 of various units but leave 0 as a method, especially when they are side-by-side in code. It seems unintuitive for the one non-dynamic value (that isn't from Default) to be not-a-const, which could hurt discoverability of the associated constants overall. Elsewhere in `std`, methods for obtaining a constant value were even deprecated, as seen with [std::u32::min_value](https://doc.rust-lang.org/std/primitive.u32.html#method.min_value).

Most importantly, ZERO costs less to use. A match supports a const pattern, but const fn can only be used if evaluated through a const context such as an inline `const { const_fn() }` or a `const NAME: T = const_fn()` declaration elsewhere. Likewise, while https://github.com/rust-lang/rust/issues/73544#issuecomment-691949373 notes `Duration::zero()` can optimize to a constant value, "can" is not "will". Only const contexts have a strong promise of such. Even without that in mind, the comment in question still leans in favor of the constant for simplicity. As it costs less for a developer to use, may cost less to optimize, and seems to have more of a community consensus for it, the associated const seems best.

r? ```@LukasKalbertodt```

3 years agoAuto merge of #78946 - jethrogb:linux-x86-llvm-no-gnu-unique, r=Mark-Simulacrum
bors [Wed, 11 Nov 2020 19:37:31 +0000 (19:37 +0000)]
Auto merge of #78946 - jethrogb:linux-x86-llvm-no-gnu-unique, r=Mark-Simulacrum

Linux dist: don't include unique symbols in libLLVM

Fixes #76980

3 years agoAuto merge of #78790 - Gankra:rust-src-vendor, r=Mark-Simulacrum
bors [Wed, 11 Nov 2020 16:24:43 +0000 (16:24 +0000)]
Auto merge of #78790 - Gankra:rust-src-vendor, r=Mark-Simulacrum

Vendor libtest's dependencies in the rust-src component

This is the Rust side of https://github.com/rust-lang/wg-cargo-std-aware/issues/23

Note that this won't produce a useful result for `cargo -Zbuild-std` if there are multiple versions of a crate vendored, but will otherwise produce a valid vendor dir.

See https://github.com/rust-lang/cargo/pull/8834 for the other half of this change.

3 years agoShip llvm-cov through llvm-tools
dalance [Wed, 11 Nov 2020 14:34:01 +0000 (23:34 +0900)]
Ship llvm-cov through llvm-tools

3 years agoLinux dist: don't include unique symbols in libLLVM
Jethro Beekman [Wed, 11 Nov 2020 13:46:04 +0000 (14:46 +0100)]
Linux dist: don't include unique symbols in libLLVM

3 years agoFix typo in comment
Ikko Ashimine [Wed, 11 Nov 2020 11:23:08 +0000 (20:23 +0900)]
Fix typo in comment

occurences -> occurrences

3 years agoAuto merge of #78825 - Nicholas-Baron:unwrap_or_corrected, r=lcnr
bors [Wed, 11 Nov 2020 09:10:30 +0000 (09:10 +0000)]
Auto merge of #78825 - Nicholas-Baron:unwrap_or_corrected, r=lcnr

`unwrap_or` lint corrected

https://github.com/rust-lang/rust/issues/78814#issuecomment-723305713

This pull request fixes the lint from clippy where `unwrap_or` could be better done as a `unwrap_or_else` or a `unwrap_or_default`.

3 years agorustc_target: Move target env "gnu" from `linux_base` to `linux_gnu_base`
Vadim Petrochenkov [Tue, 10 Nov 2020 20:32:58 +0000 (23:32 +0300)]
rustc_target: Move target env "gnu" from `linux_base` to `linux_gnu_base`

3 years agoChanged unwrap_or to unwrap_or_else in some places.
Nicholas-Baron [Fri, 6 Nov 2020 21:24:55 +0000 (13:24 -0800)]
Changed unwrap_or to unwrap_or_else in some places.

The discussion seems to have resolved that this lint is a bit "noisy" in
that applying it in all places would result in a reduction in
readability.

A few of the trivial functions (like `Path::new`) are fine to leave
outside of closures.

The general rule seems to be that anything that is obviously an
allocation (`Box`, `Vec`, `vec![]`) should be in a closure, even if it
is a 0-sized allocation.

3 years agoAuto merge of #78920 - jonas-schievink:rollup-w2mjsuh, r=jonas-schievink
bors [Wed, 11 Nov 2020 01:18:18 +0000 (01:18 +0000)]
Auto merge of #78920 - jonas-schievink:rollup-w2mjsuh, r=jonas-schievink

Rollup of 14 pull requests

Successful merges:

 - #76765 (Make it more clear what an about async fn's returns when referring to what it returns)
 - #78574 (Use check-pass instead of build-pass in regions ui test suite)
 - #78669 (Use check-pass instead of build-pass in some consts ui test suits)
 - #78847 (Assert that a return place is not used for indexing during integration)
 - #78854 (Workaround for "could not fully normalize" ICE )
 - #78875 (rustc_target: Further cleanup use of target options)
 - #78887 (Add comments to explain memory usage optimization)
 - #78890 (comment attribution fix)
 - #78896 (Clarified description of write! macro)
 - #78897 (Add missing newline to error message of the default OOM hook)
 - #78898 (add regression test for #78892)
 - #78908 ((rustdoc) [src] link for types defined by macros shows invocation, not defintion)
 - #78910 (Fix links to stabilized versions of some intrinsics)
 - #78912 (Add macro test for min-const-generics)

Failed merges:

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

3 years agorustc_taret: Remove `TargetOptions::is_like_android`
Vadim Petrochenkov [Tue, 10 Nov 2020 20:51:34 +0000 (23:51 +0300)]
rustc_taret: Remove `TargetOptions::is_like_android`

3 years agoCleanup and comment intra-doc link pass
Joshua Nelson [Tue, 10 Nov 2020 16:09:34 +0000 (11:09 -0500)]
Cleanup and comment intra-doc link pass

3 years agoRollup merge of #78912 - JulianKnodt:mcg_macro, r=lcnr
Jonas Schievink [Tue, 10 Nov 2020 13:45:36 +0000 (14:45 +0100)]
Rollup merge of #78912 - JulianKnodt:mcg_macro, r=lcnr

Add macro test for min-const-generics

Adds a test which uses a macro inside a block for a const-expression, as per #78433

r? `@lcnr`

3 years agoRollup merge of #78910 - tmiasko:intrinsics-link, r=jyn514
Jonas Schievink [Tue, 10 Nov 2020 13:45:34 +0000 (14:45 +0100)]
Rollup merge of #78910 - tmiasko:intrinsics-link, r=jyn514

Fix links to stabilized versions of some intrinsics

3 years agoRollup merge of #78908 - liketechnik:fix_macro_expand_src_link, r=jyn514
Jonas Schievink [Tue, 10 Nov 2020 13:45:32 +0000 (14:45 +0100)]
Rollup merge of #78908 - liketechnik:fix_macro_expand_src_link, r=jyn514

(rustdoc) [src] link for types defined by macros shows invocation, not defintion

Previously the [src] link on types defined by a macro pointed to the macro definition.

This pr makes the Clean-Implementation for Spans aware of macro defined types, so that the link points to the invocation instead.

I'm not totally sure if it's okay to add the 'macro awareness' in the Clean-Implementation, because it erases that knowledge for all following code. Maybe it would be more sensible to add the check only for the link generation at https://github.com/rust-lang/rust/blob/25f6938da459a57b43bdf16ed6bdad3225b2a3ce/src/librustdoc/html/render/mod.rs#L1619

Closes #39726.

3 years agoRollup merge of #78898 - SNCPlay42:issue-78892, r=Mark-Simulacrum
Jonas Schievink [Tue, 10 Nov 2020 13:45:30 +0000 (14:45 +0100)]
Rollup merge of #78898 - SNCPlay42:issue-78892, r=Mark-Simulacrum

add regression test for #78892

closes #78892, which was already fixed on nightly.

3 years agoRollup merge of #78897 - hyd-dev:alloc-error-hook-newline, r=m-ou-se
Jonas Schievink [Tue, 10 Nov 2020 13:45:28 +0000 (14:45 +0100)]
Rollup merge of #78897 - hyd-dev:alloc-error-hook-newline, r=m-ou-se

Add missing newline to error message of the default OOM hook

Currently the default OOM hook in libstd does not end the error message with a newline:
```
memory allocation of 4 bytes failedtimeout: the monitored command dumped core
/playground/tools/entrypoint.sh: line 11:     7 Aborted                 timeout --signal=KILL ${timeout} "$`@"`
```
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=030d8223eb57dfe47ef157709aa26542

This is because the `fmt::Arguments` passed to `dumb_print()` does not end with a newline. All other calls to `dumb_print()` in libstd pass a `\n`-ended `fmt::Arguments` to `dumb_print()`. For example:
https://github.com/rust-lang/rust/blob/25f6938da459a57b43bdf16ed6bdad3225b2a3ce/library/std/src/sys_common/util.rs#L18
I think the `\n` was forgotten in #51264.

This PR appends `\n` to the error string.

~~Note that I didn't add a test, because I didn't find tests for functions in ` library/std/src/alloc.rs` or a test that is similar to the test of this change would be.~~ *Edit: CI told me there is an existing test. Sorry.*

3 years agoRollup merge of #78896 - cyqsimon:master, r=m-ou-se
Jonas Schievink [Tue, 10 Nov 2020 13:45:27 +0000 (14:45 +0100)]
Rollup merge of #78896 - cyqsimon:master, r=m-ou-se

Clarified description of write! macro

Reordered the list of arguments in the description to match that in the actual macro.

Suggested and discussed [here](https://discord.com/channels/442252698964721669/443492145567891458/774341262609219624).

3 years agoRollup merge of #78890 - o752d:patch-2, r=jyn514
Jonas Schievink [Tue, 10 Nov 2020 13:45:25 +0000 (14:45 +0100)]
Rollup merge of #78890 - o752d:patch-2, r=jyn514

comment attribution fix

comment means to refer to the macro in its direct scope

3 years agoRollup merge of #78887 - camelid:dataflow-state-decl, r=jonas-schievink
Jonas Schievink [Tue, 10 Nov 2020 13:45:23 +0000 (14:45 +0100)]
Rollup merge of #78887 - camelid:dataflow-state-decl, r=jonas-schievink

Add comments to explain memory usage optimization

Add explanatory comments so that people understand that it's just an optimization and doesn't affect behavior.

3 years agoRollup merge of #78875 - petrochenkov:cleantarg, r=Mark-Simulacrum
Jonas Schievink [Tue, 10 Nov 2020 13:45:21 +0000 (14:45 +0100)]
Rollup merge of #78875 - petrochenkov:cleantarg, r=Mark-Simulacrum

rustc_target: Further cleanup use of target options

Follow up to https://github.com/rust-lang/rust/pull/77729.

Implements items 2 and 4 from the list in https://github.com/rust-lang/rust/pull/77729#issue-500228243.

The first commit collapses uses of `target.options.foo` into `target.foo`.

The second commit renames some target options to avoid tautology:
`target.target_endian` -> `target.endian`
`target.target_c_int_width` -> `target.c_int_width`
`target.target_os` -> `target.os`
`target.target_env` -> `target.env`
`target.target_vendor` -> `target.vendor`
`target.target_family` -> `target.os_family`
`target.target_mcount` -> `target.mcount`

r? `@Mark-Simulacrum`

3 years agoRollup merge of #78854 - the8472:workaround-normalization-regression-master, r=Mark...
Jonas Schievink [Tue, 10 Nov 2020 13:45:19 +0000 (14:45 +0100)]
Rollup merge of #78854 - the8472:workaround-normalization-regression-master, r=Mark-Simulacrum

Workaround for "could not fully normalize" ICE

Workaround for "could not fully normalize" ICE (#78139) by removing the `needs_drop::<T>()` calls triggering it.
Corresponding beta PR: #78845

Fixes #78139 -- the underlying bug is likely not fixed but we don't have another test case isolated for now, so closing.

3 years agoRollup merge of #78847 - tmiasko:inline-return-place, r=matthewjasper
Jonas Schievink [Tue, 10 Nov 2020 13:45:17 +0000 (14:45 +0100)]
Rollup merge of #78847 - tmiasko:inline-return-place, r=matthewjasper

Assert that a return place is not used for indexing during integration

The inliner integrates call destination place with callee return place
by remapping the local and adding extra projections as necessary.

If a call destination place contains any projections (which is already
possible) and a return place is used in an indexing projection (most
likely doesn't happen yet) the end result would be incorrect.

Add an assertion to ensure that potential issue won't go unnoticed in
the presence of more sophisticated copy propagation scheme.

3 years agoRollup merge of #78669 - sasurau4:test/check-pass-consts, r=jyn514
Jonas Schievink [Tue, 10 Nov 2020 13:45:15 +0000 (14:45 +0100)]
Rollup merge of #78669 - sasurau4:test/check-pass-consts, r=jyn514

Use check-pass instead of build-pass in some consts ui test suits

Helps with #62277

Changed tests modified by https://github.com/rust-lang/rust/pull/57175 because of the stabilization `#![feature(const_let)]`.
They should be compile-fail because the feature gate checking disallow the feature before stabilization. So the feature gate checking have nothing to do with codegen according to https://rustc-dev-guide.rust-lang.org/feature-gate-ck.html.

3 years agoRollup merge of #78574 - sasurau4:test/check-pass-regions, r=jyn514
Jonas Schievink [Tue, 10 Nov 2020 13:45:13 +0000 (14:45 +0100)]
Rollup merge of #78574 - sasurau4:test/check-pass-regions, r=jyn514

Use check-pass instead of build-pass in regions ui test suite

## Overview

Helps with #62277

Region inference have nothing to do with codegen because they are erased before codegen.
Ref: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20region.20inference.20.20nothing.20to.20do.20with.20codegen.20process.3F/near/215956759

3 years agoRollup merge of #76765 - guswynn:async_return, r=tmandry
Jonas Schievink [Tue, 10 Nov 2020 13:45:09 +0000 (14:45 +0100)]
Rollup merge of #76765 - guswynn:async_return, r=tmandry

Make it more clear what an about async fn's returns when referring to what it returns

see #76547

This is *likely* not the ONLY place that this happens to be unclear, but we can move this fn to rustc_middle or something like that and reuse it if need be, to apply it to more diagnostics

One outstanding question I have is, if the fn returns (), should I make the message more clear (what about `fn f()` vs `fn f() -> ()`, can you tell those apart in the hir?)

R? `@tmandry`

`@rustbot` modify labels +A-diagnostics +T-compiler

3 years agouse check-pass instead of build-pass in consts ui test suits
Daiki Ihara [Tue, 10 Nov 2020 12:34:05 +0000 (21:34 +0900)]
use check-pass instead of build-pass in consts ui test suits

3 years agoAuto merge of #78904 - Dylan-DPC:rollup-8d2w3vu, r=Dylan-DPC
bors [Tue, 10 Nov 2020 10:43:14 +0000 (10:43 +0000)]
Auto merge of #78904 - Dylan-DPC:rollup-8d2w3vu, r=Dylan-DPC

Rollup of 12 pull requests

Successful merges:

 - #74754 (Add `#[cfg(panic = '...')]`)
 - #76468 (Improve lifetime name annotations for closures & async functions)
 - #77016 (Test clippy on PR CI on changes)
 - #78480 (BTreeMap: fix pointer provenance rules)
 - #78502 (Update Chalk to 0.36.0)
 - #78513 (Infer the default host target from the host toolchain if possible)
 - #78566 (Enable LLVM Polly via llvm-args.)
 - #78580 (inliner: Break inlining cycles)
 - #78710 (rustc_ast: Do not panic by default when visiting macro calls)
 - #78746 (Demote i686-unknown-freebsd to tier 2 compiler target)
 - #78830 (fix `super_visit_with` for `Terminator`)
 - #78844 (Monomorphize a type argument of size-of operation during codegen)

Failed merges:

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

3 years agoAdd macro test for min-const-generics
kadmin [Mon, 9 Nov 2020 21:18:04 +0000 (21:18 +0000)]
Add macro test for min-const-generics

3 years agoUpdate src/test/ui/issues/issue-76547.rs
Tyler Mandry [Tue, 10 Nov 2020 01:44:03 +0000 (17:44 -0800)]
Update src/test/ui/issues/issue-76547.rs

Co-authored-by: Camelid <camelidcamel@gmail.com>
3 years agoadd nll compare mode stderr file
Gus Wynn [Tue, 10 Nov 2020 00:27:15 +0000 (16:27 -0800)]
add nll compare mode stderr file

3 years ago(rustdoc) [src] link for types defined by macros shows invocation
Florian Warzecha [Mon, 9 Nov 2020 18:58:19 +0000 (19:58 +0100)]
(rustdoc) [src] link for types defined by macros shows invocation

Previously the [src] link on types defined by a macro
pointed to the macro definition.
This commit makes the Clean-Implementation for Spans
aware of macro defined types,
so that the link points to the invocation instead.

3 years agoAdd flags customizing behaviour of MIR inlining
Tomasz Miąsko [Tue, 10 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Add flags customizing behaviour of MIR inlining

* `-Zinline-mir-threshold` to change the default threshold.
* `-Zinline-mir-hint-threshold` to change the threshold used by
  functions with inline hint.

3 years agoAdd comments to explain memory usage optimization
Camelid [Sun, 8 Nov 2020 21:52:15 +0000 (13:52 -0800)]
Add comments to explain memory usage optimization

3 years agoRollup merge of #78844 - tmiasko:monomorphize-sizeof, r=oli-obk
Dylan DPC [Mon, 9 Nov 2020 18:07:02 +0000 (19:07 +0100)]
Rollup merge of #78844 - tmiasko:monomorphize-sizeof, r=oli-obk

Monomorphize a type argument of size-of operation during codegen

This wasn't necessary until MIR inliner started to consider drop glue as
a candidate for inlining; introducing for the first time a generic use
of size-of operation.

No test at this point since this only happens with a custom inlining
threshold.

3 years agoRollup merge of #78830 - lcnr:mir-folder, r=oli-obk
Dylan DPC [Mon, 9 Nov 2020 18:06:59 +0000 (19:06 +0100)]
Rollup merge of #78830 - lcnr:mir-folder, r=oli-obk

fix `super_visit_with` for `Terminator`

fixes https://github.com/rust-lang/rust/pull/78182#discussion_r509265149

r? `@oli-obk`

cc `@LeSeulArtichaut`

3 years agoRollup merge of #78746 - pietroalbini:i686-freebsd, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 18:06:57 +0000 (19:06 +0100)]
Rollup merge of #78746 - pietroalbini:i686-freebsd, r=Mark-Simulacrum

Demote i686-unknown-freebsd to tier 2 compiler target

While technically the `i686-unknown-freebsd` target has been a tier 2 development platform for a long time, with full toolchain tarballs available on static.rust-lang.org, due to a bug in the manifest generation the target was never available for download through rustup.

The infrastructure team privately inquired the FreeBSD package maintainers, and they weren't relying on those tarballs either, so it's a fair assumption to say practically nobody is using those tarballs.

This PR then removes the CI builder that produces full tarballs for the target, and moves the compilation of `rust-std` for the target in `dist-various-2`. The `x86_64-unknown-freebsd` target is *not* affected.

cc `@rust-lang/infra` `@rust-lang/compiler` `@rust-lang/release`
r? `@Mark-Simulacrum`

3 years agoRollup merge of #78710 - petrochenkov:macvisit, r=davidtwco
Dylan DPC [Mon, 9 Nov 2020 18:06:55 +0000 (19:06 +0100)]
Rollup merge of #78710 - petrochenkov:macvisit, r=davidtwco

rustc_ast: Do not panic by default when visiting macro calls

Panicking by default made sense when we didn't have HIR or MIR and everything worked on AST, but now all AST visitors run early and majority of them have to deal with macro calls, often by ignoring them.

The second commit renames `visit_mac` to `visit_mac_call`, the corresponding structures were renamed earlier in https://github.com/rust-lang/rust/pull/69589.

3 years agoRollup merge of #78580 - tmiasko:inline-loop, r=oli-obk
Dylan DPC [Mon, 9 Nov 2020 18:06:53 +0000 (19:06 +0100)]
Rollup merge of #78580 - tmiasko:inline-loop, r=oli-obk

inliner: Break inlining cycles

Keep track of all instances inlined so far. When examining a new call
sites from an inlined body, skip those where callee had been inlined
already to avoid potential inlining cycles.

Fixes #78573.

3 years agoRollup merge of #78566 - JRF63:polly, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 18:06:51 +0000 (19:06 +0100)]
Rollup merge of #78566 - JRF63:polly, r=Mark-Simulacrum

Enable LLVM Polly via llvm-args.

I think doing it this way is better than in #51061. Polly has other useful options and we probably don't want to create a `-Z` flag for each one of them.

![results](https://user-images.githubusercontent.com/7283601/97695555-338f7180-1adf-11eb-82bd-5130e0e6fa89.png)

[Benchmark](https://gist.github.com/JRF63/9a6268b91720958e90dbe7abffe20298)

I noticed that `-lto` seems to interfere with polly in this specific microbenchmark, as enabling it causes the perf to drop to that of non-polly builds.

Other related PRs: #75615

3 years agoRollup merge of #78513 - jyn514:rustup-toolchain, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 18:06:49 +0000 (19:06 +0100)]
Rollup merge of #78513 - jyn514:rustup-toolchain, r=Mark-Simulacrum

Infer the default host target from the host toolchain if possible

- `beta-x86_64-unknown-linux-gnu` has beta stripped
- `rustc2` is ignored

This fixes ongoing issues where x.py will detect the wrong host triple
between MSVC and GNU.

I don't think this will break anyone's workflow - I'd be very surprised if you a) had no `[build]` section in `config.toml`, b) had rustc installed, and c) expected the default target to be something other than the default target used by `rustc`. But I could be wrong - I'm happy to hear user stories :)

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

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

3 years agoRollup merge of #78502 - matthewjasper:chalkup, r=nikomatsakis
Dylan DPC [Mon, 9 Nov 2020 18:06:46 +0000 (19:06 +0100)]
Rollup merge of #78502 - matthewjasper:chalkup, r=nikomatsakis

Update Chalk to 0.36.0

This PR updates Chalk and fixes a number of bugs in the chalk integration code.

cc `@rust-lang/wg-traits`
r? `@nikomatsakis`

3 years agoRollup merge of #78480 - ssomers:btree-alias, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 18:06:44 +0000 (19:06 +0100)]
Rollup merge of #78480 - ssomers:btree-alias, r=Mark-Simulacrum

BTreeMap: fix pointer provenance rules

Fixes #78477 and includes #78476

r? `@Mark-Simulacrum`

3 years agoRollup merge of #77016 - Mark-Simulacrum:clippy-tests, r=pietroalbini
Dylan DPC [Mon, 9 Nov 2020 18:06:42 +0000 (19:06 +0100)]
Rollup merge of #77016 - Mark-Simulacrum:clippy-tests, r=pietroalbini

Test clippy on PR CI on changes

This runs the tools builder (which builds and tests tools, including clippy) when the clippy submodule changes. This essentially returns us to the prior state when clippy was a submodule; it makes sense for us to test it on CI when it changes. It might make sense for it to be tested regardless of changing but it is somewhat rare for it to fail and we don't want to add to CI time for the majority of PRs which don't affect it.

Fixes #76999.

3 years agoRollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 18:06:39 +0000 (19:06 +0100)]
Rollup merge of #76468 - SNCPlay42:lifetime-names, r=Mark-Simulacrum

Improve lifetime name annotations for closures & async functions

* Don't refer to async functions as "generators" in error output
* Where possible, emit annotations pointing exactly at the `&` in the return type of closures (when they have explicit return types) and async functions, like we do for arguments.
Addresses #74072, but I wouldn't call that *closed* until annotations are identical for async and non-async functions.
* Emit a better annotation when the lifetime doesn't appear in the full name type, which currently happens for opaque types like `impl Future`. Addresses #74497, but further improves could probably be made (why *doesn't* it appear in the type as `impl Future + '1`?)
This is included in the same PR because the changes to `give_name_if_anonymous_region_appears_in_output` would introduce ICE otherwise (it would return `None` in cases where it didn't previously, which then gets `unwrap`ped)

3 years agoRollup merge of #74754 - davidhewitt:cfg-panic, r=ecstatic-morse
Dylan DPC [Mon, 9 Nov 2020 18:06:37 +0000 (19:06 +0100)]
Rollup merge of #74754 - davidhewitt:cfg-panic, r=ecstatic-morse

Add `#[cfg(panic = '...')]`

This PR adds conditional compilation according to the panic strategy.

I've come across a need for a flag like this a couple of times while writing tests: #74301 , https://github.com/rust-lang/rust/pull/73670#issuecomment-653629031

I'm not sure if I need to add a feature gate for this flag?

3 years agoVendor libtest's dependencies in the rust-src component
Alexis Beingessner [Thu, 5 Nov 2020 22:18:14 +0000 (17:18 -0500)]
Vendor libtest's dependencies in the rust-src component

This is the Rust side of https://github.com/rust-lang/wg-cargo-std-aware/issues/23

3 years agoAdd missing newline to error message of the default OOM hook
hyd-dev [Mon, 9 Nov 2020 14:32:58 +0000 (22:32 +0800)]
Add missing newline to error message of the default OOM hook

3 years agouse RegionNameHighlight for async fn and closure returns
SNCPlay42 [Tue, 8 Sep 2020 04:35:24 +0000 (05:35 +0100)]
use RegionNameHighlight for async fn and closure returns

3 years agoBad grammar
cyqsimon [Mon, 9 Nov 2020 15:52:33 +0000 (23:52 +0800)]
Bad grammar

3 years agoadd regression test for #78892
SNCPlay42 [Mon, 9 Nov 2020 15:43:33 +0000 (15:43 +0000)]
add regression test for #78892

3 years agoAdd `#[cfg(panic = "...")]`
David Hewitt [Sat, 25 Jul 2020 18:02:49 +0000 (19:02 +0100)]
Add `#[cfg(panic = "...")]`

3 years agoClarified description of write! macro
cyqsimon [Mon, 9 Nov 2020 15:00:31 +0000 (23:00 +0800)]
Clarified description of write! macro

3 years agoAuto merge of #78201 - joshtriplett:rustc-tls-model, r=Mark-Simulacrum
bors [Mon, 9 Nov 2020 11:08:07 +0000 (11:08 +0000)]
Auto merge of #78201 - joshtriplett:rustc-tls-model, r=Mark-Simulacrum

Compile rustc crates with the initial-exec TLS model

This should produce more efficient code, with fewer calls to
__tls_get_addr. The tradeoff is that libraries using it won't work with
dlopen, but that shouldn't be a problem for rustc's internal libraries.

3 years agoBTreeMap: fix pointer provenance rules, make borrowing explicit
Stein Somers [Wed, 28 Oct 2020 10:58:06 +0000 (11:58 +0100)]
BTreeMap: fix pointer provenance rules, make borrowing explicit

3 years agocomment attribution fix
o752d [Mon, 9 Nov 2020 03:42:10 +0000 (03:42 +0000)]
comment attribution fix

comment means to refer to the macro in its direct scope

3 years agoAuto merge of #78889 - Dylan-DPC:rollup-6zjhahf, r=Dylan-DPC
bors [Mon, 9 Nov 2020 00:36:58 +0000 (00:36 +0000)]
Auto merge of #78889 - Dylan-DPC:rollup-6zjhahf, r=Dylan-DPC

Rollup of 12 pull requests

Successful merges:

 - #77640 (Refactor IntErrorKind to avoid "underflow" terminology)
 - #78026 (Define `fs::hard_link` to not follow symlinks.)
 - #78114 (Recognize `private_intra_doc_links` as a lint)
 - #78228 (Promote aarch64-unknown-linux-gnu to Tier 1)
 - #78345 (Fix handling of item names for HIR)
 - #78437 (BTreeMap: stop mistaking node for an orderly place)
 - #78476 (fix some incorrect aliasing in the BTree)
 - #78674 (inliner: Use substs_for_mir_body)
 - #78748 (Implement destructuring assignment for tuples)
 - #78868 (Fix tab focus on restyled switches)
 - #78878 (Avoid overlapping cfg attributes when both macOS and aarch64)
 - #78882 (Nicer hunk headers for rust files)

Failed merges:

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

3 years agoRollup merge of #78882 - bjorn3:nicer_hunk_headers, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 00:13:50 +0000 (01:13 +0100)]
Rollup merge of #78882 - bjorn3:nicer_hunk_headers, r=Mark-Simulacrum

Nicer hunk headers for rust files

I found this trick at <https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more>

Before the hunk headers for changes in methods would refer to the impl:

```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..fa4264d729b 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
``@@`` -678,7 +678,7 ``@@`` impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
             ref closure_captures,
             ref generator_interior_types,
         } = *self;
-
+        // foo
         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
             type_dependent_defs.hash_stable(hcx, hasher);
             field_indices.hash_stable(hcx, hasher);
```

After the hunk headers refer to the actual function signature:

```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..fa4264d729b 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
``@@`` -678,7 +678,7 ``@@`` fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
             ref closure_captures,
             ref generator_interior_types,
         } = *self;
-
+        // foo
         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
             type_dependent_defs.hash_stable(hcx, hasher);
             field_indices.hash_stable(hcx, hasher);
```

When the function signature is visible, it will use the function
signature of the previous method as hunk header:

```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..63058dfc837 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
``@@`` -992,6 +992,7 ``@@`` pub fn typeck_opt_const_arg(
     }

     pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
+        // foo
         self.arena.alloc(Steal::new(mir))
     }
```

3 years agoRollup merge of #78878 - shepmaster:intersecting-ignores, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 00:13:48 +0000 (01:13 +0100)]
Rollup merge of #78878 - shepmaster:intersecting-ignores, r=Mark-Simulacrum

Avoid overlapping cfg attributes when both macOS and aarch64

r? ``@Mark-Simulacrum``

3 years agoRollup merge of #78868 - notriddle:master, r=GuillaumeGomez
Dylan DPC [Mon, 9 Nov 2020 00:13:46 +0000 (01:13 +0100)]
Rollup merge of #78868 - notriddle:master, r=GuillaumeGomez

Fix tab focus on restyled switches

Setting a checkbox to `display:none` makes it impossible to tab onto it, which makes the rustdoc settings page completely keyboard inaccessible.

3 years agoRollup merge of #78748 - fanzier:tuple-assignment, r=petrochenkov
Dylan DPC [Mon, 9 Nov 2020 00:13:44 +0000 (01:13 +0100)]
Rollup merge of #78748 - fanzier:tuple-assignment, r=petrochenkov

Implement destructuring assignment for tuples

This is the first step towards implementing destructuring assignment (RFC: https://github.com/rust-lang/rfcs/pull/2909, tracking issue: #71126). This PR is the first part of #71156, which was split up to allow for easier review.

Quick summary: This change allows destructuring the LHS of an assignment if it's a (possibly nested) tuple.
It is implemented via a desugaring (AST -> HIR lowering) as follows:
```rust
(a,b) = (1,2)
```
... becomes ...
```rust
{
  let (lhs0,lhs1) = (1,2);
  a = lhs0;
  b = lhs1;
}
```

Thanks to `@varkor` who helped with the implementation, particularly around default binding modes.

r? `@petrochenkov`

3 years agoRollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obk
Dylan DPC [Mon, 9 Nov 2020 00:13:42 +0000 (01:13 +0100)]
Rollup merge of #78674 - tmiasko:inline-substs-for-mir-body, r=oli-obk

inliner: Use substs_for_mir_body

Changes from 68965 extended the kind of instances that are being
inlined. For some of those, the `instance_mir` returns a MIR body that
is already expressed in terms of the types found in substitution array,
and doesn't need further substitution.

Use `substs_for_mir_body` to take that into account.

Resolves #78529.
Resolves #78560.

3 years agoRollup merge of #78476 - RalfJung:btree-alias, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 00:13:40 +0000 (01:13 +0100)]
Rollup merge of #78476 - RalfJung:btree-alias, r=Mark-Simulacrum

fix some incorrect aliasing in the BTree

This line is wrong:
```
ptr::copy(slice.as_ptr().add(idx), slice.as_mut_ptr().add(idx + 1), slice.len() - idx);
```
When `slice.as_mut_ptr()` is called, that creates a mutable reference to the entire slice, which invalidates the raw pointer previously returned by `slice.as_ptr()`. (Miri currently misses this because raw pointers are not tracked properly.)

Cc ````````@ssomers````````

3 years agoRollup merge of #78437 - ssomers:btree_no_ord_at_node_level, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 00:13:38 +0000 (01:13 +0100)]
Rollup merge of #78437 - ssomers:btree_no_ord_at_node_level, r=Mark-Simulacrum

BTreeMap: stop mistaking node for an orderly place

A second mistake in #77612 was to ignore the node module's rightful comment "this module doesn't care whether the entries are sorted". And there's a much simpler way to visit the keys in order, if you check this separately from a single pass checking everything.

r? ````````@Mark-Simulacrum````````

3 years agoRollup merge of #78345 - jyn514:proper-names, r=varkor
Dylan DPC [Mon, 9 Nov 2020 00:13:35 +0000 (01:13 +0100)]
Rollup merge of #78345 - jyn514:proper-names, r=varkor

Fix handling of item names for HIR

- Handle variants, fields, macros in `Node::ident()`
- Handle the crate root in `opt_item_name`
- Rewrite `item_name` in terms of `opt_item_name`

I need this for both https://github.com/rust-lang/rust/pull/77820 and https://github.com/rust-lang/rust/pull/78082, so splitting it out into a separate PR so it can land early.

3 years agoRollup merge of #78228 - pietroalbini:finally, r=Mark-Simulacrum
Dylan DPC [Mon, 9 Nov 2020 00:13:33 +0000 (01:13 +0100)]
Rollup merge of #78228 - pietroalbini:finally, r=Mark-Simulacrum

Promote aarch64-unknown-linux-gnu to Tier 1

This PR promotes the `aarch64-unknown-linux-gnu` target to Tier 1, as proposed by [RFC 2959]:

* The `aarch64-gnu` CI job is moved from `auto-fallible` to `auto`.
* The platform support documentation is updated, uplifting the target to Tiert 1 with a note about missing stack probes support.
* Building the documentation is enabled for the target, as we produce the `rust-docs` component for all Tier 1 platforms.

[RFC 2959]: https://github.com/rust-lang/rfcs/pull/2959

3 years agoRollup merge of #78114 - jyn514:private, r=oli-obk
Dylan DPC [Mon, 9 Nov 2020 00:13:31 +0000 (01:13 +0100)]
Rollup merge of #78114 - jyn514:private, r=oli-obk

Recognize `private_intra_doc_links` as a lint

Previously, trying to allow this would give another error!

```
warning: unknown lint: `private_intra_doc_links`
 --> private.rs:1:10
  |
1 | #![allow(private_intra_doc_links)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `broken_intra_doc_links`
  |
  = note: `#[warn(unknown_lints)]` on by default

warning: public documentation for `DocMe` links to private item `DontDocMe`
 --> private.rs:2:11
  |
2 | /// docs [DontDocMe]
  |           ^^^^^^^^^ this item is private
  |
  = note: `#[warn(private_intra_doc_links)]` on by default
  = note: this link will resolve properly if you pass `--document-private-items`
```

Fixes the issue found in https://github.com/rust-lang/rust/pull/77249#issuecomment-712339227.

r? ````````@Manishearth````````

Does anyone know why this additional step is necessary? It seems weird this has to be declared in 3 different places.

3 years agoRollup merge of #78026 - sunfishcode:symlink-hard-link, r=dtolnay
Dylan DPC [Mon, 9 Nov 2020 00:13:28 +0000 (01:13 +0100)]
Rollup merge of #78026 - sunfishcode:symlink-hard-link, r=dtolnay

Define `fs::hard_link` to not follow symlinks.

POSIX leaves it [implementation-defined] whether `link` follows symlinks.
In practice, for example, on Linux it does not and on FreeBSD it does.
So, switch to `linkat`, so that we can pick a behavior rather than
depending on OS defaults.

Pick the option to not follow symlinks. This is somewhat arbitrary, but
seems the less surprising choice because hard linking is a very
low-level feature which requires the source and destination to be on
the same mounted filesystem, and following a symbolic link could end
up in a different mounted filesystem.

[implementation-defined]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html

3 years agoRollup merge of #77640 - ethanboxx:int_error_matching_attempt_2, r=KodrAus
Dylan DPC [Mon, 9 Nov 2020 00:13:25 +0000 (01:13 +0100)]
Rollup merge of #77640 - ethanboxx:int_error_matching_attempt_2, r=KodrAus

Refactor IntErrorKind to avoid "underflow" terminology

This PR is a continuation of #76455

# Changes

- `Overflow` renamed to `PosOverflow` and `Underflow` renamed to `NegOverflow` after discussion in #76455
- Changed some of the parsing code to return `InvalidDigit` rather than `Empty` for strings "+" and "-". https://users.rust-lang.org/t/misleading-error-in-str-parse-for-int-types/49178
- Carry the problem `char` with the `InvalidDigit` variant.
- Necessary changes were made to the compiler as it depends on `int_error_matching`.
- Redid tests to match on specific errors.

r? ```@KodrAus```

3 years agoSupport inlining diverging function calls
Tomasz Miąsko [Mon, 9 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Support inlining diverging function calls

Additionally introduce storage markers for all temporaries created by
the inliner. The temporary introduced for destination rebrorrow, didn't
use them previously.

3 years agoFix links to stabilized versions of some intrinsics
Tomasz Miąsko [Mon, 9 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Fix links to stabilized versions of some intrinsics

3 years agoinliner: Break inlining cycles
Tomasz Miąsko [Mon, 9 Nov 2020 00:00:00 +0000 (00:00 +0000)]
inliner: Break inlining cycles

When examining candidates for inlining, reject those that are determined
to be recursive either because of self-recursive calls or calls to any
instances already inlined.

3 years agoinliner: Make `inline_call` infallible
Tomasz Miąsko [Fri, 6 Nov 2020 00:00:00 +0000 (00:00 +0000)]
inliner: Make `inline_call` infallible

The inliner does not support inlining of divering calls. Reject them
early on and turn `inline_call` into an infallible operation.

3 years agoDo not collect tokens for doc comments
Vadim Petrochenkov [Thu, 5 Nov 2020 17:27:48 +0000 (20:27 +0300)]
Do not collect tokens for doc comments

3 years agoAuto merge of #78712 - petrochenkov:visitok, r=Aaron1011
bors [Sun, 8 Nov 2020 20:00:51 +0000 (20:00 +0000)]
Auto merge of #78712 - petrochenkov:visitok, r=Aaron1011

rustc_ast: Visit tokens stored in AST nodes in mutable visitor

After #77271 token visiting is enabled only for one visitor in `rustc_expand\src\mbe\transcribe.rs` which applies hygiene marks to tokens produced by declarative macros (`macro_rules` or `macro`), so this change doesn't affect anything else.

When a macro has some interpolated token from an outer macro in its output
```rust
macro inner() {
    $interpolated
}
```
we can use the usual interpretation of interpolated tokens in token-based model - a None-delimited group - to write this macro in an equivalent form
```rust
macro inner() {
    ⟪ a b c d ⟫
}
```

When we are expanding the macro `inner` we need to apply hygiene marks to all tokens produced by it, including the tokens inside the group.

Before this PR we did this by visiting the AST piece inside the interpolated token and applying marks to all spans in it.
I'm not sure this is 100% correct (ideally we should apply the marks to tokens and then re-parse the AST from tokens), but it's a very good approximation at least.
We didn't however apply the marks to actual tokens stored in the nonterminal, so if we used the nonterminal as a token rather than as an AST piece (e.g. passed it to a proc macro), then we got hygiene bugs.
This PR applies the marks to tokens in addition to the AST pieces thus fixing the issue.

r? `@Aaron1011`

3 years agoBTreeMap: split off most code of append, slightly improve interfaces
Stein Somers [Mon, 26 Oct 2020 09:59:31 +0000 (10:59 +0100)]
BTreeMap: split off most code of append, slightly improve interfaces

3 years agoNicer hunk headers for rust files
bjorn3 [Sun, 8 Nov 2020 15:40:00 +0000 (16:40 +0100)]
Nicer hunk headers for rust files

I found this trick at
<https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more>

Before the hunk headers for changes in methods would refer to the impl:

```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..fa4264d729b 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -678,7 +678,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
             ref closure_captures,
             ref generator_interior_types,
         } = *self;
-
+        // foo
         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
             type_dependent_defs.hash_stable(hcx, hasher);
             field_indices.hash_stable(hcx, hasher);
```

After the hunk headers refer to the actual function signature:

```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..fa4264d729b 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -678,7 +678,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
             ref closure_captures,
             ref generator_interior_types,
         } = *self;
-
+        // foo
         hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
             type_dependent_defs.hash_stable(hcx, hasher);
             field_indices.hash_stable(hcx, hasher);
```

When the function signature is visible, it will use the function
signature of the previous method as hunk header:

```diff
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 1c6937e685c..63058dfc837 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -992,6 +992,7 @@ pub fn typeck_opt_const_arg(
     }

     pub fn alloc_steal_mir(self, mir: Body<'tcx>) -> &'tcx Steal<Body<'tcx>> {
+        // foo
         self.arena.alloc(Steal::new(mir))
     }
```

3 years agoAvoid overlapping cfg attributes when both macOS and aarch64
Jake Goulding [Sun, 8 Nov 2020 14:43:51 +0000 (09:43 -0500)]
Avoid overlapping cfg attributes when both macOS and aarch64

3 years agoAddress review comments
Vadim Petrochenkov [Sun, 8 Nov 2020 14:31:47 +0000 (17:31 +0300)]
Address review comments

3 years agorustc_target: Rename some target options to avoid tautology
Vadim Petrochenkov [Sun, 8 Nov 2020 11:57:55 +0000 (14:57 +0300)]
rustc_target: Rename some target options to avoid tautology

`target.target_endian` -> `target.endian`
`target.target_c_int_width` -> `target.c_int_width`
`target.target_os` -> `target.os`
`target.target_env` -> `target.env`
`target.target_vendor` -> `target.vendor`
`target.target_family` -> `target.os_family`
`target.target_mcount` -> `target.mcount`

3 years agoCollapse all uses of `target.options.foo` into `target.foo`
Vadim Petrochenkov [Sun, 8 Nov 2020 11:27:51 +0000 (14:27 +0300)]
Collapse all uses of `target.options.foo` into `target.foo`

with an eye on merging `TargetOptions` into `Target`.

`TargetOptions` as a separate structure is mostly an implementation detail of `Target` construction, all its fields logically belong to `Target` and available from `Target` through `Deref` impls.

3 years agoAuto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-se
bors [Sun, 8 Nov 2020 13:49:17 +0000 (13:49 +0000)]
Auto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-se

Rollup of 19 pull requests

Successful merges:

 - #76097 (Stabilize hint::spin_loop)
 - #76227 (Stabilize `Poll::is_ready` and `is_pending` as const)
 - #78065 (make concurrency helper more pleasant to read)
 - #78570 (Remove FIXME comment in print_type_sizes ui test suite)
 - #78572 (Use SOCK_CLOEXEC and accept4() on more platforms.)
 - #78658 (Add a tool to run `x.py` from any subdirectory)
 - #78706 (Fix run-make tests running when LLVM is disabled)
 - #78728 (Constantify `UnsafeCell::into_inner` and related)
 - #78775 (Bump Rustfmt and RLS)
 - #78788 (Correct unsigned equivalent of isize to be usize)
 - #78811 (Make some std::io functions `const`)
 - #78828 (use single char patterns for split() (clippy::single_char_pattern))
 - #78841 (Small cleanup in `TypeFoldable` derive macro)
 - #78842 (Honor the rustfmt setting in config.toml)
 - #78843 (Less verbose debug logging from inlining integrator)
 - #78852 (Convert a bunch of intra-doc links)
 - #78860 (rustc_resolve: Use `#![feature(format_args_capture)]`)
 - #78861 (typo and formatting)
 - #78865 (Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref)

Failed merges:

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

3 years agoRollup merge of #78865 - Aaron1011:fix/const-item-mut-reborrow, r=varkor
Mara Bos [Sun, 8 Nov 2020 12:36:33 +0000 (13:36 +0100)]
Rollup merge of #78865 - Aaron1011:fix/const-item-mut-reborrow, r=varkor

Don't fire `CONST_ITEM_MUTATION` lint when borrowing a deref

Fixes #78819

This extends the check for dereferences added in PR #77324
to cover mutable borrows, as well as direct writes. If we're operating
on a dereference of a `const` item, we shouldn't be firing the lint.

3 years agoRollup merge of #78861 - o752d:patch-1, r=jonas-schievink
Mara Bos [Sun, 8 Nov 2020 12:36:32 +0000 (13:36 +0100)]
Rollup merge of #78861 - o752d:patch-1, r=jonas-schievink

typo and formatting

fixed a typo and modified some line formatting justification while I'm here :)