Commit Graph

166693 Commits

Author SHA1 Message Date
gimbles
71ad003bf6 Improve error message when there's no checksum 2022-04-13 13:54:22 +05:30
bors
e3c43e64ec Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obk
Use mir constant in thir instead of ty::Const

This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
2022-04-13 07:50:56 +00:00
Martin Gammelsæter
5f2c6b92d1 Use .extend(..) instead of push()-ing in loop
A bit less readable but more compact, and maybe faster? We'll see.
2022-04-13 08:44:20 +02:00
Nicholas Nethercote
9c59d04d55 Speed up Vec::clear().
Currently it just calls `truncate(0)`. `truncate()` is (a) not marked as
`#[inline]`, and (b) more general than needed for `clear()`.

This commit changes `clear()` to do the work itself. This modest change
was first proposed in rust-lang#74172, where the reviewer rejected it because
there was insufficient evidence that `Vec::clear()`'s performance
mattered enough to justify the change. Recent changes within rustc have
made `Vec::clear()` hot within `macro_parser.rs`, so the change is now
clearly worthwhile.

Although it doesn't show wins on CI perf runs, this seems to be because they
use PGO. But not all platforms currently use PGO. Also, local builds don't use
PGO, and `truncate` sometimes shows up in an over-represented fashion in local
profiles. So local profiling will be made easier by this change.

Note that this will also benefit `String::clear()`, because it just
calls `Vec::clear()`.

Finally, the commit removes the `vec-clear.rs` codegen test. It was
added in #52908. From before then until now, `Vec::clear()` just called
`Vec::truncate()` with a zero length. The body of Vec::truncate() has
changed a lot since then. Now that `Vec::clear()` is doing actual work
itself, and not just calling `Vec::truncate()`, it's not surprising that
its generated code includes a load and an icmp. I think it's reasonable
to remove this test.
2022-04-13 15:39:35 +10:00
bors
b768f248e9 Auto merge of #95999 - Dylan-DPC:rollup-k2r3k11, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #95441 (Always use system `python3` on MacOS)
 - #95954 (Fix broken link in coverage tools docs)
 - #95984 (Fix spelling in docs for `can_not_overflow`)
 - #95989 (diagnostics: regression test for spurrious "help: store this in the heap")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-13 05:36:26 +00:00
Joshua Nelson
070bd64433 Make x test --stage 2 compiler/rustc_XXX faster to run
Previously, bootstrap unconditionally rebuilt the stage 2 compiler,
even if it had previously built stage 1. This changes it to reuse stage 1 if possible.
2022-04-12 23:03:55 -05:00
Dylan DPC
2b4c4dfcfd
Rollup merge of #95989 - rust-lang:notriddle/issue-82446, r=compiler-errors
diagnostics: regression test for spurrious "help: store this in the heap"

Closes #82446
2022-04-13 05:54:13 +02:00
Dylan DPC
633c391225
Rollup merge of #95984 - wcampbell0x2a:fix-spelling, r=thomcc
Fix spelling in docs for `can_not_overflow`

Introduced in https://github.com/rust-lang/rust/pull/95399
2022-04-13 05:54:13 +02:00
Dylan DPC
8d1619f1e9
Rollup merge of #95954 - AnthonyMikh:fix-broken-coverage-docs-screenshot-link, r=Dylan-DPC
Fix broken link in coverage tools docs

During stabilization the link to example screenshot wad not updated, making rendered docs somewhat less useful. Move that screenshot from unstable book into rustc docs and make documentation point to that new place. Also remove `/img` in unstable book since there are no more any files there.
2022-04-13 05:54:12 +02:00
Dylan DPC
f6dfbfef01
Rollup merge of #95441 - AlecGoncharow:issue-95204-fix, r=Mark-Simulacrum
Always use system `python3` on MacOS

This PR includes 2 changes:

1. Always use the system Python found at `/usr/bin/python3` on MacOS
2. Removes the hard requirement on having `python` in your system path if you didn't specify alternatives. The proposed change will instead attempt to find and use in order: `python` -> `python3` -> `python2`. This change isn't strictly necessary but without any change to this check, the original issue inspiring this change will still exist.

