Commit Graph

241040 Commits

Author SHA1 Message Date
Matthias Krüger
6892fcd690 simplify merging of two vecs 2023-12-12 18:42:37 +01:00
bors
27d8a57713 Auto merge of #118841 - compiler-errors:always-copy, r=jackh726
Make most `rustc_type_ir` kinds `Copy` by default

1. There's no reason why `TyKind` and `ConstKind`/`ConstData` can't be `Copy`. This allows us to avoid needing a typed arena for the two types.
2. Simplify some impls into derives.
2023-12-12 12:32:32 +00:00
bors
5b8bc568d2 Auto merge of #118817 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2023-12-12 08:22:37 +00:00
bors
1c15b82b8a Auto merge of #118857 - matthiaskrgr:rollup-t02kx2u, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #118445 (Let `reuse` look inside git submodules)
 - #118756 (use bold magenta instead of bold white for highlighting)
 - #118797 (End locals' live range before suspending coroutine)
 - #118840 (remove some redundant clones)
 - #118844 (Monomorphize args while building Instance body in StableMIR)
 - #118846 (Fix BinOp `ty()` assertion and `fn_sig()` for closures)
 - #118848 (Add myself back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-12 06:23:03 +00:00
Laurențiu Nicola
ce8d5fba85 Add rust_analyzer to EXTRA_CHECK_CFGS 2023-12-12 08:16:34 +02:00
Matthias Krüger
dae76b772d
Rollup merge of #118848 - wesleywiser:vacation, r=wesleywiser
Add myself back to review rotation
2023-12-12 06:52:52 +01:00
Matthias Krüger
d67e80f12d
Rollup merge of #118846 - celinval:smir-ty-methods, r=compiler-errors
Fix BinOp `ty()` assertion and `fn_sig()` for closures

`BinOp::ty()` was asserting that the argument types were primitives. However, the primitive check doesn't include pointers, which can be used in a `BinaryOperation`. Thus extend the arguments to include them.

Since I had to add methods to check for pointers in TyKind, I just went ahead and added a bunch more utility checks that can be handy for our users and fixed the `fn_sig()` method to also include closures.

`@compiler-errors` just wanted to confirm that today no `BinaryOperation` accept SIMD types. Is that correct?

r? `@compiler-errors`
2023-12-12 06:52:51 +01:00
Matthias Krüger
cdc4fc9f35
Rollup merge of #118844 - celinval:smir-mono-args, r=compiler-errors
Monomorphize args while building Instance body in StableMIR

The function `Instance::body()` in StableMIR is supposed to return a monomorphic body by instantiating all possibly generic constructs. We were previously instantiating type and constants, but not generic arguments. This PR ensures that we also instantiate them.

r? ``@compiler-errors``
2023-12-12 06:52:51 +01:00
Matthias Krüger
fefa8fc6c4
Rollup merge of #118840 - matthiaskrgr:cloooooone, r=compiler-errors
remove some redundant clones
2023-12-12 06:52:50 +01:00
Matthias Krüger
b862e7edce
Rollup merge of #118797 - tmiasko:dead-coro, r=davidtwco
End locals' live range before suspending coroutine

State transforms retains storage statements for locals that are not
stored inside a coroutine. It ensures those locals are live when
resuming by inserting StorageLive as appropriate. It forgot to end the
storage of those locals when suspending, which is fixed here.

While the end of live range is implicit when executing return, it is
nevertheless useful for inliner which would otherwise extend the live
range beyond return.

Fixes #117733
2023-12-12 06:52:50 +01:00
Matthias Krüger
dfc5ffacd3
Rollup merge of #118756 - jyn514:colors, r=estebank
use bold magenta instead of bold white for highlighting

according to a poll of gay people in my phone, purple is the most popular color to use for highlighting

| color      | percentage |
| ---------- | ---------- |
| bold white | 6%         |
| blue       | 14%        |
| cyan       | 26%        |
| purple     | 37%        |
| magenta    | 17%        |

unfortunately, purple is not supported by 16-color terminals, which rustc apparently wants to support for some reason.
until we require support for full 256-color terms (e.g. by doing the same feature detection as we currently do for urls), we can't use it.

instead, i have collapsed the purple votes into magenta on the theory that they're close, and also because magenta is pretty.

