Commit Graph

126175 Commits

Author SHA1 Message Date
George Bateman
badb81a612
#91939: integer to char cast error, make more targeted 2022-01-25 23:46:56 +00:00
Nicolas Abram
b75cb95c26
Update src/doc/rustc/src/linker-plugin-lto.md
Co-authored-by: Noah Lev <camelidcamel@gmail.com>
2022-01-25 20:19:43 -03:00
Eric Holk
520bd69860 Add regression test for #93197 2022-01-25 15:19:33 -08:00
Rob Pilling
a8bac9879a Remove 1-tuple unreachable case 2022-01-25 22:55:22 +00:00
Rob Pilling
a129a85144 Handle generics with ParamEnv 2022-01-25 22:51:19 +00:00
Rob Pilling
54d2d30662 Compare tuple element & arg types before suggesting a tuple 2022-01-25 22:51:19 +00:00
Rob Pilling
80059f9942 Test tuple suggestions, including tuple-as-function-argument 2022-01-25 22:51:18 +00:00
Matthias Krüger
086be2b6c4
Rollup merge of #93303 - compiler-errors:issue-93282, r=wesleywiser
Fix ICE when parsing bad turbofish with lifetime argument

Generalize conditions where we suggest adding the turbofish operator, so we don't ICE during code like

```rust
fn foo() {
  A<'a,>
}
```

but instead suggest adding a turbofish.

Fixes #93282
2022-01-25 23:06:04 +01:00
Matthias Krüger
b2c21abb9c
Rollup merge of #93291 - conradludgate:minor-fix-93231, r=GuillaumeGomez
minor fix for #93231

In #93231 I introduced the new sidebar colours to make the contrast more balanced and easier to read, but it seems I made a copy-paste error in the light theme, resulting in functions appearing green.

This one line change replaces that colour with it's corrected orange/brown colour.

I have double checked the rest of the colours and they seem ok. Sorry for the inconvenience
2022-01-25 23:06:02 +01:00
Matthias Krüger
c8999d9d91
Rollup merge of #93286 - jsha:sidebar-nowrap, r=GuillaumeGomez
Add white-space: nowrap to links in the sidebar

We already have overflow: hidden on these links, but if there is a possibility to wrap, they will wrap. This happens in particular for trait implementations because the punctuation (`<>, `) introduces opportunities for breaks. That produces inconsistent UI. Fix it by forcing them not to wrap.

Demo: https://rustdoc.crud.net/jsha/sidebar-nowrap/std/string/struct.String.html

To see the effect, scroll down to the "Trait Implementations" portion of the sidebar and look at IndexMut. Compare vs:

https://doc.rust-lang.org/std/string/struct.String.html
https://doc.rust-lang.org/nightly/std/string/struct.String.html

r? `@camelid`
2022-01-25 23:06:01 +01:00
Matthias Krüger
83cc776d7c
Rollup merge of #93250 - Aaron1011:remove-early-dedup, r=oli-obk
Remove deduplication of early lints

We already have a general mechanism for deduplicating reported
lints, so there's no need to have an additional one for early lints
specifically. This allows us to remove some `PartialEq` impls.
2022-01-25 23:06:00 +01:00
Michael Goulet
37bed05986 delay the bug once again, generalize turbofish suggestion 2022-01-25 11:11:13 -08:00
bors
8cdb3cd94e Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillot
Store a `Symbol` instead of an `Ident` in `AssocItem`

