Commit Graph

300570 Commits

Author SHA1 Message Date
Matthias Krüger
bc0262d0f1 Rollup merge of #143327 - RalfJung:miri-type-validity-error, r=oli-obk
miri: improve errors for type validity assertion failures

Miri has pretty nice errors for type validity violations, printing which field in the type the problem occurs at and so on.

However, we don't see these errors when using e.g. `mem::zeroed` as that uses `assert_zero_valid` to bail out before Miri can detect the UB.

Similar to what we did with `@saethlin's` UB checks, I think we should disable such language UB checks in Miri so that we can get better error messages. If we go for this we should probably say this in the intrinsic docs as well so that people don't think they can rely on these intrinsics catching anything.

Furthermore, I slightly changed `MaybeUninit::assume_init` so that the `.value` field does not show up in error messages any more.

`@rust-lang/miri` what do you think?
2025-07-03 05:21:36 +02:00
Matthias Krüger
5aa7dd81d8 Rollup merge of #143325 - Kobzol:bootstrap-interner, r=clubby789
Use non-global interner in `test_string_interning` in bootstrap

Just a small cleanup that we found on our GSoC call.

CC `@Shourya742`
2025-07-03 05:21:36 +02:00
Matthias Krüger
7e600de3c8 Rollup merge of #143324 - RalfJung:native-call-prep, r=oli-obk
interpret: move the native call preparation logic into Miri

`@nia-e` has to do a bunch of changes to this logic for her native call ptrace work, and it's getting annoying that the logic is split between Miri and rustc. So this moves the logic to Miri, keeping just the generic traversal part in rustc. It is unfortunate that this means we have to expose `get_alloc_raw`/`get_alloc_raw_mut`... I hope the function name is scary enough to reduce the risk of misuse.

r? `@oli-obk`
2025-07-03 05:21:35 +02:00
Matthias Krüger
f000754761 Rollup merge of #143321 - hkBst:typo-1, r=compiler-errors
byte-addresses memory -> byte-addressed memory

Small typo fix
2025-07-03 05:21:34 +02:00
Matthias Krüger
4a3c2fca22 Rollup merge of #143316 - Kobzol:bootstrap-check-tests, r=jieyouxu
Add bootstrap check snapshot tests

Split off from https://github.com/rust-lang/rust/pull/143048, so that we get a baseline of how check behaved before we make changes to it. Note that the output of the check snapshot tests is suboptimal in many places, as we're missing information about stages and the build compiler. That will be changed in https://github.com/rust-lang/rust/pull/143048.

r? `@jieyouxu`
2025-07-03 05:21:34 +02:00
Matthias Krüger
547dc74fcd Rollup merge of #143292 - compiler-errors:explicit-generic, r=oli-obk
Explicitly handle all nodes in `generics_of` when computing parent

If we, for example, forget to feed `generics_of` then it'll silently fall back to empty generics. Make this a bit more explicit.
2025-07-03 05:21:33 +02:00
Matthias Krüger
ddda937701 Rollup merge of #143273 - 1c3t3a:enum-check-negative, r=SparrowLii
Make the enum check work for negative discriminants

The discriminant check was not working correctly for negative numbers. This change fixes that by masking out the relevant bits correctly.

Fixes rust-lang/rust#143218.
2025-07-03 05:21:32 +02:00
Matthias Krüger
c3e3f43f2a Rollup merge of #143251 - lolbinarycat:bootstrap-toml-tidy-extra-checks, r=Kobzol
bootstrap: add build.tidy-extra-checks option

split off from rust-lang/rust#142924

r? `@Kobzol`
2025-07-03 05:21:32 +02:00
Matthias Krüger
6d54983ae9 Rollup merge of #143192 - GuillaumeGomez:code-line-number, r=lolbinary
Improve CSS for source code block line numbers

Extract some changes from https://github.com/rust-lang/rust/pull/137229 to make the PR smaller (thanks `@yotamofek` for the suggestion!).

