Commit Graph

19896 Commits

Author SHA1 Message Date
Santiago Pastorino b22769a7bd
Clarify explicit_predicates_of is_assoc_item_ty comment 2022-12-13 09:41:12 -03:00
Santiago Pastorino 4ae0c5518d
Make InternalSubsts rust docs a bit clearer 2022-12-13 09:28:25 -03:00
Santiago Pastorino b0c3228404
Join match arms since they do the same thing 2022-12-12 16:44:39 -03:00
Santiago Pastorino 893772025d
Fix typo 2022-12-12 16:43:38 -03:00
bors 37d7de3379 Auto merge of #105252 - bjorn3:codegen_less_pair_values, r=nagisa
Use struct types during codegen in less places

This makes it easier to use cg_ssa from a backend like Cranelift that doesn't have any struct types at all. After this PR struct types are still used for function arguments and return values. Removing those usages is harder but should still be doable.
2022-12-12 10:38:31 +00:00
bors 2176e3a7a4 Auto merge of #105592 - matthiaskrgr:rollup-1cazogq, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #104997 (Move tests)
 - #105569 (`bug!` with a better error message for failing `Instance::resolve`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-12 07:57:41 +00:00
Matthias Krüger 5877a3fce1
Rollup merge of #105569 - compiler-errors:resolve-bug-better, r=TaKO8Ki
`bug!` with a better error message for failing `Instance::resolve`

Better ICE message when `.unwrap().unwrap()` fails.
2022-12-12 08:21:32 +01:00
bors 2cd2070af7 Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Remove `token::Lit` from `ast::MetaItemLit`.

Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-12 05:16:50 +00:00
bors b397bc0727 Auto merge of #105485 - nnethercote:fix-lint-perf-regressions, r=cjgillot
Fix lint perf regressions

#104863 caused small but widespread regressions in lint performance. I tried to improve things in #105291 and #105416 with minimal success, before fully understanding what caused the regression. This PR effectively reverts all of #105291 and part of #104863 to fix the perf regression.

r? `@cjgillot`
2022-12-12 02:17:08 +00:00
Matthias Krüger 79f99e7969
Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper
llvm-wrapper: adapt for LLVM API changes

This is a follow-up of 75aec4703d. There, I updated the wrapper to only include llvm/ADT/Optional.h for LLVM version below 16. But I missed updating some of the None references.

Found by our experimental rust + llvm at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15587#0185006b-e0af-49e5-8b06-280ed125ff0d/200-539
2022-12-11 23:36:47 +01:00
Matthias Krüger 6042f5bca7
Rollup merge of #105521 - tshepang:keep-heading-separate, r=nagisa
separate heading from body
2022-12-11 23:36:46 +01:00
Matthias Krüger 6ed8cb6616
Rollup merge of #105472 - spastorino:make-encoder-use-queries, r=oli-obk
Make encode_info_for_trait_item use queries instead of accessing the HIR

This change avoids accessing the HIR on `encode_info_for_trait_item` and uses queries. We will need to execute this function for elements that have no HIR and by using queries we will be able to feed for definitions that have no HIR.

r? ``@oli-obk``
2022-12-11 23:36:46 +01:00
Matthias Krüger 4154e14f9a
Rollup merge of #105369 - chenyukang:yukang/fix-105226, r=TaKO8Ki
Detect spurious ; before assoc fn body

Fixes #105226

r? ``@TaKO8Ki``
2022-12-11 23:36:46 +01:00
Matthias Krüger aa7b5b32e3
Rollup merge of #105283 - compiler-errors:ty-var-in-hir-wfcheck, r=nagisa
Don't call `diagnostic_hir_wf_check` query if we have infer variables

Fixes #105260
2022-12-11 23:36:45 +01:00
Nicholas Nethercote 4ff5a3655f Speed up the "builtin lints only" case.
This commit partly undoes #104863, which combined the builtin lints pass
with other lints. This caused a slowdown, because often there are no
other lints, and it's faster to do a pass with a single lint directly
than it is to do a combined pass with a `passes` vector containing a
single lint.
2022-12-12 08:59:27 +11:00
Nicholas Nethercote 3c53781800 Reinstate `{Early,Late}LintPassObjects`.
I removed these in #105291, and subsequently learned they are necessary
for performance.

