Commit graph

308340 commits

Author SHA1 Message Date
Samuel Tardieu
d10ea6eab0
Cleanup: rename EarlyContext/LateContext parameters 2025-10-11 09:37:25 +02:00
Samuel Tardieu
f6665478e1
Cleanup: rename Applicability variables/parameters 2025-10-11 09:37:25 +02:00
Ada Alakbarova
097f2fd2f4
add missing test for macros
The missing external macro test for `non_canonical_clone_impl` was
caught thanks to lintcheck -- I went ahead and added all the other
combinations of the test while at it
2025-10-11 09:24:58 +02:00
Samuel Tardieu
ebbbbebf2d
Replace all item identification utils (#15682)
This introduces a new way of identifying items/paths using extension
traits with a composable set of functions rather than unique functions
for various combinations of starting points and target items. Altogether
this is a set of five traits:

* `MaybeTypeckRes`: Allows both `LateContext` and `TypeckResults` to be
used for type-dependent lookup. The implementation here will avoid ICEs
by returning `None` when debug assertions are disabled. With assertions
this will assert that we don't silently lookup anything from a different
body than the current one and that a definition actually exists.
* `HasHirId`: Simply a convenience to allow not typing `.hir_id` at call
sites.
* `MaybeQPath`: This is the old `MaybePath`. Extension functions for
type-dependent path lookups exist here. A lot of these functions aren't
used in the current PR, but what they accomplish is done in various
places I haven't cleaned up yet.
* `MaybeResPath`: Like `MaybeQPath`, but only does non-type-dependent
lookup (`QPath::Resolved`).
* `MaybeDef`: Extension functions for identifying the current definition
and accessing properties. Implemented for several types for convenience.

`MaybeDef` is implemented for `Option` to allow chaining methods
together. e.g.
`cx.ty_based_def(e).opt_parent(cx).opt_impl_ty(cx).is_diag_item(..)`
would chaining `and_then` or `if let` on every step. `MaybeQPath` and
`MaybeResPath` are also implemented for `Option` for the same reason.

`ty_based_def` is just a shorter name for `type_dependent_def`. I'm not
really attached to it, but it's nice that it's a little shorter.

changelog: none
2025-10-11 07:03:12 +00:00
Zalathar
7f0adce34a ci: Use GNU coreutils to work around a libffi-sys build failure 2025-10-11 16:29:15 +11:00
Jason Newcomb
42f2ba1869
fix(zero_repeat_side_effects): don't suggest unsuggestable types (#15815)
Fixes https://github.com/rust-lang/rust-clippy/issues/14998

changelog: [`zero_repeat_side_effects`]: don't suggest unsuggestable
types
2025-10-11 04:15:13 +00:00
Yuki Okushi
0eaa3366f9 Improve error message for ambiguous numeric types in closure parameters 2025-10-11 12:34:02 +09:00
beepster4096
033474bacf remove some deref_finder uses
elaborate drops and inline don't seem to actually need it
2025-10-10 20:30:19 -07:00
beepster4096
2da55cdb2c remove copyforderef from custom_mir
it did not create DerefTemp locals when used, so it was never actually correct.
2025-10-10 20:30:19 -07:00
beepster4096
1bd490113c slightly less trivial blessings
some optimization is behaving slightly differently on box derefs after this change, but the difference is irrelevant
2025-10-10 20:30:18 -07:00
Jason Newcomb
6bfb524e9a Remove is_trait_item 2025-10-10 23:15:59 -04:00
Jason Newcomb
e69d88bb10 Remove is_trait_method 2025-10-10 23:15:59 -04:00
Jason Newcomb
d0be3356ba Remove is_inherent_method_call 2025-10-10 23:12:44 -04:00
Jason Newcomb
e78f86d550 Remove is_diag_item_method 2025-10-10 23:09:26 -04:00
Jason Newcomb
2e6729ea64 Remove is_diag_trait_item 2025-10-10 23:09:26 -04:00
Jason Newcomb
a6078f87db Remove path_to_local_id 2025-10-10 23:09:26 -04:00
Jason Newcomb
53675ce061 Remove path_to_local 2025-10-10 23:09:26 -04:00
Jason Newcomb
3f686a074d Remove is_res_lang_ctor 2025-10-10 23:00:17 -04:00
Jason Newcomb
3ed7aa0d5f Remove path_def_id 2025-10-10 23:00:17 -04:00
Jason Newcomb
5b659ba0b4 Remove path_res 2025-10-10 22:51:33 -04:00
Jason Newcomb
53783de8f0 Remove MaybePath 2025-10-10 22:51:33 -04:00
Jason Newcomb
e1a4c90f61 Remove get_type_diagnostic_name 2025-10-10 22:47:41 -04:00
Jason Newcomb
083b1c1059 Remove is_type_lang_item 2025-10-10 22:44:01 -04:00
Jason Newcomb
fe13e0675a Remove is_type_ref_to_diagnostic_item 2025-10-10 22:41:10 -04:00
Jason Newcomb
4914f5908f Remove is_type_diagnostic_item 2025-10-10 22:41:10 -04:00
Jason Newcomb
cb32444ee6 Remove is_path_diagnostic_item 2025-10-10 22:30:57 -04:00
Jason Newcomb
d32ef64ed5 Remove is_path_lang_item 2025-10-10 22:30:57 -04:00
Jason Newcomb
748a593a7f Add new utils for defninition identification. 2025-10-10 22:30:25 -04:00
beepster4096
33cc7787bf trivial test blessings 2025-10-10 18:40:00 -07:00
Ben Kimock
029579d177 Change int-to-ptr transmute lowering back to inttoptr 2025-10-10 20:14:23 -04:00
Michael Howell
e0e5d478c1 manual_unwrap_or: fix FP edge case 2025-10-10 16:54:33 -07:00
Dawid Lachowicz
a172a66ae8
Wrap contract clauses in brances instead of parenthesis
The compiler complained about uncecessary parenthesis on contract clauses,
which were insterted by the contract macros. This commit changes the
macro to use braces as the delimiter instead, fixing the issue.
2025-10-11 00:16:44 +01:00
Dawid Lachowicz
2a5dac7682
Remove no longer used contract_checks intrinsic
The contract_checks compiler flag is now used to determine
if runtime contract checks should be enabled, as opposed
to the compiler intrinsic as previously.
2025-10-11 00:16:44 +01:00
Dawid Lachowicz
2d87527e42
Guard HIR contracts based on compiler flag rather than lang_item
This allows the optimiser to properly eliminate contract code
when runtime contract checks are disabled.

It comes at the cost of having to recompile upstream crates
(e.g. std) to enable contracts in them. However, this trade
off is acceptable if it means disabled runtime contract checks
do not affect the runtime performance of the functions they annotate.

With the proper elimination of contract code, which this change
introduces, the runtime performance of annotated functions
should be the same as the original unannotated function.
2025-10-11 00:16:44 +01:00
Dawid Lachowicz
e4ead0ec70
Guard HIR lowered contracts with contract_checks
Refactor contract HIR lowering to ensure no contract code is
executed when contract-checks are disabled.

The call to contract_checks is moved to inside the lowered fn
body, and contract closures are built conditionally, ensuring
no side-effects present in contracts occur when those are disabled.
2025-10-11 00:16:29 +01:00
dianqk
ab7d63afca
Rollup merge of #147562 - tyilo:stabilize-unsigned_nonzero_div_ceil, r=joboet
Stabilize `NonZero<u*>::div_ceil`

As per https://github.com/rust-lang/rust/issues/132968#issuecomment-3390765077

r? libs
2025-10-11 07:06:01 +08:00
dianqk
6d8272fb27
Rollup merge of #147553 - saethlin:wasip3-tier-3, r=petrochenkov
Move `wasm32-wasip3`  to the tier 3 table

https://github.com/rust-lang/rust/pull/147205 says it wanted to add this as a tier 3 target but accidentally added it to the tier 2 table.
2025-10-11 07:06:00 +08:00
dianqk
38a5143396
Rollup merge of #147551 - folkertdev:is-multiple-of-overflow-checks, r=Amanieu
remove `#[rustc_inherit_overflow_checks]` from `is_multiple_of`

Most likely this was just a result of copy-pasting. The attribute has no effect, because `%` always uses overflow checks.

r? `@Amanieu`
cc `@RalfJung`
2025-10-11 07:05:59 +08:00
dianqk
0ef3d203e8
Rollup merge of #147544 - cjgillot:nodeinit, r=saethlin
Remove StatementKind::Deinit.

It is a remnant from the time we deaggreated MIR.

Now, it is only constructed by the `LargeEnums` MIR pass, which is disabled by default.
2025-10-11 07:05:58 +08:00
dianqk
fce1bea078
Rollup merge of #147525 - dianqk:ref_prop_debuginfo, r=cjgillot
Replace locals in debuginfo records during ref_prop and dest_prop

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

r? cjgillot
2025-10-11 07:05:58 +08:00
dianqk
cfc27fbc4b
Rollup merge of #147522 - Zalathar:directive, r=jieyouxu
compiletest: Use the same directive lines for EarlyProps and ignore/only/needs

Currently we load each discovered test file to scan it for directives once for EarlyProps parsing, then reload and scan it once *per revision* for ignore processing. If a revision is not ignored, we then reload and scan it again during actual execution.

That's a bit silly, so this PR tries to reduce the number of unnecessary file loads and line scans for directive parsing, by reusing the same collection of `DirectiveLine` values for EarlyProps and for each revision's ignores.

Each individual directive still needs to be re-parsed a bunch of times, but those steps can at least avoid scanning the whole file, or having to split out names from values.

---

There's more that could be done after this, such as only doing known-directive checks once per file, or embedding file paths in each `DirectiveLine`, but I decided to stop here to allow review in modest chunks.

r? jieyouxu
2025-10-11 07:05:57 +08:00
dianqk
046260ecc5
Rollup merge of #147515 - Kobzol:update-rustc-perf, r=lqd,nnethercote
Update rustc-perf submodule

To bring in https://github.com/rust-lang/rustc-perf/pull/2274, https://github.com/rust-lang/rustc-perf/pull/2275 and https://github.com/rust-lang/rustc-perf/pull/2276.

r? `@nnethercote`

try-job: dist-x86_64-linux
try-job: dist-x86_64-msvc
2025-10-11 07:05:56 +08:00
dianqk
b01780801a
Rollup merge of #147289 - Jules-Bertholet:thread_local-shadow-mitigate, r=joboet
Mitigate `thread_local!` shadowing issues

Mitigates https://github.com/rust-lang/rust/issues/147006 and https://github.com/rust-lang/rust/issues/99018.

`@rustbot` label T-libs A-macros A-thread-locals A-hygiene
2025-10-11 07:05:56 +08:00
dianqk
e1af13b7c0
Rollup merge of #146522 - thejpster:promote-armv7a-none-eabihf, r=petrochenkov
Promote armv7a-none-eabihf to Tier 2

This PR promotes armv7a-none-eabihf to Tier 2, to join armv7r-none-eabihf and armv7a-none-eabi. I believe it was simply an oversight that it wasn't made Tier 2 before, as most Armv7-A targets have an FPU and it often makes sense to use it.

This PR wil be rebased once https://github.com/rust-lang/rust/pull/146419 completes the queue.

> - A tier 2 target must have value to people other than its maintainers. (It may
>   still be a niche target, but it must not be exclusively useful for an
>   inherently closed group.)

The `armv7a-none-eabihf` target is for all Arm Cortex-A processors (either 32-bit only, or in 32-bit mode) where the user wants to use the FPU.

>- A tier 2 target must have a designated team of developers (the "target
>  maintainers") available to consult on target-specific build-breaking issues,
>  or if necessary to develop target-specific language or library implementation
>  details. This team must have at least 2 developers.

The Embedded Devices Working Group's Arm Team have just started maintaining this target.

> - The target must not place undue burden on Rust developers not specifically
>   concerned with that target. Rust developers are expected to not gratuitously
>   break a tier 2 target, but are not expected to become experts in every tier 2
>   target, and are not expected to provide target-specific implementations for
>   every tier 2 target.

This target is highly similar to a number of existing Tier 2 targets, including `armv7r-none-eabihf` and `armv7a-none-eabi` and so it should not add undue burden.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target using cross-compilation, and explaining how to run
>   tests for the target. If at all possible, this documentation should show how
>   to run Rust programs and tests for the target using emulation, to allow
>   anyone to do so. If the target cannot be feasibly emulated, the documentation
>   should explain how to obtain and work with physical hardware, cloud systems,
>   or equivalent.

https://doc.rust-lang.org/nightly/rustc/platform-support/armv7a-none-eabi.html was added in https://github.com/rust-lang/rust/pull/146419/. It covers the `-eabi` and the `-eabihf` targets.

> - The target must document its baseline expectations for the features or
>   versions of CPUs, operating systems, libraries, runtime environments, and
>   similar.

I believe it does.

> - If introducing a new tier 2 or higher target that is identical to an existing
>   Rust target except for the baseline expectations for the features or versions
>   of CPUs, operating systems, libraries, runtime environments, and similar,
>   then the proposed target must document to the satisfaction of the approving
>   teams why the specific difference in baseline expectations provides
>   sufficient value to justify a separate target.

It uses very similar FPUs to `armv7r-none-eabihf` but is otherwise the same as `armv7a-none-eabi`.

> - Tier 2 targets must not leave any significant portions of `core` or the
>  standard library unimplemented or stubbed out, unless they cannot possibly be
>  supported on the target.

It has a full libcore, as per the other arm*-none-* targets.

> - The code generation backend for the target should not have deficiencies that
>  invalidate Rust safety properties, as evaluated by the Rust compiler team.

It should be the same backend as `armv7r-none-eabihf` and friends, except for FPU support, which is already covered in `thumbv8m.main-none-eabihf`. There are no issues that I know of.

> - If the target supports C code, and the target has an interoperable calling
>   convention for C code, the Rust target must support that C calling convention
>   for the platform via `extern "C"`. The C calling convention does not need to
>   be the default Rust calling convention for the target, however.

The ABI is EABI, the same as many other Arm targets.

> - The target must build reliably in CI, for all components that Rust's CI
>   considers mandatory.

The https://github.com/rust-embedded/cortex-ar repository has been changed in https://github.com/rust-embedded/cortex-ar/pull/57 to build this target with `-Zbuild-std=core`. Locally it seems fine.

> - The approving teams may additionally require that a subset of tests pass in
>  CI, such as enough to build a functional "hello world" program, `./x.py test
>  --no-run`, or equivalent "smoke tests". In particular, this requirement may
>  apply if the target builds host tools, or if the tests in question provide
>  substantial value via early detection of critical problems.

There are no no-std tests in the tree that I'm aware of.

> - Building the target in CI must not take substantially longer than the current
>   slowest target in CI, and should not substantially raise the maintenance
>   burden of the CI infrastructure. This requirement is subjective, to be
>   evaluated by the infrastructure team, and will take the community importance
>   of the target into account.

Building libcore is quite fast.

> - Tier 2 targets should, if at all possible, support cross-compiling. Tier 2
>   targets should not require using the target as the host for builds, even if
>   the target supports host tools.

It does.

> - In addition to the legal requirements for all targets (specified in the tier
>   3 requirements), because a tier 2 target typically involves the Rust project
>   building and supplying various compiled binaries, incorporating the target
>   and redistributing any resulting compiled binaries (e.g. built libraries,
>   host tools if any) must not impose any onerous license requirements on any
>   members of the Rust project, including infrastructure team members and those
>   operating CI systems. This is a subjective requirement, to be evaluated by
>   the approving teams.

Just libcore required (and liballoc). No known issues here.

> - Tier 2 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to ensure that tests pass for the target.

Noted

> - The target maintainers should regularly run the testsuite for the target

The https://github.com/rust-embedded/cortex-ar repository will be changed to use the rustup component when available.

> and should fix any test failures in a reasonably timely fashion.

Noted
2025-10-11 07:05:55 +08:00
dianqk
020fede547
Rollup merge of #146520 - thejpster:promote-armv8r-none-eabi, r=petrochenkov
Promote armv8r-none-eabihf target to Tier 2

This PR promotes armv8r-none-eabihf to Tier 2, joining armv7r-none-eabi, armv7r-none-eabihf and armv7a-none-eabi.

This PR wil be rebased once https://github.com/rust-lang/rust/pull/146419 completes the queue.

> - A tier 2 target must have value to people other than its maintainers. (It may
>   still be a niche target, but it must not be exclusively useful for an
>   inherently closed group.)

The `armv8r-none-eabihf` target is for the Arm Cortex-R52 processor, as found in a number of Automotive SoCs that have just been released, or are about to be released. Currently SoCs are available from NXP and Renesas.

>- A tier 2 target must have a designated team of developers (the "target
>  maintainers") available to consult on target-specific build-breaking issues,
>  or if necessary to develop target-specific language or library implementation
>  details. This team must have at least 2 developers.

The Embedded Devices Working Group's Arm Team have just started maintaining this target.

> - The target must not place undue burden on Rust developers not specifically
>   concerned with that target. Rust developers are expected to not gratuitously
>   break a tier 2 target, but are not expected to become experts in every tier 2
>   target, and are not expected to provide target-specific implementations for
>   every tier 2 target.

This target is highly similar to a number of existing Tier 2 targets, including `armv7r-none-eabihf` and so it should not add undue burden.

> - The target must provide documentation for the Rust community explaining how
>   to build for the target using cross-compilation, and explaining how to run
>   tests for the target. If at all possible, this documentation should show how
>   to run Rust programs and tests for the target using emulation, to allow
>   anyone to do so. If the target cannot be feasibly emulated, the documentation
>   should explain how to obtain and work with physical hardware, cloud systems,
>   or equivalent.

https://doc.rust-lang.org/nightly/rustc/platform-support/armv8r-none-eabihf.html exists and was updated in https://github.com/rust-lang/rust/pull/146419/

> - The target must document its baseline expectations for the features or
>   versions of CPUs, operating systems, libraries, runtime environments, and
>   similar.

I believe it does.

> - If introducing a new tier 2 or higher target that is identical to an existing
>   Rust target except for the baseline expectations for the features or versions
>   of CPUs, operating systems, libraries, runtime environments, and similar,
>   then the proposed target must document to the satisfaction of the approving
>   teams why the specific difference in baseline expectations provides
>   sufficient value to justify a separate target.

The Armv8-R architecture introduces a new FPU type, the fp-armv8, and so this requires a unique target.

> - Tier 2 targets must not leave any significant portions of `core` or the
>  standard library unimplemented or stubbed out, unless they cannot possibly be
>  supported on the target.

It has a full libcore, as per the other arm*-none-* targets.

> - The code generation backend for the target should not have deficiencies that
>  invalidate Rust safety properties, as evaluated by the Rust compiler team.

It should be the same backend as `armv7r-none-eabihf` and friends, except for FPU support, which is already covered in `thumbv8m.main-none-eabihf`. There are no issues that I know of.

> - If the target supports C code, and the target has an interoperable calling
>   convention for C code, the Rust target must support that C calling convention
>   for the platform via `extern "C"`. The C calling convention does not need to
>   be the default Rust calling convention for the target, however.

The ABI is EABI, the same as many other Arm targets.

> - The target must build reliably in CI, for all components that Rust's CI
>   considers mandatory.

The https://github.com/rust-embedded/cortex-ar repository regularly builds this target with `-Zbuild-std=core` and it seems fine.

> - The approving teams may additionally require that a subset of tests pass in
>  CI, such as enough to build a functional "hello world" program, `./x.py test
>  --no-run`, or equivalent "smoke tests". In particular, this requirement may
>  apply if the target builds host tools, or if the tests in question provide
>  substantial value via early detection of critical problems.

There are no no-std tests in the tree that I'm aware of.

> - Building the target in CI must not take substantially longer than the current
>   slowest target in CI, and should not substantially raise the maintenance
>   burden of the CI infrastructure. This requirement is subjective, to be
>   evaluated by the infrastructure team, and will take the community importance
>   of the target into account.

Building libcore is quite fast.

> - Tier 2 targets should, if at all possible, support cross-compiling. Tier 2
>   targets should not require using the target as the host for builds, even if
>   the target supports host tools.

It does.

> - In addition to the legal requirements for all targets (specified in the tier
>   3 requirements), because a tier 2 target typically involves the Rust project
>   building and supplying various compiled binaries, incorporating the target
>   and redistributing any resulting compiled binaries (e.g. built libraries,
>   host tools if any) must not impose any onerous license requirements on any
>   members of the Rust project, including infrastructure team members and those
>   operating CI systems. This is a subjective requirement, to be evaluated by
>   the approving teams.

Just libcore required (and liballoc). No known issues here.

> - Tier 2 targets must not impose burden on the authors of pull requests, or
>   other developers in the community, to ensure that tests pass for the target.

Noted

> - The target maintainers should regularly run the testsuite for the target

The https://github.com/rust-embedded/cortex-ar repository will be changed to use the rustup component when available.

> and should fix any test failures in a reasonably timely fashion.

Noted
2025-10-11 07:05:54 +08:00
dianqk
6967a8561b
Rollup merge of #145722 - Qelxiros:112815-tokenstream-extend, r=dtolnay
implement Extend<{Group, Literal, Punct, Ident}> for TokenStream

Tracking issue: rust-lang/rust#112815
2025-10-11 07:05:54 +08:00
dianqk
486fae11ca
Rollup merge of #145651 - borsakv:139093, r=cjgillot
Regression test for const promotion with Option<Ordering>

https://rust.godbolt.org/z/EjxqE8WcT

Fixes rust-lang/rust#139093

Add a regression test to ensure that comparing `Option<Ordering>` to
`Some(Ordering::Equal)` does not trigger unnecessary const promotion
in MIR.

Previously, inlined constants like `Some(Ordering::Equal)` would get
promoted, leading to more complex MIR and redundant LLVM IR checks.
This test verifies that both the direct form and the `let`-binding form
now generate equivalent, simplified MIR.

r? cjgillot
2025-10-11 07:05:53 +08:00
dianqk
a3482d97c6
Remove the temporary directory when a check ends 2025-10-11 06:57:11 +08:00
cyrgani
6a12470210 rename DecodeMut to Decode 2025-10-10 22:19:04 +02:00
Josh Triplett
7aa7ecc982 Factor out a helper function to check if a type is uninhabited 2025-10-10 13:13:49 -07:00