r? notriddle
2025-07-03 05:21:31 +02:00
Jeremy Smart
6b824e8143 avoid suggesting traits from private dependencies 2025-07-02 22:04:51 -04:00
bors
25face9808 Auto merge of #143338 - matthiaskrgr:rollup-ykaxh04, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#131923 (Derive `Copy` and `Hash` for `IntErrorKind`)
 - rust-lang/rust#138340 (Remove some unsized tuple impls now that we don't support unsizing tuples anymore)
 - rust-lang/rust#141219 (Change `{Box,Arc,Rc,Weak}::into_raw` to only work with `A = Global`)
 - rust-lang/rust#142212 (bootstrap: validate `rust.codegen-backends` & `target.<triple>.codegen-backends`)
 - rust-lang/rust#142237 (Detect more cases of unused_parens around types)
 - rust-lang/rust#142964 (Attribute rework: a parser for single attributes without arguments)
 - rust-lang/rust#143070 (Rewrite `macro_rules!` parser to not use the MBE engine itself)
 - rust-lang/rust#143235 (Assemble const bounds via normal item bounds in old solver too)
 - rust-lang/rust#143261 (Feed `explicit_predicates_of` instead of `predicates_of`)
 - rust-lang/rust#143276 (loop match: handle opaque patterns)
 - rust-lang/rust#143306 (Add `track_caller` attributes to trace origin of Clippy lints)

r? `@ghost`
`@rustbot` modify labels: rollup

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-gnu
try-job: dist-i586-gnu-i586-i686-musl
try-job: test-various
2025-07-02 23:29:03 +00:00
Emmanuel Ferdman
9ce91f7a28 update coherence example
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2025-07-02 16:16:33 -07:00
Chayim Refael Friedman
51ef8fb35d Remove keyword prefixes (macro@ or macro ) from links in the docs only if the link target is inferred
That is, do it for `[macro foo]`, but not for `[macro foo](macro foo)`.
2025-07-03 00:41:47 +03:00
bors
6677875279 Auto merge of #143337 - matthiaskrgr:rollup-lqwhe0i, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#141847 (Explain `TOCTOU` on the top of `std::fs`, and reference it in functions)
 - rust-lang/rust#142138 (Add `Vec::into_chunks`)
 - rust-lang/rust#142321 (Expose elf abi on ppc64 targets)
 - rust-lang/rust#142886 (ci: aarch64-gnu: Stop skipping `panic_abort_doc_tests`)
 - rust-lang/rust#143194 (fix bitcast of single-element SIMD vectors)
 - rust-lang/rust#143231 (Suggest use another lifetime specifier instead of underscore lifetime)
 - rust-lang/rust#143232 ([COMPILETEST-UNTANGLE 3/N] Use "directives" consistently within compiletest)
 - rust-lang/rust#143258 (Don't recompute `DisambiguatorState` for every RPITIT in trait definition)
 - rust-lang/rust#143274 (ci: support optional jobs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-02 20:25:23 +00:00
наб
a0111ec7a1 awhile -> a while where appropriate 2025-07-02 20:17:29 +02:00
Matthias Krüger
45b32efc49 Rollup merge of #143306 - samueltardieu:track-clippy-lints-emission, r=petrochenkov
Add `track_caller` attributes to trace origin of Clippy lints

This allows the use of `-Z track-diagnostics` to see the origin of Clippy lints emission, as is already the case for lints coming from rustc.
2025-07-02 19:29:39 +02:00
Matthias Krüger
bc8bcc7e8a Rollup merge of #143306 - samueltardieu:track-clippy-lints-emission, r=petrochenkov
Add `track_caller` attributes to trace origin of Clippy lints

This allows the use of `-Z track-diagnostics` to see the origin of Clippy lints emission, as is already the case for lints coming from rustc.
2025-07-02 19:29:39 +02:00
Matthias Krüger
0617a9eb95 Rollup merge of #143276 - folkertdev:loop-match-opaque-pattern, r=Nadrieril
loop match: handle opaque patterns

tracking issue https://github.com/rust-lang/rust/issues/132306
fixes https://github.com/rust-lang/rust/issues/143203

I believe the `Opaque` comes up because the range pattern is invalid? Because we do handle float patterns already so those should be fine.

r? `@Nadrieril`
2025-07-02 19:29:38 +02:00
Matthias Krüger
2becacff8b Rollup merge of #143261 - compiler-errors:explicit-pred, r=oli-obk
Feed `explicit_predicates_of` instead of `predicates_of`

Tiny nitpick, just avoiding needing to mark the `predicates_of` query as feedable since it's derived from `explicit_predicates_of`.
2025-07-02 19:29:38 +02:00
Matthias Krüger
2ce579da73 Rollup merge of #143235 - compiler-errors:const-item-bound, r=oli-obk
Assemble const bounds via normal item bounds in old solver too

Fixes the first example in https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/elaboration.20of.20const.20bounds.3F/with/526378135

