Commit Graph

49486 Commits

Author SHA1 Message Date
binarycat
e31fed054b run spellcheck as a tidy extra check in ci 2025-08-16 09:51:44 -05:00
Deadbeef
4335405fa7 overhaul &mut suggestions in borrowck errors 2025-08-16 22:34:17 +08:00
León Orell Valerian Liehr
f8f7c27d4f Clean up parsers related to generic bounds 2025-08-16 16:15:58 +02:00
Deadbeef
3450975935 remove should_render in PrintAttribute derive 2025-08-16 21:41:39 +08:00
bors
2e2642e641 Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obk
Revert "Partially outline code inside the panic! macro".

This reverts https://github.com/rust-lang/rust/pull/115670

Without any tests/benchmarks that show some improvement, it's hard to know whether the change had any positive effect. (And if it did, whether that effect is still achieved today.)
2025-08-16 10:15:46 +00:00
Jana Dönszelmann
70e26c1b7b take attr style into account in attr diagnostics 2025-08-16 10:51:09 +02:00
Jonathan Brouwer
a69ba29a0f Fix deprecation attribute on foreign statics & types 2025-08-16 09:44:43 +02:00
Jonathan Brouwer
e8f90b12fc Don't show foreign types as an allowed target if the feature is not enabled 2025-08-16 09:44:39 +02:00
Zalathar
cf8ec6798f Remove LlvmArchiveBuilder and supporting code/bindings 2025-08-16 16:38:12 +10:00
León Orell Valerian Liehr
eb3e0d4c8a Properly recover from parenthesized use-bounds (precise capturing) 2025-08-16 01:21:35 +02:00
bors
1ae7c49072 Auto merge of #145475 - jhpratt:rollup-jr0wado, r=jhpratt
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#143717 (Add `Default` impls for `Pin`ned `Box`, `Rc`, `Arc`)
 - rust-lang/rust#144054 (Stabilize as_array_of_cells)
 - rust-lang/rust#144907 (fix: Reject async assoc fns of const traits/impls in ast_passes)
 - rust-lang/rust#144922 (Implement `#[derive(From)]`)
 - rust-lang/rust#144963 (Stabilize `core::iter::chain`)
 - rust-lang/rust#145436 (fix(tests/rmake/wasm-unexpected-features): change features from `WASM1` to `MVP`)
 - rust-lang/rust#145453 (Remove duplicated tracing span in bootstrap)
 - rust-lang/rust#145454 (Fix tracing debug representation of steps without arguments in bootstrap)
 - rust-lang/rust#145455 (Do not copy files in `copy_src_dirs` in dry run)
 - rust-lang/rust#145462 (Stabilize `const_exposed_provenance` feature)
 - rust-lang/rust#145466 (Enable new `[range-diff]` feature in triagebot)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-15 23:10:31 +00:00
Jacob Pratt
2b1a288dfc Rollup merge of #144922 - Kobzol:derive-from, r=nnethercote
Implement `#[derive(From)]`

