Commit Graph

231618 Commits

Author SHA1 Message Date
bors
bf62436bce Auto merge of #114602 - compiler-errors:rpit-outlives-sadness, r=oli-obk
Map RPIT duplicated lifetimes back to fn captured lifetimes

Use the [`lifetime_mapping`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OpaqueTy.html#structfield.lifetime_mapping) to map an RPIT's captured lifetimes back to the early- or late-bound lifetimes from its parent function. We may be going thru several layers of mapping, since opaques can be nested, so we introduce `TyCtxt::map_rpit_lifetime_to_fn_lifetime` to loop through several opaques worth of mapping, and handle turning it into a `ty::Region` as well.

We can then use this instead of the identity substs for RPITs in `check_opaque_meets_bounds` to address #114285.

We can then also use `map_rpit_lifetime_to_fn_lifetime` to properly install bidirectional-outlives predicates for both RPITs and RPITITs. This addresses #114601.

I based this on #114574, but I don't actually know how much of that PR we still need, so some code may be redundant now... 🤷

---

Fixes #114597
Fixes #114579
Fixes #114285

Also fixes #114601, since it turns out we had other bugs with RPITITs and their duplicated lifetime params 😅.

Supersedes #114574

r? `@oli-obk`
2023-08-08 13:03:10 +00:00
bors
617821ab32 Auto merge of #114339 - ttsugriy:unsafe-utf8, r=davidtwco
[rustc_data_structures][base_n][perf] Remove unnecessary utf8 check.

Since all output characters taken from `BASE_64` are valid UTF8 chars there is no need to waste cycles on validation.

Even though it's obviously a perf win, I've also used a [benchmark](https://gist.github.com/ttsugriy/e1e63c07927d8f31e71695a9c617bbf3) on M1 MacBook Air with following results:
```
Running benches/base_n_benchmark.rs (target/release/deps/base_n_benchmark-825fe5895b5c2693)
push_str/old            time:   [14.670 µs 14.852 µs 15.074 µs]
Found 11 outliers among 100 measurements (11.00%)
  4 (4.00%) high mild
  7 (7.00%) high severe
push_str/new            time:   [12.573 µs 12.674 µs 12.801 µs]
Found 11 outliers among 100 measurements (11.00%)
  7 (7.00%) high mild
  4 (4.00%) high severe
```
2023-08-08 10:25:37 +00:00
Michael Goulet
0adf7048d2 add'l test 2023-08-08 09:39:59 +00:00
Michael Goulet
ef2a611803 Simplify via map_rpit_lifetime_to_fn_lifetime 2023-08-08 09:39:42 +00:00
Oli Scherer
67703b9161 Stop using identity args for opaque type wf checks and instead load the args from the single use of a RPIT in its parent function's return type 2023-08-08 09:39:42 +00:00
Michael Goulet
420ee167a8 Install bidirectional outlives predicates for RPITITs (and RPITs) correctly 2023-08-08 09:39:42 +00:00
bors
6d55184d05 Auto merge of #114520 - RalfJung:unsized-valtrees, r=oli-obk
simplify handling of valtrees for unsized types
2023-08-08 07:48:01 +00:00
bors
6742e2b185 Auto merge of #114578 - petrochenkov:noplugin, r=cjgillot
rustc_interface: Dismantle `register_plugins` query

It did three independent things:
- Constructed `LintStore`
- Prepared incremental directories and dep graph
- Initialized some fields in `Session`

The `LintStore` construction (now `passes::create_lint_store`)  is more or less left in place.

The incremental stuff is now moved into `fn dep_graph_future`.
This helps us to start loading the dep graph a bit earlier.

The `Session` field initialization is moved to tcx construction point.
Now that tcx is constructed early these fields don't even need to live in `Session`, they can live in tcx instead and be initialized at its creation (see the FIXME).

Three previously existing `rustc_interface` queries are de-querified (`register_plugins`, `dep_graph_future`, `dep_graph`) because they are only used locally in `fn global_ctxt` and their results don't need to be saved elsewhere.

On the other hand, `crate_types` and `stable_crate_id` are querified.
They are used from different places and their use is very similar to the existing `crate_name` query in this regard.
2023-08-08 05:10:11 +00:00
Michael Goulet
8dcb8e0759 Unconditionally record lifetime mapping 2023-08-08 03:16:04 +00:00
bors
8e7fd55131 Auto merge of #114604 - matthiaskrgr:rollup-o1jltfn, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #114376 (Avoid exporting __rust_alloc_error_handler_should_panic more than once.)
 - #114413 (Warn when #[macro_export] is applied on decl macros)
 - #114497 (Revert #98333 "Re-enable atomic loads and stores for all RISC-V targets")
 - #114500 (Remove arm crypto target feature)
 - #114566 (Store the laziness of type aliases in their `DefKind`)
 - #114594 (Structurally normalize weak and inherent in new solver)
 - #114596 (Rename method in `opt-dist`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-08 02:27:38 +00:00
Matthias Krüger
07b2c971a1
Rollup merge of #114596 - Kobzol:opt-dist-host, r=lqd
Rename method in `opt-dist`

This makes it clearer that the LLVM is the host one (it doesn't necessarily have to be downloaded). On Linux, it comes from the Dockerfile, on Windows it's downloaded.

Suggested here: https://github.com/rust-lang/rust/pull/114344#discussion_r1285596217

r? `@lqd`
2023-08-08 03:30:57 +02:00
Matthias Krüger
418b91a3d7
Rollup merge of #114594 - compiler-errors:new-solver-resolve-aliases, r=lcnr
Structurally normalize weak and inherent in new solver

It seems pretty obvious to me that we should be normalizing weak and inherent aliases too, since they can always be normalized. This PR still leaves open the question of what to do with opaques, though 💀

**Also**, we need to structurally resolve the target of a coercion, for the UI test to work.

r? `@lcnr`
2023-08-08 03:30:56 +02:00
Matthias Krüger
3cd0a109a8
Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, r=oli-obk
Store the laziness of type aliases in their `DefKind`

Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not.

With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*:

Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates.

As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions.

---

This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold.

`@rustbot` label F-lazy_type_alias
r? `@oli-obk`
2023-08-08 03:30:56 +02:00
Matthias Krüger
28ee1a919e
Rollup merge of #114500 - taiki-e:arm-crypto, r=Amanieu
Remove arm crypto target feature

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

LLVM has moved away from a combined `crypto` feature on both aarch64 and arm, and we did the same on aarch64, but were deferred from doing the same on arm due to compatibility with older LLVM.

As the minimum LLVM version has increased, we can now remove this (unstable) target feature on arm.

r? `@Amanieu`
2023-08-08 03:30:55 +02:00
Matthias Krüger
6f36f1ffbd
Rollup merge of #114497 - taiki-e:revert-riscv-atomic, r=Amanieu
Revert #98333 "Re-enable atomic loads and stores for all RISC-V targets"

This reverts #98333.

As said in https://github.com/rust-lang/rust/pull/98333#issuecomment-1666375293, `forced-atomics` target feature is also needed to enable atomic load/store on these targets (otherwise, libcalls are generated): https://godbolt.org/z/433qeG7vd

However, `forced-atomics` target feature is currently broken (https://github.com/rust-lang/rust/issues/114153), so AFAIK, there is currently no way to enable atomic load/store (via core::intrinsics) on these targets properly.

r? `@Amanieu`
2023-08-08 03:30:55 +02:00
Matthias Krüger
42cdc7df20
Rollup merge of #114413 - CohenArthur:warn-macro-export-decl-macros, r=cjgillot
Warn when #[macro_export] is applied on decl macros

The existing code checks if `#[macro_export]` is being applied to an item other than a macro, and warns in that case, but fails to take into account macros 2.0/decl macros, despite the attribute having no effect on these macros.

This PR adds a special case for decl macros with the aforementioned attribute, so that the warning is a bit more precise. Instead of just saying "this attribute has no effect", hint towards the fact that decl macros get exported and resolved like regular items.
It also removes a `#[macro_export]` attribute which was applied on one of `core`'s decl macros.

- core: Remove #[macro_export] from `debug_assert_matches`
- check_attrs: Warn when #[macro_export] is used on macros 2.0
2023-08-08 03:30:54 +02:00
Matthias Krüger
328e9785fb
Rollup merge of #114376 - inferiorhumanorgans:rustc-codegen-ssa-duplicate-export, r=wesleywiser
Avoid exporting __rust_alloc_error_handler_should_panic more than once.

Exporting `__rust_alloc_error_handler_should_panic` multiple times causes `ld.gold` to balk with: `error: version script assignment of  to symbol __rust_alloc_error_handler_should_panic failed: symbol not defined`

Specifically this breaks builds of 1.70.0 and newer on DragonFly and YoctoProject with `ld.gold`.  Builds with `ld.bfd` and `lld` should be unaffected.

http://errors.yoctoproject.org/Errors/Details/708194/
2023-08-08 03:30:54 +02:00
bors
443c3161dd Auto merge of #114048 - nikic:llvm-17, r=cuviper
Update to LLVM 17

Expected LLVM 17.0.0 release date: Sep 5th
Rust 1.73 release date: Oct 5th

Compatibility changes in this PR:
 - Drop LLVM_RUSTLLVM check for target-cpu table, which no longer requires a patch with LLVM 17.
 - Update powerpc data layouts, which now include function alignment information. As usual, downgrade for older LLVM versions.
 - Adjust the stack-protector.rs test so that the stack smashing does not get optimized away.
 - Adjust path of crtbegin.c and crtend.c in compiler-rt.
 - Updated dist-riscv64-linux to use binutils 2.36 in order to recognize the zicsr feature, which is no longer part of the base ISA.
 - Fixed symlink for asm include directory on dist-various-2. We should use `/usr/include/x86_64-linux-gnu/asm` for the host, rather than `/usr/include/asm-generic`.

Upstream patches:
 - [x] https://reviews.llvm.org/D156525 (backported)

Perf run: https://perf.rust-lang.org/compare.html?start=f239bb6bea94d16d902c36d72b5cabdddefb3cab&end=8030d71a95a3ea79f5fc95232c32f9b78effb92d&stat=instructions:u

Fixes #109671.

Successful: dist-x86_64-linux, dist-aarch64-linux, dist-s390x-linux, dist-powerpc-linux, armhf-gnu, wasm32
2023-08-07 21:37:42 +00:00
Jakub Beránek
65e468f9c2
Rename method in opt-dist
This makes it clearer that the LLVM is the host one (it doesn't necessarily have to be downloaded).
2023-08-07 23:10:57 +02:00
Arthur Cohen
bdf4e3de9c check_attrs: Warn when #[macro_export] is used on macros 2.0
The compiler should emit a more specific error when the `#[macro_export]`
attribute is present on a decl macro, instead of silently ignoring it.

This commit adds the required error message in rustc_passes/messages.ftl,
 as well as a note. A new variant is added to the `errors::MacroExport`
enum, specifically for the case where the attribute is added to a macro
2.0.
2023-08-07 21:14:28 +02:00
Arthur Cohen
f1776250eb core: Remove #[macro_export] from debug_assert_matches
The `debug_assert_matches` macro was marked with the `#[macro_export]` attribute,
despite being a declarative macro/macro 2.0, for which the exporting rules are similar
to items. In fact, `#[macro_export]` on a decl macro has no effect on its visibility.
2023-08-07 21:13:55 +02:00
Michael Goulet
ba4a2f7cb7 Resolve target type of coercion 2023-08-07 19:06:18 +00:00
Michael Goulet
fb9030d7dd Structurally normalize weak and inherent too 2023-08-07 19:05:59 +00:00
Nikita Popov
7867833652 Fix LLVM version check for ThinLTO import/export lists
These types changed in LLVM 18, not LLVM 17.
2023-08-07 20:36:14 +02:00
Nikita Popov
ec59919273 Symlink correct asm directory on dist-various-2
We should symlink /usr/include/x86_64-linux-gnu/asm for the host
triple, rather than /usr/include/asm-generic, which is used in the
implementation for asm for specific triple, but shouldn't be used
by itself.
2023-08-07 20:35:56 +02:00
Nikita Popov
0d37c2befb Update dist-riscv64-linux to use binutils 2.36
The zicsr feature has been split off from the base ISA. A newer
binutils version is required to recognize it.
2023-08-07 20:35:55 +02:00
Nikita Popov
5be397441e Adjust path to crtbegin.c / crtend.c
These were moved into builtins by https://reviews.llvm.org/D153989.
2023-08-07 20:35:55 +02:00
Nikita Popov
01cdc505d9 Fix stack-protector.rs on LLVM 17
Prevent fill from being (correctly) optimized away by passing the
address of the alloca to black_box.
2023-08-07 20:35:55 +02:00
Nikita Popov
ad7ea8b7e6 Update powerpc data layouts
Function pointer alignment is specified since https://reviews.llvm.org/D147016.
2023-08-07 20:35:55 +02:00
Nikita Popov
055dd282c5 Remove no longer needed LLVM_RUSTLLVM check
The bundled version now uses the LLVM 17 code path.
2023-08-07 20:35:55 +02:00
Nikita Popov
8c1c7d37b2 Update LLVM submodule 2023-08-07 20:35:55 +02:00
bors
03a119b0b0 Auto merge of #114344 - Kobzol:opt-dist-llvm-profdata, r=nikic
Use the correct `llvm-profdata` binary in `opt-dist`

Turns out that we were probably using the wrong `llvm-profdata` binary in the PGO script all along. This should resolve the performance regressions of switching the host LLVM to 17 ([host `llvm-profdata`](https://github.com/rust-lang/rust/pull/114297#issuecomment-1660521361), [target `llvm-profdata`](https://github.com/rust-lang/rust/pull/114297#issuecomment-1661127032)]).

r? `@nikic`
2023-08-07 18:34:03 +00:00
bors
63a81b0c5a Auto merge of #114585 - matthiaskrgr:rollup-h26pvus, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #113568 (Fix spurious test failure with `panic=abort`)
 - #114196 (Bubble up nested goals from equation in `predicates_for_object_candidate`)
 - #114485 (Add trait decls to SMIR)
 - #114495 (Set max_atomic_width for AVR to 16)
 - #114496 (Set max_atomic_width for sparc-unknown-linux-gnu to 32)
 - #114510 (llvm-wrapper: adapt for LLVM API changes)
 - #114562 (stabilize abi_thiscall)
 - #114570 ([miri][typo] Fix a typo in a vector_block comment.)
 - #114573 (CI: do not hide error logs in a group)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-07 15:29:14 +00:00
Matthias Krüger
d9f3d49c81
Rollup merge of #114573 - Kobzol:ci-no-group-on-error, r=oli-obk
CI: do not hide error logs in a group

This PR avoids creating a GHA group at the very end of a CI workflow when some failure has happened. Before, when a failure has happened, its GHA group was not closed, however the clock drift check function would create a new group, which would actually close the group containing the error log, thus making errors hidden by default, which is not ideal.

See discussion here: https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/GHA.20groups.20being.20closed.20on.20failures

r? bootstrap
2023-08-07 16:47:58 +02:00
Matthias Krüger
e7b7362af2
Rollup merge of #114570 - ttsugriy:miri-vc-typo, r=RalfJung
[miri][typo] Fix a typo in a vector_block comment.
2023-08-07 16:47:57 +02:00
Matthias Krüger
06daa9e263
Rollup merge of #114562 - Trolldemorted:thiscall, r=oli-obk
stabilize abi_thiscall

Closes https://github.com/rust-lang/rust/issues/42202, stabilizing the use of the "thiscall" ABI.

FCP was substituted by a poll, and the poll has been accepted.
2023-08-07 16:47:57 +02:00
Matthias Krüger
1d82946e52
Rollup merge of #114510 - krasimirgg:llvm-17-cmi, r=nikic
llvm-wrapper: adapt for LLVM API changes

No functional changes intended.

Adapts llvm-wrapper for 65e57bbed0.

Found by our experimental rust + llvm @ HEAD CI:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/21304#0189c526-86cd-4db9-bdbc-dd0132dfc22b/197-500
2023-08-07 16:47:56 +02:00
Matthias Krüger
9b1f9433db
Rollup merge of #114496 - taiki-e:sparc32-atomic, r=Amanieu
Set max_atomic_width for sparc-unknown-linux-gnu to 32

This is currently set to 64

90f0b24ad3/compiler/rustc_target/src/spec/sparc_unknown_linux_gnu.rs (L8)

However, AFAIK, this architecture doesn't support 64-bit atomics, and LLVM generates libcalls: https://godbolt.org/z/chzThWGG1

(Currently, attempts to run `cargo test` for this target result in "undefined reference to `__sync_val_compare_and_swap_8'" error. 02efe1e74f)

r? `@Amanieu`
2023-08-07 16:47:56 +02:00
Matthias Krüger
b0a5126f06
Rollup merge of #114495 - taiki-e:avr-atomic, r=Amanieu
Set max_atomic_width for AVR to 16

This is currently set to 0

90f0b24ad3/compiler/rustc_target/src/spec/avr_gnu_base.rs (L26-L27)

However, LLVM supports {8,16}-bit atomic load/store on AVR (support for RMW is still quite incomplete and only partially supported).

https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/load8.ll#L5-L13
https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/load16.ll#L3-L12
https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/store.ll#L3-L22

cc #99668

r? `@Amanieu`
2023-08-07 16:47:55 +02:00
Matthias Krüger
7a52fe5396
Rollup merge of #114485 - spastorino:add-trait-decls, r=oli-obk
Add trait decls to SMIR

r? `@oli-obk`

Closes https://github.com/rust-lang/project-stable-mir/issues/20
2023-08-07 16:47:55 +02:00
Matthias Krüger
2a643b2dc0
Rollup merge of #114196 - compiler-errors:bubble-pls, r=lcnr
Bubble up nested goals from equation in `predicates_for_object_candidate`

This used to be needed for https://github.com/rust-lang/rust/pull/114036#discussion_r1273987510, but since it's no longer, I'm opening this as a separate PR. This also fixes one ICEing UI test: (`tests/ui/unboxed-closures/issue-53448.rs`)

r? `@lcnr`
2023-08-07 16:47:54 +02:00
Matthias Krüger
bf40327270
Rollup merge of #113568 - ferrocene:pa-spurious-weak-lang-item-2, r=b-naber
Fix spurious test failure with `panic=abort`

Description on why it happens and why the fix should work is in the code comments.
2023-08-07 16:47:54 +02:00
León Orell Valerian Liehr
5468336d6b
Store the laziness of type aliases in the DefKind 2023-08-07 15:54:31 +02:00
Pietro Albini
409d9946cd
change test to use if black_box(false) 2023-08-07 15:42:24 +02:00
bors
84ec2633de Auto merge of #113902 - Enselic:lint-recursive-drop, r=oli-obk
Make `unconditional_recursion` warning detect recursive drops

Closes #55388

Also closes #50049 unless we want to keep it for the second example which this PR does not solve, but I think it is better to track that work in #57965.

r? `@oli-obk` since you are the mentor for #55388

Unresolved questions:
- [x] There are two false positives that must be fixed before merging (see diff). I suspect the best way to solve them is to perform analysis after drop elaboration instead of before, as now, but I have not explored that any further yet. Could that be an option? **Answer:** Yes, that solved the problem.

`@rustbot` label +T-compiler +C-enhancement +A-lint
2023-08-07 13:39:28 +00:00
Santiago Pastorino
6e4d7bd90e
Add TraitDef::trait_decl method 2023-08-07 10:24:12 -03:00
Santiago Pastorino
0e69a8ad20
Add all_trait_decls to SMIR 2023-08-07 10:24:11 -03:00
Santiago Pastorino
496faa857c
Convert trait declaration to SMIR 2023-08-07 10:24:08 -03:00
Santiago Pastorino
4199a3c13a
Convert unsafety using the stable method and reuse mir::Safety 2023-08-07 10:23:20 -03:00
Benedikt Radtke
3f3262e592 stabilize abi_thiscall 2023-08-07 14:11:03 +02:00