This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`
2022-01-25 18:53:45 +00:00
Michael Goulet
a090bb1dea Remove delayed bug when encountering label in bad turbofish 2022-01-25 10:47:10 -08:00
Guillaume Gomez
066fcb6fd5 Add test when there is no source code link after version 2022-01-25 17:20:59 +01:00
Guillaume Gomez
d442a37262 Fix invalid extra dot after version if no source 2022-01-25 17:09:48 +01:00
bors
92ed8747f2 Auto merge of #92353 - Kobzol:doc-attr-lists-gat, r=GuillaumeGomez
Rustdoc: remove ListAttributesIter and use impl Iterator instead

This is a continuation of https://github.com/rust-lang/rust/pull/92227.

I found that `ListAttributesIter` did not optimize well and replacing it with a simple `impl Iterator` resulted in 1-3 % instruction count wins locally.

Because I needed to use `impl Iterator` on a slice of AST attributes, I had to implement it using GAT + impl trait. I also have a version without GAT [here](5470e2a65c), if GATs are not welcome in rustdoc :D Locally it resulted in equal performance numbers.

Can I ask for a perf. run? Thanks.

r? rust-lang/rustdoc
2022-01-25 15:43:29 +00:00
Deadbeef
8b76cad0a7
Add a minimal working append_const_msg argument 2022-01-26 00:48:08 +11:00
Deadbeef
fdf7d01088
Improve selection errors for ~const trait bounds 2022-01-26 00:48:01 +11:00
Vadim Petrochenkov
00ba815a58 rustdoc: Pre-calculate traits that are in scope for doc links
This eliminates one more late use of resolver
2022-01-25 21:45:21 +08:00
Conrad Ludgate
e947dc6225 give light-theme fns the correct orange-brown colour 2022-01-25 08:00:34 +00:00
Matthias Krüger
c3ddca6d4a
Rollup merge of #93251 - jsha:theme-radio, r=GuillaumeGomez
rustdoc settings: use radio buttons for theme

This reduces the number of clicks required to change theme.

Also, simplify the UI a bit (remove setting grouping), and add a "Back" link close to the settings icon.

Demo: https://rustdoc.crud.net/jsha/theme-radio/settings.html

r? ``@GuillaumeGomez``

New:

![image](https://user-images.githubusercontent.com/220205/150702647-4826d525-54fa-439a-b24c-6d5bca6f95bf.png)

Old:

![image](https://user-images.githubusercontent.com/220205/150702669-6a4214ed-1dab-4fee-b1aa-59acfce3dbca.png)
2022-01-25 05:51:13 +01:00
Matthias Krüger
3d6f276ca7
Rollup merge of #93175 - spastorino:negative-traits-coherence-new, r=nikomatsakis
Implement stable overlap check considering negative traits

This PR implement the new disjointness rules for overlap check described in https://rust-lang.github.io/negative-impls-initiative/explainer/coherence-check.html#new-disjointness-rules

r? ``@nikomatsakis``
2022-01-25 05:51:12 +01:00
Matthias Krüger
677126cac0
Rollup merge of #93169 - CraftSpider:rustdoc-clean-inconsistency, r=GuillaumeGomez
Fix inconsistency of local blanket impls

When a blanket impl is local, go through HIR instead of middle. This fixes inconsistencies with data detected during JSON generation.

Expected this change to take longer. I also tried doing the whole item through existing clean architecture, but it didn't work out trivially, and felt like it would have added more complexity than it removed.

Properly fixes #83718
2022-01-25 05:51:12 +01:00
Matthias Krüger
8dddc86477
Rollup merge of #93144 - wesleywiser:uninhabited_type_code_cov2, r=tmandry
Work around missing code coverage data causing llvm-cov failures

If we do not add code coverage instrumentation to the `Body` of a
function, then when we go to generate the function record for it, we
won't write any data and this later causes llvm-cov to fail when
processing data for the entire coverage report.

I've identified two main cases where we do not currently add code
coverage instrumentation to the `Body` of a function:

  1. If the function has a single `BasicBlock` and it ends with a
     `TerminatorKind::Unreachable`.

  2. If the function is created using a proc macro of some kind.

For case 1, this is typically not important as this most often occurs as
a result of function definitions that take or return uninhabited
types. These kinds of functions, by definition, cannot even be called so
they logically should not be counted in code coverage statistics.

For case 2, I haven't looked into this very much but I've noticed while
testing this patch that (other than functions which are covered by case
1) the skipped function coverage debug message is occasionally triggered
in large crate graphs by functions generated from a proc macro. This may
have something to do with weird spans being generated by the proc macro
but this is just a guess.

I think it's reasonable to land this change since currently, we fail to
generate *any* results from llvm-cov when a function has no coverage
instrumentation applied to it. With this change, we get coverage data
for all functions other than the two cases discussed above.

Fixes #93054 which occurs because of uncallable functions which shouldn't
have code coverage anyway.

I will open an issue for missing code coverage of proc macro generated
functions and leave a link here once I have a more minimal repro.

r? ``@tmandry``
cc ``@richkadel``
2022-01-25 05:51:11 +01:00
Matthias Krüger
c8ede152a5
Rollup merge of #93118 - jackh726:param-heuristics-3, r=estebank
Move param count error emission to end of `check_argument_types`

The error emission here isn't exactly what is done in #92364, but replicating that is hard . The general move should make for a smaller diff.

Also included the `(usize, Ty, Ty)` to -> `Option<(Ty, Ty)>` commit.

r? ``@estebank``
2022-01-25 05:51:10 +01:00
Matthias Krüger
cf7041186c
Rollup merge of #93064 - Aaron1011:provisional-dep-node, r=michaelwoerister
Properly track `DepNode`s in trait evaluation provisional cache

Fixes #92987

During evaluation of an auto trait predicate, we may encounter a cycle.
This causes us to store the evaluation result in a special 'provisional
cache;. If we later end up determining that the type can legitimately
implement the auto trait despite the cycle, we remove the entry from
the provisional cache, and insert it into the evaluation cache.

Additionally, trait evaluation creates a special anonymous `DepNode`.
All queries invoked during the predicate evaluation are added as
outoging dependency edges from the `DepNode`. This `DepNode` is then
store in the evaluation cache - if a different query ends up reading
from the cache entry, it will also perform a read of the stored
`DepNode`. As a result, the cached evaluation will still end up
(transitively) incurring all of the same dependencies that it would
if it actually performed the uncached evaluation (e.g. a call to
`type_of` to determine constituent types).

Previously, we did not correctly handle the interaction between the
provisional cache and the created `DepNode`. Storing an evaluation
result in the provisional cache would cause us to lose the `DepNode`
created during the evaluation. If we later moved the entry from the
provisional cache to the evaluation cache, we would use the `DepNode`
associated with the evaluation that caused us to 'complete' the cycle,
not the evaluatoon where we first discovered the cycle. As a result,
future reads from the evaluation cache would miss some incremental
compilation dependencies that would have otherwise been added if the
evaluation was *not* cached.

Under the right circumstances, this could lead to us trying to force
a query with a no-longer-existing `DefPathHash`, since we were missing
the (red) dependency edge that would have caused us to bail out before
attempting forcing.

This commit makes the provisional cache store the `DepNode` create
during the provisional evaluation. When we move an entry from the
provisional cache to the evaluation cache, we create a *new* `DepNode`
that has dependencies going to *both* of the evaluation `DepNodes` we
have available. This ensures that cached reads will incur all of
the necessary dependency edges.
2022-01-25 05:51:10 +01:00
Jacob Hoffman-Andrews
abffd4af08 Add white-space: nowrap to links in the sidebar
We already have overflow: hidden on these links, but if there is a
possibility to wrap, they will wrap. This happens in particular for trait
implementations because the punctuation (`<>, `) introduces opportunities
for breaks. That produces inconsistent UI. Fix it by forcing them not to
wrap.
2022-01-24 20:19:09 -08:00
bors
e7825f2b69 Auto merge of #90842 - pierwill:localdefid-indexmap, r=wesleywiser
Use `indexmap` to avoid sorting `LocalDefId`s

See discussion in https://github.com/rust-lang/rust/pull/90408#discussion_r745935459.

Related to work on https://github.com/rust-lang/rust/issues/90317.
2022-01-24 22:04:55 +00:00
bors
51126be1b2 Auto merge of #93260 - matthiaskrgr:rollup-c5b9c76, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #92513 (std: Implement try_reserve and try_reserve_exact on PathBuf)
 - #93152 (Fix STD compilation for the ESP-IDF target (regression from CVE-2022-21658))
 - #93186 (Fix link to CVE-2022-21658)
 - #93188 (rustdoc: fix bump down typing search on Safari)
 - #93212 (Remove unneeded cursor pointer rule on mobile sidebar)
 - #93231 (adjust sidebar link brightness)
 - #93241 (Fix brief appearance of rust logo in the sidebar)
 - #93253 (Update theme on pageshow event)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-24 14:30:04 +00:00
Michael Woerister
e2367eecce Fix vec-slices debuginfo test for GDB. 2022-01-24 13:41:32 +01:00
Michael Woerister
d253e6e473 [debuginfo] Fix and unify handling of fat pointers in debuginfo. 2022-01-24 13:41:32 +01:00
Matthias Krüger
ee35ed3e1a
Rollup merge of #93253 - jsha:theme-on-show, r=GuillaumeGomez
Update theme on pageshow event

When a user goes forward or back, the page may be rendered from the back/forward cache (https://web.dev/bfcache/) rather than from scratch. If they have changed theme in the meantime, that means seeing an incorrect theme on the page they went forward or back to. The `pageshow` event fires on such navigations, so we can update the theme based on that event.

Demo: https://rustdoc.crud.net/jsha/theme-on-show/std/string/trait.ToString.html

r? `@GuillaumeGomez`
2022-01-24 12:29:57 +01:00
Matthias Krüger
d1aa2f7b0b
Rollup merge of #93241 - GuillaumeGomez:rust-logo-appearance, r=jsha
Fix brief appearance of rust logo in the sidebar

Part of #91374.

I simply removed the CSS animation on the visibility, which now makes it all appear at once. I didn't change the CSS animation on the width though, which gives:

https://user-images.githubusercontent.com/3050060/150689595-067a6e00-9875-40c8-9d8a-1e3031dbcaba.mp4

cc `@camelid`

r? `@jsha`
2022-01-24 12:29:56 +01:00
Matthias Krüger
ed1fea8571
Rollup merge of #93231 - conradludgate:doc-link-brightness, r=notriddle
adjust sidebar link brightness

Fairly simple change. I've taken the existing link colour and main body background colours, and made sure that the sidebar+link contrast is the same.

ayu:
- [main content contrast](https://colourcontrast.cc/0f1419/39afd7) - 7.31
- [current sidebar contrast](https://colourcontrast.cc/14191f/39afd7) - 6.97
- [new sidebar contrast](https://colourcontrast.cc/14191f/56b1d9) - 7.30

dark:
- [main content contrast](https://colourcontrast.cc/353535/d2991d) - 4.86
- [current sidebar contrast](https://colourcontrast.cc/14191f/d2991d) - 3.19
- [new sidebar contrast](https://colourcontrast.cc/14191f/fdbf35) - 4.87

light:
- [main content contrast](https://colourcontrast.cc/ffffff/3873ad) - 4.97
- [current sidebar contrast](https://colourcontrast.cc/f5f5f5/3873ad) - 4.56
- [new sidebar contrast](https://colourcontrast.cc/f5f5f5/356da4) - 4.97
2022-01-24 12:29:55 +01:00
Matthias Krüger
26f14bb77d
Rollup merge of #93212 - GuillaumeGomez:cursor-pointer-mobile-sidebar, r=jsha
Remove unneeded cursor pointer rule on mobile sidebar

Since it's on mobile, there isn't much point in this rule...

r? `@jsha`
2022-01-24 12:29:54 +01:00
Matthias Krüger
cce8023b45
Rollup merge of #93188 - jsha:fix-safari-bumpy-search, r=camelid
rustdoc: fix bump down typing search on Safari

Fixes #93184.

For some reason, if the search input doesn't have a previous sibling, typing in the search box increases the search-container's size by about 5px on the bottom. Putting in a dummy sibling fixes it.

https://rustdoc.crud.net/jsha/fix-safari-bumpy-search/std/string/struct.String.html

r? `@camelid`
2022-01-24 12:29:53 +01:00
Eduard-Mihai Burtescu
a8dfa3757c rustc_errors: only box the diagnostic field in DiagnosticBuilder. 2022-01-24 11:23:14 +00:00
bors
d2dc425721 Auto merge of #93014 - Kobzol:revert-92103-stable-hash-skip-zero-bytes, r=the8472
Revert "Do not hash leading zero bytes of i64 numbers in Sip128 hasher"

Reverts rust-lang/rust#92103. It had a (in retrospect, obvious) correctness problem where changing the order of two adjacent values would produce identical hashes, which is problematic in stable hashing (see [this comment](https://github.com/rust-lang/rust/pull/92103#issuecomment-1014625442)).

I'll try to send the PR again with a fix for this issue.

r? `@the8472`
2022-01-24 11:20:01 +00:00
Jakub Beránek
50f8062316
Revert "Do not hash leading zero bytes of i64 numbers in Sip128 hasher" 2022-01-24 09:07:47 +01:00
bors
ef119d704d Auto merge of #93028 - compiler-errors:const_drop_bounds, r=fee1-dead
Check `const Drop` impls considering `~const` Bounds

 This PR adds logic to trait selection to account for `~const` bounds in custom `impl const Drop` for types, elaborates the `const Drop` check in `rustc_const_eval` to check those bounds, and steals some drop linting fixes from #92922, thanks `@DrMeepster.`

r? `@fee1-dead` `@oli-obk` <sup>(edit: guess I can't request review from two people, lol)</sup>
since each of you wrote and reviewed #88558, respectively.

Since the logic here is more complicated than what existed, it's possible that this is a perf regression. But it works correctly with tests, and that makes me happy.

Fixes #92881
2022-01-24 08:05:37 +00:00
Jacob Hoffman-Andrews
b30725eab7 Update theme on pageshow event
When a user goes forward or back, the page may be rendered from the
back/forward cache (https://web.dev/bfcache/) rather than from scratch. If
they have changed theme in the meantime, that means seeing an incorrect
theme on the page they went forward or back to. The `pageshow` event
fires on such navigations, so we can update the theme based on that event.
2022-01-23 17:17:58 -08:00
Jacob Hoffman-Andrews
11b17c6c04 rustdoc settings: use radio buttons for theme
This reduces the number of clicks required to change theme.

Also, simplify the UI a bit (remove setting grouping), and add a "Back"
link close to the settings icon.
2022-01-23 15:55:50 -08:00
Aaron Hill
58d676b0cc
Remove deduplication of early lints
We already have a general mechanism for deduplicating reported
lints, so there's no need to have an additional one for early lints
specifically. This allows us to remove some `PartialEq` impls.
2022-01-23 17:05:48 -05:00
Jacob Hoffman-Andrews
bc8ef4cb66 rustdoc: fix bump down typing search on Safari 2022-01-23 12:56:19 -08:00
Conrad Ludgate
ca3d0e2316 update tests 2022-01-23 19:26:07 +00:00
Matthias Krüger
a1645e5b57
Rollup merge of #93229 - mark-i-m:noquiet, r=eddyb
Remove DiagnosticBuilder.quiet

r? `@eddyb`

cc https://github.com/rust-lang/rust/issues/69426 `@GuillaumeGomez` `@Manishearth`
2022-01-23 20:13:07 +01:00
Matthias Krüger
8810af8082
Rollup merge of #93227 - compiler-errors:gat-hrtb-wfcheck, r=jackh726
Liberate late bound regions when collecting GAT substs in wfcheck

The issue here is that the [`GATSubstCollector`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_typeck/src/check/wfcheck.rs#L604) does not currently do anything wrt `Binder`s, so the GAT substs it copies out have escaping late bound regions when it walks through types like `for<'x> fn() -> Self::Gat<'x>`.

I made that visitor call `liberate_late_bound_regions`, not sure if that's the right thing here or we need to do something else to replace these bound vars with placeholders. I'm not familiar with other code doing anything similar.. But the issue is indeed no longer ICEing.

Fixes #92954

r? `@jackh726`
since you last touched this code, feel free to reassign
2022-01-23 20:13:06 +01:00
Matthias Krüger
5adef281d6
Rollup merge of #93226 - compiler-errors:issue-93141, r=jackh726
Normalize field access types during borrowck

I think a normalize was just left out here, since we normalize analogously throughout this file.

Fixes #93141
2022-01-23 20:13:05 +01:00
Matthias Krüger
552b564df0
Rollup merge of #93219 - cr1901:msp430-asm-squashed, r=Amanieu
Add preliminary support for inline assembly for msp430.

The `llvm_asm` macro was removed recently, and the MSP430 backend relies on inline assembly to build useful embedded apps. I conveniently "found" time to implement basic support for the new inline `asm` macro syntax with the help of `@Amanieu` :D.

In addition to tests in the compiler, I have tested this locally against deployed MSP430 code and have not found any noticeable differences in firmware operation or `objdump` disassemblies between the old `llvm_asm` and the new `asm` syntax.
2022-01-23 20:13:04 +01:00
Matthias Krüger
0f2ff4b270
Rollup merge of #93213 - c410-f3r:let-chains-feature, r=matthewjasper
Fix `let_chains` and `if_let_guard` feature flags

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

cc #53667
2022-01-23 20:13:03 +01:00
Matthias Krüger
89baf0f162
Rollup merge of #91526 - petrochenkov:earlint, r=cjgillot
rustc_lint: Some early linting refactorings

The first one removes and renames some fields and methods from `EarlyContext`.

The second one uses the set of registered tools (for tool attributes and tool lints) in a more centralized way.

The third one removes creation of a fake `ast::Crate` from `fn pre_expansion_lint`.
Pre-expansion linting is done with per-module granularity on freshly loaded modules, and it previously synthesized an `ast::Crate` to visit non-root modules, now they are visited as modules.
The node ID used for pre-expansion linting is also made more precise (the loaded module ID is used).
2022-01-23 20:13:00 +01:00
Michael Goulet
4a74ace3c9 Liberate late bound regions when collecting GAT substs in wfcheck 2022-01-23 09:41:52 -08:00
Guillaume Gomez
d889a4ebac Fix brief appearance of rust logo in the sidebar 2022-01-23 18:04:41 +01:00
bors
84322efad5 Auto merge of #93066 - nnethercote:infallible-decoder, r=bjorn3
Make `Decodable` and `Decoder` infallible.

`Decoder` has two impls:
- opaque: this impl is already partly infallible, i.e. in some places it
  currently panics on failure (e.g. if the input is too short, or on a
  bad `Result` discriminant), and in some places it returns an error
  (e.g. on a bad `Option` discriminant). The number of places where
  either happens is surprisingly small, just because the binary
  representation has very little redundancy and a lot of input reading
  can occur even on malformed data.
- json: this impl is fully fallible, but it's only used (a) for the
  `.rlink` file production, and there's a `FIXME` comment suggesting it
  should change to a binary format, and (b) in a few tests in
  non-fundamental ways. Indeed #85993 is open to remove it entirely.

And the top-level places in the compiler that call into decoding just
abort on error anyway. So the fallibility is providing little value, and
getting rid of it leads to some non-trivial performance improvements.

Much of this PR is pretty boring and mechanical. Some notes about
a few interesting parts:
- The commit removes `Decoder::{Error,error}`.
- `InternIteratorElement::intern_with`: the impl for `T` now has the same
  optimization for small counts that the impl for `Result<T, E>` has,
  because it's now much hotter.
- Decodable impls for SmallVec, LinkedList, VecDeque now all use
  `collect`, which is nice; the one for `Vec` uses unsafe code, because
  that gave better perf on some benchmarks.

r? `@bjorn3`
2022-01-23 15:37:43 +00:00
bors
1e4067957b Auto merge of #93047 - matthiaskrgr:defer__dist_PlainSourceTarball, r=Mark-Simulacrum
build: dist: defer PlainSourceTarball

Apparently it changes some tool sources and invalidates their fingerprints, forcing us to build them several times (before and after vendoring sources).
I have not dug into why vendoring actually invalidates the figreprints, but moving the vendoring lower in the pipeline seems to avoid the issue.
I could imagine that we somehow write a .cargo/config somewhere which somehow makes subsequent builds use the vendored deps but I was not able to find anything.

I checked the sizes of generated archives pre and post patch and their are the same, so I hope there is no functional change.

Fixes #93033
2022-01-23 12:29:08 +00:00
Vadim Petrochenkov
9c70b6d11b Update clippy 2022-01-23 19:31:32 +08:00
Conrad Ludgate
f00b02bb69 remove duplicate rule 2022-01-23 11:05:04 +00:00
Vadim Petrochenkov
51b2338611 rustc_lint: Reuse the set of registered tools from resolver 2022-01-23 18:51:51 +08:00
Conrad Ludgate
a0748d9436 tweak all sidebar colours 2022-01-23 10:43:06 +00:00
bors
16c1a9dd7c Auto merge of #93220 - matthiaskrgr:rollup-9bkrlk0, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #90666 (Stabilize arc_new_cyclic)
 - #91122 (impl Not for !)
 - #93068 (Fix spacing for `·` between stability and source)
 - #93103 (Tweak `expr.await` desugaring `Span`)
 - #93113 (Unify search input and buttons size)
 - #93168 (update uclibc instructions for new toolchain, add link from platforms doc)
 - #93185 (rustdoc: Make some `pub` items crate-private)
 - #93196 (Remove dead code from build_helper)

Failed merges:

 - #93188 (rustdoc: fix bump down typing search on Safari)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-23 09:16:32 +00:00
Conrad Ludgate
9c3ffd7681 adjust sidebar link brightness 2022-01-23 09:06:44 +00:00
woppopo
aa6795e2d4 Add intrinsics::const_deallocate 2022-01-23 15:13:44 +09:00
mark
cf382de0cc Remove DiagnosticBuilder.quiet 2022-01-23 00:11:13 -06:00
William D. Jones
19809ed76d Add preliminary support for inline assembly for msp430. 2022-01-22 23:42:46 -05:00
pierwill
4f89224f7f Use an indexmap to avoid sorting LocalDefIds
Update `indexmap` to 1.8.0.

Bless test
2022-01-22 22:34:16 -06:00
Michael Goulet
4ff7e6e3e3 Normalize field access types during borrowck 2022-01-22 20:05:05 -08:00
bors
d13e8dd41d Auto merge of #93165 - eholk:disable-generator-drop-tracking, r=nikomatsakis
Disable drop range tracking in generators

Generator drop tracking caused an ICE for generators involving the Never type (Issue #93161). Since this breaks a test case with miri, we temporarily disable drop tracking so miri is unblocked while we properly fix the issue.
2022-01-23 02:20:50 +00:00
Rune Tynan
92206318bc Add has tests for blanket_with_local trait methods 2022-01-22 19:55:25 -05:00
Alyssa Verkade
b885700c7b [borrowck] Fix help on mutating &self in async fns
Previously, when rustc was provided an async function that tried to
mutate through a shared reference to an implicit self (as shown in the
ui test), rustc would suggest modifying the parameter signature
to `&mut` + the fully qualified name of the ty (in the case of the repro
`S`). If a user modified their code to match the suggestion, the
compiler would not accept it.

This commit modifies the suggestion so that when rustc is provided the
ui test that is also attached in this commit, it suggests (correctly)
`&mut self`. We try to be careful about distinguishing between implicit
and explicit self annotations, since the latter seem to be handled
correctly already.

Fixes rust-lang/rust#93093
2022-01-22 16:21:16 -08:00
Matthias Krüger
1a935a52be
Rollup merge of #93196 - mati865:remove-build_helper-dead-code, r=Mark-Simulacrum
Remove dead code from build_helper

Tested with `./x.py check` ran on x86_64 Linux.
2022-01-23 01:09:47 +01:00
Matthias Krüger
d4c9c5ad66
Rollup merge of #93185 - camelid:crate-private, r=GuillaumeGomez
rustdoc: Make some `pub` items crate-private

They don't need to be `pub`. Making them crate-private improves code
clarity and `dead_code` linting.
2022-01-23 01:09:46 +01:00
Matthias Krüger
389e712a46
Rollup merge of #93168 - skrap:master, r=Amanieu
update uclibc instructions for new toolchain, add link from platforms doc

2 quick things:
1) `libc` was updated to make use of features in a uclibc version more recent than the recommended toolchain in the target document, so I updated the link.
2) As has been done with other platforms, link directly from the platform support doc to the target-specific document.
2022-01-23 01:09:45 +01:00
Matthias Krüger
74b05ce746
Rollup merge of #93113 - GuillaumeGomez:unify-sizes, r=jsha
Unify search input and buttons size

Fixes #93060.

Here what it looks like:

![Screenshot from 2022-01-20 21-38-19](https://user-images.githubusercontent.com/3050060/150418571-fefd6538-b3ee-4dd2-b77b-77e96bcfa0ed.png)
![Screenshot from 2022-01-20 21-38-22](https://user-images.githubusercontent.com/3050060/150418570-53ba259b-9bd4-4084-8b43-d74a5752d712.png)

You can test it [here](https://rustdoc.crud.net/imperio/unify-sizes/std/index.html).

r? ``@jsha``
2022-01-23 01:09:44 +01:00
Matthias Krüger
a15252817a
Rollup merge of #93103 - estebank:await-span, r=nagisa
Tweak `expr.await` desugaring `Span`

Fix #93074
2022-01-23 01:09:43 +01:00
Matthias Krüger
24ac541de6
Rollup merge of #93068 - jsha:dot-spacing, r=GuillaumeGomez
Fix spacing for `·` between stability and source

This puts in an actual space (by adjusting the space-eating operators in our templates), updates the test, and remove the now-unnecessary CSS rule.

r? ``@GuillaumeGomez``
2022-01-23 01:09:42 +01:00
Matthias Krüger
55a1f8b955
Rollup merge of #91122 - dtolnay:not, r=m-ou-se
impl Not for !

The lack of this impl caused trouble for me in some degenerate cases of macro-generated code of the form `if !$cond {...}`, even without `feature(never_type)` on a stable compiler. Namely if `$cond` contains a `return` or `break` or similar diverging expression, which would otherwise be perfectly legal in boolean position, the code previously failed to compile with:

```console
error[E0600]: cannot apply unary operator `!` to type `!`
   --> library/core/tests/ops.rs:239:8
    |