Implements the `#[derive(From)]` feature ([tracking issue](https://github.com/rust-lang/rust/issues/144889), [RFC](https://github.com/rust-lang/rfcs/pull/3809)).

It allows deriving the `From` impl on structs and tuple structs with exactly one field. Some implementation notes:
- I wasn't exactly sure which spans to use in the derive generating code, so I just used `span` everywhere. I don't know if it's the Right Thing To Do. In particular the errors when `#[derive(From)]` is used on a struct with an unsized field are weirdly duplicated.
- I had to solve an import stability problem, where if I just added the unstable `macro From` to `core::convert`, previously working code like `use std::convert::From` would suddenly require an unstable feature gate, because rustc would think that you're trying to import the unstable macro. `@petrochenkov` suggested that I add the macro the the core prelude instead. This has worked well, although it only works in edition 2021+. Not sure if I botched the prelude somehow and it should live elsewhere (?).
- I had to add `Ty::AstTy`, because the `from` function receives an argument with the type of the single field, and the existing variants of the `Ty` enum couldn't represent an arbitrary type.
2025-08-15 18:13:28 -04:00
Jacob Pratt
d077146a15 Rollup merge of #144907 - ShoyuVanilla:no-const-async, r=fmease
fix: Reject async assoc fns of const traits/impls in ast_passes

Fixes rust-lang/rust#117629
2025-08-15 18:13:28 -04:00
bors
cd7cbe818e Auto merge of #142071 - lcnr:revealing-use, r=compiler-errors
`apply_member_constraints`: fix placeholder check

Checking whether the member region is *an existential region from a higher universe* is just wrong and I am pretty sure we've added that check by accident as the naming was just horribly confusing before rust-lang/rust#140466.

I've encountered this issue separately while working on rust-lang/rust#139587, but feel like it's probably easier to separately FCP this change. This allows the following code to compile
```rust
trait Proj<'a> {
    type Assoc;
}
impl<'a, 'b, F: FnOnce() -> &'b ()> Proj<'a> for F {
    type Assoc = ();
}

fn is_proj<F: for<'a> Proj<'a>>(f: F) {}
fn define<'a>() -> impl Sized + use<'a> {
    // This adds a use of `opaque::<'a>` with hidden type `&'unconstrained_b ()`.
    // 'unconstrained_b is an inference variable from a higher universe as it gets
    // created inside of the binder of `F: for<'a> Proj<'a>`. This previously
    // caused us to not apply member constraints. We now do, constraining
    // it to `'a`.
    is_proj(define::<'a>);
    &()
}

fn main() {}
```

This should not be breaking change, even in theory. Applying member constraints is incomplete in rare circumstances which means that applying them in more cases can cause spurious errors, cc rust-lang/rust#140569/rust-lang/rust#142073. However, as we always skipped these member regions in `apply_member_constraints` the skipped region is guaranteed to cause an error in `check_member_constraints` later on.
2025-08-15 18:52:12 +00:00
Samuel Moelius
c3c2c23e0d Extend QueryStability to handle IntoIterator implementations
Fix adjacent code

Fix duplicate warning; merge test into `tests/ui-fulldeps/internal-lints`

Use `rustc_middle::ty::FnSig::inputs`

Address two review comments

- https://github.com/rust-lang/rust/pull/139345#discussion_r2109006991
- https://github.com/rust-lang/rust/pull/139345#discussion_r2109058588

Use `Instance::try_resolve`

Import `rustc_middle::ty::Ty` as `Ty` rather than `MiddleTy`

Simplify predicate handling

Add more `#[allow(rustc::potential_query_instability)]` following rebase

Remove two `#[allow(rustc::potential_query_instability)]` following rebase

Address review comment

Update compiler/rustc_lint/src/internal.rs

Co-authored-by: lcnr <rust@lcnr.de>
2025-08-15 12:10:54 -04:00
Jake Goulding
c574c91e57 Demote x86_64-apple-darwin to Tier 2 with host tools
Switch to only using aarch64 runners (implying we are now
cross-compiling) and stop running tests. In the future, we could
enable (some?) tests via Rosetta 2.
2025-08-15 12:00:13 -04:00
Esteban Küber
8baab4cdf7 Detect missing derive on unresolved attribute even when not imported
```
error: cannot find attribute `sede` in this scope
  --> $DIR/missing-derive-3.rs:20:7
   |
LL |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Deserialize` and `Serialize` accept the similarly named `serde` attribute
   |
LL |     #[serde(untagged)]
   |         +

error: cannot find attribute `serde` in this scope
  --> $DIR/missing-derive-3.rs:14:7
   |
LL |     #[serde(untagged)]
   |       ^^^^^
   |
note: `serde` is imported here, but it is a crate, not an attribute
  --> $DIR/missing-derive-3.rs:4:1
   |
LL | extern crate serde;
   | ^^^^^^^^^^^^^^^^^^^
help: `serde` is an attribute that can be used by the derive macros `Deserialize` and `Serialize`, you might be missing a `derive` attribute
   |
LL + #[derive(Deserialize, Serialize)]
LL | enum B {
   |
```
2025-08-15 15:56:45 +00:00
bors
8b1889cc22 Auto merge of #145450 - Kobzol:rollup-cqclix0, r=Kobzol
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#144210 (std: thread: Return error if setting thread stack size fails)
 - rust-lang/rust#145310 (Reduce usage of `compiler_for` in bootstrap)
 - rust-lang/rust#145311 (ci: clean windows disk space in background)
 - rust-lang/rust#145340 (Split codegen backend check step into two and don't run it with `x check compiler`)
 - rust-lang/rust#145408 (Deduplicate -L search paths)
 - rust-lang/rust#145412 (Windows: Replace `GetThreadId`+`GetCurrentThread` with `GetCurrentThreadId`)
 - rust-lang/rust#145413 (bootstrap: Reduce dependencies)
 - rust-lang/rust#145426 (Fix typos in bootstrap.example.toml)
 - rust-lang/rust#145430 (Fix wrong spans with external macros in the `dropping_copy_types` lint)
 - rust-lang/rust#145431 (Enhance UI test output handling for runtime errors)
 - rust-lang/rust#145448 (Autolabel `src/tools/{rustfmt,rust-analyzer}` changes with `T-{rustfmt,rust-analyzer}`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-15 15:44:03 +00:00
Jakub Beránek
c97a9c82b2 Rollup merge of #145430 - Urgau:drop_forget_useless-145427, r=lqd
Fix wrong spans with external macros in the `dropping_copy_types` lint

This PR fixes some wrong spans manipulations when external macros are involved.

Specifically we didn't make sure the spans had the same context, which kind-of make our spans manipulations go wrong and produce weird spans. We fix that by making sure they have the same context.

Fixes https://github.com/rust-lang/rust/issues/145427
2025-08-15 16:04:01 +02:00
Jakub Beránek
30c967ddba Rollup merge of #145408 - Kobzol:deduplicate-search-paths, r=petrochenkov
Deduplicate -L search paths

For each -L passed to the compiler, we eagerly scan the whole directory. If it has a lot of files, that results in a lot of allocations. So it's needless to do this if some -L paths are actually duplicated (which can happen e.g. in the situation in the linked issue).

This PR both deduplicates the args, and also teaches rustdoc not to pass duplicated args to merged doctests.

Fixes: https://github.com/rust-lang/rust/issues/145375
2025-08-15 16:03:58 +02:00
bors
c018ae5389 Auto merge of #144991 - lcnr:ignore-usages-from-ignored-candidates, r=BoxyUwU
ignore head usages from ignored candidates

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/210. The test now takes 0.8s to compile, which seems good enough to me. We are actually still walking the entire graph here, we're just avoiding unnecessary reruns.

The basic idea is that if we've only accessed a cycle head inside of a candidate which didn't impact the final result of our goal, we don't need to rerun that cycle head even if is the used provisional result differs from the final result.

We also use this information when rebasing goals over their cycle heads. If a goal doesn't actually depend on the result of that cycle head, rebasing always succeeds. However, we still need to make sure we track the fact that we relied on the cycle head at all to avoid query instability.

It is implemented by tracking the number of `HeadUsages` for every head while evaluating goals. We then also track the head usages while evaluating a single candidate, which the search graph returns as `CandidateHeadUsages`. If there is now an always applicable candidate  candidate we know that all other candidates with that source did not matter. We then call `fn ignore_candidate_head_usages` to remove the usages while evaluating this single candidate from the total. If the final `HeadUsages` end up empty, we know that the result of this cycle head did not matter when evaluating its nested goals.
2025-08-15 12:35:09 +00:00
Zalathar
9e7d066928 Simplify the args_cstr_buff assertion 2025-08-15 20:24:13 +10:00
Zalathar
61932e1222 Avoid an unnecessary intermediate &mut reference
The `NonNull::as_mut` method returns a mut *reference*, rather than the mut
*pointer* that is intended here.
2025-08-15 20:24:13 +10:00
Zalathar
44f5ec7d56 Avoid an explicit cast from *const c_uchar to *const c_char
As noted in the `ffi` module docs, passing pointer/length byte strings from
Rust to C++ is easier if we declare them as `*const c_uchar` on the Rust side,
but `const char *` (possibly signed) on the C++ side. This is allowed because
both pointer types are ABI-compatible, regardless of char signedness.
2025-08-15 20:24:13 +10:00
Zalathar
8d0a04966c Declare module rustc_codegen_llvm::back in the normal way
Declaring these submodules directly in `lib.rs` was needlessly confusing.
2025-08-15 20:24:13 +10:00
Jakub Beránek
1f3a7471bf Implement #[derive(From)] 2025-08-15 12:07:15 +02:00
Jakub Beránek
e935a155c2 Create unstable From builtin macro and register it 2025-08-15 12:06:20 +02:00
Jakub Beránek
f39085bb37 Add derive_from unstable feature 2025-08-15 12:06:20 +02:00
bjorn3
f94a0d0ca4 Remove unused feature gate 2025-08-15 10:04:04 +00:00
bjorn3
460519a7f5 Merge link_name and export_name 2025-08-15 10:04:04 +00:00
Urgau
ae4eeb9299 Fix wrong spans with external macros in the dropping_copy_types lint 2025-08-15 11:59:23 +02:00
Zalathar
e193b5342b Use LLVMGetTypeKind 2025-08-15 19:35:35 +10:00
bjorn3
f3ef465ffb Combining no_mangle and rustc_std_internal_symbol is not allowed 2025-08-15 09:27:29 +00:00
bjorn3
4d62bf1634 All weak lang items have an explicit link name and vice versa 2025-08-15 09:21:18 +00:00
Sasha Pourcelot
51bccdd1ab Port #[custom_mir(..)] to the new attribute system 2025-08-15 11:19:29 +02:00
bors
ba412a6e70 Auto merge of #145423 - Zalathar:rollup-9jtefpl, r=Zalathar
Rollup of 21 pull requests

Successful merges:

 - rust-lang/rust#118087 (Add Ref/RefMut try_map method)
 - rust-lang/rust#122661 (Change the desugaring of `assert!` for better error output)
 - rust-lang/rust#142640 (Implement autodiff using intrinsics)
 - rust-lang/rust#143075 (compiler: Allow `extern "interrupt" fn() -> !`)
 - rust-lang/rust#144865 (Fix tail calls to `#[track_caller]` functions)
 - rust-lang/rust#144944 (E0793: Clarify that it applies to unions as well)
 - rust-lang/rust#144947 (Fix description of unsigned `checked_exact_div`)
 - rust-lang/rust#145004 (Couple of minor cleanups)
 - rust-lang/rust#145005 (strip prefix of temporary file names when it exceeds filesystem name length limit)
 - rust-lang/rust#145012 (Tail call diagnostics to include lifetime info)
 - rust-lang/rust#145065 (resolve: Introduce `RibKind::Block`)
 - rust-lang/rust#145120 (llvm: Accept new LLVM lifetime format)
 - rust-lang/rust#145189 (Weekly `cargo update`)
 - rust-lang/rust#145235 (Minor `[const]` tweaks)
 - rust-lang/rust#145275 (fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute)
 - rust-lang/rust#145322 (Resolve the prelude import in `build_reduced_graph`)
 - rust-lang/rust#145331 (Make std use the edition 2024 prelude)
 - rust-lang/rust#145369 (Do not ICE on private type in field of unresolved struct)
 - rust-lang/rust#145378 (Add `FnContext` in parser for diagnostic)
 - rust-lang/rust#145389 ([rustdoc] Revert "rustdoc search: prefer stable items in search results")
 - rust-lang/rust#145392 (coverage: Remove intermediate data structures from mapping creation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-15 09:13:10 +00:00
Shoyu Vanilla
2218ff1940 fix: Reject async assoc fns of const traits/impls in ast_passes 2025-08-15 16:31:10 +09:00
Stuart Cook
02efea51af Rollup merge of #145392 - Zalathar:create-mappings, r=petrochenkov
coverage: Remove intermediate data structures from mapping creation

The data structures in `coverage::mappings` were historically very useful for isolating the details of mapping-extraction from the details of how coverage mappings are stored in MIR.

But because of various changes that have taken place over time, they now provide little value, and cause difficulty for the coordinated changes that will be needed for introducing expansion mapping support.

In the future, the pendulum might eventually swing back towards these being useful again, but we can always reintroduce suitable intermediate data structures if and when that happens. For now, the simplicity of not having this intermediate layer is a higher priority.

There should be no changes to compiler output.
2025-08-15 16:16:43 +10:00
Stuart Cook
dc047f1385 Rollup merge of #145378 - xizheyin:144968, r=davidtwco
Add `FnContext` in parser for diagnostic

Fixes rust-lang/rust#144968

Inspired by https://github.com/rust-lang/rust/issues/144968#issuecomment-3156094581, I implemented `FnContext` to indicate whether a function should have a self parameter, for example, whether the function is a trait method, whether it is in an impl block. And I removed the outdated note.

I made two commits to show the difference.

cc ``@estebank`` ``@djc``

r? compiler
2025-08-15 16:16:41 +10:00
Stuart Cook
36515e780a Rollup merge of #145369 - estebank:issue-145367, r=compiler-errors
Do not ICE on private type in field of unresolved struct

Fix rust-lang/rust#145367.
2025-08-15 16:16:40 +10:00
Stuart Cook
14e2886028 Rollup merge of #145322 - LorrensP-2158466:early-prelude-processing, r=petrochenkov
Resolve the prelude import in `build_reduced_graph`

This pr tries to resolve the prelude import at the `build_reduced_graph` stage.
Part of batched import resolution in rust-lang/rust#145108 (cherry picked commit) and maybe needed for rust-lang/rust#139493.

r? petrochenkov
2025-08-15 16:16:39 +10:00
Stuart Cook
201e6324a7 Rollup merge of #145275 - StackOverflowExcept1on:fix-wasm32v1-none, r=alexcrichton
fix(compiler/rustc_codegen_llvm): apply `target-cpu` attribute

Resolves rust-lang/rust#140174

r? ```@alexcrichton```

try-job: `test-various*`
2025-08-15 16:16:38 +10:00
Stuart Cook
8f1202cef2 Rollup merge of #145235 - compiler-errors:comment, r=BoxyUwU
Minor `[const]` tweaks

Self explanatory
2025-08-15 16:16:38 +10:00
Stuart Cook
0166de2f87 Rollup merge of #145120 - maurer:llvm-time, r=nikic
llvm: Accept new LLVM lifetime format

In llvm/llvm-project#150248 LLVM removed the size parameter from the lifetime format. Tolerate not having that size parameter.
2025-08-15 16:16:37 +10:00
Stuart Cook
ed5279bbfe Rollup merge of #145065 - petrochenkov:riblock, r=davidtwco
resolve: Introduce `RibKind::Block`

to avoid confusing module items, blocks with items, and blocks without items.

Addresses https://github.com/rust-lang/rust/pull/143141#discussion_r2254893953 and https://github.com/rust-lang/rust/pull/143141#discussion_r2258004452.

A couple of related cleanups are also added on top.
2025-08-15 16:16:36 +10:00
Stuart Cook
711034f7a1 Rollup merge of #145012 - Kivooeo:fun-problem-fun-fix, r=compiler-errors
Tail call diagnostics to include lifetime info

Fixes https://github.com/rust-lang/rust/issues/144957

r? ```@WaffleLapkin``` ```@compiler-errors```
2025-08-15 16:16:35 +10:00
Stuart Cook
98bf7f93d4 Rollup merge of #145005 - tardyp:lto_big_filesize, r=bjorn3
strip prefix of temporary file names when it exceeds filesystem name length limit

When doing lto, rustc generates filenames that are concatenating many information.

In the case of this testcase, it is concatenating crate name and rust file name, plus some hash, and the extension. In some other cases it will concatenate even more information reducing the maximum effective crate name to about 110 chars on linux filesystems where filename max length is 255

This commit is ensuring that the temporary file names are limited in size, while still reasonably ensuring the unicity (with hashing of the stripped part)

Fix: rust-lang/rust#49914
2025-08-15 16:16:34 +10:00
Stuart Cook
60cb5502c1 Rollup merge of #145004 - bjorn3:remove_unused_fields, r=WaffleLapkin
Couple of minor cleanups
2025-08-15 16:16:33 +10:00
Stuart Cook
b955aa722e Rollup merge of #144944 - He1pa:E0793, r=compiler-errors
E0793: Clarify that it applies to unions as well

pick up inactive PR: https://github.com/rust-lang/rust/pull/131472

Also:
Adjust the language slightly to be more consistent with other similar messages (was created instead of got created).
Add a short section on union.
Add an example line showing referencing a field in a packed struct is safe if the field's type isn't more strictly aligned than the pack.

r? compiler-errors
2025-08-15 16:16:32 +10:00
Stuart Cook
44eb7a167c Rollup merge of #144865 - WaffleLapkin:track-tail, r=lqd
Fix tail calls to `#[track_caller]` functions

We want `#[track_caller]` to be semver independent, i.e. it should not be a breaking change to add or remove it. Since it changes ABI of a function (adding an additional argument) we have to be careful to preserve this property when adding tail calls.

The only way to achieve this that I can see is:
- we forbid tail calls in functions which are marked with `#[track_caller]` (already implemented)
- tail-calling a `#[track_caller]` marked function downgrades the tail-call to a normal call (or equivalently tail-calls the shim made by fn def to fn ptr cast) (this pr)

Ideally the downgrade would be performed by a MIR pass, but that requires post mono MIR opts (cc ```@saethlin,``` rust-lang/rust#131650). For now I've changed code in cg_ssa to accomodate this behaviour (+ added a hack to mono collector so that the shim is actually generated)

Additionally I added a lint, although I don't think it's strictly necessary.

Alternative to rust-lang/rust#144762 (and thus closes rust-lang/rust#144762)
Fixes https://github.com/rust-lang/rust/issues/144755
2025-08-15 16:16:31 +10:00