306566 Commits

Author SHA1 Message Date
bors
54a8a1db60 Auto merge of #146885 - lcnr:method-selection-opaques, r=BoxyUwU
support opaque types in method selection

See my notes in https://hackmd.io/4ILASx3mQ3u_gW9r1JyqCw.

This PR builds on https://github.com/rust-lang/rust/pull/145993 and allows not-yet defined opaque types as self types in the `method_autoderef_chain`.

E.g. for `Box<impl Deref<impl Foo>>` this results in the autoderef chain `Box<impl Deref> -> ?deref_hidden_ty -> ?foo_hidden_ty`. Method selection stays ambiguous if the final autoderef step is still an infer var unless that var is an opaque.

TODO: treating opaques as rigid jank.

r? `@BoxyUwU`
2025-09-26 16:10:47 +00:00
lcnr
c2e39c2f20 review 2025-09-26 16:37:08 +02:00
lcnr
d6fe533418 add tests 2025-09-26 16:33:15 +02:00
lcnr
eebf871fea move tests 2025-09-26 16:33:15 +02:00
lcnr
148fd9ad3c allow method calls on opaques 2025-09-26 16:33:15 +02:00
lcnr
6b379b560d use try_structurally_resolve_type for method receiver
We'll still error due to the `opt_bad_ty` of `method_autoderef_steps`.
This slightly worsens the span of `infer_var.method()` which is now the
same as for `Box::new(infer_var).method()`.

Unlike `structurally_resolve_type`, `probe_op` does not check whether
the infcx is already tainted, so this results in 2 previously not emitted
errors.
2025-09-26 16:33:15 +02:00
lcnr
70f6493f26 remove unnecessary structurally resolve
`autoderef` already resolved and `method_autoderef_steps` makes
sure we won't encounter an inference variable
2025-09-26 16:33:15 +02:00
lcnr
b70a15f5f6 predefined opaques to method_autoderef_steps 2025-09-26 16:33:15 +02:00
lcnr
1acd65cd6d predefined opaques use List 2025-09-26 16:33:15 +02:00
bors
a885811104 Auto merge of #146595 - Shourya742:make-cargo-test-work-for-self-test, r=Kobzol
Make cargo test work for  bootstrap self test

This PR enables the bootstrap self-test to run via cargo test. I have removed the detect_src_and_out test for now, but it will be reintroduced in a follow-up PR where all bootstrap tests will be migrated to use testCtx.

r? `@Kobzol`

try-job: aarch64-apple
2025-09-26 12:55:15 +00:00
bors
5b9007bfc3 Auto merge of #147054 - matthiaskrgr:rollup-660g92w, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#146283 (Resolve: (Ref)Cell wrappers to deny mutation during spec resolution.)
 - rust-lang/rust#146453 (Add general arm-linux.md platform doc.)
 - rust-lang/rust#146991 (const_caller_location to use real Span instead of `DUMMY_SP`)
 - rust-lang/rust#146994 (Add `clippy::unconditional_recursion` to `./x clippy ci`)
 - rust-lang/rust#147038 (Rename verbosity functions in bootstrap)
 - rust-lang/rust#147047 (rustdoc: put the toolbar on the all item index)
 - rust-lang/rust#147049 (std: fix warning in VEXos stdio module)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-26 07:45:10 +00:00
Matthias Krüger
87b8eca516
Rollup merge of #147049 - vexide:vex-std, r=workingjubilee
std: fix warning in VEXos stdio module

Fixes building `std` on the `armv7a-vex-v5` target due to an unnecessarily mutable argument in `Stdin`.

This was a stupid oversight on my part towards the end of rust-lang/rust#145973's review process. Missed a warning and had a bad bootstrap config that didn't tell me about it when testing changes.
2025-09-26 06:36:34 +02:00
Matthias Krüger
1285b164e1
Rollup merge of #147047 - notriddle:toolbar-index, r=GuillaumeGomez
rustdoc: put the toolbar on the all item index
2025-09-26 06:36:33 +02:00
Matthias Krüger
610a601f36
Rollup merge of #147038 - Kobzol:bootstrap-verbose-fn, r=jieyouxu
Rename verbosity functions in bootstrap

Just a small cleanup, these function names have been bothering me for a while. I realized that we can delete some of them outright, rather than just renaming them.

r? ``@jieyouxu``
2025-09-26 06:36:33 +02:00
Matthias Krüger
07d13a6469
Rollup merge of #146994 - cuviper:clippy-ci-recursion, r=Kobzol
Add `clippy::unconditional_recursion` to `./x clippy ci`

