Commit Graph

308721 Commits

Author SHA1 Message Date
Stuart Cook 78526e4720 Rollup merge of #148057 - Enselic:hwasan-fix-v2, r=nagisa
tests/ui/sanitizer/hwaddress.rs: Run on aarch64 and remove cgu hack

To avoid linker errors like

    relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against `.data.rel.ro..L.hwasan'

we need to have `-C target-feature=+tagged-globals`, which is documented [here](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#hwaddresssanitizer).  I learned that [here](https://github.com/llvm/llvm-project/pull/164876#issuecomment-3439034858).

Closes rust-lang/rust#83989

try-job: aarch64-gnu
2025-10-28 20:39:36 +11:00
Stuart Cook bfa7219a3a Rollup merge of #148044 - jyn514:compiletest-logging, r=Zalathar
compiletest: show output in debug logging

I had a test I was confused by; the root issue is that `error-pattern` runs before normalization, even though `//~ ERROR` runs after normalization. This logging caught the issue immediately.
2025-10-28 20:39:36 +11:00
Stuart Cook 07e505fcf4 Rollup merge of #148013 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
1.91.0 release notes

This imports https://github.com/rust-lang/rust/issues/147010 into a PR in preparation for the release next week. It also imports a subset of the Cargo release notes (cc ```@rust-lang/cargo).```

r? ```@rust-lang/release```

```@triagebot``` ping relnotes-interest-group
2025-10-28 20:39:35 +11:00
Stuart Cook b770888039 Rollup merge of #147915 - pirama-arumuga-nainar:patch-1, r=lqd
Update target maintainers android.md
2025-10-28 20:39:34 +11:00
Stuart Cook 1cf3dc6b5a Rollup merge of #147840 - jdonszelmann:unsizing-coercions, r=lcnr
Rework unsizing coercions in the new solver

Replaces https://github.com/rust-lang/rust/pull/141926, contains:

- a commit adding tests that fail before this work
- the two commits from the previous PR
- a commit in which these tests are fixed
- finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better?

I hope this is roughly what you had in mind

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/241 and https://github.com/rust-lang/trait-system-refactor-initiative/issues/238, adding tests for both

r? ````@lcnr````
2025-10-28 20:39:33 +11:00
Stuart Cook ef8003bbb9 Rollup merge of #147185 - RalfJung:repr-c-not-zst, r=petrochenkov
repr(transparent): do not consider repr(C) types to be 1-ZST

Context: https://github.com/rust-lang/unsafe-code-guidelines/issues/552