239 |     if !return () {}
    |        ^^^^^^^^^^ cannot apply unary operator `!`
```
2022-01-23 01:09:41 +01:00
Ibraheem Ahmed
32ab0b88f4 respect doc(hidden) when suggesting available fields 2022-01-22 15:48:45 -05:00
Caio
cbb0fffe59 Fix let_chains and if_let_guard feature flags 2022-01-22 17:45:45 -03:00
Jonah Petri
ab5437e861 update uclibc instructions for new toolchain, add link from platforms doc 2022-01-22 14:16:52 -05:00
Guillaume Gomez
9f30dd9cbc Remove unneeded cursor pointer rule on mobile sidebar 2022-01-22 19:43:25 +01:00
Matthias Krüger
19e414a9dc
Rollup merge of #93172 - jsha:re-remove-line, r=camelid
rustdoc: remove dashed underline under main heading

This was removed in #92797 but accidentally re-introduced by a bad merge in #92861.

r? ```@camelid```
2022-01-22 15:32:57 +01:00
Matthias Krüger
86c096e243
Rollup merge of #93170 - GuillaumeGomez:gui-tests-explanations, r=jsha
Add missing GUI test explanations

Some GUI tests didn't have a global explanation about what they were testing. This fixes it.

r? ```@jsha```
2022-01-22 15:32:55 +01:00
Matthias Krüger
a8f64c0415
Rollup merge of #93153 - tmiasko:reject-unsupported-naked-functions, r=Amanieu
Reject unsupported naked functions

Transition unsupported naked functions future incompatibility lint into an error:

* Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 #79653. Change into an error fixes a soundness issue described in #32489.

* Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 #87652.

Closes #32490.
Closes #32489.

r? ```@Amanieu``` ```@npmccallum``` ```@joshtriplett```
2022-01-22 15:32:54 +01:00
Matthias Krüger
45f5f34293
Rollup merge of #93132 - Urgau:fix-rustdoc-json-format-version, r=oli-obk
Increase the format version of rustdoc-json-types

PR https://github.com/rust-lang/rust/pull/87648 changed `rustdoc-json-types` without increasing the format version.
e7529d6a38 (diff-ede26372490522288745c5b3df2b6b2a1cc913dcd09b29af3a49935afe00c7e6)

This PR increase the format version by +1 and move the `FORMAT_VERSION` constant to the start of the file to hopefully make it more clear that `rustdoc-json-types` is versioned.
2022-01-22 15:32:52 +01:00
Matthias Krüger
9d7c8edd6c
Rollup merge of #92828 - Amanieu:unwind-abort, r=dtolnay
Print a helpful message if unwinding aborts when it reaches a nounwind function

This is implemented by routing `TerminatorKind::Abort` back through the panic handler, but with a special flag in the `PanicInfo` which indicates that the panic handler should *not* attempt to unwind the stack and should instead abort immediately.

This is useful for the planned change in https://github.com/rust-lang/lang-team/issues/97 which would make `Drop` impls `nounwind` by default.

### Code

```rust
#![feature(c_unwind)]

fn panic() {
    panic!()
}

extern "C" fn nounwind() {
    panic();
}

fn main() {
    nounwind();
}
```

### Before

```
$ ./test
thread 'main' panicked at 'explicit panic', test.rs:4:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Illegal instruction (core dumped)
```

### After

```
$ ./test
thread 'main' panicked at 'explicit panic', test.rs:4:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'panic in a function that cannot unwind', test.rs:7:1
stack backtrace:
   0:     0x556f8f86ec9b - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdccefe11a6ac4396
   1:     0x556f8f88ac6c - core::fmt::write::he152b28c41466ebb
   2:     0x556f8f85d6e2 - std::io::Write::write_fmt::h0c261480ab86f3d3
   3:     0x556f8f8654fa - std::panicking::default_hook::{{closure}}::h5d7346f3ff7f6c1b
   4:     0x556f8f86512b - std::panicking::default_hook::hd85803a1376cac7f
   5:     0x556f8f865a91 - std::panicking::rust_panic_with_hook::h4dc1c5a3036257ac
   6:     0x556f8f86f079 - std::panicking::begin_panic_handler::{{closure}}::hdda1d83c7a9d34d2
   7:     0x556f8f86edc4 - std::sys_common::backtrace::__rust_end_short_backtrace::h5b70ed0cce71e95f
   8:     0x556f8f865592 - rust_begin_unwind
   9:     0x556f8f85a764 - core::panicking::panic_no_unwind::h2606ab3d78c87899
  10:     0x556f8f85b910 - test::nounwind::hade6c7ee65050347
  11:     0x556f8f85b936 - test::main::hdc6e02cb36343525
  12:     0x556f8f85b7e3 - core::ops::function::FnOnce::call_once::h4d02663acfc7597f
  13:     0x556f8f85b739 - std::sys_common::backtrace::__rust_begin_short_backtrace::h071d40135adb0101
  14:     0x556f8f85c149 - std::rt::lang_start::{{closure}}::h70dbfbf38b685e93
  15:     0x556f8f85c791 - std::rt::lang_start_internal::h798f1c0268d525aa
  16:     0x556f8f85c131 - std::rt::lang_start::h476a7ee0a0bb663f
  17:     0x556f8f85b963 - main
  18:     0x7f64c0822b25 - __libc_start_main
  19:     0x556f8f85ae8e - _start
  20:                0x0 - <unknown>
