]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoCTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion infallible
Ralf Jung [Mon, 12 Jul 2021 16:22:15 +0000 (18:22 +0200)]
CTFE/Miri engine Pointer type overhaul: make Scalar-to-Pointer conversion infallible

This resolves all the problems we had around "normalizing" the representation of a Scalar in case it carries a Pointer value: we can just use Pointer if we want to have a value taht we are sure is already normalized.

2 years agoAuto merge of #87019 - nikic:clang-12.0.1, r=Mark-Simulacrum
bors [Tue, 13 Jul 2021 09:40:28 +0000 (09:40 +0000)]
Auto merge of #87019 - nikic:clang-12.0.1, r=Mark-Simulacrum

Use clang 12.0.1 on dist-x86_64/i686-linux

The LLD + ThinLTO __morestack bug has been fixed in 12.0.1, so
we can now update our clang version. This also means that we no
longer need to build Python 2.

2 years agoAuto merge of #86857 - fee1-dead:add-attr, r=oli-obk
bors [Tue, 13 Jul 2021 06:59:34 +0000 (06:59 +0000)]
Auto merge of #86857 - fee1-dead:add-attr, r=oli-obk

Add #[default_method_body_is_const]

`@rustbot` label F-const_trait_impl

2 years agoAuto merge of #86665 - FabianWolff:layout-field-thir-unsafeck, r=oli-obk
bors [Tue, 13 Jul 2021 04:38:39 +0000 (04:38 +0000)]
Auto merge of #86665 - FabianWolff:layout-field-thir-unsafeck, r=oli-obk

Implement Mutation- and BorrowOfLayoutConstrainedField in thir-unsafeck

Since nobody has so far claimed Mutation- and BorrowOfLayoutConstrainedField in rust-lang/project-thir-unsafeck#7, I have taken the liberty of implementing them in thir-unsafeck.

r? `@LeSeulArtichaut`

2 years agoAuto merge of #87095 - JohnTitor:rollup-mn7ggy2, r=JohnTitor
bors [Tue, 13 Jul 2021 01:52:49 +0000 (01:52 +0000)]
Auto merge of #87095 - JohnTitor:rollup-mn7ggy2, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #86344 (Split MaybeUninit::write into new feature gate and stabilize it)
 - #86811 (Remove unstable `io::Cursor::remaining`)
 - #86846 (stdio_locked: add tracking issue)
 - #86887 (rustdoc: remove dead code in `clean`)
 - #87007 (Fix rust-analyzer install when not available.)
 - #87035 (Fix implementors display)
 - #87065 (Fix ICE with unsized type in const pattern)
 - #87070 (Simplify future incompatible reporting.)
 - #87077 (:arrow_up: rust-analyzer)
 - #87078 (Rustdoc: suggest removing disambiguator if linking to field)
 - #87089 (CTFE engine: small cleanups)

Failed merges:

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

2 years agoRollup merge of #87089 - RalfJung:ctfe-memory-cleanup, r=oli-obk
Yuki Okushi [Mon, 12 Jul 2021 23:54:39 +0000 (08:54 +0900)]
Rollup merge of #87089 - RalfJung:ctfe-memory-cleanup, r=oli-obk

CTFE engine: small cleanups

I noticed these while preparing a large PR, and figured I'd better send them ahead to not muddy the diff unnecessarily.

