Commit graph

158231 commits

Author SHA1 Message Date
bors
9d39f6ab7d Auto merge of #89970 - jackh726:gats_diagnostics, r=nikomatsakis
Implementation of GATs outlives lint

See #87479 for background. Closes #87479

The basic premise of this lint/error is to require the user to write where clauses on a GAT when those bounds can be implied or proven from any function on the trait returning that GAT.

## Intuitive Explanation (Attempt) ##
Let's take this trait definition as an example:
```rust
trait Iterable {
    type Item<'x>;
    fn iter<'a>(&'a self) -> Self::Item<'a>;
}
```
Let's focus on the `iter` function. The first thing to realize is that we know that `Self: 'a` because of `&'a self`. If an impl wants `Self::Item` to contain any data with references, then those references must be derived from `&'a self`. Thus, they must live only as long as `'a`. Furthermore, because of the `Self: 'a` implied bound, they must live only as long as `Self`. Since it's `'a` is used in place of `'x`, it is reasonable to assume that any value of `Self::Item<'x>`, and thus `'x`, will only be able to live as long as `Self`. Therefore, we require this bound on `Item` in the trait.

As another example:
```rust
trait Deserializer<T> {
    type Out<'x>;
    fn deserialize<'a>(&self, input: &'a T) -> Self::Out<'a>;
}
```
The intuition is similar here, except rather than a `Self: 'a` implied bound, we have a `T: 'a` implied bound. Thus, the data on `Self::Out<'a>` is derived from `&'a T`, and thus it is reasonable to expect that the lifetime `'x` will always be less than `T`.

## Implementation Algorithm ##
* Given a GAT `<P0 as Trait<P1..Pi>>::G<Pi...Pn>` declared as `trait T<A1..Ai> for A0 { type G<Ai...An>; }` used in return type of one associated function `F`
* Given env `E` (including implied bounds) for `F`
* For each lifetime parameter `'a` in `P0...Pn`:
    * For each other type parameter `Pi != 'a` in `P0...Pn`: // FIXME: this include of lifetime parameters too
        * If `E => (P: 'a)`:
            * Require where clause `Ai: 'a`

## Follow-up questions ##
* What should we do when we don't pass params exactly?
For this example:
```rust
trait Des {
    type Out<'x, D>;
    fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>;
}
```
Should we be requiring a `D: 'x` clause? We pass `Wrap<T>` as `D` and `'z` as `'x`, and should be able to prove that `Wrap<T>: 'z`.

r? `@nikomatsakis`
2021-11-06 04:15:22 +00:00
Caleb Zulawski
1e1886908f Disable bitmask test on big endian 2021-11-06 02:29:03 +00:00
Caleb Zulawski
569c51d30d Fix off-by-one error uncovered by std::simd tests 2021-11-06 02:12:14 +00:00
Caleb Zulawski
3981ca076c Allow simd_select_bitmask to take byte arrays 2021-11-06 02:12:14 +00:00
Caleb Zulawski
7964942515 Allow simd_bitmask to return byte arrays 2021-11-06 02:08:09 +00:00
mujpao
4d50e7c760 Put empty trait braces on same line if possible 2021-11-05 20:40:49 -05:00
jackh726
b6edcbd7b5 Review comments 2021-11-05 21:33:14 -04:00
bors
18cae2680f Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakis
Normalize obligations for closure confirmation

Based on #90017

Fixes #74261
Fixes #71955
Fixes #88459