before:
![image](https://github.com/rust-lang/rust/assets/23638587/9a89eee2-8b89-422e-8554-812827bb2a23)

after:
![image](https://github.com/rust-lang/rust/assets/23638587/5bf3a917-8a20-4afd-af3e-f9491d0d57f5)

other colors for comparison:
blue: ![image](https://github.com/rust-lang/rust/assets/23638587/6f199c7b-d598-4009-8ffc-6b7b1d0d1f8c)
cyan: ![image](https://github.com/rust-lang/rust/assets/23638587/a77e4fe3-563e-4aa5-ae92-745bb67287d1)
purple: ![image](https://github.com/rust-lang/rust/assets/23638587/ffe603fb-d811-4106-95a9-4dd4c955924c)
magenta without bolding: ![image](https://github.com/rust-lang/rust/assets/23638587/cf927e5f-8b25-4dc2-b8e7-32905a11a459)

r? ``@estebank``
2023-12-12 06:52:49 +01:00
Matthias Krüger
1ee83272fb
Rollup merge of #118445 - ferrocene:jp-support-reuse-in-submodules, r=Mark-Simulacrum
Let `reuse` look inside git submodules

Changes `collect-license-metadata` and `generate-copyright` so they can now look at the git submodules.

Unfortunately `reuse` chokes on the LLVM submodule - it finds the word "Copyright" or the unicode copyright symbol in all kinds of places, including UTF-8 test cases. The `reuse` tool expressly won't let you ignore folders, so we let it scan everything and then strip out the LLVM sub-folder in post. Instead, we add in a hand-curated list of copyright information gleaned by reading the LLVM codebase carefully, which is stored in `.reuse/dep5` in Debian format where `reuse` can find and use it.

The `.reuse/dep5` continues to track copyright info for files in the tree that do not have SPDX metadata in them (i.e. all of them)
2023-12-12 06:52:49 +01:00
bors
5f5d248602 Auto merge of #118742 - lcnr:infer-var-cleanup, r=compiler-errors
refactor infer var storage

cleanup the code, discovered while working on #118725
2023-12-12 03:23:37 +00:00
Celina G. Val
638b08ebdf Remove scalar fn and tighten the BiOp Ty assertions 2023-12-11 19:02:54 -08:00
Michael Goulet
f3218b2a70 Make ConstKind and TyKind Copy 2023-12-12 01:09:12 +00:00
Michael Goulet
e947234520 Simplify some Copy impls in rustc_type_ir 2023-12-12 01:09:12 +00:00
Wesley Wiser
b9d9cc598b Wesley is not on vacation
All good things...
2023-12-11 18:58:43 -06:00
Celina G. Val
3b97b5130a Fix doc comment 2023-12-11 16:37:33 -08:00
Celina G. Val
2f790af726 Fix BinOp ty assertion and fn_sig for closures
Also added a few more util methods to TyKind to check for specific types.
2023-12-11 16:06:48 -08:00
Celina G. Val
0a65dd305f Monomorphize args while building Instance body 2023-12-11 15:29:34 -08:00
bors
e2a3c9b3f0 Auto merge of #117962 - weihanglo:debug-name-table, r=wesleywiser
fix: stop emitting `.debug_pubnames` and `.debug_pubtypes`

A continuation of #94181.
Fixes #48762
MCP can be found in <https://github.com/rust-lang/compiler-team/issues/688>.

`.debug_pubnames` and `.debug_pubtypes` are poorly designed and people
seldom use them. However, they take a considerable portion of size in
the final binary. This tells LLVM stop emitting those sections on
DWARFv4 or lower. DWARFv5 use `.debug_names` which is more concise
in size and performant for name lookup.

Some other no-really-useful personal notes:

<details><summary>Details</summary>
<p>

## Pepole saying they are not useful

* https://github.com/rust-lang/rust/issues/48762
* https://rust-lang.zulipchat.com/#narrow/stream/317568-t-compiler.2Fwg-debugging/topic/investigating.20debuginfo.20size/near/342713604
* `DwarfCompileUnit::hasDwarfPubSections()` — f633f325a1/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (L1477-L1494)
* clang default to no debug name table when no option provided — f633f325a1/clang/lib/Frontend/CompilerInvocation.cpp (L1819-L1824)
* GCC explicitly says GDB doesn't use pub sections (`TARGET_WANT_DEBUG_PUB_SECTIONS` only be true on Darwin) — 5d2a360f0a/gcc/target.def (L6985-L6990) and 319b460545/gold/dwarf_reader.h (L424-L427)
* Probably the only place that makes use of pub section in lldb — 725115d7bb/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (L2117-L2135)

* "The -gsplit-dwarf option requires -ggnu-pubnames." — 5d2a360f0a/gcc/opts.cc (L1205)

* LLVM: Always emit `.debug_names` with dwarf 5 for Apple platforms — https://reviews.llvm.org/D118754

</p>
</details>
2023-12-11 22:32:08 +00:00
Tomasz Miąsko
eaaa290dbc Remove redundant special case for resume argument
The special case is subsumed by the check for always live locals that
follows it.
2023-12-11 23:11:20 +01:00
Tomasz Miąsko
ef1831a21f End locals' live range before suspending coroutine
State transforms retains storage statements for locals that are not
stored inside a coroutine. It ensures those locals are live when
resuming by inserting StorageLive as appropriate. It forgot to end the
storage of those locals when suspending, which is fixed here.

While the end of live range is implicit when executing return, it is
nevertheless useful for inliner which would otherwise extend the live
range beyond return.
2023-12-11 23:11:20 +01:00
Weihang Lo
6aac62cdcb
refactor: only check dwarf version when emitting dwarf 2023-12-11 16:24:24 -05:00
Matthias Krüger
0564de10b1 remove some redundant clones 2023-12-11 21:54:36 +01:00
bors
21cce21d8c Auto merge of #118838 - matthiaskrgr:rollup-8kwzpho, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #118620 (resolve: Use `def_kind` query to cleanup some code)
 - #118647 (dump bootstrap shims)
 - #118726 (Do not parenthesize exterior struct lit inside match guards)
 - #118818 (llvm-wrapper: adapt for LLVM API change)
 - #118822 (Extract exhaustiveness into its own crate)
 - #118826 (Edit target doc template to remove email)
 - #118827 (Update table for linker-plugin-lto docs)
 - #118835 (Fix again `rustc_codegen_gcc` tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-11 20:02:55 +00:00
Weihang Lo
1667f3d2cc
fix: stop emitting .debug_pubnames and .debug_pubtypes
`.debug_pubnames` and `.debug_pubtypes` are poorly designed and people
seldom use them. However, they take a considerable portion of size in
the final binary. This tells LLVM stop emitting those sections on
DWARFv4 or lower. DWARFv5 use `.debug_names` which is more concise
in size and performant for name lookup.
2023-12-11 14:58:02 -05:00
Weihang Lo
a2d328fa12
test: demonstrate that dwarf debug names sections are emitted 2023-12-11 14:58:01 -05:00
Matthias Krüger
1cf538b0b1
Rollup merge of #118835 - Urgau:fix-rccg-gcc-tests, r=matthiaskrgr
Fix again `rustc_codegen_gcc` tests

Similar to https://github.com/rust-lang/rust/pull/118706

r? `@GuillaumeGomez`
2023-12-11 20:46:52 +01:00
Matthias Krüger
06d2c2a3b2
Rollup merge of #118827 - Nilstrieb:linker-plugin-lto, r=ehuss
Update table for linker-plugin-lto docs
2023-12-11 20:46:51 +01:00
Matthias Krüger
4114a83735
Rollup merge of #118826 - Nilstrieb:no-email-pls, r=davidtwco
Edit target doc template to remove email

We don't really want to communicate with target maintainers via email. GitHub is where everything happens, people should have a GitHub account that can be pinged on issues.

This doesn't necessarily have to be a strict rule, but edit the template to suggest this. The previous template made it look like we care about having an email address, which we do not.

r? ````@davidtwco````
2023-12-11 20:46:51 +01:00
Matthias Krüger
dd0887c75c
Rollup merge of #118822 - Nadrieril:librarify, r=compiler-errors
Extract exhaustiveness into its own crate

It now makes sense to extract exhaustiveness into its own crate! This was much-requested by rust-analyzer (they currently maintain by hand a copy of the algorithm), and I hope this can serve other projects e.g. clippy.

This is the churny PR: it exclusively moves code around. It's not yet useable outside of rustc but I wanted the churny parts to be out of the way.

r? `@compiler-errors`
2023-12-11 20:46:50 +01:00
Matthias Krüger
dadecea9f1
Rollup merge of #118818 - krasimirgg:llvm-18-pass, r=nikic
llvm-wrapper: adapt for LLVM API change

LLVM commit 1d608fc755 renamed the pass.

r? ````@nikic````
2023-12-11 20:46:50 +01:00
Matthias Krüger
3a0562b93c
Rollup merge of #118726 - dtolnay:matchguardlet, r=compiler-errors
Do not parenthesize exterior struct lit inside match guards

Before this PR, the AST pretty-printer injects parentheses around expressions any time parens _could_ be needed depending on what else is in the code that surrounds that expression. But the pretty-printer did not pass around enough context to understand whether parentheses really _are_ needed on any particular expression. As a consequence, there are false positives where unneeded parentheses are being inserted.

Example:

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

macro_rules! pp {
    ($e:expr) => {
        stringify!($e)
    };
}

fn main() {
    println!("{}", pp!(match () { () if let _ = Struct {} => {} }));
}
```

**Before:**

```console
match () { () if let _ = (Struct {}) => {} }
```

**After:**

```console
match () { () if let _ = Struct {} => {} }
```

This PR introduces a bit of state that is passed across various expression printing methods to help understand accurately whether particular situations require parentheses injected by the pretty printer, and it fixes one such false positive involving match guards as shown above.

There are other parenthesization false positive cases not fixed by this PR. I intend to address these in follow-up PRs. For example here is one: the expression `{ let _ = match x {} + 1; }` is pretty-printed as `{ let _ = (match x {}) + 1; }` despite there being no reason for parentheses to appear there.
2023-12-11 20:46:49 +01:00
Matthias Krüger
ea82b110fe
Rollup merge of #118647 - onur-ozkan:bootstrap-shims-dump, r=clubby789
dump bootstrap shims

When making changes to the bootstrap that shouldn't change its behavior, this feature will help developers perform comparisons to check whether the bootstrap behavior has changed or not. As an example, when removing Python from the bootstrap by migrating to Rust, this feature will be super useful for ensuring that the behavior remains unaffected. It will assist me in performing comparisons to verify that the bootstrap behavior and its outputs remains consistent throughout the migration process.

This can also be used for different purposes. For example, allowing CI to dump the shims and upload them so that developers can download them and compare with their local dump to see if CI affects the bootstrap unexpectedly. Or, make CI perform comparisons on specific bootstrap tests to check for behavior changes between the master and PR branches.
2023-12-11 20:46:49 +01:00
Matthias Krüger
670ba478de
Rollup merge of #118620 - petrochenkov:defeed2, r=compiler-errors
resolve: Use `def_kind` query to cleanup some code

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

Similar attempts to use queries in resolver resulted in perf regressions in the past, so this needs a perf run first.
2023-12-11 20:46:48 +01:00
Urgau
b1bfeb1cdf Fix rustc codegen gcc tests 2023-12-11 18:48:49 +01:00
bors
57010939ed Auto merge of #118344 - saethlin:rmeta-header-pos, r=WaffleLapkin
Use a u64 for the rmeta root position

Waffle noticed this in https://github.com/rust-lang/rust/pull/117301#discussion_r1405410174

We've upgraded the other file offsets to u64, and this one only costs 4 bytes per file. Also the way the truncation was being done before was extremely easy to miss, I sure missed it! It's not clear to me if not having this change effectively made the other upgrades from u32 to u64 ineffective, but we can have it now.

r? `@WaffleLapkin`
2023-12-11 17:21:14 +00:00
Jonathan Pallant (Ferrous Systems)
eba02abb99
Reinstate the names of the Ayu dark theme developers.
See https://github.com/rust-lang/rust/pull/71237 for more details.
2023-12-11 16:07:40 +00:00
bors
8a3765582c Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=davidtwco
Add lint against ambiguous wide pointer comparisons

This PR is the resolution of https://github.com/rust-lang/rust/issues/106447 decided in https://github.com/rust-lang/rust/issues/117717 by T-lang.

## `ambiguous_wide_pointer_comparisons`

*warn-by-default*

The `ambiguous_wide_pointer_comparisons` lint checks comparison of `*const/*mut ?Sized` as the operands.

### Example

```rust
let ab = (A, B);
let a = &ab.0 as *const dyn T;
let b = &ab.1 as *const dyn T;

let _ = a == b;
```

### Explanation

The comparison includes metadata which may not be expected.

-------

This PR also drops `clippy::vtable_address_comparisons` which is superseded by this one.

~~One thing: is the current naming right? `invalid` seems a bit too much.~~

Fixes https://github.com/rust-lang/rust/issues/117717
2023-12-11 14:33:16 +00:00
Nilstrieb
d94e3e300d Update table for linker-plugin-lto docs 2023-12-11 15:20:35 +01:00
Nilstrieb
072cf5fc51 Edit target doc template to remove email
We don't really want to communicate with target maintainers via email.
GitHub is where everything happens, people should have a GitHub account
that can be pinged on issues.

This doesn't necessarily have to be a strict rule, but edit the template
to suggest this. The previous template made it look like we care about
having an email address, which we do not.
2023-12-11 15:04:42 +01:00
bors
ff2c56344c Auto merge of #118823 - GuillaumeGomez:rollup-6v51gxv, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #118802 (Remove edition umbrella features.)
 - #118807 (Remove an allocation in min_stack)
 - #118812 (rustdoc-search: do not treat associated type names as types)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-11 12:33:04 +00:00
Nadrieril
43714edb6f Fix doc links 2023-12-11 12:53:01 +01:00
onur-ozkan
2de3cf8d6b sort dump files at the end of bootstrap
To ensure deterministic results we must sort the dump lines.
This is necessary because the order of rustc invocations different
almost all the time.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-11 14:26:19 +03:00
onur-ozkan
9eeb265f7c update auto completions
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-11 14:26:11 +03:00
onur-ozkan
f2feed1095 Dump command invocations from bootstrap shims
When making changes to the bootstrap that shouldn't change its behavior,
this feature will help developers perform comparisons to check whether the
bootstrap behavior has changed or not.

This can also be used for different purposes. For example, allowing CI to
dump the shims and upload them so that developers can download them and compare
with their local dump to see if CI affects the bootstrap unexpectedly. Or, make CI
perform comparisons on specific bootstrap tests to check for behavior changes between
the master and PR branches.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-11 14:25:19 +03:00
Guillaume Gomez
c89672e148
Rollup merge of #118812 - notriddle:notriddle/assoc-name-intern, r=GuillaumeGomez
rustdoc-search: do not treat associated type names as types

[Before](http://notriddle.com/rustdoc-html-demo-6/tor-before/tor_config/list_builder/trait.DirectDefaultEmptyListBuilderAccessors.html?search=DirectDefaultEmptyListBuilderAccessors%3CT%3DT%3E%20-%3E%20Vec%3CT%3E#associatedtype.T)

[After](http://notriddle.com/rustdoc-html-demo-6/tor-after/tor_config/list_builder/trait.DirectDefaultEmptyListBuilderAccessors.html?search=DirectDefaultEmptyListBuilderAccessors%3CT%3DT%3E%20-%3E%20Vec%3CT%3E#associatedtype.T)

[Profile](http://notriddle.com/rustdoc-html-demo-6/tor-profile/index.html)

As a bit of background information: in type-based queries, a type name that does not exist gets treated as a generic type variable.

This causes a counterintuitive behavior in the `tor_config` crate, which has a trait with an associated type variable called `T`.

This isn't a searchable concrete type, but its name still gets stored in the typeNameIdMap, as a convenient way to intern its name.

(The second commit is a mostly unrelated bugfix.)
2023-12-11 11:40:37 +01:00
Guillaume Gomez
f712d73108
Rollup merge of #118807 - SUPERCILEX:allo, r=the8472
Remove an allocation in min_stack
2023-12-11 11:40:37 +01:00
Guillaume Gomez
54d6bded30
Rollup merge of #118802 - ehuss:remove-edition-preview, r=TaKO8Ki
Remove edition umbrella features.

In the 2018 edition, there was an "umbrella" feature `#[feature(rust_2018_preview)]` which was used to enable several other features at once. This umbrella mechanism was not used in the 2021 edition and likely will not be used in 2024 either. During 2018 users reported that setting the feature was awkward, especially since they already needed to opt-in via the edition mechanism.

This PR removes this mechanism because I believe it will not be used (and will clean up and simplify the code). I believe that there are better ways to handle features and editions. In short:

- For highly experimental features, that may or may not be involved in an edition, they can implement regular feature gates like `tcx.features().my_feature`.
- For experimental features that *might* be involved in an edition, they should implement gates with `tcx.features().my_feature && span.at_least_rust_20xx()`. This requires the user to still specify `#![feature(my_feature)]`, to avoid disrupting testing of other edition features which are ready and have been accepted within the edition.
- For experimental features that have graduated to definitely be part of an edition, they should implement gates with `tcx.features().my_feature || span.at_least_rust_20xx()`, or just remove the feature check altogether and just check `span.at_least_rust_20xx()`.
- For relatively simple changes, they can skip the whole feature gating thing and just check `span.at_least_rust_20xx()`, and rely on the instability of the edition itself (which requires `-Zunstable-options`) to gate it.

I am working on documenting all of this in the rustc-dev-guide.
2023-12-11 11:40:36 +01:00