Commit Graph

46786 Commits

Author SHA1 Message Date
Michael Goulet
2de2e652ad Rollup merge of #141599 - nnethercote:rm-Box-into_inner, r=fmease,chenyukang
Remove an unnecessary use of `Box::into_inner`.

r? ```@chenyukang```
2025-05-27 13:01:42 +02:00
Michael Goulet
9d46af12e0 Rollup merge of #141584 - compiler-errors:typing-env-synthetic-body, r=lcnr
Support `opaque_types_defined_by` for `SyntheticCoroutineBody`

We create a synthetic MIR body for the `AsyncFnOnce` impl for async closures. That body goes through all passes that a regular body does, including promotion.

Promotion sometimes requires computing that the type of an rvalue is `Freeze`, which requires computing the typing env of a body. This requires calling `opaque_types_defined_by` on the body's def id, which leads to an ICE today since we don't expect that query to be called for synthetic bodies.

While we could fix this by, for example, computing the typeck root of the body before calling a `TypingEnv` constructor, I think it's appropriate to do a more general fix here since I think it's reasonable that other passes might do analysis too.

Fixes rust-lang/rust#141466

r? ```@lcnr``` or ```@oli-obk```
2025-05-27 13:01:40 +02:00
Michael Goulet
fb4cc991c0 Rollup merge of #141582 - RalfJung:cleanup, r=bjorn3
intrinsics, ScalarInt: minor cleanup

Taken out of https://github.com/rust-lang/rust/pull/141507 while we resolve technical disagreements in that PR.

r? ``@bjorn3``
2025-05-27 13:01:39 +02:00
Michael Goulet
fbac805425 Rollup merge of #141580 - oli-obk:early-dyn-catches-the-incompat, r=compiler-errors
Use more detailed spans in dyn compat errors within bodies

Within bodies we can employ the full dyn compat check query instead of only doing the minimal hir ty lowerer one. This in turn gives us better spans and also silences many follow-up duplicate or bogus errors.

alternative to https://github.com/rust-lang/rust/pull/141439, tho I think I could turn the delayed bug from that one into a bug now instead of having an error code path.

r? `@compiler-errors`
cc `@fmease`
2025-05-27 13:01:38 +02:00
Michael Goulet
7acdffb6e4 Rollup merge of #141563 - nnethercote:rm-noop, r=petrochenkov
Remove out-of-date `noop_*` names.

`mut_visit.rs` has a single function with a `noop_` prefix: `noop_filter_map_expr`. This commit renames as `walk_filter_map_expr` which is consistent with other functions in this file.

The commit also removes out-of-date comments that refer to `noop_*` methods.

r? `@petrochenkov`
2025-05-27 13:01:37 +02:00
Michael Goulet
a0d77f37f3 Rollup merge of #141536 - Urgau:ambi_wide_ptr-cmp-diag, r=fee1-dead
Improve `ambiguous_wide_pointer_comparisons` lint compare diagnostics

This PR improves the `ambiguous_wide_pointer_comparisons` lint compare diagnostics: `cmp`/`partial_cmp`, but also the operators `<`/`>`/`>=`/`<=`, by:
1. removing the reference to `std::ptr::addr_eq` which only works for equality
2. and adding an `#[expect]` suggestion for keeping the current behavior

Fixes rust-lang/rust#141510
2025-05-27 13:01:36 +02:00
Michael Goulet
77e35944af Rollup merge of #140591 - Kivooeo:new-fix-five, r=davidtwco
Fix malformed suggestion for E0061 when method is a macro token in macro context

fixes #140512

before
```rust
3  -         <Self>::$method(8)
3  +         <Self>::<Self>::$method(8, /* u8 */)
```
now
```rust
3  |         <Self>::$method(8, /* u8 */)
   |                          ++++++++++
```
2025-05-27 13:01:35 +02:00
Nicholas Nethercote
89c21f7c1a Remove out-of-date noop_* names.
`mut_visit.rs` has a single function with a `noop_` prefix:
`noop_filter_map_expr`. This commit renames as `walk_filter_map_expr`
which is consistent with other functions in this file.

The commit also removes out-of-date comments that refer to `noop_*`
methods.
2025-05-27 19:16:11 +10:00
Oli Scherer
3fff727e87 Use more detailed spans in dyn compat errors within bodies 2025-05-27 08:18:11 +00:00
bors
d76fe15402 Auto merge of #140790 - quininer:mac-xray, r=wesleywiser,jieyouxu
Enable xray support for Mac

https://github.com/rust-lang/rust/issues/102921

Upstream has supported Mac for a while, let's enable it.

I've tested it on M4 and it generates nop sled correctly.