Fixes #95204
r? ```@jyn514```
2022-04-13 05:54:11 +02:00
David Wood
9bfe0e39e4 errors: lazily load fallback fluent bundle
Loading the fallback bundle in compilation sessions that won't go on to
emit any errors unnecessarily degrades compile time performance, so
lazily create the Fluent bundle when it is first required.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-13 02:44:59 +01:00
Nicholas Nethercote
2657d8f7b3 Pass a slice instead of a Vec to transcribe.
It avoids some unnecessary allocations.
2022-04-13 11:17:31 +10:00
Nicholas Nethercote
1a7006482e Avoid use of Lrc in mbe::Frame.
This is a nice performance win on some crates.
2022-04-13 11:17:31 +10:00
Nicholas Nethercote
769e2edb78 SequenceRepetition and Delimited don't need to be Clone. 2022-04-13 11:17:31 +10:00
bors
1491e5cc14 Auto merge of #95990 - Dylan-DPC:rollup-r9bh9t7, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #95316 (Rustdoc: Discriminate required and provided associated constants and types)
 - #95405 (Move name resolution logic to a dedicated file)
 - #95914 (Implement tuples using recursion)
 - #95918 (Delay a bug when we see SelfCtor in ref pattern)
 - #95970 (Fix suggestions in case of `T:` bounds)
 - #95973 (prevent opaque types from appearing in impl headers)
 - #95986 (Autolabel library PRs with T-libs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-13 01:15:20 +00:00
Joshua Nelson
69de21385e Fix x test --doc --stage 0 library/std
I managed to break this in https://github.com/rust-lang/rust/pull/95449.
I am not quite sure why this is the correct fix, but it doesn't break `doc --stage 0`
and is strictly closer to the previous behavior.

Previously, rustdoc would error with strange issues because of the mismatched sysroot:
```
error[E0460]: found possibly newer version of crate `std` which `rustc_span` depends on
  --> /home/jnelson/rust-lang/rust/compiler/rustc_lint_defs/src/lib.rs:14:5
   |
14 | use rustc_span::{sym, symbol::Ident, Span, Symbol};
   |     ^^^^^^^^^^
   |
   = note: perhaps that crate needs to be recompiled?
   = note: the following crate versions were found:
           crate `std`: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ff9290e971253a38.rlib
           crate `std`: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-ff9290e971253a38.so
           crate `rustc_span`: /home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_span-ed11dce30c1766f9.rlib
```
2022-04-12 20:13:05 -05:00
bors
f6cef572d6 Auto merge of #95905 - vacuus:markdown-render, r=GuillaumeGomez
rustdoc: Reduce allocations in a `markdown` function

Not `html::markdown` this time, just `markdown`, haha.
2022-04-12 22:56:06 +00:00
Vadim Petrochenkov
233fa659f4 rustc_metadata: Do not encode unnecessary module children 2022-04-13 01:35:27 +03:00
Dylan DPC
bdbc398e82
Rollup merge of #95986 - yaahc:libs-autolabel, r=Mark-Simulacrum
Autolabel library PRs with T-libs

Continuation of https://github.com/rust-lang/highfive/pull/389

We're trying to improve the libs team review structure and part of that is defaulting PRs to the T-libs team to act as a mini-triage team for all the libs teams / project groups. Highfive doesn't do issue tagging so we will rely on triagebot to pre-triage for t-libs to post-triage :)
2022-04-12 23:17:02 +02:00
Dylan DPC
e96304b73d
Rollup merge of #95973 - oli-obk:tait_ub3, r=compiler-errors
prevent opaque types from appearing in impl headers

cc `@lqd`

opaque types are not distinguishable from their hidden type at the codegen stage. So we could either end up with cases where the hidden type doesn't implement the trait (which will thus ICE) or where the hidden type does implement the trait (so we'd be using its impl instead of the one written for the opaque type). This can even lead to unsound behaviour without unsafe code.

Fixes https://github.com/rust-lang/rust/issues/86411.
Fixes https://github.com/rust-lang/rust/issues/84660.

rebase of #87382 plus some diagnostic tweaks
2022-04-12 23:17:01 +02:00
Dylan DPC
d63a46ad28
Rollup merge of #95970 - WaffleLapkin:nicer_trait_suggestions, r=compiler-errors
Fix suggestions in case of `T:` bounds

This PR fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions.

For the following functions:
```rust
fn a<T:>(t: T) { [t, t]; }
fn b<T>(t: T) where T: { [t, t]; }
```

We previously suggested the following:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy:>(t: T) { [t, t]; }
  |       ++++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: + Copy { [t, t]; }
  |                        ++++++
```

Note that neither `T: Copy:` not `where T: + Copy` is a correct bound.

With this commit the suggestions are correct:
```text
...
help: consider restricting type parameter `T`
  |
1 | fn a<T: Copy>(t: T) { [t, t]; }
  |         ++++
...
help: consider further restricting this bound
  |
2 | fn b<T>(t: T) where T: Copy { [t, t]; }
  |                        ++++