This experiments with a [suggestion](https://github.com/rust-lang/rfcs/pull/3845#discussion_r2388463698) by ```@RustyYato``` to stop considering repr(C) types as 1-ZST for the purpose of repr(transparent). If we go with https://github.com/rust-lang/rfcs/pull/3845 (or another approach for fixing repr(C)), they will anyway not be ZST on all targets any more, so this removes a portability hazard. Furthermore, zero-sized repr(C) structs [may have to be treated](https://github.com/rust-lang/unsafe-code-guidelines/issues/552#issuecomment-3250657813) as non-ZST for the win64 ABI (at least that's what gcc/clang do), so allowing them to be ignored in repr(transparent) types is not entirely coherent.

Turns out we already have an FCW for repr(transparent), namely https://github.com/rust-lang/rust/issues/78586. This extends that lint to also check for repr(C).
2025-10-28 20:39:32 +11:00
Stuart Cook 68618a8f92 Rollup merge of #144936 - rcvalle:rust-cfi-fix-144641, r=lcnr
CFI: Fix types that implement Fn, FnMut, or FnOnce

When looking for instances which could either be dynamically called through a vtable or through a concrete trait method, we missed `FnPtrShim`, instead only looking at `Item` and closure-likes. Fixes rust-lang/rust#144641.

cc ```@1c3t3a``` ```@Jakob-Koschel```
2025-10-28 20:39:32 +11:00
bors df984edf44 Auto merge of #147083 - dianne:non-extended-indices, r=matthewjasper
Do not lifetime-extend array/slice indices

When lowering non-overloaded indexing operations to MIR, this uses the temporary lifetime of the index expression for the index temporary, rather than applying the temporary lifetime of the indexing operation as a whole to the index.

For example, in
```rust
let x = &xs[i];
```
previously, the temporary containing the result of evaluating `i` would live until the end of the block due to the indexing operation being [lifetime-extended](https://doc.rust-lang.org/nightly/reference/destructors.html#temporary-lifetime-extension). Under this PR, the index temporary only lives to the end of the `let` statement because it uses the more precise temporary lifetime of the index expression.

I don't think this will affect semantics in an observable way, but the more precise `StorageDead` placement may slightly improve analysis/codegen performance.

r? mir
2025-10-28 03:02:00 +00:00
pirama-arumuga-nainar 610b82ef0c Update target maintainers android.md 2025-10-27 17:04:42 -07:00
Ramon de C Valle 20d3d576d5 CFI: Rewrite FnPtrShim when generalizing
When looking for instances which could either be dynamically called
through a vtable or through a concrete trait method, we missed
`FnPtrShim`, instead only looking at `Item` and closure-likes.
2025-10-27 11:32:40 -07:00
Ralf Jung b9b29c4379 repr(transparent): do not consider repr(C) types to be 1-ZST 2025-10-27 19:25:14 +01:00
bors adaa838976 Auto merge of #148035 - bjorn3:check_skip_codegen_crate, r=madsmtm
Skip codegen_crate call in check mode

This way we don't have to spawn the coordinator thread. Some errors will no longer be emitted with this in check mode. For example the check that `-Ctarget-cpu` is passed on targets that need this.

Suggested by `@saethlin`
2025-10-27 17:24:08 +00:00
Josh Stone 83cb889bc8 Link to i32 for strict_div/rem methods
Co-authored-by: Kevin Reid <kpreid@switchb.org>
2025-10-27 09:45:28 -07:00
bors 9ea8d67cc6 Auto merge of #148167 - Zalathar:rollup-njf167h, r=Zalathar
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#145939 (const `select_unpredictable`)
 - rust-lang/rust#147478 (More intuitive error when using self to instantiate tuple struct with private field)
 - rust-lang/rust#147866 (Add built-in `const` impls for `Clone` and `Copy`)
 - rust-lang/rust#148153 (Fix duplicate 'the the' typos in comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-27 14:12:58 +00:00
Jana Dönszelmann 17566221f8 find the right error source when we can't unsize 2025-10-27 12:26:52 +01:00
Stuart Cook 791165cc73 Rollup merge of #148153 - osamakader:fix-duplicate-the, r=JonathanBrouwer
Fix duplicate 'the the' typos in comments

Fix duplicate 'the the' typos in comments
2025-10-27 22:13:23 +11:00
Stuart Cook 2e575e0022 Rollup merge of #147866 - fee1-dead-contrib:constclonebuiltin, r=lcnr
Add built-in `const` impls for `Clone` and `Copy`

cc `@compiler-errors`
2025-10-27 22:13:22 +11:00
Stuart Cook 0bd2437cac Rollup merge of #147478 - Jamesbarford:fix/tuple-private-fields-constructor, r=davidtwco
More intuitive error when using self to instantiate tuple struct with private field

Fixes https://github.com/rust-lang/rust/issues/147343
2025-10-27 22:13:21 +11:00
Stuart Cook 537a778ac3 Rollup merge of #145939 - clarfonthey:const-select-unpredictable, r=oli-obk
const `select_unpredictable`

Tracking issue: rust-lang/rust#145938
2025-10-27 22:13:21 +11:00
bors 4b53279854 Auto merge of #148040 - saethlin:trivial-consts, r=oli-obk
Add a fast path for lowering trivial consts

The objective of this PR is to improve compilation performance for crates that define a lot of trivial consts. This is a flamegraph of a build of a library crate that is just 100,000 trivial consts, taken from a nightly compiler:
<img width="842" height="280" alt="2025-10-25-164005_842x280_scrot" src="https://github.com/user-attachments/assets/e5400aaf-03bd-4461-b905-054aa82ca60f" />
My objective is to target all of the cycles in `eval_to_const_value_raw` that are not part of `mir_built`, because if you look at the `mir_built` for a trivial const, we already have the value available.

In this PR, the definition of a trivial const is this:
```rust
const A: usize = 0;
```
Specifically, we look for if the `mir_built` body is a single basic block containing one assign statement and a return terminator, where the assign statement assigns an `Operand::Constant(Const::Val)`. The MIR dumps for these look like:
```
const A: usize = {
    let mut _0: usize;

    bb0: {
        _0 = const 0_usize;
        return;
    }
}
```

The implementation is built around a new query, `trivial_const(LocalDefId) -> Option<(ConstValue, Ty)>` which returns the contents of the `Const::Val` in the `mir_built` if the `LocalDefId` is a trivial const.

Then I added _debug_ assertions to the beginning of `mir_for_ctfe` and `mir_promoted` to prevent trying to get the body of a trivial const, because that would defeat the optimization here. But these are deliberately _debug_ assertions because the consequence of failing the assertion is that compilation is slow, not corrupt. If we made these hard assertions, I'm sure there are obscure scenarios people will run into where the compiler would ICE instead of continuing on compilation, just a bit slower. I'd like to know about those, but I do not think serving up an ICE is worth it.

With the assertions in place, I just added logic around all the places they were hit, to skip over trying to analyze the bodies of trivial consts.

In the future, I'd like to see this work extended by:
* Pushing detection of trivial consts before MIR building
* Including DefKind::Static and DefKind::InlineConst
* Including consts like `_1 = const 0_usize; _0 = &_1`, which would make a lot of promoteds into trivial consts
* Handling less-trivial consts like `const A: usize = B`, which have `Operand::Constant(Const::Unevaluated)`
2025-10-27 11:02:41 +00:00
Jana Dönszelmann 3d9cb043dd prove both newly added tests are fixed by the changes 2025-10-27 12:00:41 +01:00
Jana Dönszelmann 349dbecdab move old solver coercion code to separate function 2025-10-27 12:00:41 +01:00
bors 34a8c7368c Auto merge of #148163 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to https://github.com/rust-lang/rust-analyzer/commit/049767e6faa84b2d1a951d8f227e6ebd99d728a2.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2025-10-27 07:56:13 +00:00
bors 23fced0fcc Auto merge of #146069 - camsteffen:range-desugar-span, r=SparrowLii
Mark desugared range expression spans with DesugaringKind::RangeExpr

This is a prerequisite to removing `QPath::LangItem` (rust-lang/rust#115178) because otherwise there would be no way to detect a range expression in the HIR.

There are some non-obvious Clippy changes so a Clippy team review would be good.
2025-10-27 02:50:35 +00:00
Ben Kimock a63035f9bf Explain that the current impl is only silly, not recursive 2025-10-26 22:13:12 -04:00
Ben Kimock 6ba56d227f Move trivial_const to a separate module with a doc comment 2025-10-26 22:09:33 -04:00
ltdk 6f649e4e1a const select_unpredictable 2025-10-26 21:33:00 -04:00
bors b1b464d6f6 Auto merge of #147914 - petrochenkov:oosmc-used, r=fmease
resolve: When suppressing `out_of_scope_macro_calls` suppress `unused_imports` as well

Fixes the example from this comment - https://github.com/rust-lang/rust/issues/147823#issuecomment-3421770900.
Fixes https://github.com/rust-lang/rust/issues/148143.
2025-10-26 23:44:52 +00:00
Osama Abdelkader 2aa314c024 Fix duplicate 'the the' typos in comments
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
2025-10-27 00:37:43 +03:00
bors f37aa9955f Auto merge of #147890 - tmiasko:deduce-captures-none, r=cjgillot
Deduce captures(none) for a return place and parameters

Extend attribute deduction to determine whether parameters using
indirect pass mode might have their address captured. Similarly to
the deduction of `readonly` attribute this information facilitates
memcpy optimizations.
2025-10-26 20:37:03 +00:00
Deadbeef 042018df2d respond to review 2025-10-26 19:57:05 +00:00
Deadbeef 744c670812 Add built-in const impls for Clone and Copy 2025-10-26 19:40:59 +00:00
Chayim Refael Friedman f7c1ad66cb Merge pull request #20914 from ShoyuVanilla/next-solver-tests
Add regression tests for some fixed `A-ty` issues
2025-10-26 17:41:19 +00:00
bors f977dfc388 Auto merge of #146992 - GuillaumeGomez:improve-highlight, r=yotamofek,lolbinarycat
Improve source code for `highlight.rs`

I was very bothered by the complexity of this file, in particular the handling of `pending_elems` which was very tricky to follow.

So instead, here comes a more sane approach: the content is store in a stack-like type which handles "levels" of HTML (ie, a macro expansion can contain other HTML tags which can themselves contain other, etc). Making it much simpler to keep track of what's going on.

r? `@lolbinarycat`
2025-10-26 17:31:22 +00:00
Shoyu Vanilla 85b7d646cd Add regression tests for some fixed A-ty issues 2025-10-27 02:18:52 +09:00
Shoyu Vanilla (Flint) f62cb389c4 Merge pull request #20913 from A4-Tacks/if-let-chain-for-is-method-with-if-let
Fix not applicable on let-chain for replace_is_method_with_if_let_method
2025-10-26 14:48:02 +00:00
bors 2888098522 Auto merge of #148003 - aDotInTheVoid:rustdoc-postcard-compiletest-groundwork, r=jieyouxu
compiletest: pass rustdoc mode as param, rather than implicitly

Spun out of https://github.com/rust-lang/rust/pull/142642

In the future, I want the rustdoc-json test suite to invoke rustdoc twice, once with `--output-format=json`, and once with the (not yet implemented) `--output-format=postcard` flag.

Doing that requires being able to explicitly tell the `.document()` function which format to use, rather then implicitly using json in the rustdoc-json suite, and HTML in all others.

r? `@jieyouxu`

CC `@jalil-salame`
2025-10-26 14:24:14 +00:00
Lukas Wirth 165065ae1e Merge pull request #20837 from osdyne/extension-configuration
Add an Extension Config API
2025-10-26 12:34:05 +00:00
Michael Gruenewald ce94044ff9 Don't add cargo to requiresServerReloadOpts 2025-10-26 13:22:52 +01:00
A4-Tacks 95e2b8444a Fix not applicable on let-chain for replace_is_method_with_if_let_method
Example
---
```rust
fn main() {
    let x = Some(1);
    let cond = true;
    if cond && x.is_som$0e() {}
}
```

**Before this PR**

Assist not applicable

**After this PR**

```rust
fn main() {
    let x = Some(1);
    let cond = true;
    if cond && let Some(${0:x1}) = x {}
}
```
2025-10-26 19:55:09 +08:00
bors 58b4453fbd Auto merge of #148136 - Zalathar:rollup-73hkwv8, r=Zalathar
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#148118 (Improve the ICE message for invalid nullary intrinsic calls)
 - rust-lang/rust#148134 (Add myself as a windows-msvc maintainer)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-26 11:17:09 +00:00
Stuart Cook cdacfb8158 Rollup merge of #148134 - Fulgen301:maintainer, r=Noratrieb
Add myself as a windows-msvc maintainer

As mentioned on the RPLCS Discord, I'd like to become a maintainer for windows-msvc.

r? `@jieyouxu`
2025-10-26 22:15:09 +11:00
Stuart Cook 3bf838d790 Rollup merge of #148118 - saethlin:nullary-intrinsic-check-bug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls

In https://github.com/rust-lang/rust/issues/148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.

I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.

The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when https://github.com/rust-lang/rust/pull/147793 ported two more the paragraph wasn't added. I've added it.
2025-10-26 22:15:09 +11:00
George Tokmaji e873f13454 Add myself as a windows-msvc maintainer 2025-10-26 10:58:04 +01:00
Lukas Wirth 3145078e66 Merge pull request #19918 from A4-Tacks/remove-else-branches
Add ide-assist: remove else branches
2025-10-26 08:35:08 +00:00
Lukas Wirth 64326b2d6a Merge pull request #20589 from A4-Tacks/extract-mod-not-in-impl
Fix extract multiple item in impl for extract_module
2025-10-26 08:25:00 +00:00
Lukas Wirth dbfbe8f742 Merge pull request #20712 from A4-Tacks/destruct-tuple-shorthand
Fix shorthand field pat for destructure_tuple_binding
2025-10-26 08:18:40 +00:00
Lukas Wirth 10066b373b Merge pull request #20705 from A4-Tacks/flip-range
Add ide-assist: flip_range_expr
2025-10-26 08:17:15 +00:00
Lukas Wirth 6c18a87141 Merge pull request #20764 from A4-Tacks/fix-guarded-rhs-let-else
Fix let-expr in lhs for convert_to_guarded_return
2025-10-26 08:06:08 +00:00
Lukas Wirth 9c7db53595 Merge pull request #20912 from A4-Tacks/left-side-in-cond
Fix not complete `let` before expr in condition
2025-10-26 07:19:04 +00:00