* https://maskray.me/blog/2023-06-18-port-llvm-xray-to-apple-systems
* https://github.com/llvm/llvm-project/blob/llvmorg-20.1.4/clang/lib/Driver/XRayArgs.cpp#L31

try-job: x86_64-apple-1
try-job: aarch64-apple
2025-05-26 23:44:21 +00:00
bors
2805e1dc4c Auto merge of #141605 - jieyouxu:rollup-3gjqh5l, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#140898 (minor improvements on running miri)
 - rust-lang/rust#141392 (Avoid obligation construction dance with query region constraints)
 - rust-lang/rust#141431 (Emit dummy open drop for unsafe binder)
 - rust-lang/rust#141433 (Properly analyze captures from unsafe binders)
 - rust-lang/rust#141439 (Deduplicate dyn compatibility violations due to coercion)
 - rust-lang/rust#141449 (further deduplicate ast visitor code)
 - rust-lang/rust#141513 (interpret: add allocation parameters to `AllocBytes`)
 - rust-lang/rust#141516 (speed up charsearcher for ascii chars)
 - rust-lang/rust#141526 (add a dedicated section for compiler environment variables in the unstable book)
 - rust-lang/rust#141550 (Fix `unused_braces` lint suggestion when encountering attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-26 20:30:06 +00:00
许杰友 Jieyou Xu (Joe)
bca4279457 Rollup merge of #141550 - Urgau:unused_braces-attrs, r=chenyukang
Fix `unused_braces` lint suggestion when encountering attributes

This PR fixes the `unused_braces` lint suggestion when encountering attributes by not removing them in the suggestion.

Fixes rust-lang/rust#141549
2025-05-27 01:29:22 +08:00
许杰友 Jieyou Xu (Joe)
afb57cadda Rollup merge of #141513 - nia-e:allocbytes-extend, r=RalfJung
interpret: add allocation parameters to `AllocBytes`

Necessary for a better implementation of [rust-lang/miri#4343](https://github.com/rust-lang/miri/pull/4343). Also included here is the code from that PR, adapted to this new interface for the sake of example and so that CI can run on them; the Miri changes can be reverted and merged separately, though.

r? `@RalfJung`
2025-05-27 01:29:20 +08:00
许杰友 Jieyou Xu (Joe)
be778ed1f8 Rollup merge of #141449 - fee1-dead-contrib:push-qkosmtkqztkk, r=oli-obk
further deduplicate ast visitor code

Previous PR: #141249

Tracking issue: #127615

r? `@oli-obk`
2025-05-27 01:29:19 +08:00
许杰友 Jieyou Xu (Joe)
92b07de1ca Rollup merge of #141439 - compiler-errors:dyn-compatible-coerce, r=oli-obk
Deduplicate dyn compatibility violations due to coercion

Don't unnecessarily emit dyn compatibility violations due to coercion to a non-dyn-compatible target type.

For us to even have that target type, we would have had to write `dyn Trait` somewhere in source, and that would have led to us *already* emitting a dyn compatibility violation when checking that user written type is WF.

r? oli-obk
2025-05-27 01:29:19 +08:00
许杰友 Jieyou Xu (Joe)
9f93c48ddc Rollup merge of #141433 - compiler-errors:unsafe-binder-captures, r=oli-obk
Properly analyze captures from unsafe binders

We need to represent the unsafe binder unwrap as an adjustment in HIR. Pretty straightforward b/c we already represent it as a projection elem in MIR.

Fixes #141418
Fixes #141417

r? oli-obk
2025-05-27 01:29:18 +08:00
许杰友 Jieyou Xu (Joe)
0e710d0883 Rollup merge of #141431 - compiler-errors:open-drop, r=oli-obk
Emit dummy open drop for unsafe binder

Fixes rust-lang/rust#141394

We can't taint the body in wfcheck when we have a `T: Copy` bound failure, so we end up binding MIR here. Emit a dummy open drop so that drop elaboration doesn't fail.

r? oli-obk
2025-05-27 01:29:18 +08:00
许杰友 Jieyou Xu (Joe)
aa9978229e Rollup merge of #141392 - compiler-errors:query-outlives, r=lcnr
Avoid obligation construction dance with query region constraints

And some renaming...
2025-05-27 01:29:17 +08:00
bors
40d2563ea2 Auto merge of #141500 - compiler-errors:rerun-cache-2, r=lcnr
Don't rerun goals if none of their vars have changed

r? `@ghost`

Alternative to rust-lang/rust#141488. I'm pretty sure that we don't need to re-run the goal at all if the inputs don't change... 🤔
2025-05-26 17:02:43 +00:00
Nicholas Nethercote
19802e8e9c Remove an unnecessary use of Box::into_inner. 2025-05-27 02:06:40 +10:00
bors
9c0bcb514f Auto merge of #141442 - compiler-errors:fast-path-pred, r=lcnr
Fold predicate fast path in canonicalizer and eager resolver

See individual commits.

r? lcnr
2025-05-26 13:42:30 +00:00
Michael Goulet
5e31cd30aa Support opaque_types_defined_by for SyntheticCoroutineBody 2025-05-26 12:19:34 +00:00
Michael Goulet
a59c86ab44 Deduplicate dyn compatibility violations due to coercion 2025-05-26 10:57:54 +00:00
bors
b5eb9893f4 Auto merge of #141406 - RalfJung:less-force-allocate, r=oli-obk
interpret: do not force_allocate all return places

A while ago I cleaned up our `PlaceTy` a little, but as a side-effect of that, return places had to always be force-allocated. That turns out to cause quite a few extra allocations, and for a project we are doing where we marry Miri with a model checker, that means a lot of extra work -- local variables are just so much easier to reason about than allocations.

So, this PR brings back the ability to have the return place be just a local of the caller. To make this work cleanly I had to rework stack pop handling a bit, which also changes the output of Miri in some cases as the span for errors occurring during a particular phase of stack pop changed.

With these changes, a no-std binary with a function of functions that just take and return scalar types and that uses no pointers now does not move *any* local variables into memory. :)