```

r? `@compiler-errors`

I've tried fixing #95898 here too, but got too confused with how `suggest_traits_to_import` works and what it does 😅
2022-04-12 23:17:00 +02:00
Dylan DPC
91813a7175
Rollup merge of #95918 - compiler-errors:issue-95878, r=cjgillot
Delay a bug when we see SelfCtor in ref pattern

Fixes #95878
2022-04-12 23:16:59 +02:00
Dylan DPC
6aa875aa96
Rollup merge of #95914 - c410-f3r:meta-vars, r=petrochenkov
Implement tuples using recursion

Because it is c00l3r™, requires less repetition and can be used as a reference for external people.

This change is non-essential and I am not sure about potential performance impacts so feel free to close this PR if desired.

r? `@petrochenkov`
2022-04-12 23:16:58 +02:00
Dylan DPC
2743c13de0
Rollup merge of #95405 - cjgillot:probe, r=petrochenkov
Move name resolution logic to a dedicated file

The code resolution logic from an Ident is scattered between several files.

The first commits creates `rustc_resolve::probe` module to hold the different mutually recursive functions together. Just a move, no code change.
The following commits attempt to make the logic a bit more readable.

The two fields `last_import_segment` and `unusable_binding` are replaced by function parameters.
In order to manage the fallout, `maybe_` variants of the function are added, dedicated to speculative resolution.

r? `@petrochenkov`
2022-04-12 23:16:56 +02:00
Dylan DPC
0ec00c0ba3
Rollup merge of #95316 - fmease:rustdoc-discr-req-prov-assoc-consts-tys, r=notriddle,GuillaumeGomez
Rustdoc: Discriminate required and provided associated constants and types

Currently, rustdoc merely separates required and provided associated _functions_ (i.e. methods). This PR extends this to constants (fixes #94652) and types. This makes the documentation of all three kinds of associated items more alike and consistent.

As an aside, associated types may actually be provided / have a default when users enable the unstable feature `associated_type_defaults`.

| Before | After |
|---|---|
| ![image](https://user-images.githubusercontent.com/14913065/160631832-d5862d13-b395-4d86-b45c-3873ffd4cd4e.png) | ![image](https://user-images.githubusercontent.com/14913065/160631903-33909a03-b6ee-4d75-9cbc-d188f7f8602e.png) |
| ![image](https://user-images.githubusercontent.com/14913065/160632173-040d4139-76f4-4410-851b-d8c1cef014d2.png) | ![image](https://user-images.githubusercontent.com/14913065/160632233-6fd3fe73-cadc-4291-b104-59d2e45366a6.png) |

### `clean::types::ItemKind` modification

* `ItemKind::TypedefItem(.., true)` → `ItemKind::AssocTypeItem(..)`
* `ItemKind::TypedefItem(.., false)` → `ItemKind::TypedefItem(..)`

Further, I added `ItemKind::TyAssoc{Const,Type}Item`, the “required” variant of `ItemKind::Assoc{Const,Type}Item`, analogous to `ItemKind::TyMethodItem` with `ItemKind::MethodItem`. These new variants don't contain new information really, they are just the result of me getting rid of the `Option<_>` field in `AssocConstItem` and `AssocTypeItem`.

**Goal**: Make associated items more consistent.
Originally I thought modifying `ItemKind` was necessary to achieve the new functionality of this PR but in retrospect, it does not. If you don't like the changes to `ItemKind`, I think I _can_ get rid of them.

This change is the root cause of those tiny changes in a lot of different files.

 ### Concerns and Open Questions

* **breaking changes** to hyperlinks: Some heading IDs change:
  * `associated-const` (sic!) -> `{provided,required}-associated-consts`
  * `associated-types` -> `{provided,required}-associated-types`
* **verbosity** of the headings _{Required,Provided} Associated {Constants,Types}_
* For some files, I am not sure if the changes I made are correct. So please take extra care when reviewing `conversions.rs` (conversion to JSON), `cache.rs`/`fold_item`, `stripper.rs`/`fold_item`, `check_doc_test_visibility.rs`/`should_have_doc_example`, `collect_intra_doc_links.rs`/`from_assoc_item`
* JSON output: I still map `AssocTypeItem`s to `Typedef` etc. (FIXME)
2022-04-12 23:16:55 +02:00
Camille GILLOT
0927a35e80 Bless tests. 2022-04-12 22:44:19 +02:00
Vadim Petrochenkov
276b946010 Handle unusable_binding more compactly. 2022-04-12 22:07:15 +02:00
Oli Scherer
6d0349d2ea
Apply suggestions from code review
Co-authored-by: Michael Goulet <michael@errs.io>
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2022-04-12 21:36:09 +02:00
Caio
23bf977758 Implement tuples using recursion 2022-04-12 16:23:36 -03:00
Michael Howell
7228e9b098 regression test for spurrious "help: store this in the heap"
Closes #82446
2022-04-12 12:15:40 -07:00
bors
52ca603da7 Auto merge of #95987 - m-ou-se:rollup-sdevd9b, r=m-ou-se
Rollup of 4 pull requests

Successful merges:

 - #95783 (rustdoc doctest: include signal number in exit status)
 - #95794 (`parse_tt`: a few more tweaks)
 - #95963 ([bootstrap] Grab the right FileCheck binary for dist when cross-compiling.)
 - #95975 (Don't test -Cdefault-linker-libraries=yes when cross compiling.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-12 18:44:05 +00:00
Will Crichton
6a18b68655 Add Rustdoc book link to scrape examples help. Remove remaining panic
locations in scrape examples.
2022-04-12 11:05:07 -07:00
Camille GILLOT
443333dc1f Remove NodeIdHashingMode. 2022-04-12 19:59:32 +02:00
Mara Bos
550a510431
Rollup merge of #95975 - m-ou-se:test-70093-no-cross, r=joshtriplett
Don't test -Cdefault-linker-libraries=yes when cross compiling.

See https://github.com/rust-lang/rust/pull/95727#issuecomment-1096603163 and the five comments below that.

Unblocks #95727.
2022-04-12 19:58:18 +02:00
Mara Bos
911da62586
Rollup merge of #95963 - luqmana:llvm-dist-cross-filecheck, r=Mark-Simulacrum
[bootstrap] Grab the right FileCheck binary for dist when cross-compiling.

Fixes #95862

We were using the target dir for all the other LLVM tools (`llvm-config`, `llvm-ar`, etc) but the build target dir for `FileCheck`. This meant for targets which are cross-compiled, we were copying the wrong binary.
2022-04-12 19:58:17 +02:00
Mara Bos
d6843448f1
Rollup merge of #95794 - nnethercote:parse_tt-a-few-more-tweaks, r=petrochenkov
`parse_tt`: a few more tweaks

r? `@petrochenkov`
2022-04-12 19:58:16 +02:00
Mara Bos
7644de5eda
Rollup merge of #95783 - notriddle:notriddle/doctest-signal, r=GuillaumeGomez
rustdoc doctest: include signal number in exit status

Related to #95601
2022-04-12 19:58:15 +02:00
Camille GILLOT
b796d92da3 Fix imports. 2022-04-12 19:55:47 +02:00
Camille GILLOT
abbd0b85b2 Move diagnostic methods to the dedicated module. 2022-04-12 19:54:09 +02:00
Camille GILLOT
944d852afe Simplify error reporting. 2022-04-12 19:53:46 +02:00
Camille GILLOT
d1c1bbe5f3 Move path resolution error to rustc_resolve::diagnostics. 2022-04-12 19:53:22 +02:00
Camille GILLOT
886613c916 Make the logic more explicit with let chains. 2022-04-12 19:52:58 +02:00
Camille GILLOT
3ee6f6e28a Do not record Res when builing a suggestion. 2022-04-12 19:52:34 +02:00
Camille GILLOT
55ca03c0ac Insert error after checking for binding usability. 2022-04-12 19:52:10 +02:00
Camille GILLOT
24b37a7374 Pass last_import_segment and unusable_binding as parameters. 2022-04-12 19:51:46 +02:00
Camille GILLOT
eb7f5673d9 Simplify binding finalization. 2022-04-12 19:51:22 +02:00
Camille GILLOT
e9a52c27d2 Move ident resolution to a dedicated module. 2022-04-12 19:49:02 +02:00
Jane Lusby
a21238cc29 Autotag library PRs with T-libs 2022-04-12 10:48:56 -07:00
wcampbell
9ea89e1d3d Fix spelling in docs for can_not_overflow 2022-04-12 13:29:56 -04:00
bors
de56c295c3 Auto merge of #95867 - cjgillot:fixed-size, r=oli-obk
Skip `Lazy` for some metadata tables

Some metadata tables encode their entries indirectly, through the Lazy construct. This is useful when dealing with variable length encoding, but incurs the extra cost of one u32.

Meanwhile, some fields can be encoded in a single u8, or can use a short fixed-length encoding. This PR proposes to do so, and avoid the overhead.
2022-04-12 16:12:48 +00:00