This commit reinstates them with the new and more descriptive names
`RuntimeCombined{Early,Late}LintPass`, similar to the existing passes
like `BuiltinCombinedEarlyLintPass`. It also adds some comments,
particularly emphasising how we have ways to combine passes at both
compile-time and runtime. And it moves some comments around.
2022-12-12 08:59:27 +11:00
Nicholas Nethercote 2b05f84115 Rename `run_early_passes` as `lint_callback`.
This matches the name used in `late.rs`.
2022-12-12 08:59:27 +11:00
Michael Goulet bc293ed53e bug! with a better error message for failing Instance::resolve 2022-12-11 19:48:24 +00:00
bors d137783642 Auto merge of #102900 - abrachet:master, r=bjorn3
Don't internalize __llvm_profile_counter_bias

Currently, LLVM profiling runtime counter relocation cannot be used by rust during LTO because symbols are being internalized before all symbol information is known.

This mode makes LLVM emit a __llvm_profile_counter_bias symbol which is referenced by the profiling initialization, which itself is pulled in by the rust driver here [1].

It is enabled with -Cllvm-args=-runtime-counter-relocation for platforms which are opt-in to this mode like Linux. On these platforms there will be no link error, rather just surprising behavior for a user which request runtime counter relocation. The profiling runtime will not see that symbol go on as if it were never there. On Fuchsia, the profiling runtime must have this symbol which will cause a hard link error.

As an aside, I don't have enough context as to why rust's LTO model is how it is. AFAICT, the internalize pass is only safe to run at link time when all symbol information is actually known, this being an example as to why. I think special casing this symbol as a known one that LLVM can emit which should not have it's visbility de-escalated should be fine given how seldom this pattern of defining an undefined symbol to get initilization code pulled in is. From a quick grep, __llvm_profile_runtime is the only symbol that rustc does this for.

[1] 0265a3e93b/compiler/rustc_codegen_ssa/src/back/linker.rs (L598)
2022-12-11 14:42:45 +00:00
Krasimir Georgiev cbdc00f6e6 llvm-wrapper: adapt for LLVM API changes
This is a follow-up of
75aec4703d.
There, I updated the wrapper to only include llvm/ADT/Optional.h for
LLVM version below 16. But I missed updating some of the None references.

Found by our experimental rust + llvm at HEAD bot:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15587#0185006b-e0af-49e5-8b06-280ed125ff0d/200-539
2022-12-11 09:14:50 +00:00
Matthias Krüger 2daa3bcbc2
Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-dead
compiler: remove unnecessary imports and qualified paths

Some of these imports were necessary before Edition 2021, others were already in the prelude.

I hope it's fine that this PR is so spread-out across files :/
2022-12-11 09:51:57 +01:00
Matthias Krüger cb4753135e
Rollup merge of #105411 - estebank:short-names, r=oli-obk
Introduce `with_forced_trimmed_paths`

Built on top of https://github.com/rust-lang/rust/pull/104922, only last commit is relevant.
2022-12-11 09:51:56 +01:00
Matthias Krüger 30db3a7d25
Rollup merge of #105542 - compiler-errors:confirm-nits, r=jackh726
Some method confirmation code nits

1. Make some pick methods take `&self` instead of `&mut` to avoid some cloning
2. Pass some values by reference to avoid some cloning
3. Rename a few variables here and there
2022-12-11 00:30:21 +01:00
Esteban Küber 3ad7131aa1 Introduce `with_forced_trimmed_paths` 2022-12-10 14:35:40 -08:00
Michael Goulet 11ad94d87a Some method confirmation code nits 2022-12-10 21:26:40 +00:00
bors c6fcdb6906 Auto merge of #105416 - nnethercote:more-linting-tweaks, r=cjgillot
More linting tweaks

Squeeze a little more blood from this stone.

r? `@cjgillot`
2022-12-10 19:49:51 +00:00
KaDiWa 9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Matthias Krüger ab505298ea
Rollup merge of #105482 - wesleywiser:fix_debuginfo_ub, r=tmiasko
Fix invalid codegen during debuginfo lowering