r? `@oli-obk`
2025-05-26 10:29:19 +00:00
Michael Goulet
e2215a8ad9 Don't rerun goals if none of its vars have changed 2025-05-26 10:10:03 +00:00
Michael Goulet
9d742eea25 Rename 2025-05-26 08:48:19 +00:00
Michael Goulet
4d783c3c19 Don't retry in pred_known_to_hold_modulo_regions in new solver, since new solver is more complete
Just a totally unrelated nitpick I'm folding into the PR, since it's
code I'd like for us to prune when the new solver lands.
2025-05-26 08:37:28 +00:00
Michael Goulet
3efd885927 Avoid obligation construction dance with query region constraints 2025-05-26 08:28:45 +00:00
bors
95a2212587 Auto merge of #141567 - jhpratt:rollup-uuhcmci, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#134696 (Implement `normalize_lexically`)
 - rust-lang/rust#140539 (Simplify `attribute_groups`)
 - rust-lang/rust#140863 ([rustdoc] Unify type aliases rendering with other ADT)
 - rust-lang/rust#140936 (Clarify WTF-8 safety docs)
 - rust-lang/rust#140952 (Specify that split_ascii_whitespace uses the same definition as is_ascii_whitespace)
 - rust-lang/rust#141472 (Attempt to improve the `std::fs::create_dir_all` docs related to atomicity)
 - rust-lang/rust#141502 (ci: move PR job x86_64-gnu-tools to codebuild)
 - rust-lang/rust#141559 (const-check: stop recommending the use of rustc_allow_const_fn_unstable)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-26 04:30:06 +00:00
Jacob Pratt
5a8cb6f892 Rollup merge of #141559 - RalfJung:less-rustc_allow_const_fn_unstable, r=compiler-errors
const-check: stop recommending the use of rustc_allow_const_fn_unstable

I have seen way too many people see the compiler suggest this attribute and then just apply it without a second thought. This is bad. So let's just stop recommending it; for the rare case where someone needs it, they'll eventually ask us and that way we can be sure that it is truly needed. The dev-guide still also explains `rustc_allow_const_fn_unstable`.

Cc ``@rust-lang/wg-const-eval``
2025-05-26 03:38:19 +02:00
Jacob Pratt
761e5464dd Rollup merge of #140539 - nnethercote:simplify-attribute_groups, r=jdonszelmann
Simplify `attribute_groups`

It's more complicated than it needs to be.

r? ``@jdonszelmann``
2025-05-26 03:38:16 +02:00
bors
46264e6dfd Auto merge of #138489 - tmiasko:call-tmps-lifetime, r=workingjubilee
Describe lifetime of call argument temporaries passed indirectly

Fixes #132014.
2025-05-26 01:16:52 +00:00
Nia Espera
e388a3e405 extend allocbytes with associated type 2025-05-26 00:15:16 +02:00
Ralf Jung
cf9ac0eec1 const-check: stop recommending the use of rustc_allow_const_fn_unstable 2025-05-25 22:47:21 +02:00
Michael Goulet
ade24354f4 Do not canonicalize in new solver if it has nothing to canonicalize 2025-05-25 20:14:11 +00:00
bjorn3
3816385b09 Merge commit '979dcf8e2f213e4f4b645cb62e7fe9f4f2c0c785' into sync_cg_clif-2025-05-25 2025-05-25 18:51:16 +00:00
Urgau
4765fd6b76 Fix unused_braces lint suggestion when encountering attributes 2025-05-25 18:17:43 +02:00
Urgau
77e295c39c Improve ambiguous_wide_pointer_comparisons lint compare diagnostics 2025-05-25 17:08:58 +02:00
Michael Goulet
84a3255cc3 Fast path fold_predicate in old canonicalizer 2025-05-25 14:12:17 +00:00
Guillaume Gomez
43cb506383 Rollup merge of #141541 - compiler-errors:nits, r=lcnr
Random nits