thread panicked while panicking. aborting.
Aborted (core dumped)
```
2022-01-22 15:32:49 +01:00
Mateusz Mikuła
9427ccbecd Remove dead code from build_helper 2022-01-22 12:06:44 +01:00
Jack Huey
ce31f68f9e Move param count error emission to near end of check_argument_types 2022-01-21 23:13:00 -05:00
Noah Lev
fc16b815cc rustdoc: Make some pub items crate-private
They don't need to be `pub`. Making them crate-private improves code
clarity and `dead_code` linting.
2022-01-21 18:41:50 -08:00
bors
ecf72996ed Auto merge of #93173 - matthiaskrgr:rollup-49bj7ta, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #91965 (Add more granular `--exclude` in `x.py`)
 - #92467 (Ensure that early-bound function lifetimes are always 'local')
 - #92586 (Set the allocation MIN_ALIGN for espidf to 4.)
 - #92835 (Improve error message for key="value" cfg arguments.)
 - #92843 (Improve string concatenation suggestion)
 - #92963 (Implement tuple array diagnostic)
 - #93046 (Use let_else in even more places)
 - #93109 (Improve `Arc` and `Rc` documentation)
 - #93134 (delete `Stdin::split` forwarder)
 - #93139 (rustdoc: fix overflow-wrap for table layouts)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-21 23:52:58 +00:00
Nicholas Nethercote
416399dc10 Make Decodable and Decoder infallible.
`Decoder` has two impls:
- opaque: this impl is already partly infallible, i.e. in some places it
  currently panics on failure (e.g. if the input is too short, or on a
  bad `Result` discriminant), and in some places it returns an error
  (e.g. on a bad `Option` discriminant). The number of places where
  either happens is surprisingly small, just because the binary
  representation has very little redundancy and a lot of input reading
  can occur even on malformed data.
- json: this impl is fully fallible, but it's only used (a) for the
  `.rlink` file production, and there's a `FIXME` comment suggesting it
  should change to a binary format, and (b) in a few tests in
  non-fundamental ways. Indeed #85993 is open to remove it entirely.

And the top-level places in the compiler that call into decoding just
abort on error anyway. So the fallibility is providing little value, and
getting rid of it leads to some non-trivial performance improvements.

Much of this commit is pretty boring and mechanical. Some notes about
a few interesting parts:
- The commit removes `Decoder::{Error,error}`.
- `InternIteratorElement::intern_with`: the impl for `T` now has the same
  optimization for small counts that the impl for `Result<T, E>` has,
  because it's now much hotter.
- Decodable impls for SmallVec, LinkedList, VecDeque now all use
  `collect`, which is nice; the one for `Vec` uses unsafe code, because
  that gave better perf on some benchmarks.
2022-01-22 10:38:31 +11:00
Jacob Hoffman-Andrews
ee6c33c255 Fix spacing for · between stability and source 2022-01-21 15:00:20 -08:00
Guillaume Gomez
f0525da124 Unify search input and buttons size 2022-01-21 23:38:48 +01:00
Santiago Pastorino
d2d25a5be0
Implement stable with negative coherence mode 2022-01-21 18:22:21 -03:00
Matthias Krüger
26e9357fae
Rollup merge of #93139 - jsha:fix-wrapped-names, r=Nemo157
rustdoc: fix overflow-wrap for table layouts

For all table layouts, set overflow-wrap: break-word.

Fixes #93135

Demo: https://rustdoc.crud.net/jsha/fix-wrapped-names/std/intrinsics/index.html#functions

(Compare vs https://doc.rust-lang.org/nightly/std/intrinsics/index.html - you may have to make your browser narrower to see the effect)

r? `@Nemo157`
2022-01-21 22:03:20 +01:00
Matthias Krüger
1f3a2dd0b1
Rollup merge of #92963 - terrarier2111:tuple-diagnostic, r=davidtwco
Implement tuple array diagnostic

Fixes https://github.com/rust-lang/rust/issues/92089
2022-01-21 22:03:16 +01:00
Matthias Krüger
430673f265
Rollup merge of #92843 - camelid:str-concat-sugg, r=davidtwco
Improve string concatenation suggestion

Before:

    error[E0369]: cannot add `&str` to `&str`
     --> file.rs:2:22
      |
    2 |     let _x = "hello" + " world";
      |              ------- ^ -------- &str
      |              |       |
      |              |       `+` cannot be used to concatenate two `&str` strings
      |              &str
      |
    help: `to_owned()` can be used to create an owned `String` from a string reference. String concatenation appends the string on the right to the string on the left and may require reallocation. This requires ownership of the string on the left
      |
    2 |     let _x = "hello".to_owned() + " world";
      |              ~~~~~~~~~~~~~~~~~~

After:

    error[E0369]: cannot add `&str` to `&str`
     --> file.rs:2:22
      |
    2 |     let _x = "hello" + " world";
      |              ------- ^ -------- &str
      |              |       |
      |              |       `+` cannot be used to concatenate two `&str` strings
      |              &str
      |
      = note: string concatenation requires an owned `String` on the left
    help: create an owned `String` from a string reference
      |
    2 |     let _x = "hello".to_owned() + " world";
      |                     +++++++++++
2022-01-21 22:03:15 +01:00
Matthias Krüger
e38cbc78aa
Rollup merge of #92835 - iwanders:issue-66450-improve-cfg-error-message, r=nagisa
Improve error message for key="value" cfg arguments.

Hi, I ran into difficulties using the `--cfg` flag syntax, first hit when googling for the error was issue https://github.com/rust-lang/rust/issues/66450. Reading that issue, it sounded like the best way to improve the experience was to improve the error message, this is low risk and doesn't introduce any additional argument parsing.

The issue mentions that it is entirely dependent on the shell, while this may be true, I think guiding the the user into the realization that the quotes may need to be escaped is helpful. The two suggested escapings both work in Bash and in the Windows command prompt.

fyi `@ehuss`
2022-01-21 22:03:14 +01:00
Matthias Krüger
10c9ec399e
Rollup merge of #92467 - Aaron1011:extern-local-region, r=oli-obk
Ensure that early-bound function lifetimes are always 'local'

During borrowchecking, we treat any free (early-bound) regions on
the 'defining type' as `RegionClassification::External`. According
to the doc comments, we should only have 'external' regions when
checking a closure/generator.

However, a plain function can also have some if its regions
be considered 'early bound' - this occurs when the region is
constrained by an argument, appears in a `where` clause, or
in an opaque type. This was causing us to incorrectly mark these
regions as 'external', which caused some diagnostic code
to act as if we were referring to a 'parent' region from inside
a closure.

This PR marks all instantiated region variables as 'local'
when we're borrow-checking something other than a
closure/generator/inline-const.
2022-01-21 22:03:12 +01:00
Matthias Krüger
fc694064e8
Rollup merge of #91965 - ferrocene:pa-more-granular-exclude, r=Mark-Simulacrum
Add more granular `--exclude` in `x.py`

x.py has support for excluding some steps from the current invocation, but unfortunately that's not granular enough: some steps have the same name in different modules, and that prevents excluding only *some* of them.

As a practical example, let's say you need to run everything in `./x.py test` except for the standard library tests, as those tests require IPv6 and need to be executed on a separate machine. Before this commit, if you were to just run this:

    ./x.py test --exclude library/std

...the invocation would eventually fail, as that would not only exclude running the tests for the standard library (`library/std` in the `test` module), it would also exclude generating its documentation (`library/std` in the `doc` module), breaking linkchecker.

This commit adds support to the `--exclude` flag for prefixing paths with the name of the module their step is defined in, allowing the user to choose which module to exclude from:

    ./x.py test --exclude test::library/std

This maintains backward compatibility with existing invocations, while allowing more ganular exclusion. Examples of the behavior:

| `--exclude`         | Docs    | Tests   |
| ------------------- | ------- | ------- |
| `library/std`       | Skipped | Skipped |
| `doc::library/std`  | Skipped | Run     |
| `test::library/std` | Run     | Skipped |

Note that this PR only changes the `--exclude` flag, and not in other `x.py` arguments or flags yet.

In the implementation I tried to limit the impact this would have with rustbuild as a whole as much as possible. The module name is extracted from the step by parsing the result of `std::any::type_name()`: unfortunately that output can change at any point in time, but IMO it's better than having to annotate all the existing and future `Step` implementations with the module name. I added a test to ensure the parsing works as expected, so hopefully if anyone makes changes to the output of `std::any::type_name()` they'll also notice they have to update rustbuild.

r? `@Mark-Simulacrum`
2022-01-21 22:03:11 +01:00
bors
17d29dcdce Auto merge of #92363 - the8472:less-compiletest-normalization, r=Mark-Simulacrum
Override rustc version in ui and mir-opt tests to get stable hashes

Building a dozen separate regexps for each test in compiletest consumes significant amounts of CPU cycles.

UI test timings on my machine:

OLD: 39.63s
NEW: 30.27s
2022-01-21 20:47:48 +00:00
Jacob Hoffman-Andrews
2eb8bfc643 rustdoc: remove dashed underline under main heading 2022-01-21 12:04:59 -08:00
Guillaume Gomez
78cee22fb4 Add missing GUI test explanations 2022-01-21 20:41:47 +01:00
Wesley Wiser
1a0278e1d1 Work around missing code coverage data causing llvm-cov failures
If we do not add code coverage instrumentation to the `Body` of a
function, then when we go to generate the function record for it, we
won't write any data and this later causes llvm-cov to fail when
processing data for the entire coverage report.

I've identified two main cases where we do not currently add code
coverage instrumentation to the `Body` of a function:

  1. If the function has a single `BasicBlock` and it ends with a
     `TerminatorKind::Unreachable`.

  2. If the function is created using a proc macro of some kind.

For case 1, this typically not important as this most often occurs as
the result of function definitions that take or return uninhabited
types. These kinds of functions, by definition, cannot even be called so
they logically should not be counted in code coverage statistics.

For case 2, I haven't looked into this very much but I've noticed while
testing this patch that (other than functions which are covered by case
1) the skipped function coverage debug message is occasionally triggered
in large crate graphs by functions generated from a proc macro. This may
have something to do with weird spans being generated by the proc macro
but this is just a guess.

I think it's reasonable to land this change since currently, we fail to
generate *any* results from llvm-cov when a function has no coverage
instrumentation applied to it. With this change, we get coverage data
for all functions other than the two cases discussed above.
2022-01-21 19:39:18 +00:00
Rune Tynan
66d056a9bf Update test to include self case 2022-01-21 13:19:18 -05:00
Rune Tynan
f4b42946c8 Remove FIXME and fix inconsistency of local blanket impls by using HIR for them 2022-01-21 13:01:58 -05:00
Eric Holk
2c2deff74a Add regression test for #93161 2022-01-21 09:48:39 -08:00
bors
cbaeec14f9 Auto merge of #92983 - pietroalbini:pa-bump-runner-images, r=Mark-Simulacrum
Update Linux runners to Ubuntu 20.04

r? `@Mark-Simulacrum`
2022-01-21 17:43:39 +00:00
Eric Holk
13090889f5 Disable drop range tracking in generators
Generator drop tracking caused an ICE for generators involving the Never
type (Issue #93161). Since this breaks miri, we temporarily disable drop
tracking so miri is unblocked while we properly fix the issue.
2022-01-21 09:36:24 -08:00
Cameron Steffen
b11733534d Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
Pietro Albini
b3ad40532d
allow excluding paths only from a single module
x.py has support for excluding some steps from the invocation, but
unfortunately that's not granular enough: some steps have the same name
in different modules, and that prevents excluding only *some* of them.

As a practical example, let's say you need to run everything in `./x.py
test` except for the standard library tests, as those tests require IPv6
and need to be executed on a separate machine. Before this commit, if
you were to just run this:

    ./x.py test --exclude library/std

...the execution would fail, as that would not only exclude running the
tests for the standard library, it would also exclude generating its
documentation (breaking linkchecker).

This commit adds support for an optional module annotation in --exclude
paths, allowing the user to choose which module to exclude from:

    ./x.py test --exclude test::library/std

This maintains backward compatibility, but also allows for more ganular
exclusion. More examples on how this works:

| `--exclude`         | Docs    | Tests   |
| ------------------- | ------- | ------- |
| `library/std`       | Skipped | Skipped |
| `doc::library/std`  | Skipped | Run     |
| `test::library/std` | Run     | Skipped |

Note that the new behavior only works in the `--exclude` flag, and not
in other x.py arguments or flags yet.
2022-01-21 09:33:43 +01:00
Pietro Albini
b27d59d083
replace paths in PathSet with a dedicated TaskPath struct 2022-01-21 09:33:38 +01:00
bors
0bcacb391b Auto merge of #91359 - dtolnay:args, r=Mark-Simulacrum
Emit simpler code from format_args

I made this PR so that `cargo expand` dumps a less overwhelming amount of formatting-related code.

<br>

`println!("rust")` **Before:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"],
                                                     &match () {
                                                          _args => [],
                                                      }));
};
```

**After:**

```rust
{ ::std::io::_print(::core::fmt::Arguments::new_v1(&["rust\n"], &[])); };
```

`println!("{}", x)` **Before:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(
        &["", "\n"],
        &match (&x,) {
            _args => [::core::fmt::ArgumentV1::new(
                _args.0,
                ::core::fmt::Display::fmt,
            )],
        },
    ));
};
```

**After:**

```rust
{
    ::std::io::_print(::core::fmt::Arguments::new_v1(
        &["", "\n"],
        &[::core::fmt::ArgumentV1::new(&x, ::core::fmt::Display::fmt)],
    ));
};
```
2022-01-21 06:20:18 +00:00
bors
523be2e05d Auto merge of #93138 - matthiaskrgr:rollup-m8akifd, r=matthiaskrgr
Rollup of 17 pull requests

Successful merges:

 - #91032 (Introduce drop range tracking to generator interior analysis)
 - #92856 (Exclude "test" from doc_auto_cfg)
 - #92860 (Fix errors on blanket impls by ignoring the children of generated impls)
 - #93038 (Fix star handling in block doc comments)
 - #93061 (Only suggest adding `!` to expressions that can be macro invocation)
 - #93067 (rustdoc mobile: fix scroll offset when jumping to internal id)
 - #93086 (Add tests to ensure that `let_chains` works with `if_let_guard`)
 - #93087 (Fix src/test/run-make/raw-dylib-alt-calling-convention)
 - #93091 (⬆ chalk to 0.76.0)
 - #93094 (src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`)
 - #93098 (Show a more informative panic message when `DefPathHash` does not exist)
 - #93099 (rustdoc: auto create output directory when "--output-format json")
 - #93102 (Pretty printer algorithm revamp step 3)
 - #93104 (Support --bless for pp-exact pretty printer tests)
 - #93114 (update comment for `ensure_monomorphic_enough`)
 - #93128 (Add script to prevent point releases with same number as existing ones)
 - #93136 (Backport the 1.58.1 release notes to master)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-21 03:04:43 +00:00
Tomasz Miąsko
beeba4bcea Reject may_unwind option in naked functions 2022-01-21 00:00:00 +00:00
Tomasz Miąsko
888332fee4 Reject unsupported naked functions
Transition unsupported naked functions future incompatibility lint into
an error:

* Naked functions must contain a single inline assembly block.
  Introduced as future incompatibility lint in 1.50 #79653.
  Change into an error fixes a soundness issue described in #32489.

* Naked functions must not use any forms of inline attribute.
  Introduced as future incompatibility lint in 1.56 #87652.
2022-01-21 17:38:21 +01:00
Jacob Hoffman-Andrews
9d178e5e8d rustdoc: fix overflow-wrap for table layouts
For all table layouts, set overflow-wrap: break-word.
2022-01-20 15:53:08 -08:00
The 8472
7a5796d3f1 use lazy_static to compile Regex::new instances once instead on each test 2022-01-21 00:28:07 +01:00
The 8472
8985e5ee82 Override rustc version in ui and mir-opt tests to get stable hashes
Building a dozen separate regexps for each test in compiletest consumes significant amounts of CPU cycles.
Using `RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER` stabilizes hashes calcuated for the individual tests so
no test-dependent normalization is needed. Hashes for the standard library still change so some
normalizations are still needed.
2022-01-21 00:28:07 +01:00
Matthias Krüger
9ea966a275
Rollup merge of #93128 - pietroalbini:pa-verify-stable-version-number, r=Mark-Simulacrum
Add script to prevent point releases with same number as existing ones

This will hopefully prevent what happened today with #93110 and #93121, where we built point release artifacts without changing version numbers, thus requiring another PR to change the version number.

r? `@Mark-Simulacrum`
2022-01-20 23:37:43 +01:00
Matthias Krüger
5e46f7dceb
Rollup merge of #93104 - dtolnay:ppbless, r=Mark-Simulacrum
Support --bless for pp-exact pretty printer tests

I ran into this while working on the stack of PRs containing #93102. `x.py test src/test/pretty --bless` previously would `fatal` instead of blessing the input files.