In order for LLVM to correctly generate debuginfo for msvc, we sometimes need to spill arguments to the stack and perform some direct & indirect offsets into the value. Previously, this code always performed those actions, even when not required as LLVM would clean it up during optimization.

However, when MIR inlining is enabled, this can cause problems as the operations occur prior to the spilled value being initialized. To solve this, we first calculate the necessary offsets using just the type which is side-effect free and does not alter the LLVM IR. Then, if we are in a situation which requires us to generate the LLVM IR (and this situation only occurs for arguments, not local variables) then we perform the same calculation again, this time generating the appropriate LLVM IR as we go.

r? `@tmiasko` but feel free to reassign if you want 🙂

Fixes #105386
2022-12-10 15:01:45 +01:00
Matthias Krüger 62160cba7b
Rollup merge of #105410 - TaKO8Ki:fix-105257, r=BoxyUwU
Consider `parent_count` for const param defaults

Fixes #105257
2022-12-10 15:01:44 +01:00
Matthias Krüger b66e123677
Rollup merge of #105234 - JakobDegen:unneeded-field, r=oli-obk
Remove unneeded field from `SwitchTargets`

This had a fixme already. The only change in behavior is that the mir dumps now no longer contains labels for the types of the integers on the edges of a switchint:

Before:
![image](https://user-images.githubusercontent.com/51179609/205467622-34401a68-dca6-43eb-915e-b9fda1988860.png)

After:
![image](https://user-images.githubusercontent.com/51179609/205467634-b5b2a259-9cb4-4843-845c-592c500f0f9c.png)

I don't think that's a problem though. The information is still available to a user that really cares by checking the type of `_2`, so it honestly feels like a bit of an improvement to me.

r? mir
2022-12-10 15:01:43 +01:00
Matthias Krüger 7e1857db1e
Rollup merge of #105192 - estebank:point-at-lhs-on-binop, r=fee1-dead
Point at LHS on binop type err if relevant
2022-12-10 15:01:43 +01:00
Matthias Krüger 3b7a1593f5
Rollup merge of #104460 - Nilstrieb:expand-the-translation, r=davidtwco
Migrate parts of `rustc_expand` to session diagnostics

This migrates everything but the `mbe` and `proc_macro` modules. It also contains a few cleanups and drive-by/accidental diagnostic improvements which can be seen in the diff for the UI tests.
2022-12-10 15:01:42 +01:00
bors b12b83674f Auto merge of #105525 - matthiaskrgr:rollup-ricyw5s, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #98391 (Reimplement std's thread parker on top of events on SGX)
 - #104019 (Compute generator sizes with `-Zprint_type_sizes`)
 - #104512 (Set `download-ci-llvm = "if-available"` by default when `channel = dev`)
 - #104901 (Implement masking in FileType comparison on Unix)
 - #105082 (Fix Async Generator ABI)
 - #105109 (Add LLVM KCFI support to the Rust compiler)
 - #105505 (Don't warn about unused parens when they are used by yeet expr)
 - #105514 (Introduce `Span::is_visible`)
 - #105516 (Update cargo)
 - #105522 (Remove wrong note for short circuiting operators)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-10 11:16:18 +00:00
nils 2f9f097cb8 Migrate parts of `rustc_expand` to session diagnostics
This migrates everything but the `mbe` and `proc_macro` modules. It also
contains a few cleanups and drive-by/accidental diagnostic improvements
which can be seen in the diff for the UI tests.
2022-12-10 11:02:41 +01:00
Matthias Krüger cf840069f3
Rollup merge of #105514 - estebank:is_visible, r=oli-obk
Introduce `Span::is_visible`

r? `@oli-obk`
2022-12-10 09:24:44 +01:00
Matthias Krüger 9e87dd907e
Rollup merge of #105505 - WaffleLapkin:yeet_unused_parens_lint, r=fee1-dead
Don't warn about unused parens when they are used by yeet expr

Don't even get me started on how I've found this.
2022-12-10 09:24:44 +01:00
Matthias Krüger 947fe7e341
Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
Add LLVM KCFI support to the Rust compiler

This PR adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.)

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653).

LLVM KCFI can be enabled with -Zsanitizer=kcfi.