- remove remaining use of Pointer in Allocation API (I missed those in https://github.com/rust-lang/rust/pull/85472)
- remove unnecessary deallocate_local hack (this logic does not seem necessary any more)

r? `@oli-obk`

2 years agoRollup merge of #87078 - fee1-dead:rustdoc, r=jyn514
Yuki Okushi [Mon, 12 Jul 2021 23:54:38 +0000 (08:54 +0900)]
Rollup merge of #87078 - fee1-dead:rustdoc, r=jyn514

Rustdoc: suggest removing disambiguator if linking to field

This fixes #85615.

`@rustbot` label T-rustdoc

2 years agoRollup merge of #87077 - lnicola:rust-analyzer-2021-07-12, r=lnicola
Yuki Okushi [Mon, 12 Jul 2021 23:54:37 +0000 (08:54 +0900)]
Rollup merge of #87077 - lnicola:rust-analyzer-2021-07-12, r=lnicola

:arrow_up: rust-analyzer

`@bors` r+

2 years agoRollup merge of #87070 - ehuss:simplify-future-report, r=oli-obk
Yuki Okushi [Mon, 12 Jul 2021 23:54:36 +0000 (08:54 +0900)]
Rollup merge of #87070 - ehuss:simplify-future-report, r=oli-obk

Simplify future incompatible reporting.

This simplifies the implementation of the future incompatible reporting system. Instead of having a separate field in the future_incompatible definition, this reuses the `FutureIncompatibilityReason` enum. It also drops the "date" field. Cargo does not use the date field, and there isn't much of a need for this to be structured, and I am skeptical that the date can be predicted reliably. The date or release version can be listed in the lint text if desired.

2 years agoRollup merge of #87065 - FabianWolff:issue-87046, r=oli-obk
Yuki Okushi [Mon, 12 Jul 2021 23:54:34 +0000 (08:54 +0900)]
Rollup merge of #87065 - FabianWolff:issue-87046, r=oli-obk

Fix ICE with unsized type in const pattern

Fixes #87046. The `deref_const()` query currently contains the following check:
https://github.com/rust-lang/rust/blob/e9a387d6cf5961a7f2dcb671da3147bd413355c4/compiler/rustc_mir/src/const_eval/mod.rs#L191-L204

i.e. this will cause an ICE for every unsized type except slices. An error is reported with my changes if such a type is used as a const pattern (this should not be a breaking change, since so far, this has caused an ICE).

2 years agoRollup merge of #87035 - GuillaumeGomez:fix-implementors-display, r=notriddle
Yuki Okushi [Mon, 12 Jul 2021 23:54:33 +0000 (08:54 +0900)]
Rollup merge of #87035 - GuillaumeGomez:fix-implementors-display, r=notriddle

Fix implementors display

Part of https://github.com/rust-lang/rust/issues/86632.

This PR does a few things:
 * It fixes of the JS rendered implementors.
 * It generates anchors for JS rendered implementors to make it coherent with the others.
 * It adds a test to ensure that we won't have the same issue again.
 * It changes the way we render the rustdoc-gui crates to simplify it a bit and also to allow to have dependencies without going through compiletest.

Before:

![Screenshot from 2021-07-10 13-30-13](https://user-images.githubusercontent.com/3050060/125174172-b4048700-e1c3-11eb-8f0e-c46081371d4f.png)

After:

![Screenshot from 2021-07-10 21-11-15](https://user-images.githubusercontent.com/3050060/125174173-b49d1d80-e1c3-11eb-8740-1dbbff70c2eb.png)

I plan to add the `[src]` links in another PR because this one is already big enough.

cc `@Mark-Simulacrum` (for the bootstrap changes)

r? `@Nemo157`

2 years agoRollup merge of #87007 - ehuss:fix-rust-analyzer-install, r=Mark-Simulacrum
Yuki Okushi [Mon, 12 Jul 2021 23:54:32 +0000 (08:54 +0900)]
Rollup merge of #87007 - ehuss:fix-rust-analyzer-install, r=Mark-Simulacrum

Fix rust-analyzer install when not available.

This changes it so that `x.py install` won't fail if rust-analyzer isn't available. This was changed in #86568 to handle the case where installing on stable/beta, and `extended=true`, to skip rust-analyzer. But I neglected to update the install part to also ignore it.

Fixes #86999

2 years agoRollup merge of #86887 - jyn514:cleanup-clean, r=CraftSpider
Yuki Okushi [Mon, 12 Jul 2021 23:54:31 +0000 (08:54 +0900)]
Rollup merge of #86887 - jyn514:cleanup-clean, r=CraftSpider

rustdoc: remove dead code in `clean`

Builds on https://github.com/rust-lang/rust/pull/86886 and should not be merged before.

2 years agoRollup merge of #86846 - tlyu:stdio-locked-tracking, r=joshtriplett
Yuki Okushi [Mon, 12 Jul 2021 23:54:30 +0000 (08:54 +0900)]
Rollup merge of #86846 - tlyu:stdio-locked-tracking, r=joshtriplett

stdio_locked: add tracking issue

Add the tracking issue number #86845 to the stability attributes for the implementation in #86799.

r? `@joshtriplett`
`@rustbot` label +A-io +C-cleanup +T-libs-api

2 years agoRollup merge of #86811 - soerenmeier:remove_remaining, r=yaahc
Yuki Okushi [Mon, 12 Jul 2021 23:54:28 +0000 (08:54 +0900)]
Rollup merge of #86811 - soerenmeier:remove_remaining, r=yaahc

Remove unstable `io::Cursor::remaining`

Adding `io::Cursor::remaining` in #86037 caused a conflict with the implementation of `bytes::Buf` for `io::Cursor`, leading to an error in nightly, see https://github.com/rust-lang/rust/issues/86369#issuecomment-867723485.

This fixes the error by temporarily removing the `remaining` function.

r? `@yaahc`

2 years agoRollup merge of #86344 - est31:maybe-uninit-extra, r=RalfJung
Yuki Okushi [Mon, 12 Jul 2021 23:54:27 +0000 (08:54 +0900)]
Rollup merge of #86344 - est31:maybe-uninit-extra, r=RalfJung

Split MaybeUninit::write into new feature gate and stabilize it

This splits off the `MaybeUninit::write` function from the `maybe_uninit_extra` feature gate into a new `maybe_uninit_write` feature gate and stabilizes it.

Earlier work to improve the documentation of the write function: #86220

Tracking issue: #63567

2 years agoAuto merge of #87018 - nikic:llvm-12.0.1, r=Mark-Simulacrum
bors [Mon, 12 Jul 2021 23:24:25 +0000 (23:24 +0000)]
Auto merge of #87018 - nikic:llvm-12.0.1, r=Mark-Simulacrum

Update to LLVM 12.0.1

LLVM 12.0.1 has been released, rebase our fork on top of it.

2 years agoAuto merge of #86320 - hi-rustin:rustin-patch-fix-span, r=estebank
bors [Mon, 12 Jul 2021 20:43:28 +0000 (20:43 +0000)]
Auto merge of #86320 - hi-rustin:rustin-patch-fix-span, r=estebank

shrinking the deprecated span

ref: https://github.com/rust-lang/rust/pull/85617#issuecomment-854947988

part of #85403

r? `@estebank`

The reason is that if we use method_span directly, it will cause the in_derive_expansion judgment to fail.

2 years agoProvide a better error when `x.py install src/doc` doesn't work.
Eric Huss [Mon, 12 Jul 2021 20:29:47 +0000 (13:29 -0700)]
Provide a better error when `x.py install src/doc` doesn't work.

2 years agoUse the write function in some more places
est31 [Mon, 12 Jul 2021 18:32:23 +0000 (20:32 +0200)]
Use the write function in some more places

2 years agoremove unnecessary deallocate_local hack
Ralf Jung [Mon, 12 Jul 2021 16:45:56 +0000 (18:45 +0200)]
remove unnecessary deallocate_local hack

2 years agoAdd test for implementors
Guillaume Gomez [Sat, 10 Jul 2021 19:10:14 +0000 (21:10 +0200)]
Add test for implementors

2 years agoSimplify build system for rustdoc-gui test crates
Guillaume Gomez [Sat, 10 Jul 2021 19:09:51 +0000 (21:09 +0200)]
Simplify build system for rustdoc-gui test crates

2 years agoAuto merge of #87087 - fee1-dead:fix-try-2, r=joshtriplett
bors [Mon, 12 Jul 2021 16:55:44 +0000 (16:55 +0000)]
Auto merge of #87087 - fee1-dead:fix-try-2, r=joshtriplett

Remove `multiple-definitions` test

r? `@joshtriplett`

Temporary solution to #87084.

2 years agoremove remaining use of Pointer in Allocation API
Ralf Jung [Mon, 12 Jul 2021 16:45:26 +0000 (18:45 +0200)]
remove remaining use of Pointer in Allocation API

2 years agoRemove `multiple-definitions` test
Deadbeef [Mon, 12 Jul 2021 16:14:28 +0000 (00:14 +0800)]
Remove `multiple-definitions` test

2 years agoAuto merge of #86841 - GuillaumeGomez:reexported-macro-2-render, r=Stupremee
bors [Mon, 12 Jul 2021 11:52:55 +0000 (11:52 +0000)]
Auto merge of #86841 - GuillaumeGomez:reexported-macro-2-render, r=Stupremee

Fix rendering of reexported macros 2.0 and fix visibility of reexported items

So, this PR grew a bit out of focus, it does the following things:

* Fixes #86276.
* Fixes visibility display for reexported items: it now takes the visibility of the "use" statement rather than the visibility of the reexported item itself).
* Fixes the display of reexported items if "--document-private-items" option is used. Before, they were simply skipped.
* Fixes inconsistency on typedef items: they didn't display their visibility contrary to other items.

I added tests to check everything listed above.

cc `@camelid` `@ollie27` (in case one of you want to review?)

r? `@jyn514`

2 years agosuggest removing disambiguator if linking to field
Deadbeef [Mon, 12 Jul 2021 11:04:51 +0000 (19:04 +0800)]
suggest removing disambiguator if linking to field

2 years ago:arrow_up: rust-analyzer
Laurențiu Nicola [Mon, 12 Jul 2021 06:54:59 +0000 (09:54 +0300)]
:arrow_up: rust-analyzer

2 years agoUpdate to LLVM 12.0.1
Nikita Popov [Sat, 10 Jul 2021 08:20:19 +0000 (10:20 +0200)]
Update to LLVM 12.0.1

2 years agoAuto merge of #86815 - FabianWolff:issue-84210, r=varkor
bors [Mon, 12 Jul 2021 01:00:43 +0000 (01:00 +0000)]
Auto merge of #86815 - FabianWolff:issue-84210, r=varkor

Improve error reporting for modifications behind `&` references

I had a look at #84210 and noticed that #85823 has effectively already fixed #84210.

However, the string matching in #85823 is _very_ crude and already breaks down when a variable name starts with `mut`. I have made this a bit more robust; further improvements could definitely be made but are complicated by the lack of information provided by an earlier pass:
https://github.com/rust-lang/rust/blob/ce331ee6ee010438d1a58c7da8ced4f26d69a20e/compiler/rustc_mir_build/src/build/matches/mod.rs#L2103-L2107

I have also fixed a missing comma in the error message.

2 years agoAuto merge of #86249 - FabianWolff:issue-86238, r=varkor
bors [Sun, 11 Jul 2021 22:39:16 +0000 (22:39 +0000)]
Auto merge of #86249 - FabianWolff:issue-86238, r=varkor

Report an error if resolution of closure call functions failed

This pull request fixes #86238. The current implementation seems to assume that resolution of closure call functions (I'm not sure what the proper term is; I mean `call` of `Fn` etc.) can never fail:
https://github.com/rust-lang/rust/blob/60f1a2fc4b535ead9c85ce085fdce49b1b097531/compiler/rustc_typeck/src/check/callee.rs#L590-L595

But actually, it can, if the `fn`/`fn_mut`/`fn_once` lang items are not defined, or don't have an associated `call`/`call_mut`/`call_once` function, leading to the ICE described in #86238. I have therefore turned the `span_bug!()` into an error message, which prevents the ICE.

2 years agoSimplify future incompatible reporting.
Eric Huss [Sun, 11 Jul 2021 20:08:58 +0000 (13:08 -0700)]
Simplify future incompatible reporting.

2 years agoAuto merge of #87068 - JohnTitor:rollup-2xuisfx, r=JohnTitor
bors [Sun, 11 Jul 2021 19:34:04 +0000 (19:34 +0000)]
Auto merge of #87068 - JohnTitor:rollup-2xuisfx, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #73936 (Rustdoc: Change all 'optflag' arguments to 'optflagmulti')
 - #86926 (Update regex crates)
 - #86951 ([docs] Clarify behaviour of f64 and f32::sqrt when argument is negative zero)
 - #87031 (Update reference.md)
 - #87037 (cleanup(rustdoc): remove unused function getObjectNameById)
 - #87045 (Fix tracking issue for `bool_to_option`)
 - #87049 (Account for `submodules = false` in config.toml when updating LLVM submodule)
 - #87061 (Do not suggest adding a semicolon after `?`)

Failed merges:

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

2 years agoRollup merge of #87061 - FabianWolff:issue-87051, r=oli-obk
Yuki Okushi [Sun, 11 Jul 2021 19:32:05 +0000 (04:32 +0900)]
Rollup merge of #87061 - FabianWolff:issue-87051, r=oli-obk

Do not suggest adding a semicolon after `?`

Fixes #87051. I have only modified `report_return_mismatched_types()`, i.e. my changes only affect suggestions to add `;` for return type mismatches, but this never makes sense after `?`, because the function cannot return `()` if `?` is used (it has to return a `Result` or an `Option`), and a semicolon won't help if the expected and actual `Err` types differ, even if the expected one is `()`.

2 years agoRollup merge of #87049 - jyn514:no-submodules, r=Mark-Simulacrum
Yuki Okushi [Sun, 11 Jul 2021 19:32:04 +0000 (04:32 +0900)]
Rollup merge of #87049 - jyn514:no-submodules, r=Mark-Simulacrum

Account for `submodules = false` in config.toml when updating LLVM submodule

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

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

2 years agoRollup merge of #87045 - jhpratt:fix-tracking-issue, r=jyn514
Yuki Okushi [Sun, 11 Jul 2021 19:32:03 +0000 (04:32 +0900)]
Rollup merge of #87045 - jhpratt:fix-tracking-issue, r=jyn514

Fix tracking issue for `bool_to_option`

The previous tracking issue was closed in favor of the current.

2 years agoRollup merge of #87037 - notriddle:notriddle/search-cleanup-getobjectnamefromid,...
Yuki Okushi [Sun, 11 Jul 2021 19:32:02 +0000 (04:32 +0900)]
Rollup merge of #87037 - notriddle:notriddle/search-cleanup-getobjectnamefromid, r=GuillaumeGomez

cleanup(rustdoc): remove unused function getObjectNameById

This function was used in an earlier version, when idx's were used to serialize function inputs and outputs. That's not done any more, so removed the JS-side support for it.

2 years agoRollup merge of #87031 - ZuseZ4:patch-1, r=GuillaumeGomez
Yuki Okushi [Sun, 11 Jul 2021 19:32:01 +0000 (04:32 +0900)]
Rollup merge of #87031 - ZuseZ4:patch-1, r=GuillaumeGomez

Update reference.md

I ran into a link to the outdated src/doc/reference.md here: https://users.rust-lang.org/t/conditional-compilation-for-debug-release/1098/6
Apparently the Rust reference has moved again, so the link gave a 404 error. This should fix it.

2 years agoRollup merge of #86951 - cyberia-ng:fp-negative-zero-sqrt-docs, r=Mark-Simulacrum
Yuki Okushi [Sun, 11 Jul 2021 19:31:59 +0000 (04:31 +0900)]
Rollup merge of #86951 - cyberia-ng:fp-negative-zero-sqrt-docs, r=Mark-Simulacrum

[docs] Clarify behaviour of f64 and f32::sqrt when argument is negative zero

From IEEE 754 section 6.3:
> Except that squareRoot(−0) shall be −0, every numeric squareRoot result shall have a positive sign.

2 years agoRollup merge of #86926 - bjorn3:update_some_deps, r=Mark-Simulacrum
Yuki Okushi [Sun, 11 Jul 2021 19:31:59 +0000 (04:31 +0900)]
Rollup merge of #86926 - bjorn3:update_some_deps, r=Mark-Simulacrum

Update regex crates

This removes two dependencies of rustbuild

2 years agoRollup merge of #73936 - zachlute:rustdoc-optflagmulti, r=jyn514
Yuki Okushi [Sun, 11 Jul 2021 19:31:58 +0000 (04:31 +0900)]
Rollup merge of #73936 - zachlute:rustdoc-optflagmulti, r=jyn514

Rustdoc: Change all 'optflag' arguments to 'optflagmulti'

Because specifying these flags multiple times will never be discernibly different in functionality from specifying them a single time, there is no reason to fail and report an error to the user.

This might be a slightly controversial change. it's tough to say, but it's hard to imagine a case where somebody was depending on this behavior, and doing this seem actively better for the user.

This originally came up in discussion of a fix for  [Cargo #8373](https://github.com/rust-lang/cargo/issues/8373), in [Cargo PR #8422](https://github.com/rust-lang/cargo/pull/8422).

The issue is that Cargo will automatically add things like `--document-private-items` to binaries, because it's the only thing that makes sense there. Then some poor user comes along and adds `--document-private-items` to their `rustdoc` flags for the project and suddenly they're getting errors for specifying a flag twice and need to track down which targets to actually add it to without getting duplicates for reasons they won't understand without deep understanding of Cargo behavior.

We're apparently hesitant to inspect `rustdoc` flags provided by the user directly in Cargo, because they're supposed to be opaque, so looking to see if it's already provided before adding it is evidently a non-starter. In trying to resolve that, one suggestion I came up with was to just change `rustdoc` to support passing the flag multiple times, because the user's intent should be clear and it's not *really* an error, so maybe this is a case of 'be permissive in what you accept'.

This PR is an attempt to do that in a straightforward manner for purposes of discussion.

2 years agoFix ICE with unsized type in const pattern
Fabian Wolff [Sun, 11 Jul 2021 17:16:26 +0000 (19:16 +0200)]
Fix ICE with unsized type in const pattern

2 years agoAuto merge of #85941 - cjgillot:qresolve, r=Aaron1011
bors [Sun, 11 Jul 2021 16:09:17 +0000 (16:09 +0000)]
Auto merge of #85941 - cjgillot:qresolve, r=Aaron1011

Reduce the amount of untracked state in TyCtxt -- Take 2

Main part of #85153

The offending line (https://github.com/rust-lang/rust/pull/85153#discussion_r642866298) is replaced by a FIXME until the possible bug and the perf concern are both resolved.

r? `@Aaron1011`

2 years agoAdd comments why install steps should never fail.
Eric Huss [Sun, 11 Jul 2021 16:01:31 +0000 (09:01 -0700)]
Add comments why install steps should never fail.

2 years agoDo not suggest adding a semicolon after `?`
Fabian Wolff [Sun, 11 Jul 2021 15:04:11 +0000 (17:04 +0200)]
Do not suggest adding a semicolon after `?`

2 years agoAuto merge of #87057 - RalfJung:miri, r=RalfJung
bors [Sun, 11 Jul 2021 13:45:37 +0000 (13:45 +0000)]
Auto merge of #87057 - RalfJung:miri, r=RalfJung

update Miri

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

2 years agoupdate Miri
Ralf Jung [Sun, 11 Jul 2021 12:04:58 +0000 (14:04 +0200)]
update Miri

2 years agoAuto merge of #86995 - sexxi-goose:rewrite, r=nikomatsakis
bors [Sun, 11 Jul 2021 11:25:31 +0000 (11:25 +0000)]
Auto merge of #86995 - sexxi-goose:rewrite, r=nikomatsakis

2229: Rewrite/Refactor Closure Capture Analaysis

While handling all the differnet edge cases the code for the captur analysis got pretty compicated. Looking at the overall picture of the edge cases the rules can still be layed out simply.

Alogithm: https://hackmd.io/D3I_gwvuT-SPnJ22tgJumw

r? `@nikomatsakis`

Closes https://github.com/rust-lang/project-rfc-2229/issues/52
Implementation part of https://github.com/rust-lang/project-rfc-2229/issues/53

2 years agoAuto merge of #87042 - petrochenkov:cleanquotspan, r=Aaron1011
bors [Sun, 11 Jul 2021 08:46:43 +0000 (08:46 +0000)]
Auto merge of #87042 - petrochenkov:cleanquotspan, r=Aaron1011

Cleanup span quoting

I finally got to reviewing https://github.com/rust-lang/rust/pull/84278.
See the individual commit messages.
r? `@Aaron1011`

2 years agoAuto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplett
bors [Sun, 11 Jul 2021 06:31:42 +0000 (06:31 +0000)]
Auto merge of #83918 - workingjubilee:stable-rangefrom-pat, r=joshtriplett

Stabilize "RangeFrom" patterns in 1.55

Implements a partial stabilization of #67264 and #37854.
Reference PR: https://github.com/rust-lang/reference/pull/900

# Stabilization Report

This stabilizes the `X..` pattern, shown as such, offering an exhaustive match for unsigned integers:
```rust
match x as u32 {
      0 => println!("zero!"),
      1.. => println!("positive number!"),
}
```

Currently if a Rust author wants to write such a match on an integer, they must use `1..={integer}::MAX` . By allowing a "RangeFrom" style pattern, this simplifies the match to not require the MAX path and thus not require specifically repeating the type inside the match, allowing for easier refactoring. This is particularly useful for instances like the above case, where different behavior on "0" vs. "1 or any positive number" is desired, and the actual MAX is unimportant.

Notably, this excepts slice patterns which include half-open ranges from stabilization, as the wisdom of those is still subject to some debate.

## Practical Applications

Instances of this specific usage have appeared in the compiler:
https://github.com/rust-lang/rust/blob/16143d10679537d3fde4247e15334e78ad9d55b9/compiler/rustc_middle/src/ty/inhabitedness/mod.rs#L219
https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/compiler/rustc_ty_utils/src/ty.rs#L524

And I have noticed there are also a handful of "in the wild" users who have deployed it to similar effect, especially in the case of rejecting any value of a certain number or greater. It simply makes it much more ergonomic to write an irrefutable match, as done in Katholieke Universiteit Leuven's [SCALE and MAMBA project](https://github.com/KULeuven-COSIC/SCALE-MAMBA/blob/05e5db00d553573534258585651c525d0da5f83f/WebAssembly/scale_std/src/fixed_point.rs#L685-L695).

## Tests
There were already many tests in [src/test/ui/half-open-range/patterns](https://github.com/rust-lang/rust/tree/90a2e5e3fe59a254d4d707aa291517b3791ea5a6/src/test/ui/half-open-range-patterns), as well as [generic pattern tests that test the `exclusive_range_pattern` feature](https://github.com/rust-lang/rust/blob/673d0db5e393e9c64897005b470bfeb6d5aec61b/src/test/ui/pattern/usefulness/integer-ranges/reachability.rs), many dating back to the feature's introduction and remaining standing to this day. However, this stabilization comes with some additional tests to explore the... sometimes interesting behavior of interactions with other patterns. e.g. There is, at least, a mild diagnostic improvement in some edge cases, because before now, the pattern `0..=(5+1)` encounters the `half_open_range_patterns` feature gate and can thus emit the request to enable the feature flag, while also emitting the "inclusive range with no end" diagnostic. There is no intent to allow an `X..=` pattern that I am aware of, so removing the flag request is a strict improvement. The arrival of the `J | K` "or" pattern also enables some odd formations.

Some of the behavior tested for here is derived from experiments in this [Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=58777b3c715c85165ac4a70d93efeefc) example, linked at https://github.com/rust-lang/rust/issues/67264#issuecomment-812770692, which may be useful to reference to observe the current behavior more closely.

In addition tests constituting an explanation of the "slicing range patterns" syntax issue are included in this PR.

## Desiderata

The exclusive range patterns and half-open range patterns are fairly strongly requested by many authors, as they make some patterns much more natural to write, but there is disagreement regarding the "closed" exclusive range pattern or the "RangeTo" pattern, especially where it creates "off by one" gaps in the presence of a "catch-all" wildcard case. Also, there are obviously no range analyses in place that will force diagnostics for e.g. highly overlapping matches. I believe these should be warned on, ideally, and I think it would be reasonable to consider such a blocker to stabilizing this feature, but there is no technical issue with the feature as-is from the purely syntactic perspective as such overlapping or missed matches can already be generated today with such a catch-all case. And part of the "point" of the feature, at least from my view, is to make it easier to omit wildcard matches: a pattern with such an "open" match produces an irrefutable match and does not need the wild card case, making it easier to benefit from exhaustiveness checking.

## History

- Implemented:
  - Partially via exclusive ranges: https://github.com/rust-lang/rust/pull/35712
  - Fully with half-open ranges: https://github.com/rust-lang/rust/pull/67258
- Unresolved Questions:
  - The precedence concerns of https://github.com/rust-lang/rust/pull/48501 were considered as likely requiring adjustment but probably wanting a uniform consistent change across all pattern styles, given https://github.com/rust-lang/rust/issues/67264#issuecomment-720711656, but it is still unknown what changes might be desired
  - How we want to handle slice patterns in ranges seems to be an open question still, as witnessed in the discussion of this PR!

I checked but I couldn't actually find an RFC for this, and given "approved provisionally by lang team without an RFC", I believe this might require an RFC before it can land? Unsure of procedure here, on account of this being stabilizing a subset of a feature of syntax.

r? `@scottmcm`

2 years agoAuto merge of #86965 - sexxi-goose:rfc2229-improve-lint, r=nikomatsakis,lqd
bors [Sun, 11 Jul 2021 03:50:28 +0000 (03:50 +0000)]
Auto merge of #86965 - sexxi-goose:rfc2229-improve-lint, r=nikomatsakis,lqd

Improves migrations lint for RFC2229

This PR improves the current disjoint capture migration lint by providing more information on why drop order or auto trait implementation for a closure is impacted by the use of the new feature.

The drop order migration lint will now look something like this:
```
error: changes to closure capture in Rust 2021 will affect drop order
  --> $DIR/significant_drop.rs:163:21
   |
LL |             let c = || {
   |                     ^^
...
LL |                 tuple.0;
   |                 ------- in Rust 2018, closure captures all of `tuple`, but in Rust 2021, it only captures `tuple.0`
...
LL |         }
   |         - in Rust 2018, `tuple` would be dropped here, but in Rust 2021, only `tuple.0` would be dropped here alongside the closure
```

The auto trait migration lint will now look something like this:
```
error: changes to closure capture in Rust 2021 will affect `Send` trait implementation for closure
  --> $DIR/auto_traits.rs:14:19
   |
LL |     thread::spawn(move || unsafe {
   |                   ^^^^^^^^^^^^^^ in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure would no longer implement `Send` as `fptr.0` does not implement `Send`
...
LL |         *fptr.0 = 20;
   |         ------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
```

r? `@nikomatsakis`

Closes https://github.com/rust-lang/project-rfc-2229/issues/54

2 years agoAccount for `submodules = false` in config.toml when updating LLVM submodule
Joshua Nelson [Sun, 11 Jul 2021 01:33:03 +0000 (21:33 -0400)]
Account for `submodules = false` in config.toml when updating LLVM submodule

2 years agoAuto merge of #86416 - Amanieu:asm_clobber_only, r=nagisa
bors [Sun, 11 Jul 2021 01:06:58 +0000 (01:06 +0000)]
Auto merge of #86416 - Amanieu:asm_clobber_only, r=nagisa

Add clobber-only register classes for asm!

These are needed to properly express a function call ABI using a clobber
list, even though we don't support passing actual values into/out of
these registers.

2 years agoFix tracking issue for `bool_to_option`
Jacob Pratt [Sat, 10 Jul 2021 22:25:01 +0000 (18:25 -0400)]
Fix tracking issue for `bool_to_option`

2 years agoAuto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett
bors [Sat, 10 Jul 2021 21:42:40 +0000 (21:42 +0000)]
Auto merge of #85953 - inquisitivecrystal:weak-linkat-in-fs-hardlink, r=joshtriplett

Fix linker error

Currently, `fs::hard_link` determines whether platforms have `linkat` based on the OS, and uses `link` if they don't. However, this heuristic does not work well if a platform provides `linkat` on newer versions but not on older ones. On old MacOS, this currently causes a linking error.

This commit fixes `fs::hard_link` by telling it to use `weak!` on macOS. This means that, on  that operating system, we now check for `linkat` at runtime and use `link` if it is not available.

Fixes #80804.

`@rustbot` label T-libs-impl

2 years agorustc_span: Reorder some `ExpnData` fields in accordance with comments
Vadim Petrochenkov [Sat, 10 Jul 2021 21:40:25 +0000 (00:40 +0300)]
rustc_span: Reorder some `ExpnData` fields in accordance with comments

A drive-by change.

2 years agorustc_expand: Simplify span quoting in proc macro server
Vadim Petrochenkov [Sat, 10 Jul 2021 20:44:22 +0000 (23:44 +0300)]
rustc_expand: Simplify span quoting in proc macro server

- The `Rustc::expn_id` field kept redundant information
- `SyntaxContext` is no longer thrown away before `save_proc_macro_span` because it's thrown away during metadata encoding anyway

2 years agoChange all instance of optflag added since the original change to optflagmulti.
Zach Lute [Sat, 10 Jul 2021 21:32:14 +0000 (14:32 -0700)]
Change all instance of optflag added since the original change to optflagmulti.

2 years agoChange all 'optflag' arguments to 'optflagmulti'
Zach Lute [Wed, 1 Jul 2020 18:25:54 +0000 (11:25 -0700)]
Change all 'optflag' arguments to 'optflagmulti'

Because specifying these flags multiple times will never be discernibly different in functionality from specifying them a single time, there is no reason to fail and report an error to the user.

2 years agorustc_expand: Remove redundant field from proc macro expander structures
Vadim Petrochenkov [Sat, 10 Jul 2021 20:15:30 +0000 (23:15 +0300)]
rustc_expand: Remove redundant field from proc macro expander structures

This information is already available from `ExpnData`

2 years agocleanup(rustdoc): remove unused function getObjectNameById
Michael Howell [Sat, 10 Jul 2021 20:16:16 +0000 (13:16 -0700)]
cleanup(rustdoc): remove unused function getObjectNameById

This function was used in an earlier version, when idx's were used
to serialize function inputs and outputs. That's not done any more,
so removed the JS-side support for it.

2 years agorustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`
Vadim Petrochenkov [Sat, 10 Jul 2021 19:14:52 +0000 (22:14 +0300)]
rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`

The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.

2 years agoMake tests pass on old macos
Aris Merchant [Tue, 6 Jul 2021 03:44:55 +0000 (20:44 -0700)]
Make tests pass on old macos

On old macos systems, `fs::hard_link()` will follow symlinks.
This changes the test `symlink_hard_link` to exit early on
these systems, so that tests can pass.

2 years agoChange `weak!` and `linkat!` to macros 2.0
Aris Merchant [Tue, 6 Jul 2021 03:28:10 +0000 (20:28 -0700)]
Change `weak!` and `linkat!` to macros 2.0

`weak!` is needed in a test in another module. With macros
1.0, importing `weak!` would require reordering module
declarations in `std/src/lib.rs`, which is a bit too
evil.

2 years agoAuto merge of #86873 - nikic:opaque-ptrs, r=nagisa
bors [Sat, 10 Jul 2021 19:01:41 +0000 (19:01 +0000)]
Auto merge of #86873 - nikic:opaque-ptrs, r=nagisa

Improve opaque pointers support

Opaque pointers are coming, and rustc is not ready.

This adds partial support by passing an explicit load type to LLVM. Two issues I've encountered:
 * The necessary type was not available at the point where non-temporal copies were generated. I've pushed the code for that upwards out of the memcpy implementation and moved the position of a cast to make do with the types we have available. (I'm not sure that cast is needed at all, but have retained it in the interest of conservativeness.)
 * The `PlaceRef::project_deref()` function used during debuginfo generation seems to be buggy in some way -- though I haven't figured out specifically what it does wrong. Replacing it with `load_operand().deref()` did the trick, but I don't really know what I'm doing here.

2 years agoUpdate reference.md
Manuel Drehwald [Sat, 10 Jul 2021 17:51:36 +0000 (19:51 +0200)]
Update reference.md

Apparently the Rust reference has moved again, so the link gave a 404 error.

2 years agoAuto merge of #87029 - JohnTitor:rollup-0yapv7z, r=JohnTitor
bors [Sat, 10 Jul 2021 16:41:26 +0000 (16:41 +0000)]
Auto merge of #87029 - JohnTitor:rollup-0yapv7z, r=JohnTitor

Rollup of 5 pull requests

Successful merges:

 - #87006 (Revert the revert of renaming traits::VTable to ImplSource)
 - #87011 (avoid reentrant lock acquire when ThreadIds run out)
 - #87013 (Fix several ICEs related to malformed `#[repr(...)]` attributes)
 - #87020 (remove const_raw_ptr_to_usize_cast feature)
 - #87028 (Fix type: `'satic` -> `'static`)

Failed merges:

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

2 years agoRollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkov
Yuki Okushi [Sat, 10 Jul 2021 16:15:43 +0000 (01:15 +0900)]
Rollup merge of #87028 - aDotInTheVoid:patch-1, r=petrochenkov

Fix type: `'satic` -> `'static`

Pointed out on discord: https://discord.com/channels/273534239310479360/490356824420122645/863434443170250793

~~The fact that this compiles is probably a bug.~~ Nope it's `#![feature(in_band_lifetimes)]` (Thanks to [floppy](https://discord.com/channels/273534239310479360/490356824420122645/863437381671059486)

~~[The docs](https://doc.rust-lang.org/stable/nightly-rustc/rustc_mir/transform/inline/struct.Inliner.html#method.check_codegen_attributes) seem to indicate rust thinks this function is generic over the lifetime `'satic`~~ This is because of `in_band_lifetimes`

2 years agoRollup merge of #87020 - RalfJung:const_raw_ptr_to_usize_cast, r=oli-obk
Yuki Okushi [Sat, 10 Jul 2021 16:15:42 +0000 (01:15 +0900)]
Rollup merge of #87020 - RalfJung:const_raw_ptr_to_usize_cast, r=oli-obk

remove const_raw_ptr_to_usize_cast feature

This feature currently has the strange status of "const-only `unsafe`", which was an experiment that we no longer think is a good idea. We need to find better ways to enable things like "messing with the low bits of a pointer" during CTFE.

r? `@oli-obk`

2 years agoRollup merge of #87013 - FabianWolff:issue-83921, r=estebank
Yuki Okushi [Sat, 10 Jul 2021 16:15:41 +0000 (01:15 +0900)]
Rollup merge of #87013 - FabianWolff:issue-83921, r=estebank

Fix several ICEs related to malformed `#[repr(...)]` attributes

This PR fixes #83921. #83921 actually contains two related but distinct issues (one of them incorrectly reported as a duplicate in https://github.com/rust-lang/rust/issues/83921#issuecomment-814640734):

In the first, a call to `delay_span_bug` leads to an ICE when compiling with `-Zunpretty=everybody_loops` (and some other pretty-printing modes), because the corresponding error is emitted in a later pass, which does not run when only pretty-printing is requested.

The second issue is about parsing `#[repr(...)]` attributes. Currently, all of the following cause an ICE when applied to a struct/enum:
```rust
#[repr(packed())]
#[repr(align)]
#[repr(align(2, 4))]
#[repr(align())]
#[repr(i8())]
#[repr(u32(42))]
#[repr(i64 = 2)]
```
I have fixed this by expanding the well-formedness checks in `find_repr_attrs()`.

2 years agoRollup merge of #87011 - RalfJung:thread-id-supply-shortage, r=nagisa
Yuki Okushi [Sat, 10 Jul 2021 16:15:40 +0000 (01:15 +0900)]
Rollup merge of #87011 - RalfJung:thread-id-supply-shortage, r=nagisa

avoid reentrant lock acquire when ThreadIds run out

Discovered by `@bjorn3`

2 years agoRollup merge of #87006 - ptrojahn:implsource_vtable, r=jonas-schievink
Yuki Okushi [Sat, 10 Jul 2021 16:15:39 +0000 (01:15 +0900)]
Rollup merge of #87006 - ptrojahn:implsource_vtable, r=jonas-schievink

Revert the revert of renaming traits::VTable to ImplSource

As #72114 and #73055 were merged so closely together I think this
accidentally happened while rebasing

2 years agoUse nproc instead of hardcoded 10 for build parallelism
Nikita Popov [Sat, 10 Jul 2021 16:15:01 +0000 (18:15 +0200)]
Use nproc instead of hardcoded 10 for build parallelism

2 years agoUpdate binutils version
Nikita Popov [Sat, 10 Jul 2021 16:12:01 +0000 (18:12 +0200)]
Update binutils version

This is needed to handle R_X86_64_REX_GOTPCRELX relocations.

2 years agoAdd AArch64 z* registers as aliases for v* registers
Amanieu d'Antras [Sat, 10 Jul 2021 15:29:07 +0000 (17:29 +0200)]
Add AArch64 z* registers as aliases for v* registers

2 years agoAdd clobber-only register classes for asm!
Amanieu d'Antras [Thu, 17 Jun 2021 20:00:52 +0000 (21:00 +0100)]
Add clobber-only register classes for asm!

These are needed to properly express a function call ABI using a clobber
list, even though we don't support passing actual values into/out of
these registers.

2 years agoFix typo: `satic` -> `static`
Nixon Enraght-Moony [Sat, 10 Jul 2021 15:06:24 +0000 (16:06 +0100)]
Fix typo: `satic` -> `static`

2 years agoImplement Mutation- and BorrowOfLayoutConstrainedField in thir-unsafeck
Fabian Wolff [Sun, 27 Jun 2021 12:59:38 +0000 (14:59 +0200)]
Implement Mutation- and BorrowOfLayoutConstrainedField in thir-unsafeck

2 years agoAuto merge of #81360 - Aaron1011:trait-caller-loc, r=nagisa
bors [Sat, 10 Jul 2021 14:11:39 +0000 (14:11 +0000)]
Auto merge of #81360 - Aaron1011:trait-caller-loc, r=nagisa

Support forwarding caller location through trait object method call

Since PR #69251, the `#[track_caller]` attribute has been supported on
traits. However, it only has an effect on direct (monomorphized) method
calls. Calling a `#[track_caller]` method on a trait object will *not*
propagate caller location information - instead, `Location::caller()` will
return the location of the method definition.

This PR forwards caller location information when `#[track_caller]` is
present on the method definition in the trait. This is possible because
`#[track_caller]` in this position is 'inherited' by any impls of that
trait, so all implementations will have the same ABI.

This PR does *not* change the behavior in the case where
`#[track_caller]` is present only on the impl of a trait.
While all implementations of the method might have an explicit
`#[track_caller]`, we cannot know this at codegen time, since other
crates may have impls of the trait. Therefore, we keep the current
behavior of not forwarding the caller location, ensuring that all
implementations of the trait will have the correct ABI.

See the modified test for examples of how this works

2 years agoUpdate `DepNode`'s size
Deadbeef [Sat, 10 Jul 2021 13:46:31 +0000 (21:46 +0800)]
Update `DepNode`'s size

2 years agoFix display for external trait implementors
Guillaume Gomez [Sat, 10 Jul 2021 12:58:36 +0000 (14:58 +0200)]
Fix display for external trait implementors

2 years agoTest for misusing attribute
Deadbeef [Sat, 10 Jul 2021 07:58:16 +0000 (15:58 +0800)]
Test for misusing attribute

2 years agoUpdate tests
Deadbeef [Sat, 10 Jul 2021 07:17:09 +0000 (15:17 +0800)]
Update tests

2 years agoUpdate CTFE to allow fns marked with the attr
Deadbeef [Sat, 10 Jul 2021 03:17:14 +0000 (11:17 +0800)]
Update CTFE to allow fns marked with the attr

2 years agoPermit calls to default const fns of impl const
Deadbeef [Sat, 10 Jul 2021 03:16:46 +0000 (11:16 +0800)]
Permit calls to default const fns of impl const

2 years agofunctions marked with attr are not const
Deadbeef [Sat, 10 Jul 2021 03:16:03 +0000 (11:16 +0800)]
functions marked with attr are not const

2 years agoAdd impl_constness query
Deadbeef [Sat, 10 Jul 2021 03:15:11 +0000 (11:15 +0800)]
Add impl_constness query

2 years agoCheck if the attribute is applied correctly
Deadbeef [Sat, 10 Jul 2021 03:13:52 +0000 (11:13 +0800)]
Check if the attribute is applied correctly

2 years agoSkip check for calling functions in same trait
Deadbeef [Wed, 7 Jul 2021 03:52:40 +0000 (11:52 +0800)]
Skip check for calling functions in same trait

2 years agoTreat trait fns marked with the attr as const
Deadbeef [Tue, 6 Jul 2021 05:05:24 +0000 (13:05 +0800)]
Treat trait fns marked with the attr as const

2 years agoApplied suggestions
Deadbeef [Sun, 4 Jul 2021 15:50:34 +0000 (23:50 +0800)]
Applied suggestions

2 years agoAdd #[default_method_body_is_const]
Deadbeef [Sun, 4 Jul 2021 04:24:20 +0000 (12:24 +0800)]
Add #[default_method_body_is_const]

2 years agorename variable
Ralf Jung [Sat, 10 Jul 2021 12:14:09 +0000 (14:14 +0200)]
rename variable

2 years agoremove duplicate test
Ralf Jung [Sat, 10 Jul 2021 11:48:44 +0000 (13:48 +0200)]
remove duplicate test

2 years agobless missing tests
Ralf Jung [Sat, 10 Jul 2021 11:03:35 +0000 (13:03 +0200)]
bless missing tests

2 years agoUse clang 12.0.1 on dist-x86_64/i686-linux
Nikita Popov [Sat, 10 Jul 2021 08:44:31 +0000 (10:44 +0200)]
Use clang 12.0.1 on dist-x86_64/i686-linux

The LLD + ThinLTO __morestack bug has been fixed in 12.0.1, so
we can now update our clang version. This also means that we no
longer need to build Python 2.

2 years agoremove const_raw_ptr_to_usize_cast feature
Ralf Jung [Sat, 10 Jul 2021 09:33:42 +0000 (11:33 +0200)]
remove const_raw_ptr_to_usize_cast feature

2 years agoavoid reentrant lock acquire when ThreadIds run out
Ralf Jung [Fri, 9 Jul 2021 18:50:08 +0000 (20:50 +0200)]
avoid reentrant lock acquire when ThreadIds run out

2 years agoUpdate docs for `fs::hard_link`
Aris Merchant [Wed, 7 Jul 2021 07:23:29 +0000 (00:23 -0700)]
Update docs for `fs::hard_link`