Commit Graph

1097 Commits

Author SHA1 Message Date
Matthias Krüger
abde841f0a remove redundant clones 2023-07-23 09:48:07 +02:00
David Tolnay
5bbf0a8306
Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"
This reverts commit 557359f925, reversing
changes made to 1e6c09a803.
2023-07-21 22:35:57 -07:00
Moulins
8b847ef734 add crate-local -Z reference_niches unstable flag (does nothing for now) 2023-07-21 03:31:45 +02:00
bors
b14fd2359f Auto merge of #113695 - bjorn3:fix_rlib_cdylib_metadata_handling, r=pnkfelix,petrochenkov
Verify that all crate sources are in sync

This ensures that rustc will not attempt to link against a cdylib as if it is a rust dylib when an rlib for the same crate is available. Previously rustc didn't actually check if any further formats of a crate which has been loaded are of the same version and if they are actually valid. This caused a cdylib to be interpreted as rust dylib as soon as the corresponding rlib was loaded. As cdylibs don't export any rust symbols, linking would fail if rustc decides to link against the cdylib rather than the rlib.

Two crates depended on the previous behavior by separately compiling a test crate as both rlib and dylib. These have been changed to capture their original spirit to the best of my ability while still working when rustc verifies that all crates are in sync. It is unlikely that build systems depend on the current behavior and in any case we are taking a lot of measures to ensure that any change to either the source or the compilation options (including crate type) results in rustc rejecting it as incompatible. We merely didn't do this check here for now obsolete perf reasons.

Fixes https://github.com/rust-lang/rust/issues/10786
Fixes https://github.com/rust-lang/rust/issues/82151
Fixes https://github.com/rust-lang/rust/issues/82972
Closes https://github.com/bevy-cheatbook/bevy-cheatbook/issues/114
2023-07-20 09:00:10 +00:00
bors
39f42ad9e8 Auto merge of #113865 - Dylan-DPC:rollup-pt960bk, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #113444 (add tests for alias bound preference)
 - #113716 (Add the `no-builtins` attribute to functions when `no_builtins` is applied at the crate level.)
 - #113754 (Simplify native_libs query)
 - #113765 (Make it clearer that edition functions are `>=`, not `==`)
 - #113774 (Improve error message when closing bracket interpreted as formatting fill character)
 - #113785 (Fix invalid display of inlined re-export when both local and foreign items are inlined)
 - #113803 (Fix inline_const with interpolated block)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-19 18:17:59 +00:00
Dylan DPC
dbb6b1ac31
Rollup merge of #113754 - cjgillot:simplify-foreign, r=petrochenkov
Simplify native_libs query

Drive-by cleanup I saw while implementing https://github.com/rust-lang/rust/pull/113734
2023-07-19 22:37:07 +05:30
bjorn3
8c9a8b63c9 Fix review comments 2023-07-19 14:53:26 +00:00
bjorn3
52853c2694 Don't compress dylib metadata 2023-07-19 14:47:06 +00:00
bjorn3
008be2d7b6 Verify that all crate sources are in sync
This ensures that rustc will not attempt to link against a cdylib as if
it is a rust dylib when an rlib for the same crate is available.
Previously rustc didn't actually check if any further formats of a
crate which has been loaded are of the same version and if they are
actually valid. This caused a cdylib to be interpreted as rust dylib as
soon as the corresponding rlib was loaded. As cdylibs don't export any
rust symbols, linking would fail if rustc decides to link against the
cdylib rather than the rlib.

Two crates depended on the previous behavior by separately compiling a
test crate as both rlib and dylib. These have been changed to capture
their original spirit to the best of my ability while still working
when rustc verifies that all crates are in sync. It is unlikely that
build systems depend on the current behavior and in any case we are
taking a lot of measures to ensure that any change to either the source
or the compilation options (including crate type) results in rustc
rejecting it as incompatible. We merely didn't do this check here for
now obsolete perf reasons.
2023-07-19 14:47:05 +00:00
Camille GILLOT
186be726d6 Encode shorthands for spans in metadata. 2023-07-19 12:22:11 +00:00
Camille GILLOT
fdc93f307f Do not fetch HIR in native_libs. 2023-07-17 07:37:03 +00:00
Camille GILLOT
51e1f7a561 Simplify foreign_modules. 2023-07-17 07:37:03 +00:00
bors
6f65ef5717 Auto merge of #113562 - saethlin:larger-incr-comp-offset, r=nnethercote
Use u64 for incr comp allocation offsets

Fixes https://github.com/rust-lang/rust/issues/76037
Fixes https://github.com/rust-lang/rust/issues/95780
Fixes https://github.com/rust-lang/rust/issues/111613