Tested by making a silly pretty-printer tweak and running the above command: 98823c3929ebfe796786345c5ee713f63317d9c6
2022-01-20 23:37:41 +01:00
Matthias Krüger
51fd48f157
Rollup merge of #93099 - tomkris:rustdoc-fix, r=jsha
rustdoc: auto create output directory when "--output-format json"

This PR allows rustdoc to automatically create output directory in case it does not exist (when run with `--output-format json`).

This fixes rustdoc crash:

````
$ rustdoc --output-format json -Z unstable-options src/main.rs
error: couldn't generate documentation: No such file or directory (os error 2)
  |
  = note: failed to create or modify "doc/main.json"

error: aborting due to previous error
````

With this fix behavior of `rustdoc --output-format json` becomes consistent with `rustdoc --output-format html` (which already auto-creates output directory if it's missing)
2022-01-20 23:37:39 +01:00
Matthias Krüger
6cdd2e510c
Rollup merge of #93094 - Enselic:check-for-enum-tuple-struct-fields, r=CraftSpider
src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`

The presence of `struct_field`s is being checked for already in
`variant_struct.rs`. We should also check for them in `variant_tuple_struct.rs`.

This PR is one small step towards resolving #92945.
2022-01-20 23:37:37 +01:00
Matthias Krüger
894a867fd2
Rollup merge of #93087 - ricobbe:alt-calling-convention-test-fix, r=Mark-Simulacrum
Fix src/test/run-make/raw-dylib-alt-calling-convention

Fix the test headers so that the test now runs on all intended platforms; it is currently ignored on all platforms because the headers are incorrect.  Also comment out a couple of function calls that fail because of an unrelated problem, described in issue #91167.
2022-01-20 23:37:36 +01:00
Matthias Krüger
0a9aaec8eb
Rollup merge of #93086 - c410-f3r:let-guard, r=Mark-Simulacrum
Add tests to ensure that `let_chains` works with `if_let_guard`

The current machinery already makes such combination possible but lacks tests.

cc `@matthewjasper`
2022-01-20 23:37:35 +01:00
Matthias Krüger
35a53b229f
Rollup merge of #93067 - jsha:fix-scroll-padding-top, r=GuillaumeGomez
rustdoc mobile: fix scroll offset when jumping to internal id

Followup to #92692. The semantics of `scroll-margin-top` are a little surprising - the attribute needs to be applied to the element that gets scrolled into the viewport, not the scrolling element.

This fixes an issue where clicking on a method (or other item) from the sidebar takes you to a scroll position where the topbar covers up the method name.

I'm interested in ideas for how to test this with browser-ui-test, but I think it doesn't yet have what I need. What I need is an assert that `<element>.getBoundingClientRect().y` is > 45.

Demo: https://rustdoc.crud.net/jsha/fix-scroll-padding-top/std/string/struct.String.html#method.extend_from_within

r? `@GuillaumeGomez`
2022-01-20 23:37:34 +01:00
Matthias Krüger
dc393b2ecc
Rollup merge of #93061 - estebank:macr-suggestion, r=cjgillot
Only suggest adding `!` to expressions that can be macro invocation
2022-01-20 23:37:33 +01:00
Matthias Krüger
aa7f4520a1
Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddle
Fix star handling in block doc comments

Fixes #92872.

Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in:

```rust
/// he
/**
* hello
*/
#[doc = "boom"]
```

We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars.

r? ``@camelid``
2022-01-20 23:37:32 +01:00
Matthias Krüger
530c884372
Rollup merge of #92860 - CraftSpider:rustdoc-json-impl-ice, r=jsha
Fix errors on blanket impls by ignoring the children of generated impls

Related to #83718

We can safely skip the children, as they don't contain any new info, and may be subtly different for reasons hard to track down, in ways that are consistently worse than the actual generic impl.
2022-01-20 23:37:31 +01:00
Matthias Krüger
10a7204af9
Rollup merge of #92856 - GuillaumeGomez:exclude-test-doc_auto_cfg, r=Nemo157
Exclude "test" from doc_auto_cfg

Fixes #91740.

cc `@Nemo157` (you were the one suggesting this iirc)
r? `@camelid`
2022-01-20 23:37:30 +01:00
Matthias Krüger
3d10c64b26
Rollup merge of #91032 - eholk:generator-drop-tracking, r=nikomatsakis
Introduce drop range tracking to generator interior analysis

This PR addresses cases such as this one from #57478:
```rust
struct Foo;
impl !Send for Foo {}

let _: impl Send = || {
    let guard = Foo;
    drop(guard);
    yield;
};
```

Previously, the `generator_interior` pass would unnecessarily include the type `Foo` in the generator because it was not aware of the behavior of `drop`. We fix this issue by introducing a drop range analysis that finds portions of the code where a value is guaranteed to be dropped. If a value is dropped at all suspend points, then it is no longer included in the generator type. Note that we are using "dropped" in a generic sense to include any case in which a value has been moved. That is, we do not only look at calls to the `drop` function.

There are several phases to the drop tracking algorithm, and we'll go into more detail below.
1. Use `ExprUseVisitor` to find values that are consumed and borrowed.
2. `DropRangeVisitor` uses consume and borrow information to gather drop and reinitialization events, as well as build a control flow graph.
3. We then propagate drop and reinitialization information through the CFG until we reach a fix point (see `DropRanges::propagate_to_fixpoint`).
4. When recording a type (see `InteriorVisitor::record`), we check the computed drop ranges to see if that value is definitely dropped at the suspend point. If so, we skip including it in the type.

## 1. Use `ExprUseVisitor` to find values that are consumed and borrowed.

We use `ExprUseVisitor` to identify the places where values are consumed. We track both the `hir_id` of the value, and the `hir_id` of the expression that consumes it. For example, in the expression `[Foo]`, the `Foo` is consumed by the array expression, so after the array expression we can consider the `Foo` temporary to be dropped.

In this process, we also collect values that are borrowed. The reason is that the MIR transform for generators conservatively assumes anything borrowed is live across a suspend point (see `rustc_mir_transform::generator::locals_live_across_suspend_points`). We match this behavior here as well.

## 2. Gather drop events, reinitialization events, and control flow graph

After finding the values of interest, we perform a post-order traversal over the HIR tree to find the points where these values are dropped or reinitialized. We use the post-order index of each event because this is how the existing generator interior analysis refers to the position of suspend points and the scopes of variables.

During this traversal, we also record branching and merging information to handle control flow constructs such as `if`, `match`, and `loop`. This is necessary because values may be dropped along some control flow paths but not others.

## 3. Iterate to fixed point

The previous pass found the interesting events and locations, but now we need to find the actual ranges where things are dropped. Upon entry, we have a list of nodes ordered by their position in the post-order traversal. Each node has a set of successors. For each node we additionally keep a bitfield with one bit per potentially consumed value. The bit is set if we the value is dropped along all paths entering this node.

To compute the drop information, we first reverse the successor edges to find each node's predecessors. Then we iterate through each node, and for each node we set its dropped value bitfield to the intersection of all incoming dropped value bitfields.

If any bitfield for any node changes, we re-run the propagation loop again.

## 4. Ignore dropped values across suspend points

At this point we have a data structure where we can ask whether a value is guaranteed to be dropped at any post order index for the HIR tree. We use this information in `InteriorVisitor` to check whether a value in question is dropped at a particular suspend point. If it is, we do not include that value's type in the generator type.

Note that we had to augment the region scope tree to include all yields in scope, rather than just the last one as we did before.

r? `@nikomatsakis`
2022-01-20 23:37:29 +01:00
Loïc BRANSTETT
1521b53c53 Increase the format version of rustdoc-json-types 2022-01-20 22:14:02 +01:00
Guillaume Gomez
b0df7653d0 More clean up 2022-01-20 22:13:32 +01:00
Guillaume Gomez
caec4a23f2 Extra cfg_hide a bit to handle inner cfgs 2022-01-20 22:05:26 +01:00
Guillaume Gomez
fd005f53c2 Update doc_auto_cfg test 2022-01-20 22:05:26 +01:00
Guillaume Gomez
682ef4db80 Exclude "test" from doc_auto_cfg rendering 2022-01-20 22:05:25 +01:00
Pietro Albini
855c17643a
add script to prevent point releases with same number as existing ones 2022-01-20 21:27:17 +01:00
Matthias Krüger
d893b0ab32
Rollup merge of #93108 - lnicola:rust-analyzer-2022-01-20, r=lnicola
⬆️ rust-analyzer

r? `@ghost`
2022-01-20 17:10:42 +01:00
Matthias Krüger
6c627d25f6
Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddle
Fix star handling in block doc comments

Fixes #92872.

Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in:

```rust
/// he
/**
* hello
*/
#[doc = "boom"]
```

We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars.

r? `@camelid`
2022-01-20 17:10:41 +01:00
Matthias Krüger
ed3bf67db7
Rollup merge of #92861 - jsha:mobile-column-flex, r=GuillaumeGomez
Rustdoc mobile: put out-of-band info on its own line

Before this, the item name and the stability, source link, and "collapse
all docs" would compete for room on a single line, resulting in awkward
wrapping behavior on mobile. This gives a separate line for that
out-of-band information. It also removes the "copy path" icon on mobile
to make a little more room.

Demo: https://rustdoc.crud.net/jsha/mobile-column-flex/std/string/struct.String.html

r? `@GuillaumeGomez`
2022-01-20 17:10:39 +01:00
Matthias Krüger
5c10dbd85f
Rollup merge of #92704 - 5225225:std_mem_transmute_ref_t_mut_t, r=michaelwoerister
Change lint message to be stronger for &T -> &mut T transmute

The old message implied that it's only UB if you use the reference to mutate, which (as far as I know) is not true. As in, the following program has UB, and a &T -> &mut T transmute is effectively an `unreachable_unchecked`.

```rust
fn main() {
    #[allow(mutable_transmutes)]
    unsafe {
        let _ = std::mem::transmute::<&i32, &mut i32>(&0);
    }
}
```

In the future, it might be a good idea to use the edition system to make this a hard error, since I don't think it is *ever* defined behaviour? Unless we rule that `&UnsafeCell<i32> -> &mut i32` is fine. (That, and you always could just use `.get()`, so you're not losing anything)
2022-01-20 17:10:37 +01:00
Matthias Krüger
1839829f0a
Rollup merge of #92680 - camelid:assoc-item-cleanup, r=petrochenkov
intra-doc: Use the impl's assoc item where possible

Before, the trait's associated item would be used. Now, the impl's
associated item is used. The only exception is for impls that use
default values for associated items set by the trait. In that case,
the trait's associated item is still used.

As an example of the old and new behavior, take this code:

    trait MyTrait {
        type AssocTy;
    }

    impl MyTrait for String {
        type AssocTy = u8;
    }

Before, when resolving a link to `String::AssocTy`,
`resolve_associated_trait_item` would return the associated item for
`MyTrait::AssocTy`. Now, it would return the associated item for
`<String as MyTrait>::AssocTy`, as it claims in its docs.

r? `@petrochenkov`
2022-01-20 17:10:36 +01:00
Matthias Krüger
db1253f1d2
Rollup merge of #92582 - lcnr:generic-arg-infer, r=BoxyUwU
improve `_` constants in item signature handling

removing the "type" from the error messages does slightly worsen the error messages for types, but figuring out whether the placeholder is for a type or a constant and correctly dealing with that seemed fairly difficult to me so I took the easy way out  Imo the error message is still clear enough.

r? `@BoxyUwU` cc `@estebank`
2022-01-20 17:10:35 +01:00
Matthias Krüger
413f490677
Rollup merge of #92183 - tmandry:issue-74256, r=estebank
Point at correct argument when async fn output type lifetime disagrees with signature

Fixes most of #74256.

## Problems fixed

This PR fixes a couple of related problems in the error reporting code.

### Highlighting the wrong argument

First, the error reporting code was looking at the desugared return type of an `async fn` to decide which parameter to highlight. For example, a function like

```rust
async fn async_fn(self: &Struct, f: &u32) -> &u32
{ f }
```

desugars to

```rust
async fn async_fn<'a, 'b>(self: &'a Struct, f: &'b u32)
-> impl Future<Output = &'a u32> + 'a + 'b
{ f }
```

Since `f: &'b u32` is returned but the output type is `&'a u32`, the error would occur when checking that `'a: 'b`.

The reporting code would look to see if the "offending" lifetime `'b` was included in the return type, and because the code was looking at the desugared future type, it was included. So it defaulted to reporting that the source of the other lifetime `'a` (the `self` type) was the problem, when it was really the type of `f`. (Note that if it had chosen instead to look at `'a` first, it too would have been included in the output type, and it would have arbitrarily reported the error (correctly this time) on the type of `f`.)

Looking at the actual future type isn't useful for this reason; it captures all input lifetimes. Using the written return type for `async fn` solves this problem and results in less confusing error messages for the user.

This isn't a perfect fix, unfortunately; writing the "manually desugared" form of the above function still results in the wrong parameter being highlighted. Looking at the output type of every `impl Future` return type doesn't feel like a very principled approach, though it might work. The problem would remain for function signatures that look like the desugared one above but use different traits. There may be deeper changes required to pinpoint which part of each type is conflicting.

### Lying about await point capture causing lifetime conflicts

The second issue fixed by this PR is the unnecessary complexity in `try_report_anon_anon_conflict`. It turns out that the root cause I suggested in https://github.com/rust-lang/rust/issues/76547#issuecomment-692863608 wasn't really the root cause. Adding special handling to report that a variable was captured over an await point only made the error messages less correct and pointed to a problem other than the one that actually occurred.

Given the above discussion, it's easy to see why: `async fn`s capture all input lifetimes in their return type, so holding an argument across an await point should never cause a lifetime conflict! Removing the special handling simplified the code and improved the error messages (though they still aren't very good!)