The clippy lint catches some things that rustc's equivalent builtin lint
does not, for example rust-lang/rust#146940:

    error: function cannot return without recursing
        --> library/std/src/path.rs:3428:5
         |
    3428 | /     fn eq(&self, other: &String) -> bool {
    3429 | |         self == &*other
    3430 | |     }
         | |_____^
         |
    note: recursive call site
        --> library/std/src/path.rs:3429:9
         |
    3429 |         self == &*other
         |         ^^^^^^^^^^^^^^^
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unconditional_recursion
         = note: requested on the command line with `-D clippy::unconditional-recursion`
2025-09-26 06:36:32 +02:00
Matthias Krüger
b184550f0e
Rollup merge of #146991 - cachebag:span-caller-location, r=RalfJung
const_caller_location to use real Span instead of `DUMMY_SP`

Clarifying usage of DUMMY_SP
2025-09-26 06:36:32 +02:00
Matthias Krüger
72fee890e2
Rollup merge of #146453 - thejpster:arm-linux-docs, r=petrochenkov
Add general arm-linux.md platform doc.

Adds a new page that covers all 32-bit Arm Linux systems. This means that we can reduce the amount of information required in the target specific pages to just the Tier level, the maintainer, and any specific details for that target.

I have no changed those pages yet, though. Let's start with this.
2025-09-26 06:36:31 +02:00
Matthias Krüger
82e9e54ef3
Rollup merge of #146283 - LorrensP-2158466:resolve-cm-cell, r=petrochenkov
Resolve: (Ref)Cell wrappers to deny mutation during spec resolution.

Introduces wrappers around `Cell` and `RefCell` that only allow mutation when we are not in speculative resolution. This is preparatory work for rust-lang/rust#145108.

It would allow us to make `ImportData` and `ModuleData` sync and send safe.

r? ``@petrochenkov``
2025-09-26 06:36:30 +02:00
bors
40ace17fc3 Auto merge of #145882 - m-ou-se:format-args-extend-1-arg, r=petrochenkov
Extended temporary argument to format_args!() in all cases

Fixes https://github.com/rust-lang/rust/issues/145880 by removing the special case.
2025-09-26 04:34:09 +00:00
bors
b733736ea2 Auto merge of #146919 - lcnr:yeet-fast-path, r=fee1-dead
remove incorrect fast path

Using `tcx.is_copy_modulo_regions` drops information from the current `typing_env`. Writing a regression test for this is really hard. We need to prove `Copy` of something that doesn't directly reference a coroutine or an opaque, but does so indirectly.

cc rust-lang/rust#146813.
2025-09-25 23:50:40 +00:00
Michael Howell
51ae86dec9 rustdoc-search: add test case for all/index.html search 2025-09-25 15:45:11 -07:00
Tropical
0ede3fe48c std: fix warning in VEXos stdio module 2025-09-25 16:34:20 -05:00
Michael Howell
8daad494b1 rustdoc: put the toolbar on the all item index 2025-09-25 14:19:22 -07:00
bors
7ac0330c6d Auto merge of #147037 - matthiaskrgr:rollup-xtgqzuu, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#116882 (rustdoc: hide `#[repr]` if it isn't part of the public ABI)
 - rust-lang/rust#135771 ([rustdoc] Add support for associated items in "jump to def" feature)
 - rust-lang/rust#141032 (avoid violating `slice::from_raw_parts` safety contract in `Vec::extract_if`)
 - rust-lang/rust#142401 (Add proper name mangling for pattern types)
 - rust-lang/rust#146293 (feat: non-panicking `Vec::try_remove`)
 - rust-lang/rust#146859 (BTreeMap: Don't leak allocators when initializing nodes)
 - rust-lang/rust#146924 (Add doc for `NonZero*` const creation)
 - rust-lang/rust#146933 (Make `render_example_with_highlighting` return an `impl fmt::Display`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 20:35:49 +00:00
Akrm Al-Hakimi
c98b3b2da4 const_caller_location: edit FIXME to explain use of DUMMY_SP
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-25 16:09:27 -04:00
bors
eabf390b4c Auto merge of #146697 - cjgillot:invalidate-patch, r=lcnr
Avoid invalidating CFG caches from MirPatch::apply.

Small effort to reduce invalidating CFG caches.
2025-09-25 17:19:29 +00:00
Josh Stone
a2d2869924 Add clippy::unconditional_recursion to ./x clippy ci
The clippy lint catches some things that rustc's equivalent builtin lint
does not, for example rust-lang/rust#146940:

    error: function cannot return without recursing
        --> library/std/src/path.rs:3428:5
         |
    3428 | /     fn eq(&self, other: &String) -> bool {
    3429 | |         self == &*other
    3430 | |     }
         | |_____^
         |
    note: recursive call site
        --> library/std/src/path.rs:3429:9
         |
    3429 |         self == &*other
         |         ^^^^^^^^^^^^^^^
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unconditional_recursion
         = note: requested on the command line with `-D clippy::unconditional-recursion`
