Commit Graph

48471 Commits

Author SHA1 Message Date
Matthias Krüger
170fd43d7d Rollup merge of #143135 - tshepang:typos, r=compiler-errors
fix typos on some doc comments
2025-06-29 06:59:31 +02:00
Matthias Krüger
6404d29442 Rollup merge of #143088 - firefighterduck:improve-doc-discr-tag, r=RalfJung
Improve documentation of `TagEncoding`

This PR is follow-up from the [discussion here](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20VariantId.3DDiscriminant.20when.20tag.20is.20niche.20encoded.3F/with/524384295).

It aims at making the `TagEncoding` documentation less ambiguous and more detailed with references to relevant implementation sides. It especially clears up the ambiguous use of discriminant/variant index, which sparked the discussion referenced above.

PS: While working with layout data, I somehow ended up looking at the docs for `FakeBorrowKind` and noticed that the one example was not in a doc comment. I hope that this is minor enough of a fix for it to be okay in this otherwise unrelated PR.
2025-06-29 06:59:30 +02:00
Matthias Krüger
fd0062cde4 Rollup merge of #143063 - bvanjoi:docs-resolve, r=petrochenkov
explain `ImportData::imported_module`

r? `@petrochenkov`
2025-06-29 06:59:30 +02:00
Matthias Krüger
e68f13c9d4 Rollup merge of #142641 - bjorn3:proc_macro_symbols_o, r=jieyouxu
Generate symbols.o for proc-macros too

To ensure used statics are functioning correctly for proc-macros too.
2025-06-29 06:59:28 +02:00
bors
dddd7ab962 Auto merge of #143161 - GuillaumeGomez:subtree-update_cg_gcc_2025-06-28, r=GuillaumeGomez
GCC backend subtree update

cc `@antoyo`

r? ghost
2025-06-29 04:18:46 +00:00
León Orell Valerian Liehr
f77fead002 Fix the span of trait bound modifier [const] 2025-06-29 04:56:28 +02:00
Yotam Ofek
8429c9911b Remove unused feature gates 2025-06-28 23:36:46 +00:00
Guillaume Gomez
3dcbc1e5bc Remove () returned value 2025-06-29 00:20:15 +02:00
Ralf Jung
75c6e14931 rename Pointer::from_addr_invalid to match strict provenance API 2025-06-29 00:16:19 +02:00
Ralf Jung
58dce8ca86 give Pointer::into_parts a more scary name and offer a safer alternative 2025-06-29 00:16:19 +02:00
bors
cf38b8e663 Auto merge of #143157 - matthiaskrgr:rollup-90rtm3a, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#123476 (std::net: adding `unix_socket_exclbind` feature for solaris/illumos.)
 - rust-lang/rust#142708 (Do not include NUL-terminator in computed length)
 - rust-lang/rust#142963 (Skip unnecessary components in x64 try builds)
 - rust-lang/rust#142987 (rustdoc: show attributes on enum variants)
 - rust-lang/rust#143031 (Add windows-gnullvm hosts to the manifest)
 - rust-lang/rust#143082 (update internal `send_signal` comment)
 - rust-lang/rust#143110 (Use tidy to sort `sym::*` items)
 - rust-lang/rust#143111 (BTreeSet: remove duplicated code by reusing `from_sorted_iter`)
 - rust-lang/rust#143114 (Minor Documentation Improvements)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: dist-i586-gnu-i586-i686-musl
2025-06-28 22:13:42 +00:00
Guillaume Gomez
a420d39afb Fix signature of filter_landing_pad 2025-06-29 00:00:58 +02:00
Guillaume Gomez
13d0ef30c9 Remove unwanted semi-colon in rustc_codegen_gcc 2025-06-28 23:50:00 +02:00
Guillaume Gomez
f8491b11f3 Merge commit 'b7091eca6d8eb0fe88b58cc9a7aec405d8de5b85' into subtree-update_cg_gcc_2025-06-28 2025-06-28 23:37:08 +02:00
Michael Goulet
1347b48584 Remove additional call to lookup_op_method 2025-06-28 20:48:58 +00:00
Michael Goulet
ed16ae851b Do not freshen ReError 2025-06-28 20:48:58 +00:00
Matthias Krüger
7103bbb86a Rollup merge of #143110 - yotamofek:pr/tidy-sort-for-symbols, r=nnethercote
Use tidy to sort `sym::*` items