## Future work

* Fix error reporting on the "desugared" form of this code
* Get the `suggest_adding_lifetime_params` suggestion firing on these examples
  * cc #42703, I think

r? `@estebank`
2022-01-20 17:10:34 +01:00
Matthias Krüger
405cf20442
Rollup merge of #91694 - euclio:stability-improvements, r=GuillaumeGomez
rustdoc: decouple stability and const-stability

This PR tweaks the stability rendering code to consider stability and const-stability separately. This fixes two issues:

- Stabilities that match the enclosing item are now always omitted, even if the item has const-stability as well (#90552)
- Const-stable unstable functions will now have their (const-) stability rendered.

Fixes #90552.
2022-01-20 17:10:33 +01:00
Matthias Krüger
02379e917b
Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelix
Stabilize `-Z print-link-args` as `--print link-args`

We have stable options for adding linker arguments; we should have a
stable option to help debug linker arguments.

Add documentation for the new option. In the documentation, make it clear that
the *exact* format of the output is not a stable guarantee.
2022-01-20 17:10:32 +01:00
Laurențiu Nicola
3b100458c1 ⬆️ rust-analyzer 2022-01-20 12:14:08 +02:00
Artem Kryvokrysenko
4e17170c54 rustdoc: auto create output directory when "--output-format json"
This PR allows rustdoc to automatically create output directory in case
it does not exist (when run with `--output-format json`).

This fixes rustdoc crash:

````
$ rustdoc --output-format json -Z unstable-options src/main.rs
error: couldn't generate documentation: No such file or directory (os error 2)
  |
  = note: failed to create or modify "doc/main.json"

error: aborting due to previous error
````

With this fix behavior of `rustdoc --output-format json` becomes consistent
with `rustdoc --output-format html` (which already auto-creates output
directory if it's missing)
2022-01-19 22:28:07 -08:00
Jacob Hoffman-Andrews
152e888905 Rustdoc mobile: put out-of-band on its own line
Before this, the item name and the stability, source link, and "collapse
all docs" would compete for room on a single line, resulting in awkward
wrapping behavior on mobile. This gives a separate line for that
out-of-band information. It also removes the "copy path" icon on mobile
to make a little more room.

Also, switch to flex-wrap: wrap, so anytime there's not enough room for
`source`, it gets bumped to the next line.
2022-01-19 20:52:09 -08:00
David Tolnay
dcb0721a29
Support --bless for pp-exact pretty printer tests 2022-01-19 20:15:08 -08:00
Esteban Kuber
7356e28abb Tweak expr.await desugaring Span
Fix #93074
2022-01-20 04:09:46 +00:00
Michael Goulet
b7e4433974 Foreign types are trivially drop
- Also rename a trivial_const_drop to match style of other functions in
  the util module.
- Also add a test for `const Drop` that doesn't depend on a `~const`
  bound.
- Also comment a bit why we remove the const bound during dropck impl
  check.
2022-01-19 20:07:04 -08:00
Aaron Hill
c8941d3e48
Store a Symbol instead of an Ident in AssocItem
This is the same idea as #92533, but for `AssocItem` instead
of `VariantDef`/`FieldDef`.

With this change, we no longer have any uses of
`#[stable_hasher(project(...))]`
2022-01-19 17:13:21 -05:00
Tyler Mandry
698631e16c Simplify error reporting code, remove await point wording 2022-01-19 21:33:57 +00:00
Tyler Mandry
5c15ad7fca NiceRegionError: Use written return type for async fn 2022-01-19 21:33:57 +00:00
Martin Nordholts
ab239cc749 src/test/rustdoc-json: Check for struct_fields in variant_tuple_struct.rs
The presence of `struct_field`s is being checked for already in
`variant_struct.rs`. We should also check for them in `variant_tuple_struct.rs`.
2022-01-19 22:10:26 +01:00
Michael Goulet
8547f5732c never is trivially const-drop, and add test 2022-01-19 12:59:28 -08:00
Jacob Hoffman-Andrews
801ac0e24f Fix scroll offset when jumping to internal id 2022-01-19 12:45:16 -08:00
Amanieu d'Antras
5eb6fff824 Add links to the reference and rust by example for asm! docs and lints 2022-01-19 20:00:10 +00:00
Amanieu d'Antras
2f1a12f8b7 Update rust-by-examples 2022-01-19 20:00:07 +00:00
Caio
f491a9f601 Add tests to ensure that let_chains works with if_let_guard 2022-01-19 16:23:44 -03:00
Richard Cobbe
10858d28af Fix test directives; comment out calls broken on windows-gnu 2022-01-19 10:54:08 -08:00
Matthias Krüger
623791df24
Rollup merge of #93005 - GuillaumeGomez:templates-in-html, r=notriddle
Move back templates into html folder

Follow-up of https://github.com/rust-lang/rust/pull/92526.

r? `@notriddle`
2022-01-19 19:19:49 +01:00
Matthias Krüger
bcb093efcd
Rollup merge of #92800 - ehuss:docs-fallback, r=Mark-Simulacrum
Add manifest docs fallback.

This adds a fallback so that the rustup manifest will contain the rust-docs component for all hosts. There is a mapping so that the docs that get downloaded are roughly close to the actual host. There inevitably will be things that don't match. Ideally the standard library docs would be the same for every platform (`cfg(doc)` goes a long way towards this), but there are still lots of minor differences.

Closes #69525
2022-01-19 19:19:48 +01:00
Matthias Krüger
715cda2e81
Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser
mangling_v0: Skip extern blocks during mangling

There's no need to include the dummy `Nt` into the symbol name, items in extern blocks belong to their parent modules for all purposes except for inheriting the ABI and attributes.

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

(There's also a drive-by fix to the `rust-demangler` tool's tests, which don't run on CI, I initially attempted using them for testing this PR.)
2022-01-19 19:19:45 +01:00
Esteban Kuber
017747fa5a Only suggest adding ! to expressions that can be macro invocation 2022-01-19 18:00:10 +00:00
Eric Huss
c8e6889e08 Add assert that fallback targets must be available. 2022-01-19 09:41:04 -08:00
Guillaume Gomez
06b00ad199 Add test for block doc comments 2022-01-19 11:18:17 +01:00
Guillaume Gomez
2938be612d Correctly handle starts in block doc comments 2022-01-19 11:18:17 +01:00
Guillaume Gomez
48f5dcad10 Move back templates into html folder 2022-01-19 11:13:24 +01:00
Matthias Krüger
ea1275a62c
Rollup merge of #93062 - ehuss:update-books, r=ehuss
Update books

## nomicon

1 commits in c05c452b36358821bf4122f9c418674edd1d713d..66d097d3d80e8f88c288c6879c7c2b909ecf8ad4
2021-12-13 15:23:48 +0900 to 2022-01-05 05:45:21 +0900
- Fix typo / type error in FFI code example (rust-lang/nomicon#327)

## reference

8 commits in f8ba2f12df60ee19b96de24ae5b73af3de8a446b..4dee6eb63d728ffb9e7a2ed443e9ada9275c69d2
2022-01-03 11:02:08 -0800 to 2022-01-18 09:26:33 -0800
- (minor) Remove Expression Path sub-types splits in Pattern specs (rust-lang/reference#1138)
- Document destructuring assignment (rust-lang/reference#1116)
- Document the 2021 edition changes to macros-by-example `pat` metavariables (rust-lang/reference#1135)
- Improve the documentation of macros-by-example metavariable names (rust-lang/reference#1130)
- trait-bounds.md: add pronoun 'that' (rust-lang/reference#1131)
- Say that macros-by-example `ident` metavariables can match raw identifiers (rust-lang/reference#1133)
- State in the UAX31 profile description that a lone `_` is not an identifier (rust-lang/reference#1129)
- Document syntax reserved in Rust 2021 (rust-lang/reference#1128)

## book

17 commits in d3740fb7aad0ea4a80ae20f64dee3a8cfc0c5c3c..f17df27fc14696912c48b8b7a7a8fa49e648088d
2022-01-03 21:46:04 -0500 to 2022-01-18 17:46:28 -0500
- Add a notice to the top of all nostarch snapshots
- Fix quotes
- Grammar (minor): 'or' → 'and' for enum variants
- Propagate edits of chapter 8 to src
- Replies to nostarch edits
- more edits
- ch8 from nostarch
- Fix grammar and line wrapping
- Merge remote-tracking branch 'origin/pr/2880'
- Remove wikipedia link
- Merge remote-tracking branch 'origin/pr/2927'
- Snapshot of ch14 for nostarch
- Backport fixes to chapter 14 noticed while doing nostarch snapshot
- Fix usage of find piped into xargs
- Adjust some more line numbers of Cargo.toml includes
- Merge branch '2909'
- Merge remote-tracking branch 'parkerziegler/fix/ch14-add-one-naming'

## rustc-dev-guide

7 commits in 875464457c4104686faf667f47848aa7b0f0a744..78dd6a4684cf8d6b72275fab6d0429ea40b66338
2021-12-28 22:17:49 -0600 to 2022-01-18 14:44:26 -0300
- Reorganize and expand the testing chapters. (rust-lang/rustc-dev-guide#1281)
- Add inline assembly internals (rust-lang/rustc-dev-guide#1266)
- Spelling: Rename `rust` to `Rust` (rust-lang/rustc-dev-guide#1288)
- Clean up section about FCPs (rust-lang/rustc-dev-guide#1287)
- Address more review comments in rust-lang/rustc-dev-guide#1286.
- Address review comments in rust-lang/rustc-dev-guide#1286.
- Streamline "Getting Started" some more.
2022-01-19 10:42:21 +01:00
Matthias Krüger
7f2dbcba38
Rollup merge of #92797 - jsha:fewer-lines, r=GuillaumeGomez
Remove horizontal lines at top of page

They are not needed to separate the search bar and the title, which are visually distinct on their own.

Part of #59840

Demo: https://rustdoc.crud.net/jsha/fewer-lines/std/string/struct.String.html

r? `@GuillaumeGomez`
2022-01-19 10:42:17 +01:00
Matthias Krüger
9a82f74cdf
Rollup merge of #92783 - FabianWolff:issue-92726, r=nikomatsakis
Annotate dead code lint with notes about ignored derived impls

Fixes #92726. CC `@pmetzger,` is this what you had in mind?

r? `@nikomatsakis`
2022-01-19 10:42:16 +01:00
Matthias Krüger
5d2928f7b9
Rollup merge of #88642 - c410-f3r:let_chains_2, r=matthewjasper
Formally implement let chains

## Let chains

My longest and hardest contribution since #64010.

Thanks to `@Centril` for creating the RFC and special thanks to `@matthewjasper` for helping me since the beginning of this journey. In fact, `@matthewjasper` did much of the complicated MIR stuff so it's true to say that this feature wouldn't be possible without him. Thanks again `@matthewjasper!`

With the changes proposed in this PR, it will be possible to chain let expressions along side local variable declarations or ordinary conditional expressions. In other words, do much of what the `if_chain` crate already does.

## Other considerations

* `if let guard` and `let ... else` features need special care and should be handled in a following PR.

* Irrefutable patterns are allowed within a let chain context

* ~~Three Clippy lints were already converted to start dogfooding and help detect possible corner cases~~

cc #53667
2022-01-19 10:42:12 +01:00
Aaron Hill
02f1a565fe
Properly track DepNodes in trait evaluation provisional cache
Fixes #92987

During evaluation of an auto trait predicate, we may encounter a cycle.
This causes us to store the evaluation result in a special 'provisional
cache;. If we later end up determining that the type can legitimately
implement the auto trait despite the cycle, we remove the entry from
the provisional cache, and insert it into the evaluation cache.

Additionally, trait evaluation creates a special anonymous `DepNode`.
All queries invoked during the predicate evaluation are added as
outoging dependency edges from the `DepNode`. This `DepNode` is then
store in the evaluation cache - if a different query ends up reading
from the cache entry, it will also perform a read of the stored
`DepNode`. As a result, the cached evaluation will still end up
(transitively) incurring all of the same dependencies that it would
if it actually performed the uncached evaluation (e.g. a call to
`type_of` to determine constituent types).

Previously, we did not correctly handle the interaction between the
provisional cache and the created `DepNode`. Storing an evaluation
result in the provisional cache would cause us to lose the `DepNode`
created during the evaluation. If we later moved the entry from the
provisional cache to the evaluation cache, we would use the `DepNode`
associated with the evaluation that caused us to 'complete' the cycle,
not the evaluatoon where we first discovered the cycle. As a result,
future reads from the evaluation cache would miss some incremental
compilation dependencies that would have otherwise been added if the
evaluation was *not* cached.

Under the right circumstances, this could lead to us trying to force
a query with a no-longer-existing `DefPathHash`, since we were missing
the (red) dependency edge that would have caused us to bail out before
attempting forcing.

This commit makes the provisional cache store the `DepNode` create
during the provisional evaluation. When we move an entry from the
provisional cache to the evaluation cache, we create a *new* `DepNode`
that has dependencies going to *both* of the evaluation `DepNodes` we
have available. This ensures that cached reads will incur all of
the necessary dependency edges.
2022-01-18 23:12:42 -05:00
Matthias Krüger
5f58a78da0 build: dist: defer PlainSourceTarball
Apparently it changes some tool sources and invalidates their fingerprints, forcing us to build them several times (before and after vendoring sources).
I have not dug into why vendoring actually invalidates the figreprints, but the moving the vendoring lower in the pipeline seems to avoid the issue.
I could imagine that we somehow write a .cargo/config somewhere which somehow makes subsequent builds use the vendored deps but I was not able to find anything.

I checked the sizes of generated archives pre and post patch and their are the same, so I hope there is not functional change.

Fixes #93033
2022-01-19 04:43:52 +01:00
Eric Huss
84e0d9db6c Update books 2022-01-18 19:23:45 -08:00
Eric Huss
bfacc5cc73 Update cargo 2022-01-18 19:14:33 -08:00
Jacob Hoffman-Andrews
fa9a8430ea Remove horizontal lines at top of page
They are not needed to separate the search bar and the title, which are
visually distinct on their own.
2022-01-18 18:45:43 -08:00
Noah Lev
7c4eca0687 Make suggestions verbose 2022-01-18 16:38:06 -08:00
Noah Lev
7507fb6306 Shorten and improve messages 2022-01-18 16:32:58 -08:00
Noah Lev
29a2d6b505 intra-doc: Use the impl's assoc item where possible
Before, the trait's associated item would be used. Now, the impl's
associated item is used. The only exception is for impls that use
default values for associated items set by the trait. In that case,
the trait's associated item is still used.

As an example of the old and new behavior, take this code:

    trait MyTrait {
        type AssocTy;
    }

    impl MyTrait for String {
        type AssocTy = u8;
    }

Before, when resolving a link to `String::AssocTy`,
`resolve_associated_trait_item` would return the associated item for
`MyTrait::AssocTy`. Now, it would return the associated item for
`<String as MyTrait>::AssocTy`, as it claims in its docs.
2022-01-18 16:05:12 -08:00
Caio
5f74ef4fb1 Formally implement let chains 2022-01-18 19:38:17 -03:00
Eric Holk
e0a5370ef0 Respond to code review comments 2022-01-18 14:25:31 -08:00
Eric Holk
32930d9ea7 Safely handle partial drops
We previously weren't tracking partial re-inits while being too
aggressive around partial drops. With this change, we simply ignore
partial drops, which is the safer, more conservative choice.
2022-01-18 14:25:30 -08:00
Eric Holk
887e843eeb Update async-fn-nonsend.rs
The previous commit made the non_sync_with_method_call case pass due to
the await being unreachable. Unfortunately, this isn't actually the
behavior the test was verifying. This change lifts the panic into a
helper function so that the generator analysis still thinks the await
is reachable, and therefore we preserve the same testing behavior.
2022-01-18 14:25:30 -08:00
Eric Holk
787f4cbd15 Handle uninhabited return types
This changes drop range analysis to handle uninhabited return types such
as `!`. Since these calls to these functions do not return, we model
them as ending in an infinite loop.
2022-01-18 14:25:30 -08:00
Eric Holk
a7df4e8d2f Handle empty loops better 2022-01-18 14:25:29 -08:00
Eric Holk
4a70de7932 Handle reinits in match guards 2022-01-18 14:25:29 -08:00
Eric Holk
7d82e4f764 Update stderr files 2022-01-18 14:25:28 -08:00
Eric Holk
30e1b1e92e Address code review comments
1. Add test case for partial drops
2. Simplify code in `propagate_to_fixpoint` and remove most clones
3. Clean up PostOrderIndex creation
2022-01-18 14:25:27 -08:00
Eric Holk
46760b4e67 Update async-fn-nonsend.stderr 2022-01-18 14:25:27 -08:00
Eric Holk
457415294c Handle more cases with conditionally initialized/dropped values 2022-01-18 14:25:25 -08:00
Eric Holk
298ca2f679 Basic loop support 2022-01-18 14:25:25 -08:00
Eric Holk
96117701f9 Support reinitialization of variables 2022-01-18 14:25:25 -08:00
Eric Holk
aa029d4bbe Support conditional drops
This adds support for branching and merging control flow and uses this
to correctly handle the case where a value is dropped in one branch of
an if expression but not another.

There are other cases we need to handle, which will come in follow up
patches.

Issue #57478
2022-01-18 14:25:24 -08:00
Eric Holk
f246c0b116 Attribute drop to parent expression of the consume point
This is needed to handle cases like `[a, b.await, c]`. `ExprUseVisitor`
considers `a` to be consumed when it is passed to the array, but the
array is not quite live yet at that point. This means we were missing
the `a` value across the await point. Attributing drops to the parent
expression means we do not consider the value consumed until the
consuming expression has finished.

Issue #57478
2022-01-18 14:25:24 -08:00
Eric Holk
f664cfc47c Make generator and async-await tests pass
The main change needed to make this work is to do a pessimistic over-
approximation for AssignOps. The existing ScopeTree analysis in
region.rs works by doing both left to right and right to left order and
then choosing the most conservative ordering. This behavior is needed
because AssignOp's evaluation order depends on whether it is a primitive
type or an overloaded operator, which runs as a method call.

This change mimics the same behavior as region.rs in
generator_interior.rs.

Issue #57478
2022-01-18 14:25:24 -08:00
Eric Holk
c4dee40170 Track drops across multiple yields 2022-01-18 14:25:24 -08:00
Eric Holk
f712df8c5d Track drop points in generator_interior
This change adds the basic infrastructure for tracking drop ranges in
generator interior analysis, which allows us to exclude dropped types
from the generator type.

Not yet complete, but many of the async/await and generator tests pass.
The main missing piece is tracking branching control flow (e.g. around
an `if` expression). The patch does include support, however, for
multiple yields in th e same block.

Issue #57478
2022-01-18 14:25:23 -08:00
Eric Holk
4be32f896a Add test case for #57478 2022-01-18 14:25:23 -08:00
Matthias Krüger
5a4f47460b
Rollup merge of #92780 - b-naber:postpone-const-eval-coherence, r=lcnr
Directly use ConstValue for single literals in blocks

Addresses the minimal repro in https://github.com/rust-lang/rust/issues/92186, but doesn't fix the underlying problem (which would be solved by solving the anon subst problem afaict).

I do, however, think that it makes sense in general to treat single literals in anon blocks as const values directly, especially in light of the problem that the issue refers to (anon const evaluation being postponed until infer variables in substs can be resolved, which was introduced by https://github.com/rust-lang/rust/pull/90023), i.e. while we do get warnings for those unnecessary braces, we should try to avoid errors caused by those braces if possible.
2022-01-18 22:00:47 +01:00
Matthias Krüger
ff476b3009
Rollup merge of #92692 - jsha:cool-sidebar, r=GuillaumeGomez
Simplify and unify rustdoc sidebar styles

Fixes #59860

This switches to just use size, weight, and spacing to distinguish headings in the sidebar. We no longer use boxes, horizontal bars, or centering to distinguish headings. This makes it much easier to understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to shift around elements from the sidebar to make the topbar. Now, the topbar gets its own elements, which can be styled on their own. This makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width slightly.

As a very minor change, removed version from the "All types" page. It's now only on the crate page.

struct - https://rustdoc.crud.net/jsha/cool-sidebar/std/vec/struct.Vec.html
trait - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/trait.Read.html
crate - https://rustdoc.crud.net/jsha/cool-sidebar/std/index.html
mod - https://rustdoc.crud.net/jsha/cool-sidebar/std/any/index.html
macro - https://rustdoc.crud.net/jsha/cool-sidebar/std/macro.panic.html
fn - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/fn.stdin.html
type alias - https://rustdoc.crud.net/jsha/cool-sidebar/std/io/type.Result.html
keyword - https://rustdoc.crud.net/jsha/cool-sidebar/std/keyword.as.html
primitive - https://rustdoc.crud.net/jsha/cool-sidebar/std/primitive.pointer.html

r? `@GuillaumeGomez`
cc `@camelid`
[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/sidebar.20headings).

Note: This has a lot of smaller commits, but I plan to squash them before merging.
2022-01-18 22:00:46 +01:00
Matthias Krüger
7889f96103
Rollup merge of #92425 - calebzulawski:simd-cast, r=workingjubilee
Improve SIMD casts

* Allows `simd_cast` intrinsic to take `usize` and `isize`
* Adds `simd_as` intrinsic, which is the same as `simd_cast` except for saturating float-to-int conversions (matching the behavior of `as`).

cc `@workingjubilee`
2022-01-18 22:00:45 +01:00
Matthias Krüger
f372476d2c
Rollup merge of #91150 - dtolnay:qpath, r=davidtwco
Let qpath contain NtTy: `<$:ty as $:ty>::…`

Example:

```rust
macro_rules! m {
    (<$type:ty as $trait:ty>::$name:ident) => {
        <$type as $trait>::$name
    };
}

fn main() {
    let _: m!(<str as ToOwned>::Owned);
}
```

Previous behavior:

```console
error: expected identifier, found `ToOwned`
 --> src/main.rs:3:19
  |
3 |         <$type as $trait>::$name
  |                   ^^^^^^ expected identifier
...
8 |     let _: m!(<str as ToOwned>::Owned);
  |            ---------------------------
  |            |
  |            this macro call doesn't expand to a type
  |            in this macro invocation
```

The <code>expected identifier, found \`ToOwned\`</code> error is particularly silly. I think it should be fine to accept this code as long as $trait is of the form `TyKind::Path(None, path)`; if it is any other kind of `NtTy`, we'll keep the same behavior as before.
2022-01-18 22:00:43 +01:00
Matthias Krüger
dd621a4c5c
Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoerister
Implement raw-dylib support for windows-gnu

Add support for `#[link(kind = "raw-dylib")]` on windows-gnu targets.  Work around binutils's linker's inability to read import libraries produced by LLVM by calling out to the binutils `dlltool` utility to create an import library from a temporary .DEF file; this approach is effectively a slightly refined version of `@mati865's` earlier attempt at this strategy in PR #88801.  (In particular, this attempt at this strategy adds support for `#[link_ordinal(...)]` as well.)

In support of #58713.
2022-01-18 22:00:42 +01:00
David Tolnay
039a058306
Add a more complete test of rustdoc macro_rules matcher rendering 2022-01-18 12:25:58 -08:00
David Tolnay
f562b24830
Convert macro-generated-macro snapshot to /text() using PR 92914 2022-01-18 11:14:43 -08:00
David Tolnay
a6c9d8f524
Invert the keyword list to list only *no* space before delim 2022-01-18 11:14:42 -08:00
David Tolnay
c70c646a0f
Eliminate string comparison from rustdoc keyword spacing logic 2022-01-18 11:14:41 -08:00
David Tolnay
aff5296c78
Move test of macro-generated macro with linebreak to snapshot 2022-01-18 11:14:40 -08:00
David Tolnay
81b1e32790
Move render_macro_matcher to own module 2022-01-18 11:14:30 -08:00
David Tolnay
0904614751
Render more readable macro matchers in rustdoc 2022-01-18 11:13:29 -08:00
David Tolnay
d950c1b200
Extend rustdoc macro-generated-macro test 2022-01-18 11:04:00 -08:00
David Tolnay
7ee21e3de1
Bless coverage-reports after format_args change 2022-01-18 11:00:18 -08:00
Jacob Hoffman-Andrews
6a5f8b1aef Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.

I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.

Because the heading font sizes are bigger, increase the sidebar width
slightly.

As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-18 10:43:14 -08:00
threadexception
ef46e38c2b Implement tuple array diagnostic
Co-authored-by: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co>
2022-01-18 15:22:35 +01:00
lcnr
b2d8f0c77d generic_arg_infer: placeholder in signature err 2022-01-18 12:23:43 +01:00
bors
7bc7be860f Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obk
allow eq constraints on associated constants

Updates #70256

(cc `@varkor,` `@Centril)`
2022-01-18 09:58:39 +00:00
Michael Goulet
33e5efbd58 adjust tests 2022-01-18 01:46:17 -08:00
bors
7531d2fdd4 Auto merge of #93021 - matthiaskrgr:rollup-o7z8zoe, r=matthiaskrgr
Rollup of 14 pull requests

Successful merges:

 - #92629 (Pick themes on settings page, not every page)
 - #92640 (Fix ICEs related to `Deref<Target=[T; N]>` on newtypes)
 - #92701 (Add some more attribute validation)
 - #92803 (Hide mobile sidebar on some clicks)
 - #92830 (Rustdoc style cleanups)
 - #92866 ("Does exists" typos fix)
 - #92870 (add `rustc_diagnostic_item` attribute to `AtomicBool` type)
 - #92914 (htmldocck: Add support for `/text()` in ``@snapshot`)`
 - #92923 (Abstract the pretty printer's ringbuffer to be infinitely sized)
 - #92946 (Exclude llvm-libunwind from the self-contained set on s390x-musl targets)
 - #92947 (rustdoc: Use `intersperse` in a `visit_path` function)
 - #92997 (Add `~const` bound test for negative impls)
 - #93004 (update codegen test for LLVM 14)
 - #93016 (Stabilize vec_spare_capacity)

Failed merges:

 - #92924 (Delete pretty printer tracing)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-18 06:07:58 +00:00
Eric Huss
6a1099c202 Disable docs on aarch64-apple-darwin.
This builder is the slowest in the fleet. This should cut a considerable
amount of time. The manifest should now include the docs from
x86_64-apple-darwin. Although those docs are slightly different, it
should be close enough. When aarch64-apple-darwin heads towards tier 1,
we can revisit whether or not to re-enable the docs.
2022-01-17 20:21:44 -08:00
Matthias Krüger
b8c544de71
Rollup merge of #93004 - krasimirgg:threadlocal-llvm-up, r=nikic
update codegen test for LLVM 14

Fixes https://github.com/rust-lang/rust/issues/93003.
2022-01-18 04:42:10 +01:00
Matthias Krüger
baeff67b5f
Rollup merge of #92997 - woppopo:test92114, r=Mark-Simulacrum
Add `~const` bound test for negative impls

Resolves #92114 which has been fixed in #92892.
2022-01-18 04:42:09 +01:00
Matthias Krüger
71e5bfed70
Rollup merge of #92947 - vacuus:rustdoc-core-visit-path, r=camelid
rustdoc: Use `intersperse` in a `visit_path` function

(~~Is there a better way to word the title?~~ Eh, this works, I guess.)
I'm surprised that the compiler didn't complain when I left out the `.to_string()`, but hey, if it works then it works.
2022-01-18 04:42:08 +01:00
Matthias Krüger
b05be976ef
Rollup merge of #92946 - kaniini:chore/llvm-libunwind-s390x, r=Mark-Simulacrum
Exclude llvm-libunwind from the self-contained set on s390x-musl targets

llvm-libunwind does not support s390x targets at present, so we cannot build it
for s390x targets.  Accordingly, remove it from the self-contained set.
2022-01-18 04:42:07 +01:00
Matthias Krüger
be3d25bd78
Rollup merge of #92914 - camelid:snapshot-text, r=GuillaumeGomez
htmldocck: Add support for `/text()` in `@snapshot`

This allows just testing the text, in cases where the HTML tags don't
matter.

See https://github.com/rust-lang/rust/pull/92908#discussion_r785191758 for an example of when this would be useful.

r? `@GuillaumeGomez`
2022-01-18 04:42:05 +01:00
Matthias Krüger
ae8f39e4d4
Rollup merge of #92866 - maxwase:does_exist_typo, r=Mark-Simulacrum
"Does exists" typos fix

Fixed some typos
2022-01-18 04:42:03 +01:00
Matthias Krüger
deee6f770f
Rollup merge of #92830 - jsha:style-cleanups, r=GuillaumeGomez
Rustdoc style cleanups

 - Make "since" version numbers grey again (regressed in #92602).
 - Remove unneeded selectors for when crate filter dropdown is a
   sibling of search-input.
 - Crate filter dropdown doesn't need to be 100% width on mobile.
 - Only build crate filter dropdown when there is more than one crate.
 - Remove unused addCrateDropdown

 Demo: https://rustdoc.crud.net/jsha/style-cleanups/std/string/struct.String.html

 r? `@GuillaumeGomez`
2022-01-18 04:42:02 +01:00
Matthias Krüger
cc2339ce83
Rollup merge of #92803 - jsha:hide-sidebar, r=GuillaumeGomez
Hide mobile sidebar on some clicks

When the user clicks outside the sidebar, the sidebar should close. Also, when the user clicks an internal link in the sidebar, it should close.

Fixes #92682

Demo: https://rustdoc.crud.net/jsha/hide-sidebar/std/string/struct.String.html
2022-01-18 04:42:00 +01:00
Matthias Krüger
804072fdfc
Rollup merge of #92701 - ehuss:even-more-attr-validation, r=matthewjasper
Add some more attribute validation

This adds some more validation for the position of attributes:

* `link` is only valid on an `extern` block
* `windows_subsystem` and `no_builtins` are only valid at the crate level
2022-01-18 04:41:59 +01:00
Matthias Krüger
cb5ecff8b2
Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnr
Fix ICEs related to `Deref<Target=[T; N]>` on newtypes

1. Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type.
    For example, given `[T; _]` we know `_` is a `usize`. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize.
Fixes #92626
Fixes #83704

2. Don't stash the autoderef'd slice type that we get from method lookup, but instead recreate it during method confirmation. We need to do this because the type we receive back after picking the method references a type variable that does not exist after probing is done.
Fixes #92637

... A better solution for the second issue would be to actually _properly_ implement `Deref` for `[T; N]` instead of fixing this autoderef hack to stop leaking inference variables. But I actually looked into this, and there are many complications with const impls.
2022-01-18 04:41:58 +01:00
Matthias Krüger
d501ead009
Rollup merge of #92629 - jsha:theme-picker-local-only-2, r=GuillaumeGomez
Pick themes on settings page, not every page

This hides the paintbrush icon on most pages by default, in preference for the settings on the settings page.  When loading from a local file, and not in mobile view, continue to show the theme picker. That's because some browsers limit access to localStorage from file:/// URLs, so choosing a theme from settings.html doesn't take effect.

Fixes #84539
Part of #59840

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/theme-picker-local-only-2/std/io/trait.Read.html
2022-01-18 04:41:58 +01:00
bors
e4ff9031ac Auto merge of #93001 - flip1995:clippyup, r=Manishearth
Out of cycle Clippy update

I want to do an out-of-cycle sync for rust-lang/rust-clippy#8295, and possibly backport this to stable together with https://github.com/rust-lang/rust/issues/92938. If this doesn't get backported to stable, then I at least want to backport it to beta.

r? `@Manishearth`
2022-01-18 02:32:36 +00:00
Jacob Hoffman-Andrews
ae99e23c11 Add staged_api for tests 2022-01-17 13:23:46 -08:00
kadmin
b77bb5cb25 Update with final comments 2022-01-17 20:04:37 +00:00
Jacob Hoffman-Andrews
b71f1fb002 Hide mobile sidebar on some clicks
When the user clicks outside the sidebar, the sidebar should close.
Also, when the user clicks an internal link in the sidebar, it should
close.
2022-01-17 12:01:35 -08:00
kadmin
1c1ce2fbda Add term to ExistentialProjection
Also prevent ICE when adding a const in associated const equality.
2022-01-17 20:01:22 +00:00
kadmin
f396888c4d Update w/ comments
Removes uses of ty() where a method is implemented on TypeFoldable, and also directly formats
a Term.
2022-01-17 20:01:21 +00:00
kadmin
e7529d6a38 Update term for use in more places
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the
future, but slightly worried it allows items which are consts which only accept types.
2022-01-17 19:59:40 +00:00
Jacob Hoffman-Andrews
43b9268592 Rustdoc style cleanups
- Make "since" version numbers grey again (regressed in #92602).
 - Remove unneeded selectors for when crate filter dropdown is a
   sibling of search-input.
 - Crate filter dropdown doesn't need to be 100% width on mobile.
 - Only build crate filter dropdown when there is more than one crate.
 - Remove unused addCrateDropdown.
2022-01-17 11:45:28 -08:00
Matthias Krüger
25f73b7815
Rollup merge of #92936 - vacuus:html-markdown-parse, r=GuillaumeGomez
rustdoc: Remove `collect` in `html::markdown::parse`
2022-01-17 20:07:08 +01:00
Matthias Krüger
6acb7043e7
Rollup merge of #92825 - pierwill:rustc-version-force-rename, r=Mark-Simulacrum
Rename environment variable for overriding rustc version
2022-01-17 20:07:06 +01:00
Matthias Krüger
51aa20de07
Rollup merge of #92801 - jsha:overflow-wrap, r=GuillaumeGomez
Enable wrapping words by default

Faced with a very long word, browsers will let it overflow its
box horizontally rather than break it in the middle. We essentially
never want that behavior. We would rather break the word and keep it
inside its horizontal limits. So we apply a default overflow-wrap:
break-word/anywhere to the document as a while.

In some contexts we would rather add a horizontal scrollbar (code
blocks), or elide the excess text with an ellipsis (sidebar). Those
still work as expected.

Fixes #92771

[Some related discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/wrap.20.2F.20overflow.20.2F.20scroll) and a related issue: #92421.

Demo: https://rustdoc.crud.net/jsha/overflow-wrap/std/iter/trait.Iterator.html#method.try_find

r? ``@GuillaumeGomez``
2022-01-17 20:07:05 +01:00
Matthias Krüger
32d85c0b5a
Rollup merge of #92164 - WaffleLapkin:rustc_must_implement_one_of_attr, r=Aaron1011
Implement `#[rustc_must_implement_one_of]` attribute

This PR adds a new attribute — `#[rustc_must_implement_one_of]` that allows changing the "minimal complete definition" of a trait. It's similar to GHC's minimal `{-# MINIMAL #-}` pragma, though `#[rustc_must_implement_one_of]` is weaker atm.

Such attribute was long wanted. It can be, for example, used in `Read` trait to make transitions to recently added `read_buf` easier:
```rust
#[rustc_must_implement_one_of(read, read_buf)]
pub trait Read {
    fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
        let mut buf = ReadBuf::new(buf);
        self.read_buf(&mut buf)?;
        Ok(buf.filled_len())
    }

    fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> {
        default_read_buf(|b| self.read(b), buf)
    }
}

impl Read for Ty0 {}
//^ This will fail to compile even though all `Read` methods have default implementations

// Both of these will compile just fine
impl Read for Ty1 {
    fn read(&mut self, buf: &mut [u8]) -> Result<usize> { /* ... */ }
}
impl Read for Ty2 {
    fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<()> { /* ... */ }
}
```

For now, this is implemented as an internal attribute to start experimenting on the design of this feature. In the future we may want to extend it:
- Allow arbitrary requirements like `a | (b & c)`
- Allow multiple requirements like
  - ```rust
    #[rustc_must_implement_one_of(a, b)]
    #[rustc_must_implement_one_of(c, d)]
    ```
- Make it appear in rustdoc documentation
- Change the syntax?
- Etc

Eventually, we should make an RFC and make this (or rather similar) attribute public.

---

I'm fairly new to compiler development and not at all sure if the implementation makes sense, but at least it passes tests :)
2022-01-17 20:07:02 +01:00
Matthias Krüger
67bcbde3c5
Rollup merge of #90498 - joshtriplett:target-tier-policy-draft-updates, r=Mark-Simulacrum
Clarifications in the target tier policy

We've added several targets since the introduction of the target tier policy. Based on experiences of those adding such targets, and discussions around such additions, clarify the target tier policy to make it easier to follow and work with.

None of these changes substantively change the requirements on targets. (In some cases the changes do direct target submitters to follow specific process requirements for the addition of a target, such as how to respond to requirements, where to put target-specific documentation, or what should appear in that documentation. Those changes are procedural in nature and document the procedures we already direct people to follow.)

- Clarify how to quote and respond to the target tier policy requirements. Several times, people have seemed unclear on how to respond to some of the policy requirements, particularly those that just state things the target developers must *not* do (e.g. not posting to PRs that break the target). Add a note that such requirements just need acknowledgement, nothing more.
- Clarify dependency requirements in the face of cross-compilation. I previously phrased this confusingly in terms of "host tools", since that is the case where an exception applies (allowing proprietary target libraries commonly used by binaries for the target). Rephrase it to apply equally to cross-compilation. This doesn't change the net effect of the requirements, since other requirements already cover the dependencies of the Rust toolchain.
- Clarify documentation about running binaries. The requirement for target documentation talks about "running tests", but tier 3 targets often don't support running the full testsuite, and in practice the documentation for how to run an individual binary may be more useful. Change "running tests" to "running binaries, or running tests".
- Explain where to place target-specific documentation (a subdirectory of platform-support, with a link from the platform-support entry for the target).
- Add a template for target-specific documentation.
2022-01-17 20:07:01 +01:00
David Tolnay
490569c9ef
Bless clippy ui tests after format_args change 2022-01-17 11:04:46 -08:00
David Tolnay
abf1d94b1a
Emit simpler code from format_args 2022-01-17 10:38:30 -08:00
Cameron Steffen
3afbae33ab Remove __CLIPPY_INTERNAL_TESTS env var 2022-01-17 12:37:05 -06:00
kadmin
67f56671d0 Use Term in ProjectionPredicate
ProjectionPredicate should be able to handle both associated types and consts so this adds the
first step of that. It mainly just pipes types all the way down, not entirely sure how to handle
consts, but hopefully that'll come with time.
2022-01-17 17:44:56 +00:00