Commit Graph

303456 Commits

Author SHA1 Message Date
Samuel Moelius cbfa17a993 Reorder lto options from most to least optimizing 2025-08-17 12:55:04 -04:00
Miguel Ojeda 1a29d9c23f Add -Zindirect-branch-cs-prefix option
This is intended to be used for Linux kernel RETPOLINE builds.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-08-17 16:51:42 +02:00
Alice Ryhl 1cd7080c3a Add -Zindirect-branch-cs-prefix (from draft PR) 2025-08-17 16:50:23 +02:00
bohan 9878616a3d resolve: debug for block module 2025-08-17 22:37:42 +08:00
Samuel Moelius 3b0ff9cb69 Add //@ ignore-stage1 to query_stability.rs test 2025-08-17 10:32:13 -04:00
sayantn 40fc7df963 Add runtime detection for APX-F and AVX10 2025-08-17 19:34:18 +05:30
bors 425a9c0a0e Auto merge of #145284 - nnethercote:type_name-print-regions, r=lcnr
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 rust-lang/rust#145168.

r? `@lcnr`
2025-08-17 10:24:20 +00:00
Sebastien Marie 8792010768 Rust build fails on OpenBSD after using file_lock feature
PR 130999 added the file_lock feature, but doesn't included OpenBSD in the supported targets (Tier 3 platform), leading to a compilation error ("try_lock() not supported").
2025-08-17 09:01:28 +02:00
bors 99ba556567 Auto merge of #144081 - RalfJung:const-ptr-fragments, r=oli-obk
const-eval: full support for pointer fragments

This fixes https://github.com/rust-lang/const-eval/issues/72 and makes `swap_nonoverlapping` fully work in const-eval by enhancing per-byte provenance tracking with tracking of *which* of the bytes of the pointer this one is. Later, if we see all the same bytes in the exact same order, we can treat it like a whole pointer again without ever risking a leak of the data bytes (that encode the offset into the allocation). This lifts the limitation that was discussed quite a bit in https://github.com/rust-lang/rust/pull/137280.

For a concrete piece of code that used to fail and now works properly consider this example doing a byte-for-byte memcpy in const without using intrinsics:
```rust
use std::{mem::{self, MaybeUninit}, ptr};

type Byte = MaybeUninit<u8>;

const unsafe fn memcpy(dst: *mut Byte, src: *const Byte, n: usize) {
    let mut i = 0;
    while i < n {
        *dst.add(i) = *src.add(i);
        i += 1;
    }
}

const _MEMCPY: () = unsafe {
    let ptr = &42;
    let mut ptr2 = ptr::null::<i32>();
    // Copy from ptr to ptr2.
    memcpy(&mut ptr2 as *mut _ as *mut _, &ptr as *const _ as *const _, mem::size_of::<&i32>());
    assert!(*ptr2 == 42);
};
```
What makes this code tricky is that pointers are "opaque blobs" in const-eval, we cannot just let people look at the individual bytes since *we don't know what those bytes look like* -- that depends on the absolute address the pointed-to object will be placed at. The code above "breaks apart" a pointer into individual bytes, and then puts them back together in the same order elsewhere. This PR implements the logic to properly track how those individual bytes relate to the original pointer, and to recognize when they are in the right order again.

We still reject constants where the final value contains a not-fully-put-together pointer: I have no idea how one could construct an LLVM global where one byte is defined as "the 3rd byte of a pointer to that other global over there" -- and even if LLVM supports this somehow, we can leave implementing that to a future PR. It seems unlikely to me anyone would even want this, but who knows.^^

This also changes the behavior of Miri, by tracking the order of bytes with provenance and only considering a pointer to have valid provenance if all bytes are in the original order again. This is related to https://github.com/rust-lang/unsafe-code-guidelines/issues/558. It means one cannot implement XOR linked lists with strict provenance any more, which is however only of theoretical interest. Practically I am curious if anyone will show up with any code that Miri now complains about - that would be interesting data. Cc `@rust-lang/opsem`
2025-08-17 04:33:31 +00:00
Josh Triplett bc9725c1ea Indent some code inside cfg_select!
The previous code inside `cfg_if!` wasn't indented, so the conversion to
`cfg_select!` left it not indented. Indent it.
2025-08-16 16:01:08 -07:00
binarycat 2050a3b297 std: fix more typos 2025-08-16 13:36:29 -05:00
binarycat 0d797d23cf typos: allow moreso 2025-08-16 13:36:29 -05:00
binarycat d73e6b46e7 tidy: add better error reporting for if typos can't be run 2025-08-16 13:36:29 -05:00
binarycat 6a51eef11b tidy: run typos check in src root, not current dir 2025-08-16 13:36:29 -05:00
binarycat 1cb4fd7dd1 tidy now installs typos-cli as-needed via cargo 2025-08-16 13:36:29 -05:00
Camille Gillot f35d001325 Visit and print async_fut local for async drop. 2025-08-16 18:26:27 +00:00
Deadbeef e78b41703f refactor return type of suggest_ampmut into an enum 2025-08-17 01:33:49 +08:00
Pascal S. de Kloe 1f77424a79 fmt::DisplayInt abstraction obsolete with better macro 2025-08-16 18:33:20 +02:00
Camille Gillot a84373085e Simplify span_data_to_lines_and_cols. 2025-08-16 16:23:21 +00:00
Camille Gillot 6c15339017 Simplify decode_span. 2025-08-16 16:21:23 +00:00
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
Josh Triplett 1ae4a0cc34 library: Migrate from cfg_if to cfg_select
Migrate the standard library from using the external `cfg_if` crate to
using the now-built-in `cfg_select` macro.