Thank you again, `@bjorn3,` `@eddyb,` `@nagisa,` and `@ojeda,` for all the help!
2022-12-10 09:24:43 +01:00
Matthias Krüger 020d7af949
Rollup merge of #105082 - Swatinem:async-abi, r=compiler-errors
Fix Async Generator ABI

This change was missed when making async generators implement `Future` directly.
It did not cause any problems in codegen so far, as `GeneratorState<(), Output>`
happens to have the same ABI as `Poll<Output>`.
2022-12-10 09:24:43 +01:00
Matthias Krüger 0f5d3ba30f
Rollup merge of #104019 - compiler-errors:print-generator-sizes, r=wesleywiser
Compute generator sizes with `-Zprint_type_sizes`

Fixes #103887
r? `@pnkfelix`
2022-12-10 09:24:41 +01:00
bors cbc70ff277 Auto merge of #105357 - oli-obk:feeding, r=cjgillot,petrochenkov
Group some fields in a common struct so we only pass one reference instead of three

r? `@cjgillot`
2022-12-10 08:23:16 +00:00
bors a000811405 Auto merge of #105512 - matthiaskrgr:rollup-i74avrf, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #102406 (Make `missing_copy_implementations` more cautious)
 - #105265 (Add `rustc_on_unimplemented` to `Sum` and `Product` trait.)
 - #105385 (Skip test on s390x as LLD does not support the platform)
 - #105453 (Make `VecDeque::from_iter` O(1) from `vec(_deque)::IntoIter`)
 - #105468 (Mangle "main" as "__main_void" on wasm32-wasi)
 - #105480 (rustdoc: remove no-op mobile CSS `#sidebar-toggle { text-align }`)
 - #105489 (Fix typo in apple_base.rs)
 - #105504 (rustdoc: make stability badge CSS more consistent)
 - #105506 (Tweak `rustc_must_implement_one_of` diagnostic output)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-10 05:32:44 +00:00
Tshepang Mbambo 6a43946370 separate heading from body 2022-12-10 04:48:37 +02:00
Esteban Küber b9da55afb5 Introduce `Span::is_visible` 2022-12-09 14:35:55 -08:00
Matthias Krüger 376b0bce36
Rollup merge of #105506 - estebank:rustc_must_implement_one_of, r=compiler-errors
Tweak `rustc_must_implement_one_of` diagnostic output
2022-12-09 22:31:59 +01:00
Matthias Krüger f78babd6c4
Rollup merge of #105489 - eltociear:patch-17, r=Dylan-DPC
Fix typo in apple_base.rs

erronous -> erroneous
2022-12-09 22:31:58 +01:00
Matthias Krüger 320d018268
Rollup merge of #105468 - sunfishcode:sunfishcode/main-void-wasi, r=estebank
Mangle "main" as "__main_void" on wasm32-wasi

On wasm, the age-old C trick of having a main function which can either have no arguments or argc+argv doesn't work, because wasm requires caller and callee signatures to match. WASI's current strategy is to have compilers mangle main's name to indicate which signature they're using. Rust uses the no-argument form, which should be mangled as `__main_void`.

This is needed on wasm32-wasi as of #105395.
2022-12-09 22:31:57 +01:00
Matthias Krüger 4fae5891d0
Rollup merge of #102406 - mejrs:missing_copy, r=wesleywiser
Make `missing_copy_implementations` more cautious

- Fixes https://github.com/rust-lang/rust/issues/98348
- Also makes the lint not fire on large types and types containing raw pointers. Thoughts?
2022-12-09 22:31:54 +01:00
bors 0d5573e6da Auto merge of #105363 - WaffleLapkin:thin2win_box_next_argument, r=nnethercote
Shrink `rustc_parse_format::Piece`

This makes both variants closer together in size (previously they were different by 208 bytes -- 16 vs 224). This may make things worse, but it's worth a try.

r? `@nnethercote`
2022-12-09 21:27:35 +00:00
Esteban Küber b3b17bde31 Tweak `rustc_must_implement_one_of` diagnostic output 2022-12-09 10:44:11 -08:00
Maybe Waffle 84a46352ac Don't warn about unused parens when they are used by yeet expr 2022-12-09 18:32:06 +00:00