Two completely random commits that I didn't know where to integrate into another PR.

* Don't use the full type relation machinery to equate two regions (it's overkill).
* Add a comment that `select_in_new_trait_solver` shouldn't be used directly.

r? lcnr or reassign
2025-05-25 15:11:49 +02:00
Guillaume Gomez
9460f64362 Rollup merge of #141512 - Noratrieb:stop-trimming-this-much, r=compiler-errors
Avoid extra path trimming in method not found error

Method errors have an extra check that force trim paths whenever the normal string is longer than 10 characters, which can be quite unhelpful when multiple items have the same name (for example an `Error`).

A user reported this force trimming as being quite unhelpful when they had a method error where the precise path of the `Error` mattered.

The code uses `tcx.short_string` already to get the normal path, which tries to be clever around trimming paths if necessary, so there is no reason for this extra force trimming.
2025-05-25 15:11:48 +02:00
Guillaume Gomez
d72bc29a33 Rollup merge of #141443 - RalfJung:c-variadic-teach-help, r=workingjubilee
make teach_help message for cast-before-pass-to-variadic more precise

r? `@workingjubilee`
based on your comment [here](https://github.com/rust-lang/rust/issues/44930#issuecomment-2199663198)
2025-05-25 15:11:47 +02:00
Guillaume Gomez
b0ae228007 Rollup merge of #141413 - est31:cfg_version_env_var, r=jieyouxu
Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRING

The `#[cfg(version(...))]` feature is currently under-tested. Part of it is the difficulty that it is hard to write a test that never changes, while the version of the Rust compiler indeed *does* change.

PR #81468 added the first and so far only test of `#[cfg(version(...))]`'s functionality (there is one other test for the *syntax*, that also acts as feature gate). But that test uses a proc macro that parses the version: the text of the test doesn't contain the actual `#[cfg(version(...))]`.

This PR makes `#[cfg(version(...))]` respect `RUSTC_OVERRIDE_VERSION_STRING`, added by PR #124339, allowing us to virtually pin the rustc version and write tests from all directions against some specific version.

The PR also adds a functional test of `#[cfg(version(...))]` that leverages `RUSTC_OVERRIDE_VERSION_STRING`.

Pulled out of #141137.

Tracking issue: #64796
2025-05-25 15:11:47 +02:00
Michael Goulet
9a8cf3dd0c Comment for not using select_in_new_trait_solver 2025-05-25 10:37:58 +00:00
Michael Goulet
7820d2caba Don't use relation just to equate regions in response 2025-05-25 10:37:43 +00:00
Ralf Jung
4e8b8dad7f fix help message
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-05-25 09:35:36 +02:00
est31
f3245e48f9 Make #[cfg(version)] respect RUSTC_OVERRIDE_VERSION_STRING 2025-05-24 23:54:17 +02:00
Noratrieb
01503d0c1e Avoid extra path trimming in method not found error
Method errors have an extra check that force trim paths whenever the
normal string is longer than 10 characters, which can be quite unhelpful
when multiple items have the same name (for example an `Error`).

A user reported this force trimming as being quite unhelpful when they
had a method error where the precise path of the `Error` mattered.

The code uses `tcx.short_string` already to get the normal path, which
tries to be clever around trimming paths if necessary, so there is no
reason for this extra force trimming.
2025-05-24 23:31:07 +02:00
bors
3d86494a0d Auto merge of #141518 - GuillaumeGomez:rollup-ivjep2j, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#140066 (Stabilize `<[T; N]>::as_mut_slice` as `const`)
 - rust-lang/rust#141105 (additional edge cases tests for `path.rs` 🧪 )
 - rust-lang/rust#141487 (Update askama to `0.14.0`)
 - rust-lang/rust#141498 (Use C-string literals to reduce boilerplate)
 - rust-lang/rust#141505 (rename internal panicking::try to catch_unwind)
 - rust-lang/rust#141511 (Cleanup CodegenFnAttrFlags)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-24 21:00:10 +00:00
Guillaume Gomez
7cd749deff Rollup merge of #141511 - Noratrieb:codegen-fn-attrs, r=compiler-errors
Cleanup CodegenFnAttrFlags

- Rename `USED` to `USED_COMPILER` to better reflect its behavior.
- Reorder some items to group the used and allocator flags together
- Renumber them without gaps
2025-05-24 21:23:50 +02:00