1
Fork 0
Commit graph

286843 commits

Author SHA1 Message Date
Vadim Petrochenkov
38f7060a73 Revert "Deduplicate template parameter creation"
This reverts commit 6adc2c1fd6.
2025-04-15 21:00:11 +03:00
Josh Triplett
043c5ff982 Add warning comment to Take::get_ref and Chain::get_ref
The methods `Take::get_mut` and `Chain::get_mut` include comments
warning about modifying the I/O state of the underlying reader. However,
many readers (e.g. `File`) allow I/O using a shared reference (e.g.
`&File`). So, add the same caveat to the `get_ref` methods.
2025-04-15 10:54:08 -07:00
bors
414da5b63d Auto merge of #138906 - thaliaarchi:unsupported-test-exe, r=bjorn3
Reject test executables when not supported by target

Currently, compiling tests for SOLID produces an ICE, because SOLID does not support executables.

See https://github.com/rust-lang/rust/issues/138047
2025-04-15 16:05:15 +00:00
reddevilmidzy
812095031b Add test for issue 125668 2025-04-15 23:51:10 +09:00
Jason Newcomb
52694034ba Add copy_within to IndexSlice 2025-04-15 10:44:28 -04:00
Waffle Lapkin
8934ac5759
add a comment for code that isn't 2025-04-15 15:02:05 +02:00
Waffle Lapkin
dda4d7bc44
slightly correct comments and diagnostics about checking modifications
I feel like they are still wrong, but maybe less so .-.

The `info:` was unhelpful -- we only use upstream in CI nowdays.
2025-04-15 15:02:05 +02:00
Waffle Lapkin
52f4b16075
use helper function instead of writing rustfmt stamp by hand 2025-04-15 15:02:05 +02:00
Waffle Lapkin
502b630cd1
tidy: don't crush on non-existent submodules 2025-04-15 15:01:56 +02:00
Jakub Beránek
3c01dfe2ae
Rename is_builder_target to is_host_target 2025-04-15 14:13:53 +02:00
Jakub Beránek
2907ab5bf9
Move is_builder_target, is_system_llvm and is_rust_llvm from Builder to Config 2025-04-15 14:12:48 +02:00
Obei Sideg
ee53c26b41
Add explicit_extern_abis unstable feature
also add `explicit-extern-abis` feature section to
the unstable book.
2025-04-15 14:33:19 +03:00
bors
40dacd50b7 Auto merge of #139632 - Darksonn:cfi-fmt, r=m-ou-se
cfi: do not transmute function pointers in formatting code