These issues are all reporting ICEs caused by using `u32` to store offsets to allocations in the incremental compilation cache. This PR aims to lift that limitation by changing the offset type in question to `u64`.

There are two perf runs in this PR. The first reports a regression, and the second does not. The changes are the same in both. I rebased the PR then did the second perf run because I noticed that the primary regression in it was very commonly seen in spurious regression reports.

I do not know what the perf run will report when this is merged. I would not be surprised to see regression or neutral, but the cachegrind diffs for the regression point at `try_mark_previous_green` which is a common source of inexplicable regressions and I don't think should be perturbed by this PR.

I'm not opposed to adding a regression test such as
```rust
fn main() {
    println!("{}", [37; 1 << 30].len());
}
```
But that program takes 1 minute to compile and consumes 4.6 GB of memory then writes that much to disk. Is that a concerning amount of resource use for a test?

r? `@nnethercote`
2023-07-17 04:45:10 +00:00
Ben Kimock
4e117a9b4e Use u64 for incr comp allocation offsets 2023-07-14 17:03:34 -04:00
Matthias Krüger
0baf4406da
Rollup merge of #113698 - compiler-errors:rpitit-check, r=spastorino
Make it clearer that we're just checking for an RPITIT

Tiny nit to use `is_impl_trait_in_trait` more, to make it clearer that we're just checking whether a def-id is an RPITIT, rather than doing something meaningful with the `opt_rpitit_info`.

r? `@spastorino`
2023-07-14 19:33:29 +02:00
Michael Goulet
14672eba8b Make it clearer that we're just checking for an RPITIT 2023-07-14 15:18:48 +00:00
Mahdi Dibaiee
e55583c4b8 refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
Mark Rousskov
cc907f80b9 Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
Santiago Pastorino
20429af7a3
Replace RPITIT current impl with new strategy that lowers as a GAT 2023-07-08 18:21:34 -03:00
bors
0130c3a06e Auto merge of #113215 - compiler-errors:rpitit-predicates-tweaks, r=spastorino
Make RPITITs assume/require their parent method's predicates

Removes a FIXME from the `param_env` query where we were manually adding the parent function's predicates to the RPITIT's assumptions.

r? `@spastorino`
2023-07-04 04:24:24 +00:00
Nilstrieb
ba0f5dcd14 Revert "Suggest x build library for a custom toolchain that fails to load core"
This reverts commit b913f5593d.

CI builds with profile=nightly, causing different test output.

Making the output depend on the release channel was not a great idea.
2023-07-03 12:48:52 +00:00
Mu001999
b913f5593d Suggest x build library for a custom toolchain that fails to load core 2023-07-02 17:53:44 +08:00
Michael Goulet
0d2fede817 reflow comment, not a FIXME i think 2023-06-30 18:51:27 +00:00
Michael Goulet
0506250f8c Encode item bounds for DefKind::ImplTraitPlaceholder 2023-06-29 16:37:13 +00:00
bors
5bd28f5eac Auto merge of #98867 - cjgillot:metaloop, r=oli-obk
Refactor metadata emission to avoid visiting HIR

This PR refactors metadata emission to be based on tables and iteration over definitions.

In a first part, this PR moves information from the `EntryKind` enum to tables, until removing the `EntryKind` enum.
In a second part, the iteration scheme is refactored to avoid fetching HIR unless strictly necessary.

r? `@ghost`
2023-06-28 16:16:27 +00:00
Camille GILLOT
0faea7728f Encode impls in encode_impls. 2023-06-27 16:50:34 +00:00
Camille GILLOT
845fcc1939 Use instrument macro. 2023-06-27 16:50:34 +00:00
Camille GILLOT
fd81e964b8 Retire encode_info_for_items. 2023-06-27 16:50:34 +00:00
Camille GILLOT
22df32264a Encode Impl separately. 2023-06-27 16:50:34 +00:00
Camille GILLOT
45a9a5460f Encode Trait info in def-id loop. 2023-06-27 16:50:34 +00:00
Camille GILLOT
1a9d34fd81 Merge assoc_item functions. 2023-06-27 16:50:34 +00:00
Camille GILLOT
3c790b3730 Encode fn_sig separately.
Closures do not have a `fn_sig`, so no reason to encode one.
2023-06-27 16:50:34 +00:00
Michael Goulet
fbdef58414 Migrate predicates_of and caller_bounds to Clause 2023-06-26 23:12:03 +00:00
Camille GILLOT
3d9ba07a0e Use constness query to encode constness. 2023-06-26 16:45:41 +00:00
Camille GILLOT
cbe1578690 Encode info for Fn/AssocFn in a single place. 2023-06-26 16:45:01 +00:00
bors
1d67eba687 Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, r=compiler-errors
Various impl trait in assoc tys cleanups

r? `@compiler-errors`

All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature.