Use tidy to sort the symbols in the invocation of `symbols!`, instead of implementing the ordering check inside the proc macro.

(asked `````@nnethercote````` about this on zulip, he didn't have any reservations about making this change)

This has a couple of benefits:
- tidy's "version sort" (thanks to rust-lang/rust#141311 !) is nicer than the naive-cmp sort, so, e.g. `AtomicI{8, 16, 32, 64, 128}` are properly sorted by bit width.
- consistency with the rest of the repo
- allows us to remove a bit of order-verifying code from the `symbols!` proc macro impl
2025-06-28 22:05:32 +02:00
Matthias Krüger
c6de7ca41a Rollup merge of #142708 - Darksonn:location-len-without-nul, r=Mark-Simulacrum
Do not include NUL-terminator in computed length

This PR contains just the first commit of rust-lang/rust#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case.

There should be no visible changes in the behavior or API.
2025-06-28 22:05:28 +02:00
bors
11ad40bb83 Auto merge of #142625 - cjgillot:inline-nocycle, r=oli-obk
Only compute recursive callees once.

Inlining MIR in a cyclic call graph may create query cycles, which are ICEs. The current implementation `mir_callgraph_reachable(inlining_candidate, being_optimized)` checks if calling `inlining_candidate` may cycle back to `being_optimized` that we are currently inlining into.

This PR replaces this device with query `mir_callgraph_cyclic(being_optimized)` which searches the call graph for all cycles going back to `being_optimized`, and returns the set of functions involved in those cycles.

This is a tradeoff:
- in the current implementation, we perform more walks, but shallower;
- in this new implementation, we perform fewer walks, but exhaust the graph.

I'd have liked to compute this using some kind of SCC, but generic parameters make resolution path-dependent, so usual graph algorithms do not apply.
2025-06-28 19:11:42 +00:00
bohan
f99cdf8b1c explain ImportData::imported_module 2025-06-29 00:23:35 +08:00
bors
7ba34c7045 Auto merge of #142317 - compiler-errors:perf-fold, r=lcnr
Don't fold in Instantiate when there's nothing to fold

Maybe this helps idk

r? lcnr
2025-06-28 13:31:12 +00:00
Florian Sextl
1c25bfba9d move discr=varid check to layout_sanity_check 2025-06-28 14:47:27 +02:00
Florian Sextl
3d968973c9 fix docs of FakeBorrowKind 2025-06-28 13:54:51 +02:00
Florian Sextl
ac6cfdef13 improve TagEncoding docs 2025-06-28 13:54:51 +02:00
Jonathan Brouwer
1249c14232 Port #[link_name] to the new attribute parsing infrastructure
Co-authored-by: Anne Stijns <anstijns@gmail.com>
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-28 13:53:37 +02:00
Kornel
c9ef11695f Keep inlined var_debug_info only when full debug info is used 2025-06-28 12:22:49 +01:00
Tshepang Mbambo
bc00a633c6 fix typos on some doc comments 2025-06-28 13:13:59 +02:00
bors
b63223c152 Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlin
Insert checks for enum discriminants when debug assertions are enabled

Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```

An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.

This check is similar to Miri's capabilities of checking for valid construction of enum values.

This PR is inspired by saethlin@'s PR
https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments!

I also pair-programmed large parts of this together with vabr-g@.

r? `@saethlin`
2025-06-28 10:25:00 +00:00
ywxt
36462f901e Correct comments. 2025-06-28 17:58:21 +08:00
ywxt
0ff1fb27d3 Restore to HashSet
Co-authored-by: Zoxc <zoxc32@gmail.com>
2025-06-28 17:58:21 +08:00
ywxt
46e18d1fe0 Add FIXMEs for those ignored tests. 2025-06-28 17:58:21 +08:00
ywxt
44e69f592f Add a comment for the wait_for_jobs function.
Co-authored-by: Zoxc <zoxc32@gmail.com>
2025-06-28 17:58:20 +08:00
ywxt
0ceac216c9 Only work-steal in the main loop for rustc_thread_pool
Co-authored-by: Zoxc <zoxc32@gmail.com>
2025-06-28 17:58:20 +08:00
Yotam Ofek
00b64f8851 Use tidy to sort sym::* items 2025-06-28 09:25:55 +00:00
bors
d41e12f1f4 Auto merge of #143116 - matthiaskrgr:rollup-zy9ez06, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#139858 (New const traits syntax)
 - rust-lang/rust#140809 (Reduce special casing for the panic runtime)
 - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined)
 - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver)
 - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell)
 - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv)
 - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`)
 - rust-lang/rust#143106 (gce: don't ICE on non-local const)

