Commit Graph

21219 Commits

Author SHA1 Message Date
Jakub Beránek
1f3a7471bf Implement #[derive(From)] 2025-08-15 12:07:15 +02:00
Jakub Beránek
c0839ea7d2 Add feature gate test 2025-08-15 12:06:20 +02:00
Urgau
ae4eeb9299 Fix wrong spans with external macros in the dropping_copy_types lint 2025-08-15 11:59:23 +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
ywxt
36ab1bf367 Add more tests 2025-08-15 14:16:47 +08:00
Stuart Cook
21d37d0c15 Rollup merge of #145389 - GuillaumeGomez:unstable-search, r=fmease
[rustdoc] Revert "rustdoc search: prefer stable items in search results"

Reverts https://github.com/rust-lang/rust/pull/141658 and reverts https://github.com/rust-lang/rust/pull/145349.

Reopens https://github.com/rust-lang/rust/issues/138067.

r? ```@fmease```
2025-08-15 16:16:42 +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
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
ywxt
e17989edc7 Add the directive compare-output-by-lines 2025-08-15 14:16:32 +08: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
Stuart Cook
603b61df57 Rollup merge of #143075 - workingjubilee:interrupts-may-return-nevermore, r=davidtwco
compiler: Allow `extern "interrupt" fn() -> !`

While reviewing rust-lang/rust#142633 I overlooked a few details because I was kind of excited.

- Fixes rust-lang/rust#143072
2025-08-15 16:16:31 +10:00
Stuart Cook
e3a178234d Rollup merge of #142640 - Sa4dUs:ad-intrinsic, r=ZuseZ4
Implement autodiff using intrinsics

This PR aims to move autodiff logic to `autodiff` intrinsic. Allowing us to delete a great part of our frontend code and overall, simplify the compilation pipeline of autodiff functions.
2025-08-15 16:16:30 +10:00
Stuart Cook
1eeb8e8b15 Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov
Change the desugaring of `assert!` for better error output

In the desugaring of `assert!`, we now expand to a `match` expression instead of `if !cond {..}`.

The span of incorrect conditions will point only at the expression, and not the whole `assert!` invocation.

```
error[E0308]: mismatched types
  --> $DIR/issue-14091.rs:2:13
   |
LL |     assert!(1,1);
   |             ^ expected `bool`, found integer
```

We no longer mention the expression needing to implement the `Not` trait.

```
error[E0308]: mismatched types
  --> $DIR/issue-14091-2.rs:15:13
   |
LL |     assert!(x, x);
   |             ^ expected `bool`, found `BytePos`
```

Now `assert!(val)` desugars to:

```rust
match val {
    true => {},
    _ => $crate::panic::panic_2021!(),
}
```

Fix #122159.
2025-08-15 16:16:29 +10:00
bors
8800ec1665 Auto merge of #144591 - RalfJung:pattern-valtrees, r=BoxyUwU
Patterns: represent constants as valtrees

Const patterns are always valtrees now. Let's represent that in the types. We use `ty::Value` for this since it nicely packages value and type, and has some convenient methods.

Cc `@Nadrieril` `@BoxyUwU`
2025-08-15 05:49:54 +00:00
bors
3507a749b3 Auto merge of #145407 - Kobzol:rollup-g6yhx82, r=Kobzol
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#137872 (Include whitespace in "remove |" suggestion and make it hidden)
 - rust-lang/rust#144631 (Fix test intrinsic-raw_eq-const-bad for big-endian)
 - rust-lang/rust#145233 (cfg_select: Support unbraced expressions)
 - rust-lang/rust#145261 (Improve tracing in bootstrap)
 - rust-lang/rust#145324 (Rename and document `ONLY_HOSTS` in bootstrap)
 - rust-lang/rust#145353 (bootstrap: Fix jemalloc 64K page support for aarch64 tools)
 - rust-lang/rust#145379 (bootstrap: Support passing `--timings` to cargo)
 - rust-lang/rust#145397 (Rust documentation, use `rustc-dev-guide` :3)
 - rust-lang/rust#145398 (Use `default_field_values` in `Resolver`)
 - rust-lang/rust#145401 (cleanup: Remove useless `[T].iter().last()`)
 - rust-lang/rust#145403 (Adjust error message grammar to be less awkward)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-14 23:30:10 +00:00
Josh Triplett
354fcf2b52 mbe: Handle applying macro_rules derives
Add infrastructure to apply a derive macro to arguments, consuming and
returning a `TokenTree` only.

Handle `SyntaxExtensionKind::MacroRules` when expanding a derive, if the
macro's kinds support derive.

Add tests covering various cases of `macro_rules` derives.