best reviewed commit by commit
2023-06-23 23:26:38 +00:00
Michael Goulet
471830b3a4 migrate inferred_outlives_of to Clause 2023-06-22 18:34:24 +00:00
Michael Goulet
46a650f4e0 Migrate item_bounds to ty::Clause 2023-06-22 18:34:23 +00:00
Oli Scherer
c8979e587b Move opaque_type_origin_unchecked onto TyCtxt and re-use it where it was open coded 2023-06-22 14:31:15 +00:00
Nilstrieb
a98c14f3a9
Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnr
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind`

Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`).

1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`.
2. Add a new `Clause` type which is parallel to `Predicate`.
    * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸

The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that...

r? ``@lcnr`` or ``@oli-obk``

[^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21 07:37:01 +02:00
Camille GILLOT
7d5b2e4926 Make closure_saved_names_of_captured_variables a query. 2023-06-19 16:50:52 +00:00
Michael Goulet
fca56a8d2c s/Clause/ClauseKind 2023-06-19 14:57:42 +00:00
The 8472
114d5f221c s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 2023-06-14 09:28:54 +02:00
bors
343ad6f059 Auto merge of #111626 - pjhades:output, r=b-naber
Write to stdout if `-` is given as output file

With this PR, if `-o -` or `--emit KIND=-` is provided, output will be written to stdout instead. Binary output (those of type `obj`, `llvm-bc`, `link` and `metadata`) being written this way will result in an error unless stdout is not a tty. Multiple output types going to stdout will trigger an error too, as they will all be mixded together.

This implements https://github.com/rust-lang/compiler-team/issues/431

The idea behind the changes is to introduce an `OutFileName` enum that represents the output - be it a real path or stdout - and to use this enum along the code paths that handle different output types.
2023-06-09 09:45:40 +00:00
bors
a97c36dd2e Auto merge of #109005 - Nilstrieb:dont-forgor-too-much-from-cfg, r=petrochenkov
Remember names of `cfg`-ed out items to mention them in diagnostics

# Examples

## `serde::Deserialize` without the `derive` feature (a classic beginner mistake)

I had to slightly modify serde so that it uses explicit re-exports instead of a glob re-export. (Update: a serde PR was merged that adds the manual re-exports)

```
error[E0433]: failed to resolve: could not find `Serialize` in `serde`
   --> src/main.rs:1:17
    |
1   | #[derive(serde::Serialize)]
    |                 ^^^^^^^^^ could not find `Serialize` in `serde`
    |
note: crate `serde` has an item named `Serialize` but it is inactive because its cfg predicate evaluated to false
   --> /home/gh-Nilstrieb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.160/src/lib.rs:343:1
    |
343 | #[cfg(feature = "serde_derive")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
344 | pub use serde_derive::{Deserialize, Serialize};
    |                                     ^^^^^^^^^
    = note: the item is gated behind the `serde_derive` feature
    = note: see https://doc.rust-lang.org/cargo/reference/features.html for how to activate a crate's feature
```
(the suggestion is not ideal but that's serde's fault)

I already tested the metadata size impact locally by compiling the `windows` crate without any features. `800k`  -> `809k`

r? `@ghost`
2023-06-07 17:38:57 +00:00
Jing Peng
ade6c36e53 fix
- remove useless commands from test Makefile
- do not unnecessarily remove metadata temporary files because they'll be managed by MaybeTempDir
- remove unused FailedRemove error introduced by this PR
2023-06-06 17:54:34 -04:00
Jing Peng
9b1a1e1d95 Write to stdout if - is given as output file
If `-o -` or `--emit KIND=-` is provided, output will be written
to stdout instead. Binary output (`obj`, `llvm-bc`, `link` and
`metadata`) being written this way will result in an error unless
stdout is not a tty. Multiple output types going to stdout will
trigger an error too, as they will all be mixded together.
2023-06-06 17:53:29 -04:00
Camille GILLOT
ca4d0d4c24 Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
Nilstrieb
a647ba250a Remember names of cfg-ed out items to mention them in diagnostics
`#[cfg]`s are frequently used to gate crate content behind cargo
features. This can lead to very confusing errors when features are
missing. For example, `serde` doesn't have the `derive` feature by
default. Therefore, `serde::Serialize` fails to resolve with a generic
error, even though the macro is present in the docs.

This commit adds a list of all stripped item names to metadata. This is
filled during macro expansion and then, through a fed query, persisted
in metadata. The downstream resolver can then access the metadata to
look at possible candidates for mentioning in the errors.

This slightly increases metadata (800k->809k for the feature-heavy
windows crate), but not enough to really matter.
2023-06-01 19:17:19 +02:00
Deadbeef
21bc5cded4 Rename impl_defaultness to defaultness 2023-06-01 06:14:06 +00:00