bors [Mon, 4 Jan 2021 13:23:08 +0000 (13:23 +0000)]
Auto merge of #80651 - GroteGnoom:issue-78123-fix, r=Nadrieril
Add note to non-exhaustive match on reference to empty
Rust prints "type `&A` is non-empty" even is A is empty.
This is the intended behavior, but can be confusing.
This commit adds a note to non-exhaustive pattern errors if they are a
reference to something uninhabited.
I did not add tests to check that the note is not shown for
non-references or inhabited references, because this is already done
in other tests.
Maybe the added test is superfluous, because
`always-inhabited-union-ref` already checks for this case.
This does not handle &&Void or &&&void etc. I could add those as special
cases as well and ignore people who need quadruple
references.
bors [Mon, 4 Jan 2021 10:32:28 +0000 (10:32 +0000)]
Auto merge of #80661 - jyn514:duplicate-types, r=GuillaumeGomez
Cleanup rustdoc handling of associated types
This is best reviewed a commit at a time. No particular reason for these changes, they just stood out as I was reviewing https://github.com/rust-lang/rust/pull/80653 and thinking about https://github.com/rust-lang/rust/issues/80379. The new test case worked before, it just wasn't tested.
bors [Mon, 4 Jan 2021 05:04:04 +0000 (05:04 +0000)]
Auto merge of #80554 - GuillaumeGomez:more-js-cleanup, r=jyn514
More js cleanup
Part of #79052 (Same kind as #80515).
This one is about some small fixes:
* Replacing some loops with `onEachLazy`.
* Removing unused function arguments.
* Turn `buildHelperPopup` into a variable so it can be "replaced" once the function has been called once so it's not called again.
bors [Mon, 4 Jan 2021 02:15:57 +0000 (02:15 +0000)]
Auto merge of #80418 - oli-obk:this_could_have_been_so_simple, r=RalfJung
Allow references to interior mutable data behind a feature gate
supercedes #80373 by simply not checking for interior mutability on borrows of locals that have `StorageDead` and thus can never be leaked to the final value of the constant
bors [Sun, 3 Jan 2021 20:24:16 +0000 (20:24 +0000)]
Auto merge of #77859 - bugadani:no-duplicate-ref-link-error, r=jyn514
Rustdoc: only report broken ref-style links once
This PR assigns the markdown `LinkType` to each parsed link and passes this information into the link collector.
If a link can't be resolved in `resolve_with_disambiguator`, the failure is cached for the link types where we only want to report the error once (namely `Shortcut` and `Reference`).
Daniel Noom [Sun, 3 Jan 2021 13:13:33 +0000 (14:13 +0100)]
Add note to non-exhaustive match on reference to empty
Rust prints "type `&A` is non-empty" even is A is empty.
This is the intended behavior, but can be confusing.
This commit adds a note to non-exhaustive pattern errors if they are a
reference to something uninhabited.
I did not add tests to check that the note is not shown for
non-references or inhabited references, because this is already done
in other tests.
Maybe the added test is superfluous, because
`always-inhabited-union-ref` already checks for this case.
This does not handle &&Void or &&&void etc. I could add those as special
cases as well and ignore people who need quadruple
references.
bors [Sun, 3 Jan 2021 17:42:27 +0000 (17:42 +0000)]
Auto merge of #80655 - GuillaumeGomez:rollup-ai7soid, r=GuillaumeGomez
Rollup of 5 pull requests
Successful merges:
- #80580 (Add suggestion for "ignore" doc code block)
- #80591 (remove allow(incomplete_features) from std)
- #80617 (Detect invalid rustdoc test commands)
- #80628 (reduce borrowing and (de)referencing around match patterns (clippy::match_ref_pats))
- #80646 (Clean up in `each_child_of_item`)
Guillaume Gomez [Sun, 3 Jan 2021 16:09:13 +0000 (17:09 +0100)]
Rollup merge of #80646 - bugadani:meta, r=petrochenkov
Clean up in `each_child_of_item`
This PR hopes to eliminate some of the surprising elements I encountered while reading the function.
- `macros_only` is checked against inside the loop body, but if it is `true`, the loop is skipped anyway
- only query `span` when relevant
- no need to allocate attribute vector
Guillaume Gomez [Sun, 3 Jan 2021 16:09:08 +0000 (17:09 +0100)]
Rollup merge of #80591 - lcnr:incomplete-features, r=RalfJung
remove allow(incomplete_features) from std
cc https://github.com/rust-lang/rust/pull/80349#issuecomment-753357123
> Now I am somewhat concerned that the standard library uses some of these features...
I think it is theoretically ok to use incomplete features in the standard library or the compiler if we know that there is an already working subset and we explicitly document what we have to be careful about. Though at that point it is probably better to try and split the incomplete feature into two separate ones, similar to `min_specialization`.
Will be interesting once `feature(const_evaluatable_checked)` works well enough to imo be used in the compiler but not yet well enough to be removed from `INCOMPLETE_FEATURES`.
bors [Sun, 3 Jan 2021 06:29:42 +0000 (06:29 +0000)]
Auto merge of #80261 - GuillaumeGomez:attr-rework, r=jyn514
rustdoc DocFragment rework
Kind of a follow-up of #80119.
A few things are happening in this PR. I'm not sure about the impact on perf though so I'm very interested about that too (if the perf is worse, then we can just close this PR).
The idea here is mostly about reducing the memory usage by relying even more on `Symbol` instead of `String`. The only issue is that `DocFragment` has 3 modifications performed on it:
1. Unindenting
2. Collapsing similar comments into one
3. "Beautifying" (weird JS-like comments handling).
To do so, I saved the information about unindent and the "collapse" is now on-demand (which is why I'm not sure the perf will be better, it has to be run multiple times...).
bors [Sat, 2 Jan 2021 18:13:48 +0000 (18:13 +0000)]
Auto merge of #80412 - GuillaumeGomez:fix-search-section-pos, r=jyn514
Fix search section position on small devices
Fixes #79526.
This is exactly the same issue fixed in 9c36491538476dd3ff5ec834944aacdaceb12f30 (in https://github.com/rust-lang/rust/pull/79936) but applied to the search section. When the width becomes too small, the search input goes on its own line to get more space, making it go "under" the section following (so either "main" or "search"). The fix is to simply make the section go more under so that it doesn't go over the search input.
bors [Sat, 2 Jan 2021 15:31:53 +0000 (15:31 +0000)]
Auto merge of #80550 - bugadani:markdown-refactor, r=jyn514
Cleanup markdown span handling, take 2
This PR includes the cleanups made in #80244 except for the removal of `locate()`.
While the biggest conceptual part in #80244 was the removal of `locate()`, it introduced a diagnostic regression.
Additional cleanup:
- Use `RefCell` to avoid building two separate vectors for the links
Work to do:
- [ ] Decide if `locate()` can be simplified by assuming `s` is always in `md`
- [ ] Should probably add some tests that still provide the undesired diagnostics causing #80381
cc `@jyn514` This is the best I can do without patching Pulldown to provide multiple ranges for reference-style links. Also, since `locate` is probably more efficient than `rfind` (at least it's constant time), I decided to not check the link type and just cover every &str as it was before.
bors [Sat, 2 Jan 2021 13:12:15 +0000 (13:12 +0000)]
Auto merge of #6530 - m-ou-se:2021, r=phansch
Initial support for Rust 2021.
Clippy treated Rust 2021 as Rust 2015, because 2018 was checked with `==` instead of `>=`. This fixes that, such that 2018-specific things are also enabled for 2021.
Mara Bos [Sat, 2 Jan 2021 11:29:14 +0000 (11:29 +0000)]
Rollup merge of #80599 - lqd:issue_805889, r=varkor
`const_generics_defaults`: don't ICE in the unimplemented parts
The thought was that we could use `todo!`s to ensure we wouldn't forget to implement parts of the experimental gate.
However, that can also lead to a suboptimal experience for users as shown in #80589 having both the error/warning about the experimental feature, and the ICE.
Mara Bos [Sat, 2 Jan 2021 11:29:12 +0000 (11:29 +0000)]
Rollup merge of #80578 - RalfJung:panic-lint-description, r=lcnr
improve unconditional_panic description
The fact that the lint is triggered by the ConstProp pass is an implementation detail, I do not think that this should be mentioned in the description.
bors [Sat, 2 Jan 2021 09:52:26 +0000 (09:52 +0000)]
Auto merge of #80115 - tgnottingham:specialize_opaque_u8_sequences, r=oli-obk
rustc_serialize: specialize opaque encoding and decoding of some u8 sequences
This specializes encoding and decoding of some contiguous u8 sequences to use a more efficient implementation. The default implementations process each u8 individually, but that isn't necessary for the opaque encoder and decoder. The opaque encoding for u8s is a no-op, so we can just copy entire sequences as-is, rather than process them byte by byte.
This also changes some encode and decode implementations for contiguous sequences to forward to the slice and vector implementations, so that they can take advantage of the new specialization when applicable.
bors [Sat, 2 Jan 2021 04:12:48 +0000 (04:12 +0000)]
Auto merge of #79870 - sharnoff:smart-pointer-Any-type_id, r=shepmaster
Add docs note about `Any::type_id` on smart pointers
Fixes #79868.
There's an issue I've run into a couple times while using values of type `Box<dyn Any>` - essentially, calling `value.type_id()` doesn't dereference to the trait object, but uses the implementation of `Any` for `Box<dyn Any>`, giving us the `TypeId` of the container instead of the object inside it.
I couldn't find any notes about this in the documentation and - while it could be inferred from existing knowledge of Rust and the blanket implemenation of `Any` - I think it'd be nice to have a note about it in the documentation for the `any` module.
Anyways, here's a first draft of a section about it. I'm happy to revise wording :)
bors [Fri, 1 Jan 2021 22:44:52 +0000 (22:44 +0000)]
Auto merge of #80581 - jyn514:ci-llvm, r=Mark-Simulacrum
Give a better error for download-ci-llvm if .xz is not supported
Previously:
```
curl: (22) The requested URL returned error: 404
failed to run: curl -# -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /tmp/tmp6ptXJV https://ci-artifacts.rust-lang.org/rustc-builds/99ad5a1a2824fea1ecf60068fd3636beae7ea2da/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.gz
```
Now:
```
error: XZ support is required to download LLVM
help: consider disabling `download-ci-llvm` or using a different version of python
Build completed unsuccessfully in 0:00:00
```
Follow-up to https://github.com/rust-lang/rust/pull/80435.
bors [Fri, 1 Jan 2021 20:01:45 +0000 (20:01 +0000)]
Auto merge of #80569 - notriddle:patch-3, r=jyn514
Use Array.prototype.filter instead of open-coding
Part of #79052, originally suggested in https://github.com/rust-lang/rust/pull/79052#discussion_r523468743 by `@jyn514`
Besides making main.js smaller (always a plus), this also performs better by using the optimized filter implementation in your browser's JavaScript engine (according to `@GuillaumeGomez,` an 84% performance improvement).
bors [Fri, 1 Jan 2021 16:12:27 +0000 (16:12 +0000)]
Auto merge of #80565 - camelid:fix-not-has, r=GuillaumeGomez
Fix tests that incorrectly used `!@has` instead of `@!has`
The command is ``@!has`,` not `!`@has`.` I don't think these checks were
doing anything before! Ideally we would accept `!`@has`` as well, or at
least fail tests that use `!`@has`.` The current behavior seems to be
silently ignoring the check, which is very confusing.
Joshua Nelson [Fri, 1 Jan 2021 15:22:25 +0000 (10:22 -0500)]
Give a better error for download-ci-llvm if .xz is not supported
Previously:
```
curl: (22) The requested URL returned error: 404
failed to run: curl -# -y 30 -Y 10 --connect-timeout 30 --retry 3 -Sf -o /tmp/tmp6ptXJV https://ci-artifacts.rust-lang.org/rustc-builds/99ad5a1a2824fea1ecf60068fd3636beae7ea2da/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.gz
```
Now:
```
error: XZ support is required to download LLVM
help: consider disabling `download-ci-llvm` or using a different version of python
Build completed unsuccessfully in 0:00:00
```
Mara Bos [Fri, 1 Jan 2021 15:21:31 +0000 (16:21 +0100)]
Initial support for Rust 2021.
Clippy treated Rust 2021 as Rust 2015, because 2018 was checked with
`==` instead of `>=`. This fixes that, such that 2018-specific things
are also enabled for 2021.
bors [Fri, 1 Jan 2021 13:17:42 +0000 (13:17 +0000)]
Auto merge of #80547 - lqd:const_generics_defaults, r=varkor
In which we start to parse const generics defaults
As discussed in this [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/const.20generic.20defaults), this PR extracts the parsing parts from `@JulianKnodt's` PR #75384 for a better user-experience using the newly stabilized `min_const_generics` (albeit temporary) as shown in #80507: trying to use default values on const generics currently results in parse errors, as if the user didn't use the correct syntax (which is somewhat true but also misleading).
This PR extracts (and slightly modifies in a couple places) `@JulianKnodt's` parsing code (with attribution if I've done everything correctly), AST and HIR changes, and feature gate setup.
This feature is now marked as "incomplete" and thus will also print out the expected "const generics default values are unstable" error instead of a syntax error. Note that, as I've only extracted the parsing part, the actual feature will not work at all if enabled. There will be ICEs, and inference errors on the const generics default values themselves.
Fixes #80507.
Once this merges, I'll:
- modify the const generics tracking issue to refer to the `const_generics_defaults` gate rather than the older temporary name it uses there.
- create the GH `F-const_generics_defaults` label
bors [Fri, 1 Jan 2021 10:29:43 +0000 (10:29 +0000)]
Auto merge of #80310 - Manishearth:box-try-alloc, r=kennytm
Add fallible Box, Arc, and Rc allocator APIs
cc https://github.com/rust-lang/rust/issues/48043
It was suggested in https://github.com/rust-lang/rust/issues/48043#issuecomment-748008486 that `Box::try_*` follows the spirit of RFC 2116. This PR is an attempt to add the relevant APIs, tied to the same feature gate. Happy to make any changes or turn this into an RFC if necessary.