Note that due to a pre-existing FIXME in `expand.rs`, derives are
re-queued and some errors get emitted twice. Duplicate diagnostic
suppression makes them not visible, but the FIXME should still get
fixed.
2025-08-14 14:23:05 -07:00
Josh Triplett
8fb98ef368 mbe: Parse macro derive rules
This handles various kinds of errors, but does not allow applying the
derive yet.

This adds the feature gate `macro_derive`.
2025-08-14 13:53:57 -07:00
Jakub Beránek
069892180b Rollup merge of #145403 - shepmaster:grammar, r=estebank
Adjust error message grammar to be less awkward

r? ``@estebank``
2025-08-14 21:48:48 +02:00
Jakub Beránek
01bd889098 Rollup merge of #145233 - joshtriplett:cfg-select-expr, r=jieyouxu
cfg_select: Support unbraced expressions

Tracking issue for `cfg_select`: rust-lang/rust#115585

When operating on expressions, `cfg_select!` can now handle expressions
without braces. (It still requires braces for other things, such as
items.)

Expand the test coverage and documentation accordingly.

---

I'm not sure whether deciding to extend `cfg_select!` in this way is T-lang or T-libs-api. I've labeled for both, with the request that both teams don't block on each other. :)
2025-08-14 21:48:42 +02:00
Jakub Beránek
fadd083512 Rollup merge of #144631 - fneddy:fix_be_test_intrinsic_const_bad, r=compiler-errors
Fix test intrinsic-raw_eq-const-bad for big-endian

The test fails on s390x and presumably other big-endian systems, due to print of raw values. To fix the tests remove the raw output values in the error note with normalize-stderr.
2025-08-14 21:48:42 +02:00
Jakub Beránek
18afb69767 Rollup merge of #137872 - estebank:extra-vert, r=compiler-errors
Include whitespace in "remove |" suggestion and make it hidden

Tweak error rendering of patterns with an extra `|` on either end.

Built on #137409. Only last commit is relevant.

? ``@compiler-errors``
2025-08-14 21:48:41 +02:00
bors
898aff704d Auto merge of #145085 - JonathanBrouwer:target_checking, r=jdonszelmann
Rework target checking for built-in attributes

This is a refactoring of target checking for built-in attributes.
This PR has the following goals:
- Only refactor the 80% of the attributes that are simple to target check. More complicated ones like `#[repr]` will be in a future PR. Tho I have written the code in such a way that this will be possible to add in the future.
- No breaking changes.
  - This part of the codebase is not very well tested though, we can do a crater run if we want to be sure.
  - I've spotted quite a few weird situations (like I don't think an impl block should be deprecated?). We can propose fixing these to  in a future PR

Fixes https://github.com/rust-lang/rust/issues/143780
Fixes https://github.com/rust-lang/rust/issues/138510

I've split it in commits and left a description on some of the commits to help review.
r? `@jdonszelmann`
2025-08-14 19:38:35 +00:00
Marcelo Domínguez
cdd4118204 Update autodiff tests for the new intrinsics impl 2025-08-14 18:33:43 +00:00
Kivooeo
51df1dad6c fixed diagnostic 2025-08-14 17:28:50 +00:00
Jake Goulding
65d329d189 Adjust error message grammar to be less awkward 2025-08-14 12:50:07 -04:00
Jonathan Brouwer
4bb7bf64e0 Update uitests
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-14 18:18:42 +02:00
Esteban Küber
caadc8df35 Do not ICE on private type in field of unresolved struct 2025-08-14 15:59:32 +00:00
Vadim Petrochenkov
f369e066e6 resolve: Add one more test case for "binding is available in a different scope" help 2025-08-14 18:50:58 +03:00
lcnr
3ebf611005 it's not a borrow checker limitation :< 2025-08-14 17:43:39 +02:00
Esteban Küber
9dfee2ef35 fix alignment test 2025-08-14 15:41:54 +00:00
bors
be00ea1968 Auto merge of #144542 - sayantn:stabilize-sse4a-tbm, r=Amanieu,traviscross
Stabilize `sse4a` and `tbm` target features