The code duplication here is not that nice, but it's at least very localized.

cc `@davidtwco`

r? oli-obk
2025-07-02 19:29:37 +02:00
Matthias Krüger
383f107867 Rollup merge of #143070 - joshtriplett:macro-rules-parse, r=petrochenkov
Rewrite `macro_rules!` parser to not use the MBE engine itself

The `macro_rules!` parser was written to match the series of rules using the macros-by-example (MBE) engine and a hand-written equivalent of the left-hand side of a MBE macro. This was complex to read, difficult to extend, and produced confusing error messages. Because it was using the MBE engine, any parse failure would be reported as if some macro was being applied to the `macro_rules!` invocation itself; for instance, errors would talk about "macro invocation", "macro arguments", and "macro call", when they were actually about the macro *definition*.

And in practice, the `macro_rules!` parser only used the MBE engine to extract the left-hand side and right-hand side of each rule as a token tree, and then parsed the rest using a separate parser.

Rewrite it to parse the series of rules using a simple loop, instead. This makes it more extensible in the future, and improves error messages. For instance, omitting a semicolon between rules will result in "expected `;`" and "unexpected token", rather than the confusing "no rules expected this token in macro call".

This work was greatly aided by pair programming with Vincenzo Palazzo (`@vincenzopalazzo)` and Eric Holk (`@eholk).`

For review, I recommend reading the two commits separately.
2025-07-02 19:29:37 +02:00
Matthias Krüger
2dbb9be326 Rollup merge of #142964 - GrigorenkoPV:attributes/argless, r=oli-obk
Attribute rework: a parser for single attributes without arguments

Part of rust-lang/rust#131229

r? `@jdonszelmann`

I think code (with comments) speaks for itself.

The only subtlety: now `#[cold]`, `#[no_mangle]`, & `#[track_caller]` do not get thrown away when malformed (i.e. have arguments). This doesn't matter too much (I think), because an error gets emitted either way, so the compilation will not finish.
2025-07-02 19:29:36 +02:00
Matthias Krüger
6ebf642a04 Rollup merge of #142237 - benschulz:unused-parens-fn, r=fee1-dead
Detect more cases of unused_parens around types

With this change, more unused parentheses around bounds and types nested within bounds are detected.
2025-07-02 19:29:35 +02:00
Matthias Krüger
d50240b471 Rollup merge of #142212 - GrigorenkoPV:codegens, r=Kobzol
bootstrap: validate `rust.codegen-backends` & `target.<triple>.codegen-backends`

As per https://github.com/rust-lang/rust/issues/142184#issuecomment-2954124009.

Closes rust-lang/rust#142184.
2025-07-02 19:29:35 +02:00
Matthias Krüger
1a686c669e Rollup merge of #141219 - Amanieu:leak_alloc, r=joboet
Change `{Box,Arc,Rc,Weak}::into_raw` to only work with `A = Global`

Also applies to `Vec::into_raw_parts`.

The expectation is that you can round-trip these methods with `from_raw`, but this is only true when using the global allocator. With custom allocators you should instead be using `into_raw_with_allocator` and `from_raw_in`.

The implementation of `Box::leak` is changed to use `Box::into_raw_with_allocator` and explicitly leak the allocator (which was already the existing behavior). This is because, for `leak` to be safe, the allocator must not free its underlying backing store. The `Allocator` trait only guarantees that allocated memory remains valid until the allocator is dropped.
2025-07-02 19:29:34 +02:00
Matthias Krüger
7c9a03b969 Rollup merge of #138340 - oli-obk:one-size-fits-all, r=m-ou-se
Remove some unsized tuple impls now that we don't support unsizing tuples anymore

Since https://github.com/rust-lang/rust/pull/137728 there is no sound way to create unsized tuples anymore. While we can't remove them from the language (tried here: https://github.com/rust-lang/rust/pull/138093) due to people using `PhantomData<(T, U)>` where `U: ?Sized` (they'd have to use `(PhantomData<T>, PhantomData<U>)` now), we can remove the impls from libcore I believe.

r? libs I guess?
2025-07-02 19:29:34 +02:00
Matthias Krüger
e0499e4583 Rollup merge of #131923 - ranger-ross:impl-copy-hash-interrorkind, r=tgross35
Derive `Copy` and `Hash` for `IntErrorKind`

This PR derives `Copy` and `Hash` for `IntErrorKind` to make it easier to work with. (see #131826)

I think an argument could be made to also derive `PartialOrd` + `Ord` as well given that other error kinds in the std like [`io::ErrorKind`](https://doc.rust-lang.org/src/std/io/error.rs.html#212-428) do this. Granted these seem much less useful for errors.

Fixes https://github.com/rust-lang/rust/issues/131826
2025-07-02 19:29:33 +02:00
Matthias Krüger
c572231fb9 Rollup merge of #143274 - marcoieni:optional-jobs, r=Kobzol
ci: support optional jobs

try-job: optional-mingw-check-1
2025-07-02 19:28:09 +02:00
Matthias Krüger
7fa00aa75f Rollup merge of #143258 - compiler-errors:disambiguator-state, r=oli-obk
Don't recompute `DisambiguatorState` for every RPITIT in trait definition

The `associated_type_for_impl_trait_in_trait` currently needs to rerun the `RPITVisitor` for every RPITIT to compute its disambiguator.

Instead of synthesizing all of the RPITITs def ids one at a time in different queries, just synthesize them inside of the `associated_types_for_impl_traits_in_associated_fn` query. There we can just share the same `DisambiguatorState` for all the RPITITs in one function signature.

r? ``````@Zoxc`````` or ``````@oli-obk`````` cc rust-lang/rust#140453
2025-07-02 19:28:08 +02:00
Matthias Krüger
df7cac9e03 Rollup merge of #143232 - jieyouxu:compiletest-maintenance-3, r=Kobzol
[COMPILETEST-UNTANGLE 3/N] Use "directives" consistently within compiletest

Instead of using *both* "headers" and "directives" within compiletest to refer to the same thing. This of course induces some churn, but it's been bugging me for a while, and I rather do the self-consistency changes now than later.

The first commit tries to be mostly move-only to help per-file git history.

I intend to revisit rustc-dev-guide's testing docs, but I don't want to do it on rust-lang/rust side because it would need syncing and might conflict.
2025-07-02 19:28:07 +02:00
Matthias Krüger
3ff0aa530d Rollup merge of #143231 - xizheyin:143152, r=fee1-dead
Suggest use another lifetime specifier instead of underscore lifetime

cc rust-lang/rust#143152

r? compiler
2025-07-02 19:28:07 +02:00
Matthias Krüger
4f44014c5c Rollup merge of #143194 - folkertdev:fix-single-element-simd-bitcast, r=workingjubilee
fix bitcast of single-element SIMD vectors

in effect this reverts https://github.com/rust-lang/rust/pull/142768 and adds additional tests. That PR relaxed the conditions on an early return in an incorrect way that would create broken LLVM IR.

https://godbolt.org/z/PaaGWTv5a

```rust
#![feature(repr_simd)]

#[repr(simd)]
#[derive(Clone, Copy)]
struct S([i64; 1]);

#[no_mangle]
pub extern "C" fn single_element_simd(b: S) -> i64 {
    unsafe { std::mem::transmute(b) }
}
```
at the time of writing generates this LLVM IR, where the type of the return is different from the function's return type.

```llvm
define noundef i64 ``````@single_element_simd(<1`````` x i64> %b) unnamed_addr {
start:
  ret <1 x i64> %b
}
```

The test output is actually the same for the existing tests, showing that the change didn't actually matter for any tested behavior. It is probably a bit faster to do the early return, but, well, it's incorrect in general.

zullip thread: [#t-compiler > Is transmuting a &#96;T&#96; to &#96;Tx1&#96; (one-element SIMD vector) UB?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Is.20transmuting.20a.20.60T.60.20to.20.60Tx1.60.20.28one-element.20SIMD.20vector.29.20UB.3F/with/526262799)
cc ``````@sayantn``````
r? ``````@scottmcm``````
2025-07-02 19:28:06 +02:00
Matthias Krüger
453a2a9102 Rollup merge of #142886 - Enselic:aarch64-panic, r=cuviper
ci: aarch64-gnu: Stop skipping `panic_abort_doc_tests`

The skipped test passes since `nightly-2024-11-29`. See https://github.com/rust-lang/rust/issues/123733#issuecomment-2928770365 and https://github.com/rust-lang/rust/issues/123733#issuecomment-2929091266 for more info.

Let's stop skipping it to increase the chance of detecting a regression.

r? ``````@cuviper`````` who added the skip in https://github.com/rust-lang/rust/pull/123828

Also see https://github.com/rust-lang/rust/pull/142304 for an alternative regression test that I am hoping to also land in the near future to complement the test we now stop skipping, but I need to investigate that setup more.
2025-07-02 19:28:06 +02:00
Matthias Krüger
d5658d33de Rollup merge of #142321 - ostylk:fix/ppc64_abi, r=workingjubilee
Expose elf abi on ppc64 targets

Fixes https://github.com/rust-lang/rust/issues/60617 (after MCP https://github.com/rust-lang/compiler-team/issues/885 is accepted) by exposing the abi information on ppc64 targets.
Conditional compilation can now use `cfg(target_abi = "elfv1")` or `cfg(target_abi = "elfv2")` to determine the abi in use.

Technical details are included in the other PR https://github.com/rust-lang/rust/pull/142598
2025-07-02 19:28:05 +02:00
Matthias Krüger
6a31e693eb Rollup merge of #142138 - ashivaram23:vec_into_chunks, r=scottmcm
Add `Vec::into_chunks`

Tracking issue rust-lang/rust#142137
2025-07-02 19:28:04 +02:00
Matthias Krüger
0d5af18c14 Rollup merge of #141847 - xizheyin:141837, r=jhpratt
Explain `TOCTOU` on the top of `std::fs`, and reference it in functions

Fixes rust-lang/rust#141837

r? ``````@workingjubilee``````
2025-07-02 19:28:03 +02:00
bors
1ce9c977ff Auto merge of #143214 - camsteffen:remove-let-chains-feature, r=est31
Remove let_chains unstable feature

Per https://github.com/rust-lang/rust/issues/53667#issuecomment-3016742982 (but then I also noticed rust-lang/rust#140722)

This replaces the feature gate with a parser error that says let chains require 2024.

A lot of tests were using the unstable feature. I either added edition:2024 to the test or split out the parts that require 2024.
2025-07-02 17:18:47 +00:00
Bastian Kersting
8a0d8dde44 Make the enum check work for negative discriminants
The discriminant check was not working correctly for negative numbers.
This change fixes that by masking out the relevant bits correctly.
2025-07-02 20:02:27 +03:00
Michael Goulet
0330525b1c Explicitly handle all nodes in generics_of when computing parent 2025-07-02 16:55:18 +00:00
antoyo
75a4fb996a Merge pull request #424 from rust-lang/remove-overwrite-target-triple-env-var
Remove OVERWRITE_TARGET_TRIPLE env var now that config.sh is gone
2025-07-02 12:24:02 -04:00
Antoni Boucher
f1c71ffb47 Clean some config stuff up 2025-07-02 11:56:55 -04:00
binarycat
1d3cbb3a1c bootstrap: add CONFIG_CHANGE_HISTORY entry for build.tidy-extra-checks 2025-07-02 10:56:22 -05:00
binarycat
90b2d24692 bootstrap: add build.tidy-extra-checks option 2025-07-02 10:53:55 -05:00
Antoni Boucher
188108733a Update the doc to reflect the new way to specify the linker for cross-compilation 2025-07-02 11:48:49 -04:00
Ralf Jung
8362508989 miri: improve errors for type validity assertion failures 2025-07-02 17:47:46 +02:00
Antoni Boucher
21c8639d79 Fix to use the correct expected output for m68k CI test 2025-07-02 11:39:27 -04:00
Antoni Boucher
ed1e9b7015 Manually run in a VM in the m68k CI 2025-07-02 11:26:29 -04:00
Philipp Krones
8b034bc598 Add Triagebot's concern capability to the Clippy repository (#14916)
This is a newly added triagebot capability, which allows registering and
then resolving concerns with an issue or a pull request. The concerns
are gathered by Triagebot in the issue/PR summary.

Concerns are different from notes: when a concern is resolved, it is
striked through in the issue/PR summary, and a link to the comment
resolving it is also added, whereas a note can only be removed and then
disappears from the summary.

The `has-concerns` label, which must be created at the time of merging
this change, will be automatically set on issues/PRs that have
unresolved concerns, and cleared when all concerns are resolved.

changelog: none
2025-07-02 15:24:32 +00:00
Shoyu Vanilla
4cfc341451 fix: Honor rust-analyzer.cargo.noDeps option when fetching sysroot metadata 2025-07-03 00:16:05 +09:00
antoyo
bd100e241b Merge pull request #727 from rust-lang/test/ci
Fix m68k CI
2025-07-02 10:51:30 -04:00