2025-09-25 10:08:23 -07:00
Jakub Beránek
8ea9122c9b
Rename verbose to do_if_verbose 2025-09-25 18:55:59 +02:00
LorrensP-2158466
0374df1b50 Introduce and use CmCell during import resolution. 2025-09-25 18:38:36 +02:00
Matthias Krüger
c6d0059fb8
Rollup merge of #146933 - yotamofek:pr/rustdoc/highlight_no_write_str, r=GuillaumeGomez
Make `render_example_with_highlighting` return an `impl fmt::Display`

Removes some more usages of `write_str`. Shouldn't affect runtime, but makes the codebase a bit more consistent.
Each commit can be reviewed separately
2025-09-25 18:15:11 +02:00
Matthias Krüger
781f71a6fe
Rollup merge of #146924 - cptpiepmatz:doc-nonzero-const-creation, r=joboet
Add doc for `NonZero*` const creation

I ran into trouble using `NonZero*` values because I didn’t see any clear way to create them at compile time. At first I ended up using `NonZero*::new_unchecked` a lot, until I realized that `Option::unwrap` and `Option::expect` are `const` and can be used in a `const` context. With that, you can create non-zero values at compile time safely, without touching `unsafe`. This wasn’t obvious to me and my peers who’ve been using Rust for a while, so I thought adding a note to the docs would make it easier for others to discover.

If this should be worded differently or placed in another location, we can do that. I just want to make this more obvious.
2025-09-25 18:15:10 +02:00
Matthias Krüger
83cf8f9860
Rollup merge of #146859 - cammeresi:btree-alloc-20250920, r=joboet
BTreeMap: Don't leak allocators when initializing nodes

Memory was allocated via `Box::leak` and thence intended to be tracked and deallocated manually, but the allocator was also leaked, not tracked, and never dropped.  Now it is dropped immediately.

According to my reading of the `Allocator` trait, if a copy of the allocator remains live, then its allocations must remain live.  Since the B-tree has a copy of the allocator that will only be dropped after the nodes, it's safe to not store the allocator in each node (which would be a much more intrusive change).

Fixes: rust-lang/rust#106203
2025-09-25 18:15:09 +02:00
Matthias Krüger
fea9196e52
Rollup merge of #146293 - BenjaminBrienen:try_remove, r=joboet
feat: non-panicking `Vec::try_remove`

`if index < my_vector.len() { Some(my_vector.remove(index)) } else { None }` is annoying to write and non-panicking functions are broadly useful.

APC: https://github.com/rust-lang/libs-team/issues/649

Tracking issue: https://github.com/rust-lang/rust/issues/146954
2025-09-25 18:15:09 +02:00
Matthias Krüger
958d1438b6
Rollup merge of #142401 - oli-obk:pattern-mango, r=petrochenkov
Add proper name mangling for pattern types

requires adding demangler support first https://github.com/rust-lang/rustc-demangle/pull/81

needed for https://github.com/rust-lang/rust/pull/136006#discussion_r2139792593 as otherwise we will have symbol collisions
2025-09-25 18:15:08 +02:00
Matthias Krüger
e3f7626732
Rollup merge of #141032 - petrosagg:extract-if-ub, r=joboet
avoid violating `slice::from_raw_parts` safety contract in `Vec::extract_if`

The implementation of the `Vec::extract_if` iterator violates the safety contract adverized by `slice::from_raw_parts` by always constructing a mutable slice for the entire length of the vector even though that span of memory can contain holes from items already drained. The safety contract of `slice::from_raw_parts` requires that all elements must be properly
initialized.

As an example we can look at the following code:

```rust
let mut v = vec![Box::new(0u64), Box::new(1u64)];
for item in v.extract_if(.., |x| **x == 0) {
    drop(item);
}
```

In the second iteration a `&mut [Box<u64>]` slice of length 2 will be constructed. The first slot of the slice contains the bitpattern of an already deallocated box, which is invalid.

This fixes the issue by only creating references to valid items and using pointer manipulation for the rest. I have also taken the liberty to remove the big `unsafe` blocks in place of targetted ones with a SAFETY comment. The approach closely mirrors the implementation of `Vec::retain_mut`.

**Note to reviewers:** The diff is easier to follow with whitespace hidden.
2025-09-25 18:15:07 +02:00
Matthias Krüger
a028b7a9e3
Rollup merge of #135771 - GuillaumeGomez:jump-to-def-perf, r=fmease
[rustdoc] Add support for associated items in "jump to def" feature

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

r? ``@fmease``
2025-09-25 18:15:06 +02:00
Matthias Krüger
a39d5134cd
Rollup merge of #116882 - fmease:rustdoc-generalized-priv-repr-heuristic, r=rustdoc
rustdoc: hide `#[repr]` if it isn't part of the public ABI

> [!IMPORTANT]
> Temporarily stacked on top of PR https://github.com/rust-lang/rust/pull/146527; only the last commit is relevant!