This PR stabilizes the feature flag `sse4a_target_feature` and `tbm_target_feature` (tracking issue rust-lang/rust#44839).

# Public API
The 2 `x86` target features `sse4a` and `tbm`

Also, these were added in LLVM2.6 and LLVM3.4-rc1, respectively, and as the minimum LLVM required for rustc is LLVM19, we are safe in that front too!

As all of the required tasks have been done (adding the target features to rustc, implementing their runtime detection in std_detect and implementing the associated intrinsics in core_arch), these target features can be stabilized now. The intrinsics were stabilized *long* ago, in 1.27.0

Reference PR:

- https://github.com/rust-lang/reference/pull/1949

cc `@rust-lang/lang`

`@rustbot` label I-lang-nominated
r? lang
2025-08-14 14:01:12 +00:00
lcnr
aa3691ea08 add regression test 2025-08-14 15:32:50 +02:00
xizheyin
3ce555f631 Add FnContext in parser for diagnostic
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-08-14 21:31:47 +08:00
xizheyin
f5bc29568c Add test suggest-self-in-bare-function
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-08-14 21:31:36 +08:00
LorrensP-2158466
ff560d3c9a resolve prelude import at build_reduced_graph phase 2025-08-14 15:28:35 +02:00
Nicholas Nethercote
8296ad0456 Print regions in type_name.
Currently they are skipped, which is a bit weird, and it sometimes
causes malformed output like `Foo<>` and `dyn Bar<, A = u32>`.

Most regions are erased by the time `type_name` does its work. So all
regions are now printed as `'_` in non-optional places. Not perfect, but
better than the status quo.

`c_name` is updated to trim lifetimes from MIR pass names, so that the
`PASS_NAMES` sanity check still works. It is also renamed as
`simplify_pass_type_name` and made non-const, because it doesn't need
to be const and the non-const implementation is much shorter.

The commit also renames `should_print_region` as
`should_print_optional_region`, which makes it clearer that it only
applies to some regions.

Fixes #145168.
2025-08-14 21:13:06 +10:00
Guillaume Gomez
a195cf63b8 Revert "rustdoc search: prefer stable items in search results"
This reverts commit 1140e90074.
2025-08-14 13:06:05 +02:00
Guillaume Gomez
762b7ecdb0 Rollup merge of #145372 - petrochenkov:noresmacpath, r=jackh726
resolve: Miscellaneous cleanups

See individual commits.

All noticed when reviewing recent PRs to name resolution.
2025-08-14 11:39:41 +02:00
Guillaume Gomez
707e956946 Rollup merge of #145361 - xizheyin:145294, r=compiler-errors
Suppress wrapper suggestion when expected and actual ty are the same adt and the variant is unresolved

Fixes rust-lang/rust#145294

I initially tried the desired suggestion in this issue, but since that suggestion occurs in the expected type, it is inappropriate to suggest for expected expressions (see other suggest methods in the same file). I believe that suppressing the incorrect suggestion is the more appropriate choice here.

I opted for a slightly more general approach: when the expected type and actual type are the same ADT (e.g., both are Result in this example), we assume that code tend to compare the internal generic parameters(i.e. `Option<&str>` vs `Option<String>`, instead of `E = _` vs `Result<Option<String>>>`). When `E` is an unresolved infer type in the expected type (`_` in this example), we should not wrapp the actual type.

Two commits show the difference.

r? compiler
2025-08-14 11:39:40 +02:00
Guillaume Gomez
44d3217c20 Rollup merge of #145323 - scrabsha:push-pqwvmznzzmpr, r=jdonszelmann
Port the `#[linkage]` attribute to the new attribute system

r? `@jdonszelmann`
2025-08-14 11:39:39 +02:00
Guillaume Gomez
952584942c Rollup merge of #145250 - fmease:regr-test-for-attr-meta-ice, r=jdonszelmann
Add regression test for a former ICE involving helper attributes containing interpolated tokens

Add regression test for rust-lang/rust#140612 from rust-lang/rust#140601 or rather rust-lang/rust#140859 that only added it to `stable` not `master`.
Supersedes https://github.com/rust-lang/rust/pull/140584.

r? `@jdonszelmann` or anyone
2025-08-14 11:39:37 +02:00
Guillaume Gomez
f676dd8729 Rollup merge of #140434 - a4lg:rustdoc-multi-footnote-refs, r=fmease,GuillaumeGomez
rustdoc: Allow multiple references to a single footnote

Multiple references to a single footnote is a part of GitHub Flavored Markdown syntax (although not explicitly documented as well as regular footnotes, it is implemented in GitHub's fork of CommonMark) and not prohibited by rustdoc.

cf. <587a12bb54/test/extensions.txt (L762-L780)>

However, using it makes multiple `sup` elements with the same `id` attribute, which is invalid per the HTML specification.

Still, not only this is a valid GitHub Flavored Markdown syntax, this is helpful on certain cases and actually tested (accidentally) in `tests/rustdoc/footnote-reference-in-footnote-def.rs`.

This commit keeps track of the number of references per footnote and gives unique ID to each reference.
It also emits *all* back links from a footnote to its references as "↩" (return symbol) plus a numeric list in superscript.

As a known limitation, it assumes that all references to a footnote are rendered (this is not always true if a dangling footnote has one or more references but considered a reasonable compromise).

Also note that, this commit is designed so that no HTML changes will occur unless multiple references to a single footnote is actually used.
2025-08-14 11:39:32 +02:00
StackOverflowExcept1on
3a250b7939 rewrite test with #![no_core] 2025-08-14 12:26:51 +03:00