r? `@nikomatsakis`
2021-11-06 01:12:39 +00:00
Caleb Zulawski
4e00aa68c7 rotate_{left,right} -> rotate_lanes_{left,right} 2021-11-06 00:34:23 +00:00
Dmitry Murzin
9027db984b Update IntelliJ Integration (#4238) 2021-11-05 19:29:52 -05:00
Matthias Krüger
592fd2818c pointee_info_at() does not need mutable access 2021-11-06 01:03:56 +01:00
bors
d32993afe8 Auto merge of #90631 - matthiaskrgr:rollup-a5tzjh3, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #89942 (Reorder `widening_impl`s to make the doc clearer)
 - #90569 (Fix tests using `only-i686` to use the correct `only-x86` directive)
 - #90597 (Warn for variables that are no longer captured)
 - #90623 (Remove more checks for LLVM < 12)
 - #90626 (Properly register text_direction_codepoint_in_comment lint.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-05 22:12:31 +00:00
Josh Stone
e96a0a8681 Revert "Do not call getpid wrapper after fork in tests"
This reverts commit 12fbabd27f.

It was only needed because of using raw `clone3` instead of `fork`, but
we only do that now when a pidfd is requested.
2021-11-05 14:49:26 -07:00
Josh Stone
6edaaa6db8 Also note tool expectations of fork vs clone3
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-11-05 14:49:24 -07:00
Josh Stone
fa2eee7bf2 Update another comment on fork vs. clone3 2021-11-05 14:48:52 -07:00
Josh Stone
85b55ce00d Only use clone3 when needed for pidfd
In #89522 we learned that `clone3` is interacting poorly with Gentoo's
`sandbox` tool. We only need that for the unstable pidfd extensions, so
otherwise avoid that and use a normal `fork`.
2021-11-05 14:48:41 -07:00
Matthias Krüger
952fea793e rustdoc: clippy::complexity fixes 2021-11-05 22:06:17 +01:00
Tomasz Miąsko
59edb9d382 Remove Candidate::source_info 2021-11-05 21:31:25 +01:00
Tomasz Miąsko
7bc827b34b Refactor single variant Candidate enum into a struct
`Candidate` enum has only a single `Ref` variant.  Refactor it into a
struct and reduce overall indentation of the code by two levels.

No functional changes.
2021-11-05 21:31:18 +01:00
Matthias Krüger
f5f6f73faf
Rollup merge of #90626 - rusticstuff:be-more-accepting, r=jyn514
Properly register text_direction_codepoint_in_comment lint.

This makes it known to the compiler so it can be configured like with `#![allow(text_direction_codepoint_in_comment)]`.

Fixes #90614.
2021-11-05 21:12:31 +01:00
Matthias Krüger
9032b9d876
Rollup merge of #90623 - cuviper:llvm-12, r=nikic
Remove more checks for LLVM < 12

We already updated the minimum to 12 in #90175, but we missed a few `get_version()` checks.
2021-11-05 21:12:30 +01:00
Matthias Krüger
4b1cb73f1d
Rollup merge of #90597 - nikomatsakis:issue-90465, r=wesleywiser
Warn for variables that are no longer captured

r? `@wesleywiser`

cc `@rust-lang/wg-rfc-2229`

Fixes #90465
2021-11-05 21:12:29 +01:00
Matthias Krüger
cd24ffb266
Rollup merge of #90569 - wesleywiser:fix_only_i686_tests, r=Mark-Simulacrum
Fix tests using `only-i686` to use the correct `only-x86` directive

We translate `i686` to `x86` which means tests marked as `only-i686`
never ran. Update those tests to use `only-x86`.

We parse the `only-` architecture directive here

27143a9094/src/tools/compiletest/src/util.rs (L160-L168)

and we translate `i686` to `x86` here

27143a9094/src/tools/compiletest/src/util.rs (L56)
2021-11-05 21:12:28 +01:00
Matthias Krüger
d6f12f7630
Rollup merge of #89942 - JohnTitor:reorder-widening_impl, r=dtolnay
Reorder `widening_impl`s to make the doc clearer

Fixes #88736
This moves `{widening,carrying}_mul`s to the bottom to place consts on the top.
2021-11-05 21:12:28 +01:00
Leonora Tindall
768554af79 Add a chapter on reading Rustdoc output
Includes documentation for:
 - general page structure
 - navigation
 - searching
 - themes
 - deep-linking

Doesn't include docs on the settings page.
2021-11-05 14:44:23 -05:00
Josh Stone
767471edeb Update LLVM comments around NoAliasMutRef 2021-11-05 12:22:51 -07:00
Hans Kratz
9db9811ddf Properly register text_direction_codepoint_in_comment lint. 2021-11-05 20:12:40 +01:00
David Tolnay
1f9807799c
Add test to confirm fnn_unsuffixed does not emit exponent notation 2021-11-05 12:06:49 -07:00
bors
0d1754e8bf Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514
Fix ICE when rustdoc is scraping examples inside of a proc macro

This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations.

* A macro-rules macro that takes a function call as input: good
* A macro-rules macro that generates a function call as output: bad
* A proc-macro that generates a function call as output: bad
* An attribute macro that generates a function call as output: bad
* An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans

I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg

<img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png">

(cc `@mejrs)`

Additionally, this PR fixes an ordering bug in the highlighting logic.

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

r? `@jyn514`
2021-11-05 19:05:36 +00:00
Josh Stone
aa35158383 Update the documented default of -Zmutable-noalias 2021-11-05 12:01:59 -07:00
Yuki Okushi
0b3a002805
Reorder widening_impls to make the doc clearer 2021-11-05 11:55:51 -07:00
Josh Stone
c9567e2424 Move outline-atomics to aarch64-linux target definitions 2021-11-05 10:28:12 -07:00
Josh Stone
1d04577ee0 Remove some minor checks for LLVM < 12 2021-11-05 10:26:16 -07:00
Tomasz Miąsko
5a09e12135 Initialize LLVM time trace profiler on each code generation thread
In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was
extended to support multiple threads.

`timeTraceProfilerInitialize` creates a thread local profiler instance.
When a thread finishes `timeTraceProfilerFinishThread` moves a thread
local instance into a global collection of instances. Finally when all
codegen work is complete `timeTraceProfilerWrite` writes data from the
current thread local instance and the instances in global collection
of instances.

Previously, the profiler was intialized on a single thread only. Since
this thread performs no code generation on its own, the resulting
profile was empty.

Update LLVM codegen to initialize & finish time trace profiler on each
code generation thread.
2021-11-05 17:47:11 +01:00
Niko Matsakis
4154e8acf0 apply suggestions from code review 2021-11-05 12:43:42 -04:00
Will Crichton
82b23be3c1 Fix rustdoc-scrape-examples-macros test not being cross-platform 2021-11-05 09:32:04 -07:00
bors
045612b8b9 Auto merge of #90616 - mathstuf:error_codes-comment-uniformity, r=GuillaumeGomez
error_codes: uniformly comment error codes
2021-11-05 16:00:23 +00:00
Ben Boeckel
863e5226d3 error_codes: uniformly comment error codes 2021-11-05 11:57:17 -04:00
bors
d22dd65835 Auto merge of #90604 - mbartlett21:iterator-reexports, r=kennytm
Re-export some iterators from `core` in `std`

These iterators seem to have been forgotten to be re-exported from `std` (through `alloc`)

These are stable:

`core::slice::{SplitInclusive, SplitInclusiveMut}`

This one is still unstable:

`core::slice::EscapeAscii` (cc #77174)
2021-11-05 12:22:13 +00:00
bors
489ec310d2 Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkov
clippy::perf fixes
2021-11-05 09:17:39 +00:00
mbartlett21
ed63c71d61
Fix str::SplitInclusive stabilisation date 2021-11-05 17:46:58 +10:00
Tor Hovland
d4bcee9638 Added a regression test. 2021-11-05 08:46:29 +01:00
mbartlett21
d606dbe256
Add feature to alloc so we can re-export. 2021-11-05 17:35:07 +10:00
mbartlett21
9ae92ad19a
Re-export core::slice::EscapeAscii 2021-11-05 17:14:57 +10:00
mbartlett21
03d1f24db8
Re-export core::slice::SplitInclusive[Mut] 2021-11-05 15:44:43 +10:00
bors
b99bd8f8be Auto merge of #90598 - JohnTitor:rollup-kz1qioz, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #90507 (Suggest `extern crate alloc` when using undeclared module `alloc`)
 - #90530 (Simplify js tester a bit)
 - #90533 (Add note about x86 instruction prefixes in asm! to unstable book)
 - #90537 (Update aarch64 `target_feature` list for LLVM 12.)
 - #90544 (Demote metadata load warning to "info".)
 - #90554 (Clean up some `-Z unstable-options` in tests.)
 - #90556 (Add more text and examples to `carrying_{add|mul}`)
 - #90563 (rustbot allow labels)
 - #90571 (Fix missing bottom border for headings in sidebar)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-05 04:35:13 +00:00
Muhammad Falak R Wani
d468418209
rustdoc: use Type::def_id() instead of Type::def_id_no_primitives()
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2021-11-05 07:44:05 +05:30
Will Crichton
c62817bfe2 Move rustdoc-scrape-examples-macros test to run-make-fulldeps 2021-11-04 18:52:59 -07:00
Yuki Okushi
3821ab231b
Rollup merge of #90571 - GuillaumeGomez:missing-bottom-border-sidebar, r=jsha
Fix missing bottom border for headings in sidebar

Fixes #90568.

r? ```@jsha```
2021-11-05 10:32:47 +09:00
Yuki Okushi
1aa8c01c29
Rollup merge of #90563 - joshtriplett:rustbot-allow-labels, r=Mark-Simulacrum
rustbot allow labels

`relnotes` was inspired by https://github.com/rust-lang/rust/pull/90521 , and by the various `must_use` PRs; in all of those cases, the submitter of the PR could know that `relnotes` applied, but couldn't apply it themselves.

For `needs-fcp`, I think people should be able to help triage by observing that a change needs an FCP before we can apply it.
2021-11-05 10:32:47 +09:00