Follow-up to #115954.
Addresses #115199 point 2.
Related to #128728.
Discussion [on the LKML](https://lore.kernel.org/all/20250410115420.366349-1-panikiel@google.com/).

cc `@maurer` `@rcvalle` `@RalfJung`
2025-04-15 11:11:31 +00:00
MarcoIeni
73065b9484
CI: rename MacOS runner 2025-04-15 12:28:32 +02:00
Mara Bos
1ca9300989 Update tests. 2025-04-15 11:14:23 +02:00
Mara Bos
d20b270b4e Don't name macro internals in "does not live long enough" errors. 2025-04-15 11:14:23 +02:00
Mara Bos
1dd77cd24a Implement pin!() using super let. 2025-04-15 11:14:21 +02:00
León Orell Valerian Liehr
6242335fdb
Improve diagnostic for E0178 (bad + in type)
Namely, use a more sensical primary span.
Don't pretty-print AST nodes for the diagnostic message. Why:
* It's lossy (e.g., it doesn't replicate trailing `+`s in trait objects.
* It's prone to leak error nodes (printed as `(/*ERROR*/)`) since
  the LHS can easily represent recovered code (e.g., `fn(i32?) + T`).
2025-04-15 10:08:49 +02:00
León Orell Valerian Liehr
8887af72a0
Improve parse errors for lifetimes in type position 2025-04-15 10:08:36 +02:00
Jakub Beránek
c49b0bdb1a
Use rust-cache to speed-up citool compilation 2025-04-15 10:04:25 +02:00
bors
f433fa46b0 Auto merge of #139845 - Zalathar:rollup-u5u5y1v, r=Zalathar
Rollup of 17 pull requests

Successful merges:

 - #138374 (Enable contracts for const functions)
 - #138380 (ci: add runners for vanilla LLVM 20)
 - #138393 (Allow const patterns of matches to contain pattern types)
 - #139517 (std: sys: process: uefi: Use NULL stdin by default)
 - #139554 (std: add Output::exit_ok)
 - #139660 (compiletest: Add an experimental new executor to replace libtest)
 - #139669 (Overhaul `AssocItem`)
 - #139671 (Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file})
 - #139750 (std/thread: Use default stack size from menuconfig for NuttX)
 - #139772 (Remove `hir::Map`)
 - #139785 (Let CStrings be either 1 or 2 byte aligned.)
 - #139789 (do not unnecessarily leak auto traits in item bounds)
 - #139791 (drop global where-bounds before merging candidates)
 - #139798 (normalize: prefer `ParamEnv` over `AliasBound` candidates)
 - #139822 (Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix)
 - #139833 (Fix some HIR pretty-printing problems)
 - #139836 (Basic tests of MPMC receiver cloning)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-15 08:02:23 +00:00
Waffle Lapkin
6c441cc7a5
canonicalize test build dir before normalizing it
Fix fixes failures of the following tests when build directory is a
symlink:
- `tests/ui/error-codes/E{0464,0523}.rs`
- `tests/ui/crate-loading/crateresolve{1,2}.rs` (those are the same tests)
2025-04-15 09:46:22 +02:00
Waffle Lapkin
1397dabd1e
fix typo 2025-04-15 09:42:30 +02:00
Waffle Lapkin
fc8df06f4f
update submodules if the directory doesn't exist 2025-04-15 09:42:25 +02:00
mejrs
4ac3877521 unstable book; document macro_metavar_expr_concat 2025-04-15 09:28:04 +02:00
Alice Ryhl
6513df9652 Add comment
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-04-15 07:25:42 +00:00
Alice Ryhl
1cbdfab75d Use full path for core::mem::transmute
Suggested-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
2025-04-15 07:24:35 +00:00
Tamir Duberstein
2009ca6d88 Remove #![feature(no_sanitize)] 2025-04-15 07:24:34 +00:00
Nicholas Nethercote
c12b4aade0 Use a dummy ident for a lint_if_path_starts_with_module call.
This is pretty weird code. As the `HACK` comment indicates, we push the
empty ident here only to make the path longer, so certain checks to
occur within `lint_if_path_starts_with_module`. `dummy` is a better
choice because it explicitly communicates that the actual value doesn't
matter.
2025-04-15 16:05:13 +10:00
Nicholas Nethercote
2b43e66496 Remove a kw::Empty usage in symbol mangling.
Field names are never empty, so the unwrap is unnecessary.
2025-04-15 16:05:13 +10:00
Nicholas Nethercote
f3847f0639 Remove some "name isn't empty" assertions.
These were low value even before #137978 resulted in empty names being
used much less. (Why check for non-emptiness in these three places?
There are thousands of places in the compiler you could check.)
2025-04-15 16:04:11 +10:00
Stuart Cook
783b08156e
Rollup merge of #139836 - glyn:test-mpmc-receiver-cloning, r=jhpratt
Basic tests of MPMC receiver cloning

Ref: https://github.com/rust-lang/rust/issues/126840#issuecomment-2802321146
2025-04-15 15:47:32 +10:00
Stuart Cook
4d5284a866
Rollup merge of #139833 - nnethercote:fix-139633, r=oli-obk
Fix some HIR pretty-printing problems

r? `@oli-obk`
2025-04-15 15:47:32 +10:00
Stuart Cook
45b644b3c1
Rollup merge of #139822 - 0x79de:fix-eopnotsupp-mapping, r=dtolnay
Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix

This change maps the EOPNOTSUPP errno value (95) to std::io::ErrorKind::Unsupported in the decode_error_kind function for Unix platforms. Previously, it was incorrectly mapped to ErrorKind::Uncategorized.

Fixes #139803
2025-04-15 15:47:31 +10:00
Stuart Cook
b21c5cd025
Rollup merge of #139798 - lcnr:where-bounds-gt-alias-bound, r=compiler-errors
normalize: prefer `ParamEnv` over `AliasBound` candidates

cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/175 not the only issue affecting bevy sadly

r? ``@compiler-errors``
2025-04-15 15:47:30 +10:00
Stuart Cook
e8c9dcc79e
Rollup merge of #139791 - lcnr:ignore-global-where-bounds, r=compiler-errors
drop global where-bounds before merging candidates

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/172

r? ```@compiler-errors```
2025-04-15 15:47:30 +10:00
Stuart Cook
8118fca7fd
Rollup merge of #139789 - lcnr:opaques-auto-trait-leakage, r=compiler-errors
do not unnecessarily leak auto traits in item bounds

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/158

Not a fix for https://github.com/rust-lang/trait-system-refactor-initiative/issues/173 as you may have realized/tried yourself, cc #139788. However, fixing this feels desirable regardless and I don't see any reason not to.

r? ```@compiler-errors```
2025-04-15 15:47:29 +10:00
Stuart Cook
5a9455f560
Rollup merge of #139785 - fneddy:fix_test_cstring_merging_alignment, r=Mark-Simulacrum
Let CStrings be either 1 or 2 byte aligned.

We see a regression on the `tests/assembly/cstring-merging.rs` test on s390x.

Some architectures (like s390x) require strings to be 2 byte aligned. Therefor the section name will be marked with a .2  postfix on this architectures.

Allowing a section name with a .1 or .2 postfix will make the test pass on either platform.
2025-04-15 15:47:29 +10:00
Stuart Cook
9d6c95d146
Rollup merge of #139772 - nnethercote:rm-hir-Map, r=Zalathar
Remove `hir::Map`

A follow-up to https://github.com/rust-lang/rust/pull/139232.

r? `@Zalathar`
2025-04-15 15:47:28 +10:00
Stuart Cook
36df54881d
Rollup merge of #139750 - no1wudi:fix, r=tgross35
std/thread: Use default stack size from menuconfig for NuttX

* Update comments to clarify the usage of zero as an indication for default stack size configuration
* Adjust conditional compilation to reflect the changes in stack size handling for the NuttX platform

This change improves clarity and consistency in stack size configuration across platforms.
2025-04-15 15:47:28 +10:00
Stuart Cook
bc4e7ad248
Rollup merge of #139671 - m-ou-se:proc-macro-span, r=dtolnay
Proc macro span API redesign: Replace proc_macro::SourceFile by Span::{file, local_file}

Simplification/redesign of the unstable proc macro span API, tracked in https://github.com/rust-lang/rust/issues/54725:

Before:

```rust
impl Span {
    pub fn line(&self) -> usize;
    pub fn column(&self) -> usize;
    pub fn source_file(&self) -> SourceFile;
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SourceFile { .. }

impl !Send for SourceFile {}
impl !Sync for SourceFile {}

impl SourceFile {
    pub fn path(&self) -> PathBuf;
    pub fn is_real(&self) -> bool;
}
```

After:

```rust
impl Span {
    pub fn line(&self) -> usize;
    pub fn column(&self) -> usize;
    pub fn file(&self) -> String; // Mapped file name, for display purposes.
    pub fn local_file(&self) -> Option<PathBuf>; // Real file name as it exists on disk.
}
```

This resolves the last blocker for stabilizing these methods. (Stabilizing will be a separate PR with FCP.)
2025-04-15 15:47:27 +10:00
Stuart Cook
13cd5256ac
Rollup merge of #139669 - nnethercote:overhaul-AssocItem, r=oli-obk
Overhaul `AssocItem`

`AssocItem` has multiple fields that only make sense some of the time. E.g. the `name` can be empty if it's an RPITIT associated type. It's clearer and less error prone if these fields are moved to the relevant `kind` variants.

r? ``@fee1-dead``
2025-04-15 15:47:27 +10:00
Stuart Cook
efcf4f9d2d
Rollup merge of #139660 - Zalathar:new-executor, r=jieyouxu
compiletest: Add an experimental new executor to replace libtest

This PR adds a new "executor" to compiletest for running the list of collected tests, to eventually replace the current dependency on unstable libtest internals.

The new executor is currently inactive by default. It must be activated explicitly by passing `-n` or `--new-executor` to compiletest, e.g. `./x test ui -- -n`.

(After some amount of wider manual testing, the new executor will hopefully be made the default, and the libtest dependency can be removed. Contributors should not notice any change.)

The new executor is a stripped-down rewrite of the subset of libtest needed by compiletest.

# Supported functionality
- Specifying the number of concurrent tests with `RUST_TEST_THREADS`
- Filtering and skipping tests by name (substring or exact-match)
- Forcibly running ignored tests with `--ignored`
- Optional fail-fast with `--fail-fast`
- JSON output, compatible with bootstrap's parser for libtest output
- Running each test in its own thread
- Short backtraces that ignore the executor itself
- Slow test detection, with a hard-coded timeout of 60 seconds
- Capturing stdout/stderr, via `#![feature(internal_output_capture)]`
- Suppressing output capture with `--no-capture`

# Unsupported functionality
- Non-JSON output, as this is handled by bootstrap instead
- Separate code path for concurrency=1, as the concurrent path should handle this case naturally
- Fallback to running tests synchronously if new threads can't be spawned
- Special handling of hosts that don't support basic functionality like threads or timers
  - Our ability to test *targets* should be unaffected
- Graceful handling of some edge cases that could occur in arbitrary user-written unit tests, but would represent bugs in compiletest
- Due to the current need for output capture, the new executor is still not entirely written in stable Rust

---
r? jieyouxu
2025-04-15 15:47:26 +10:00
Stuart Cook
6a9d27d320
Rollup merge of #139554 - lolbinarycat:std-output-exit_ok, r=tgross35
std: add Output::exit_ok

approved in ACP https://github.com/rust-lang/libs-team/issues/554

Tracking issue: https://github.com/rust-lang/rust/issues/84908
2025-04-15 15:47:26 +10:00
Stuart Cook
46b197ad3b
Rollup merge of #139517 - Ayush1325:uefi-cmd-stdin-null, r=joboet
std: sys: process: uefi: Use NULL stdin by default

According to the docs in `Command::output`:

> By default, stdout and stderr are captured (and used to provide the
resulting output). Stdin is not inherited from the parent and any attempt by the child process to read from the stdin stream will result in the stream immediately closing.

This was being violated by UEFI which was inheriting stdin by default.

While the docs don't explicitly state that the default should be NULL, the behaviour seems like reading from NULL.

UEFI however, has a bit of a problem. The `EFI_SIMPLE_TEXT_INPUT_PROTOCOL` only provides support for reading 1 key press. This means that you either get an error, or it is assumed that the keypress was read successfully. So there is no way to have a successful read of length 0. Currently, I am returning UNSUPPORTED error when trying to read from NULL stdin. On linux however, you will get a read of length 0 for Null stdin.

One possible way to get around this is to translate one of the UEFI errors to a read 0 (Maybe unsupported?). It is also possible to have a non-standard error code, but well, not sure if we go that route.

Alternatively, if meaning of Stdio::Null is platform dependent, it should be fine to keep the current behaviour of returning an error.

cc ```@nicholasbishop``` ```@dvdhrm```
2025-04-15 15:47:25 +10:00
Stuart Cook
aa9a80cc34
Rollup merge of #138393 - oli-obk:pattern-type-in-pattern, r=BoxyUwU
Allow const patterns of matches to contain pattern types

Trying to pattern match on a type containing a pattern type will currently fail with an ICE

```rust
error: internal compiler error: compiler/rustc_mir_build/src/builder/matches/test.rs:459:18: invalid type for non-scalar compare: (u32) is 1..
  --> src/main.rs:22:5
   |
22 |     TWO => {}
   |     ^^^
```

because the compiler tries to generate a MIR `BinOp(Eq)` operation on a pattern type, which is not supported. While we could support that, there are side effects of allowing this (none that would compile, but the compiler would simultaneously think it could `==` pattern types and that it could not because `PartialEq` is not implemented. So instead I change the logic for pattern matching to transmute pattern types to their base type before comparing.

r? ```@BoxyUwU```

cc #123646 ```@scottmcm``` ```@joshtriplett```
2025-04-15 15:47:25 +10:00
Stuart Cook
b8413ab8ed
Rollup merge of #138380 - cuviper:ci-llvm-20, r=Kobzol
ci: add runners for vanilla LLVM 20

Ubuntu 25.04 has `llvm-20` packages that we can start testing with.
The `Dockerfile` is otherwise the same as the `llvm-18`/`19` runners.

try-job: x86_64-gnu-llvm-20-1
try-job: x86_64-gnu-llvm-20-2
try-job: x86_64-gnu-llvm-20-3
2025-04-15 15:47:24 +10:00
Stuart Cook
380ad1b5d4
Rollup merge of #138374 - celinval:issue-136925-const-contract, r=compiler-errors,oli-obk,RalfJung
Enable contracts for const functions

Use `const_eval_select!()` macro to enable contract checking only at runtime. The existing contract logic relies on closures, which are not supported in constant functions.

This commit also removes one level of indirection for ensures clauses since we no longer build a closure around the ensures predicate.

Resolves #136925

**Call-out:** This is still a draft PR since CI is broken due to a new warning message for unreachable code when the bottom of the function is indeed unreachable. It's not clear to me why the warning wasn't triggered before.

r? ```@compiler-errors```
2025-04-15 15:47:24 +10:00
Nicholas Nethercote
65942d19cd Avoid using kw::Empty for param names in rustdoc. 2025-04-15 15:34:20 +10:00
Nicholas Nethercote
40978580ec Avoid using kw::Empty when comparing names. 2025-04-15 15:34:20 +10:00