This does not yet eliminate the dependency from
`library/std/Cargo.toml`, because while the standard library itself no
longer uses `cfg_if`, it also incorporates the `backtrace` crate, which
does.

Migration assisted by the following vim command (after selecting the
full `cfg_if!` invocation):

```
'<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e
```

This is imperfect, but substantially accelerated the process. This
prompts for confirmation on the `} else {` since that can also appear
inside one of the arms. This also requires manual intervention to handle
any multi-line conditions.
2025-08-16 05:28:31 -07:00
Urgau e906a59ebb Fix unicode_data.rs mention message 2025-08-16 12:55:23 +02: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
Jakub Beránek 814b8e682c Only check std in cross-compilation instead of building it 2025-08-16 11:24:19 +02:00
Jana Dönszelmann 70e26c1b7b take attr style into account in attr diagnostics 2025-08-16 10:51:09 +02:00
Jakub Beránek ddf39cabf2 Avoid copying rustc rmeta artifacts into the build compiler sysroot
This helps to avoid polluting the sysroot of the build compiler.
2025-08-16 09:49:18 +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
Jakub Beránek cdea62dc44 Optimize copy_src_dirs 2025-08-16 08:57:05 +02:00
Jakub Beránek 5107ac92bb Do not call fs::remove_file in cp_link_filtered_recurse
The target is removed by `copy_link` too, so no need to duplicate the syscall.
2025-08-16 08:56:41 +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
Alan Urmancheev 9fab380839 Fix typo in doc for library/std/src/fs.rs#set_permissions
"privalage" -> "privilege"
2025-08-16 02:30:18 +04:00
Jacob Pratt cf28e2b0d5 Rollup merge of #145466 - Urgau:triagebot-range-diff, r=Kobzol
Enable new `[range-diff]` feature in triagebot

This new feature adds a comment to triagebot range-diff feature when a PR is rebased  onto a different base/master commit.

Related to [#t-compiler > Experimental range-diff for force-push @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Experimental.20range-diff.20for.20force-push/near/534649322)

r? Kobzol
2025-08-15 18:13:33 -04:00
Jacob Pratt 2a9bb562ff Rollup merge of #145462 - Kivooeo:stabilize-const_exposed_provenance, r=RalfJung
Stabilize `const_exposed_provenance` feature

This closes [tracking issue](https://github.com/rust-lang/rust/issues/144538) and stabilises `fn with_exposed_provenance` and `fn with_exposed_provenance_mut` in const
2025-08-15 18:13:32 -04:00
Jacob Pratt 56e9a67d16 Rollup merge of #145455 - Kobzol:bootstrap-copy-src-dirs-dry-run, r=jieyouxu
Do not copy files in `copy_src_dirs` in dry run

This reduces the time to run the current 9 dist snapshot tests from ~24s to ~2s on my PC.

r? `@jieyouxu`
2025-08-15 18:13:32 -04:00
Jacob Pratt 4fa90ef799 Rollup merge of #145454 - Kobzol:bootstrap-fix-step-debug-repr, r=jieyouxu
Fix tracing debug representation of steps without arguments in bootstrap

I was wondering why I see `lainSourceTarbal` in tracing logs...

r? `@jieyouxu`
2025-08-15 18:13:31 -04:00
Jacob Pratt 71adb87994 Rollup merge of #145453 - Kobzol:bootstrap-cmd-span, r=jieyouxu
Remove duplicated tracing span in bootstrap

`trace_cmd` is now called also in the `stream` method, so including it also here was duplicating command spans.

r? `@jieyouxu`
2025-08-15 18:13:31 -04:00
Jacob Pratt 58c08c512b Rollup merge of #145436 - StackOverflowExcept1on:patch-1, r=alexcrichton
fix(tests/rmake/wasm-unexpected-features): change features from `WASM1` to `MVP`

missed this in rust-lang/rust#145275
since test calls `rustc` with  `-C target-cpu mvp`
try-job: `test-various`
2025-08-15 18:13:30 -04:00
Jacob Pratt 2776a21a4f Rollup merge of #144963 - rossmacarthur-forks:stabilize-core-iter-chain, r=jhpratt
Stabilize `core::iter::chain`

Closes rust-lang/rust#125964
2025-08-15 18:13:29 -04: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
Jacob Pratt 7a05f26a3b Rollup merge of #144054 - jsimmons:stabilize-as-array-of-cells, r=tgross35
Stabilize as_array_of_cells

This PR stabilizes

```rust
impl<T, const N: usize> Cell<[T; N]> {
    pub const fn as_array_of_cells(&self) -> &[Cell<T>; N];
}
```

Stabilization report: https://github.com/rust-lang/rust/issues/88248#issuecomment-3082986863
Closes: https://github.com/rust-lang/rust/issues/88248
2025-08-15 18:13:27 -04:00
Jacob Pratt 41e40f3630 Rollup merge of #143717 - Jules-Bertholet:pin-default, r=dtolnay
Add `Default` impls for `Pin`ned `Box`, `Rc`, `Arc`

Fixes rust-lang/rust#143688.

`@rustbot` label T-libs-api needs-fcp

Also needs a crater run, as the `Box` impls could theoretically be breaking due to `#[fundamental]` (though a [cursory search](https://github.com/search?q=%2Fimpl%28%3C.*%3E%29%3F+Default+for+Pin%3C%2F+path%3A*.rs&type=code) suggests this is unlikely to cause issues).
2025-08-15 18:13:26 -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