Follow-up to rust-lang/rust#115439.
Unblocks rust-lang/rust#116743, CC ``@dtolnay.``

Fixes rust-lang/rust#66401.
Fixes rust-lang/rust#128364.
Fixes rust-lang/rust#137440.

Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise.

`--document-{private,hidden}-items` works as expected in this context, too.

Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
2025-09-25 18:15:06 +02:00
Jakub Beránek
5a6e3ccceb
Remove is_verbose_than function 2025-09-25 18:14:33 +02:00
Jakub Beránek
5595f437c7
Remove verbose_than function 2025-09-25 18:13:34 +02:00
Jakub Beránek
191c7ed10f
Make cargo test work again 2025-09-25 18:05:26 +02:00
Tim 'Piepmatz' Hesse
185ae698aa add doc for NonZero* const creation 2025-09-25 17:52:24 +02:00
bors
6f34f4ee07 Auto merge of #147019 - Zalathar:rollup-boxzbmo, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#145067 (RawVecInner: add missing `unsafe` to unsafe fns)
 - rust-lang/rust#145277 (Do not materialise X in [X; 0] when X is unsizing a const)
 - rust-lang/rust#145973 (Add `std` support for `armv7a-vex-v5`)
 - rust-lang/rust#146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization)
 - rust-lang/rust#146735 (unstably constify float mul_add methods)
 - rust-lang/rust#146737 (f16_f128: enable some more tests in Miri)
 - rust-lang/rust#146766 (Add attributes for #[global_allocator] functions)
 - rust-lang/rust#146905 (llvm: update remarks support on LLVM 22)
 - rust-lang/rust#146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`)
 - rust-lang/rust#147005 (Small string formatting cleanup)
 - rust-lang/rust#147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`)
 - rust-lang/rust#147008 (bootstrap.py: Respect build.jobs while building bootstrap tool)
 - rust-lang/rust#147013 (rustdoc: Fix documentation for `--doctest-build-arg`)
 - rust-lang/rust#147015 (Use `LLVMDisposeTargetMachine`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 14:03:21 +00:00
Jakub Beránek
079addf985
Ensure that --build-dir is always specified in tests 2025-09-25 15:07:34 +02:00
Stuart Cook
59866ef305
Rollup merge of #147015 - Zalathar:dispose-tm, r=lqd
Use `LLVMDisposeTargetMachine`

After bumping the minimum LLVM version to 20 (rust-lang/rust#145071), we no longer need to run any custom code when disposing of a TargetMachine, so we can just use the upstream LLVM-C function.
2025-09-25 20:32:00 +10:00
Stuart Cook
a6325412f8
Rollup merge of #147013 - fmease:fix-docs-doctest-build-arg, r=GuillaumeGomez
rustdoc: Fix documentation for `--doctest-build-arg`

In https://github.com/rust-lang/rust/pull/139863, I forgot to update the documentation.

Tracking issue: https://github.com/rust-lang/rust/issues/134172
2025-09-25 20:32:00 +10:00
Stuart Cook
fe4cceb73d
Rollup merge of #147008 - neuschaefer:bootstrap-jobs, r=Kobzol
bootstrap.py: Respect build.jobs while building bootstrap tool

On resource-constrained systems, it is vital to respect the value of build.jobs, in order to avoid overwhelming the available memory.
2025-09-25 20:31:59 +10:00
Stuart Cook
3053a18ec9
Rollup merge of #147007 - LawnGnome:tosocketaddrs-doc, r=tgross35
Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`

Although the examples below this list do imply that there's an impl of `ToSocketAddrs` for `&[SocketAddr]`, it's not actually noted in the list of default implementations.
2025-09-25 20:31:58 +10:00
Stuart Cook
62aa0ae29f
Rollup merge of #147005 - GuillaumeGomez:string-formatting-cleanup, r=jdonszelmann
Small string formatting cleanup

This PR is mostly useless. I was going through this file, saw that and corrected it. That's pretty much it. Feel free to close it if it's a bother.
2025-09-25 20:31:58 +10:00
Stuart Cook
231002f0c2
Rollup merge of #146982 - fmease:fix-rmake-linker-warning, r=bjorn3
Remove erroneous normalization step in `tests/run-make/linker-warning`

Fixes rust-lang/rust#146977.

r? bjorn3 or reassign
2025-09-25 20:31:57 +10:00
Stuart Cook
2565b27cc0
Rollup merge of #146905 - durin42:llvm-22-bitstream-remarks, r=nikic
llvm: update remarks support on LLVM 22

LLVM change dfbd76bda01e removed separate remark support entirely, but
it turns out we can just drop the parameter and everything appears to
work fine.

Fixes rust-lang/rust#146912 as far as I can tell (the test passes.)
2025-09-25 20:31:56 +10:00