Failed merges:

 - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-27 23:15:35 +00:00
Matthias Krüger
0e79b8914d Rollup merge of #143106 - yotamofek:pr/gce/non-local-ice, r=BoxyUwU
gce: don't ICE on non-local const

Fixes rust-lang/rust#133808

I have absolutely no idea what I'm doing here, but I followed `@BoxyUwU` 's [instructions](https://github.com/rust-lang/rust/issues/133808#issuecomment-3009122957), and turns out this small change fixes rust-lang/rust#133808, and doesn't seem to break anything else.
(This code path is only reachable when the GCE feature gate is enabled, so even if it does break in a way that is not caught by current test coverage, I guess it's not as bad as breaking stable or non-incomplete features?)

Anyways, r? `@BoxyUwU` , if you don't mind.
2025-06-27 22:13:07 +02:00
Matthias Krüger
0f89445e39 Rollup merge of #143104 - davidtwco:issue-142652-dyn-pointeesized-deny, r=compiler-errors
hir_analysis: prohibit `dyn PointeeSized`

Fixes rust-lang/rust#142652
Supersedes rust-lang/rust#142663

`dyn PointeeSized` is nonsensical as a `dyn PointeeSized` needs to be `MetaSized`, so lets reject it to avoid hitting code paths that expect a builtin impl for `PointeeSized`

r? `@compiler-errors`
2025-06-27 22:13:07 +02:00
Matthias Krüger
994ed31a96 Rollup merge of #143096 - RalfJung:tag_for_variant, r=compiler-errors
tag_for_variant: properly pass TypingEnv

Hard-coding `fully_monomorphized` here does not seem right...

This came up [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20VariantId.3DDiscriminant.20when.20tag.20is.20niche.20encoded.3F/with/526103956).
2025-06-27 22:13:06 +02:00
Matthias Krüger
088f6ab1c5 Rollup merge of #143092 - RalfJung:const-check-lifetime-ext, r=oli-obk
const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology

This error recently got changed in https://github.com/rust-lang/rust/pull/140942 to use the terminology of "top-level scope", but after further discussion in https://github.com/rust-lang/reference/pull/1865 it seems the reference will not be using that terminology after all. So let's also remove it from the compiler again, and let's focus on what actually happens with these temporaries: their lifetime is extended until the end of the program.

r? ``@oli-obk`` ``@traviscross``
2025-06-27 22:13:06 +02:00
Matthias Krüger
2d59c4e0fe Rollup merge of #143046 - RalfJung:zst-unsafe-cell, r=lcnr,oli-obk
const validation: properly ignore zero-sized UnsafeCell

Fixes https://github.com/rust-lang/rust/issues/142948
r? `@oli-obk`
2025-06-27 22:13:05 +02:00
Matthias Krüger
9108907a18 Rollup merge of #142806 - compiler-errors:norm-ct-has-ty, r=lcnr,BoxyUwU
Normalize before computing ConstArgHasType goal in new solver

This is a fix for rust-lang/rust#139905. See the description I left in the test.

I chose to fix this by normalizing the type before matching on its `.kind()` in `compute_const_arg_has_type_goal` (since it feels somewhat consistent with how we normalize types before assembling their candidates, for example); however, there are several other solutions that come to mind for fixing this ICE:
1. (this solution)
2. Giving `ConstKind::Error` a proper type, like `ConstKind::Value`, so that consts don't go from failing to passing `ConstArgHasType` goals after normalization (i.e. `UNEVALUATED` would normalize into a `ConstKind::Error(_, bool)` type rather than losing its type altogether).
3. Just suppressing the errors and accepting the fact that goals can go from fail->pass after normalization.

Thoughts? Happy to discuss this fix further.

r? `@BoxyUwU`
2025-06-27 22:13:03 +02:00
Matthias Krüger
190a1a7f74 Rollup merge of #142730 - bend-n:suggest_declaring_modules_when_file_found_but_module_not_defined, r=petrochenkov
suggest declaring modules when file found but module not defined

suggests declaring modules when a module is found but not defined, i.e
```
├── main.rs: `use thing::thang;`
└── thing.rs: `struct thang`
```
or
```
├── main.rs: `use thing::thang;`
└── thing
    └── mod.rs: `struct thang`
```
which currently is just
```rust
error[E0432]: unresolved import `yeah`
 --> src/main.rs:1:1
  |
1 | use thing::thang;
  |     ^^^^^ use of unresolved module or unlinked crate `thing`
  |
```
but now would have this nice help:
```text
= help: you may have forgotten to declare the module `thing`. use `mod thing` in this file to declare this module.
```
2025-06-27 22:13:02 +02:00
Matthias Krüger
9d15167921 Rollup merge of #140809 - bjorn3:panic_runtime_cleanup, r=petrochenkov
Reduce special casing for the panic runtime

See the individual commits for more info.
2025-06-27 22:13:01 +02:00
Matthias Krüger
36c2b011cb Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-dead
New const traits syntax

This PR only affects the AST and doesn't actually change anything semantically.

All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser

Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error

r? ``@fee1-dead``

cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27 22:13:00 +02:00
bors
bdaba05a95 Auto merge of #143064 - flip1995:clippy-subtree-update, r=GuillaumeGomez
Clippy subtree update

r? `@Manishearth`

Cargo.lock update due to version bump
2025-06-27 20:07:50 +00:00
Yotam Ofek
0e32036deb gce: don't ICE on non-local const 2025-06-27 18:07:07 +00:00
David Wood
2057423506 hir_analysis: prohibit dyn PointeeSized 2025-06-27 17:01:47 +00:00
Michael Goulet
ccbe9834fb Use one more let chain 2025-06-27 16:35:06 +00:00
Michael Goulet
66ea349392 Use let chains in the new solver 2025-06-27 16:29:48 +00:00
bors
fe5f3dedf7 Auto merge of #143091 - GuillaumeGomez:rollup-f300qwe, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#142270 (Rustdoc js: even more typechecking improvements)
 - rust-lang/rust#142420 (Report infer ty errors during hir ty lowering)
 - rust-lang/rust#142671 (add #![rustc_no_implicit_bounds])
 - rust-lang/rust#142721 (Add tracing to `InterpCx::layout_of()` )
 - rust-lang/rust#142818 (Port `#[used]` to new attribute parsing infrastructure)
 - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise)
 - rust-lang/rust#143051 (Add tracing to `validate_operand`)
 - rust-lang/rust#143060 (Only args in main diag are saved and restored without removing the newly added ones)
 - rust-lang/rust#143065 (Improve recovery when users write `where:`)
 - rust-lang/rust#143084 (const-eval: error when initializing a static writes to that static)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-27 16:10:20 +00:00