3281 Commits

Author SHA1 Message Date
Jeremy Smart
1a1510816a
handle const generics, ?Sized, early bound lifetimes 2025-09-16 10:17:25 -04:00
Bryanskiy
bd089e1e6e Default auto traits: revert to the default supertraits 2025-09-10 15:08:06 +03:00
bors
7ad23f43a2 Auto merge of #146375 - matthiaskrgr:rollup-utik9zj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#145463 (Reject invalid literal suffixes in tuple indexing, tuple struct indexing, and struct field name position)
 - rust-lang/rust#145929 (fix APITIT being treated as a normal generic parameter in suggestions)
 - rust-lang/rust#146001 (Update getopts to remove unicode-width dependency)
 - rust-lang/rust#146365 (triagebot: warn about #[rustc_intrinsic_const_stable_indirect])
 - rust-lang/rust#146366 (add approx_delta to all gamma tests)
 - rust-lang/rust#146373 (fix comments about trait solver cycle heads)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-09 18:14:23 +00:00
Matthias Krüger
85f3989ca5
Rollup merge of #145929 - Qelxiros:apitit-suggestion, r=BoxyUwU
fix APITIT being treated as a normal generic parameter in suggestions

closes rust-lang/rust#126395
2025-09-09 17:32:20 +02:00
bors
364da5d88d Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnr
rename erase_regions to erase_and_anonymize_regions

I find it consistently confusing that `erase_regions` does more than replacing regions with `'erased`. it also makes some code look real goofy to be writing manual folders to erase regions with a comment saying "we cant use erase regions" :> or code that re-calls erase_regions on types with regions already erased just to anonymize all the bound regions.

r? lcnr

idk how i feel about the name being almost twice as long now
2025-09-09 15:04:44 +00:00
Boxy
e379c77586 erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00
Jana Dönszelmann
6087d89004
fixup limit handling code 2025-09-08 15:07:12 -07:00
Jeremy Smart
2f0c1035ed
fix APITIT being treated as a normal generic parameter in suggestions 2025-09-08 08:32:22 -04:00
Jacob Pratt
00d5dc5c9d
Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35
Implement Integer funnel shifts

Tracking issue: rust-lang/rust#145686
ACP: https://github.com/rust-lang/libs-team/issues/642

This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else

Thanks `@folkertdev` for the fixes and tests

cc `@rust-lang/libs-api`
2025-09-04 01:43:21 -04:00
Stuart Cook
cd59ee791f
Rollup merge of #145342 - dianne:if-let-super-let, r=nnethercote
fix drop scope for `super let` bindings within `if let`

Fixes rust-lang/rust#145328 by making non-lifetime-extended `super let` reuse the logic used to compute drop scopes for non-lifetime-extended temporaries.

Also fixes rust-lang/rust#145374, which regressed due to rust-lang/rust#143376 introducing `if let`-like scopes for match arms with guards.

Tracking issue for `super let`: rust-lang/rust#139076

This is a regression fix / breaking change for macros stably exposing `super let`, including `pin!` and `format_args!`.
Nominating to be discussed alongside rust-lang/rust#145328: ```@rustbot``` label +I-lang-nominated +I-libs-api-nominated
2025-09-04 10:01:53 +10:00
sayantn
62b4347e80
Add funnel_sh{l,r} functions and intrinsics
- Add a fallback implementation for the intrinsics
 - Add LLVM backend support for funnel shifts

Co-Authored-By: folkertdev <folkert@folkertdev.nl>
2025-09-03 14:13:24 +05:30
Guillaume Gomez
07f7d86f36
Rollup merge of #146102 - fmease:rm-dead-eff-code-iii, r=fee1-dead
Remove dead code stemming from an old effects desugaring

CC https://github.com/rust-lang/rust/pull/132374, https://github.com/rust-lang/rust/pull/133443.

r? fee1-dead
2025-09-02 17:08:58 +02:00
Guillaume Gomez
ae0e7b97e0
Rollup merge of #144066 - RalfJung:extern-c-variadics, r=workingjubilee
stabilize c-style varargs for sysv64, win64, efiapi, aapcs

This has been split up so the PR now only contains the extended_varargs_abi_support stabilization; "system" has been moved to https://github.com/rust-lang/rust/pull/145954.

**Previous (combined) PR description:**

This stabilizes extern block declarations of variadic functions with the system, sysv64, win64, efiapi, aapcs ABIs. This corresponds to the extended_varargs_abi_support and extern_system_varargs feature gates.

The feature gates were split up since it seemed like there might be further discussion needed for what exactly "system" ABI variadic functions should do, but a [consensus](https://github.com/rust-lang/rust/issues/136946#issuecomment-2967847553) has meanwhile been reached: they shall behave like "C" functions. IOW, the ABI of a "system" function is (bold part is new in this PR):
- "stdcall" for win32 targets **for non-variadic functions**
- "C" for everything else

This had been previously stabilized *without FCP* in https://github.com/rust-lang/rust/pull/116161, which got reverted in https://github.com/rust-lang/rust/pull/136897. There was also a "fun" race condition involved with the system ABI being [added](https://github.com/rust-lang/rust/pull/119587) to the list of variadic-supporting ABIs between the creation and merge of rust-lang/rust#116161.

There was a question raised [here](https://github.com/rust-lang/rust/pull/116161#issuecomment-1983829513) whether t-lang even needs to be involved for a change like this. Not sure if that has meanwhile been clarified? The behavior of the "system" ABI (a Rust-specific ABI) definitely feels like t-lang territory to me.

Fixes rust-lang/rust#100189
Cc `@rust-lang/lang`

# Stabilization report

> ## General design

>  ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?

AFAIK there is no RFC. The tracking issues are
- https://github.com/rust-lang/rust/issues/100189
- https://github.com/rust-lang/rust/issues/136946

>  ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

The only controversial point is whether "system" ABI functions should support variadics.
- Pro: This allows crates like windows-rs to consistently use "system", see e.g. https://github.com/microsoft/windows-rs/issues/3626.
- Cons: `@workingjubilee` had some implementation concerns, but I think those have been [resolved](https://github.com/rust-lang/rust/issues/136946#issuecomment-2967847553). EDIT: turns out Jubilee still has concerns (she mentioned that in a DM); I'll let her express those.

Note that "system" is already a magic ABI we introduced to "do the right thing". This just makes it do the right thing in more cases. In particular, it means that on Windows one can almost always just do
```rust
extern "system" {
  // put all the things here
}
```
and it'll do the right thing, rather than having to split imports into non-varargs and varargs, with the varargs in a separate `extern "C"` block (and risking accidentally putting a non-vararg there).

(I am saying "almost" always because some Windows API functions actually use cdecl, not stdcall, on x86. Those of course need to go in `extern "C"` blocks.)

> ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?

Actually defining variadic functions in Rust remains unstable, under the [c_variadic feature gate](https://github.com/rust-lang/rust/issues/44930).

> ## Has a Call for Testing period been conducted? If so, what feedback was received?
>
> Does any OSS nightly users use this feature? For instance, a useful indication might be "search <grep.app> for `#![feature(FEATURE_NAME)]` and had `N` results".

There was no call for testing.

A search brings up https://github.com/rust-osdev/uefi-rs/blob/main/uefi-raw/src/table/boot.rs using this for "efiapi". This doesn't seem widely used, but it is an "obvious" gap in our support for c-variadics.

> ## Implementation quality

All rustc does here is forward the ABI to LLVM so there's lot a lot to say here...

> ### Summarize the major parts of the implementation and provide links into the code (or to PRs)
>
> An example for async closures: <https://rustc-dev-guide.rust-lang.org/coroutine-closures.html>.

The check for allowed variadic ABIs is [here](9c870d30e2/compiler/rustc_hir_analysis/src/lib.rs (L109-L126)).

The special handling of "system" is [here](c24914ec83/compiler/rustc_target/src/spec/abi_map.rs (L82-L85)).

> ### Summarize existing test coverage of this feature
>
> Consider what the "edges" of this feature are.  We're particularly interested in seeing tests that assure us about exactly what nearby things we're not stabilizing.
>
> Within each test, include a comment at the top describing the purpose of the test and what set of invariants it intends to demonstrate. This is a great help to those reviewing the tests at stabilization time.
>
> - What does the test coverage landscape for this feature look like?
>   - Tests for compiler errors when you use the feature wrongly or make mistakes?
>   - Tests for the feature itself:
>       - Limits of the feature (so failing compilation)
>       - Exercises of edge cases of the feature
>       - Tests that checks the feature works as expected (where applicable, `//@ run-pass`).
>   - Are there any intentional gaps in test coverage?
>
> Link to test folders or individual tests (ui/codegen/assembly/run-make tests, etc.).

Prior PRs add a codegen test for all ABIs and tests actually calling extern variadic functions for sysv64 and win64:
- https://github.com/rust-lang/rust/pull/144359
- https://github.com/rust-lang/rust/pull/144379

We don't have a way of executing uefi target code in the test suite, so it's unclear how to fully test efiapi. aapcs could probably be done? (But note that we have hardly an such actually-calling-functions tests for ABI things, we almost entirely rely on codegen tests.)

The test ensuring that we do *not* stabilize *defining* c-variadic functions is `tests/ui/feature-gates/feature-gate-c_variadic.rs`.

> ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?

None that I am aware of.

> ### What FIXMEs are still in the code for that feature and why is it ok to leave them there?

None that I am aware of.

> ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization

`@Soveu` added sysv64, win64, efiapi, aapcs to the list of ABIs that allow variadics, `@beepster4096` added system.  `@workingjubilee` recently refactored the ABI handling in the compiler, also affecting this feature.

> ### Which tools need to be adjusted to support this feature. Has this work been done?
>
> Consider rustdoc, clippy, rust-analyzer, rustfmt, rustup, docs.rs.

Maybe RA needs to be taught about the new allowed ABIs? No idea how precisely they mirror what exactly rustc accepts and rejects here.

> ## Type system and execution rules

> ### What compilation-time checks are done that are needed to prevent undefined behavior?
>
>  (Be sure to link to tests demonstrating that these tests are being done.)

Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.

> ### Does the feature's implementation need checks to prevent UB or is it sound by default and needs opt in in places to perform the dangerous/unsafe operations? If it is not sound by default, what is the rationale?

Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.

> ### Can users use this feature to introduce undefined behavior, or use this feature to break the abstraction of Rust and expose the underlying assembly-level implementation? (Describe.)

Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.

> ### What updates are needed to the reference/specification? (link to PRs when they exist)

- https://github.com/rust-lang/reference/pull/1936

> ## Common interactions

> ### Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries?

No.

> ### What other unstable features may be exposed by this feature?

None.
2025-09-02 17:08:52 +02:00
Nicholas Nethercote
301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
Ralf Jung
f6d55aea2c stabilize extended_varargs_abi_support 2025-09-02 08:48:12 +02:00
León Orell Valerian Liehr
6fc0cf4288
Remove dead code stemming from an old effects desugaring 2025-09-01 21:39:01 +02:00
lcnr
6fd0e50ecf autoderef final ty is already resolved 2025-08-29 10:53:39 +02:00
Nicholas Nethercote
200f56d605 Add itertools to [workspace.dependencies]. 2025-08-27 14:21:21 +10:00
Nicholas Nethercote
c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
lcnr
d6a18e1867 change non-defining use error message 2025-08-25 14:20:18 +02:00
lcnr
14b0ba6a05 support non-defining uses in HIR typeck 2025-08-25 14:20:18 +02:00
lcnr
17ac2fc96d change HIR typeck unification handling approach 2025-08-22 13:39:38 +02:00
Folkert de Vries
d25910eaeb
make prefetch intrinsics safe 2025-08-20 00:35:42 +02:00
Stuart Cook
8f1202cef2
Rollup merge of #145235 - compiler-errors:comment, r=BoxyUwU
Minor `[const]` tweaks

Self explanatory
2025-08-15 16:16:38 +10:00
Marcelo Domínguez
250d77e5d7 Complete functionality and general cleanup 2025-08-14 16:30:15 +00:00
Marcelo Domínguez
5c631041aa Basic implementation of autodiff intrinsic 2025-08-14 16:29:58 +00:00
Cameron Steffen
d4eb0947f1 Cleanup assoc parent utils 2025-08-13 09:33:09 -05:00
dianne
8fc3938d99 fix scope of super let bindings within if let
They now use the enclosing temporary scope as their scope, regardless of
which `ScopeData` was used to mark it.
2025-08-13 01:38:22 -07:00
Cameron Steffen
bf266dc834 Propagate TraitImplHeader to hir 2025-08-11 17:05:42 -05:00
Stuart Cook
64aea0027a
Rollup merge of #135331 - fmease:ban-assoc-ty-unbounds, r=lcnr
Reject relaxed bounds inside associated type bounds (ATB)

**Reject** relaxed bounds — most notably `?Sized` — inside associated type bounds `TraitRef<AssocTy: …>`.

This was previously accepted without warning despite being incorrect: ATBs are *not* a place where we perform *sized elaboration*, meaning `TraitRef<AssocTy: …>` does *not* elaborate to `TraitRef<AssocTy: Sized + …>` if `…` doesn't contain `?Sized`. Therefore `?Sized` is meaningless. In no other (stable) place do we (intentionally) allow relaxed bounds where we don't also perform sized elab, this is highly inconsistent and confusing! Another point of comparison: For the desugared `$SelfTy: TraitRef, $SelfTy::AssocTy: …` we don't do sized elab either (and thus also don't allow relaxed bounds).

Moreover — as I've alluded to back in https://github.com/rust-lang/rust/pull/135841#pullrequestreview-2619462717 — some later validation steps only happen during sized elaboration during HIR ty lowering[^1]. Namely, rejecting duplicates (e.g., `?Trait + ?Trait`) and ensuring that `Trait` in `?Trait` is equal to `Sized`[^2]. As you can probably guess, on stable/master we don't run these checks for ATBs (so we allow even more nonsensical bounds like `Iterator<Item: ?Copy>` despite T-types's ruling established in the FCP'ed rust-lang/rust#135841).

This PR rectifies all of this. I cratered this back in 2025-01-10 with (allegedly) no regressions found ([report](https://github.com/rust-lang/rust/pull/135331#issuecomment-2585330783), [its analysis](https://github.com/rust-lang/rust/pull/135331#issuecomment-2585356422)). [However a contributor manually found two occurrences](https://github.com/rust-lang/rust/issues/135229#issuecomment-2581832852) of `TraitRef<AssocTy: ?Sized>` in small hobby projects (presumably via GH code search). I immediately sent downstream PRs: https://github.com/Gui-Yom/turbo-metrics/pull/14, https://github.com/ireina7/summon/pull/1 (however, the owners have showed no reaction so far).

I'm leaning towards banning these forms **without a FCW** because a FCW isn't worth the maintenance cost[^3]. Note that associated type bounds were stabilized in 1.79.0 (released 2024-06-13 which is 13 months ago), so the proliferation of ATBs shouldn't be that high yet. If you think we should do another crater run since the last one was 6 months ago, I'm fine with that.

Fixes rust-lang/rust#135229.

[^1]: I consider this a flaw in the implementation and [I've already added a huge FIXME](82a02aefe0/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs (L195-L207)).
[^2]: To be more precise, if the internal flag `-Zexperimental-default-bounds` is provided other "default traits" (needs internal feature `lang_items`) are permitted as well (cc closely related internal feature: `more_maybe_bounds`).
[^3]: Having to track this and adding an entire lint whose remnants would remain in the code base forever (we never *fully* remove lints).
2025-08-11 18:22:31 +10:00
Michael Goulet
50323736ad Remove unnecessary trait predicate eq function 2025-08-11 01:46:42 +00:00
bors
ca77504943 Auto merge of #145142 - Zalathar:rollup-oi6s8kg, r=Zalathar
Rollup of 23 pull requests

Successful merges:

 - rust-lang/rust#141658 (rustdoc search: prefer stable items in search results)
 - rust-lang/rust#141828 (Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code)
 - rust-lang/rust#144823 (coverage: Extract HIR-related helper code out of the main module)
 - rust-lang/rust#144883 (Remove unneeded `drop_in_place` calls)
 - rust-lang/rust#144923 (Move several more float tests to floats/mod.rs)
 - rust-lang/rust#144988 (Add annotations to the graphviz region graph on region origins)
 - rust-lang/rust#145010 (Couple of minor abi handling cleanups)
 - rust-lang/rust#145017 (Explicitly disable vector feature on s390x baseline of bad-reg test)
 - rust-lang/rust#145027 (Optimize `char::is_alphanumeric`)
 - rust-lang/rust#145050 (add member constraints tests)
 - rust-lang/rust#145073 (update enzyme submodule to handle llvm 21)
 - rust-lang/rust#145080 (Escape diff strings in MIR dataflow graphviz)
 - rust-lang/rust#145082 (Fix some bad formatting in `-Zmacro-stats` output.)
 - rust-lang/rust#145083 (Fix cross-compilation of Cargo)
 - rust-lang/rust#145096 (Fix wasm target build with atomics feature)
 - rust-lang/rust#145097 (remove unnecessary `TypeFoldable` impls)
 - rust-lang/rust#145100 (Rank doc aliases lower than equivalently matched items)
 - rust-lang/rust#145103 (rustc_metadata: remove unused private trait impls)
 - rust-lang/rust#145115 (defer opaque type errors, generally greatly reduce tainting)
 - rust-lang/rust#145119 (rustc_public: fix missing parenthesis in pretty discriminant)
 - rust-lang/rust#145124 (Recover `for PAT = EXPR {}`)
 - rust-lang/rust#145132 (Refactor map_unit_fn lint)
 - rust-lang/rust#145134 (Reduce indirect assoc parent queries)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-09 08:57:23 +00:00
Stuart Cook
d88a309114
Rollup merge of #145134 - camsteffen:indirect-assoc-parent, r=cjgillot
Reduce indirect assoc parent queries

Simplify some code that uses multiple queries to get the parent of an associated item.
2025-08-09 13:58:55 +10:00
bors
2de2456fb7 Auto merge of #143376 - dianne:guard-scope, r=matthewjasper
add a scope for `if let` guard temporaries and bindings

This fixes my concern with `if let` guard drop order, namely that the guard's bindings and temporaries were being dropped after their arm's pattern's bindings, instead of before (https://github.com/rust-lang/rust/pull/141295#issuecomment-2968975596). The guard's bindings and temporaries now live in a new scope, which extends until (but not past) the end of the arm, guaranteeing they're dropped before the arm's pattern's bindings.

This only introduces a new scope for match arms with guards. Perf results (https://github.com/rust-lang/rust/pull/143376#issuecomment-3034922617) seemed to indicate there wasn't a significant hit to introduce a new scope on all match arms, but guard patterns (rust-lang/rust#129967) will likely benefit from only adding new scopes when necessary (with some patterns requiring multiple nested scopes).

Tracking issue for `if_let_guard`: rust-lang/rust#51114

Tests are adapted from examples by `@traviscross,` `@est31,` and myself on rust-lang/rust#141295.
2025-08-09 03:19:26 +00:00
Cameron Steffen
eec8585f65 Reduce indirect assoc parent queries 2025-08-08 17:28:19 -05:00
Trevor Gross
6fa6a854cd
Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic
atomicrmw on pointers: move integer-pointer cast hacks into backend

Conceptually, we want to have atomic operations on pointers of the form `fn atomic_add(ptr: *mut T, offset: usize, ...)`. However, LLVM does not directly support such operations (https://github.com/llvm/llvm-project/issues/120837), so we have to cast the `offset` to a pointer somewhere.

This PR moves that hack into the LLVM backend, so that the standard library, intrinsic, and Miri all work with the conceptual operation we actually want. Hopefully, one day LLVM will gain a way to represent these operations without integer-pointer casts, and then the hack will disappear entirely.

Cc ```@nikic``` -- this is the best we can do right now, right?
Fixes https://github.com/rust-lang/rust/issues/134617
2025-08-08 14:22:44 -05:00
dianne
0bdaef5b63 only introduce a guard scope for arms with guards 2025-08-07 16:51:41 -07:00
dianne
b2241c78c8 add a scope for if let guard temporaries and bindings
This ensures `if let` guard temporaries and bindings are dropped before
the match arm's pattern's bindings.
2025-08-07 16:43:20 -07:00
Esteban Küber
99196657fc Use tcx.short_string() in more diagnostics
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`.

We add support for shortening the path of "trait path only".

Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem).

When we don't actually print out a shortened type we don't need the "use `--verbose`" note.

On E0599 show type identity to avoid expanding the receiver's generic parameters.

Unify wording on `long_ty_path` everywhere.
2025-08-07 21:18:00 +00:00
León Orell Valerian Liehr
02ea38cfff
Fortify generic param default checks 2025-08-06 01:26:26 +02:00
Stuart Cook
7307dc0ca1
Rollup merge of #144694 - compiler-errors:with-self-ty, r=SparrowLii
Distinguish prepending and replacing self ty in predicates

There are two kinds of functions called `with_self_ty`:
1. Prepends the `Self` type onto an `ExistentialPredicate` which lacks it in its internal representation.
2. Replaces the `Self` type of an existing predicate, either for diagnostics purposes or in the new trait solver when normalizing that self type.

This PR distinguishes these two because I often want to only grep for one of them. Namely, let's call it `with_replaced_self_ty` when all we're doing is replacing the self type.
2025-08-04 14:58:09 +10:00
bors
7cd950546b Auto merge of #144704 - compiler-errors:explode-wf, r=lcnr
expand WF obligations when checking method calls

Don't wrap a bunch of signatures in `FnPtr` then check their WF; instead, check the WFness of each input/output separately.

This is useful for the new trait solver, since because we stall on root obligations we end up needing to repeatedly recompute the WFness of possibly very large function signature types if it ends up bottoming out in ambiguity.

This may also give us more chances to hit the WF fast path for certain types like built-ins.

Finally, this just seems conceptually correct to do. There's nothing conceptually that suggests that wrapping the function signature in an fn pointer makes sense at all to do; I'm guessing that it was just convenient so that we didn't have to register WF obligations in a loop, but it doesn't affect the readability of this code at all.
2025-08-03 09:29:54 +00:00
bors
da19b9d24c Auto merge of #144677 - nnethercote:bound-const-handling, r=lcnr
Improve bound const handling

A few changes to make const handling more similar to type handling.

r? `@compiler-errors` -errors
2025-08-03 05:26:43 +00:00
Samuel Tardieu
d082ff4c04
Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=Amanieu
Improve formatting of doc code blocks

We don't currently apply automatic formatting to doc comment code blocks. As a
result, it has built up various idiosyncracies, which make such automatic
formatting difficult. Some of those idiosyncracies also make things harder for
human readers or other tools.

This PR makes a few improvements to doc code formatting, in the hopes of making
future automatic formatting easier, as well as in many cases providing net
readability improvements.

I would suggest reading each commit separately, as each commit contains one
class of changes.
2025-08-02 11:24:24 +02:00
bors
63f6845e57 Auto merge of #144458 - compiler-errors:no-witness-mini, r=lcnr
Remove the witness type from coroutine *args* (without actually removing the type)

This does as much of rust-lang/rust#144157 as we can without having to break rust-lang/rust#143545 and/or introduce some better way of handling higher ranked assumptions.

Namely, it:
* Stalls coroutines based off of the *coroutine* type rather than the witness type.
* Reworks the dtorck constraint hack to not rely on the witness type.
* Removes the witness type from the args of the coroutine, eagerly creating the type for nested obligations when needed (auto/clone impls).

I'll experiment with actually removing the witness type in a follow-up.

r? lcnr
2025-08-01 21:07:49 +00:00
Michael Goulet
e9765781b2 Remove the witness type from coroutine args 2025-07-31 17:38:28 +00:00
Jana Dönszelmann
26c28ee2ef
Rollup merge of #144726 - jdonszelmann:move-attr-data-structures, r=lcnr
merge rustc_attr_data_structures into rustc_hir

this move was discussed on zulip: [#t-compiler > attribute parsing rework @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/528530091)

Many PRs in the attribute rework depend on this move.
2025-07-31 17:19:40 +02:00
Jana Dönszelmann
e1d3ad89c7
remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
Nicholas Nethercote
1901dde97b Deduplicate IntTy/UintTy/FloatTy.
There are identical definitions in `rustc_type_ir` and `rustc_ast`. This
commit removes them and places a single definition in `rustc_ast_ir`.
This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but
means a bunch of silly conversion functions can be removed.

The one annoying wrinkle is that the old version had differences in
their `Debug` impls, e.g. one printed `u32` while the other printed
`U32`. Some compiler error messages rely on the former (yuk), and some
clippy output depends on the latter. So the commit also changes clippy
to not rely on `Debug` and just implement what it needs itself.
2025-07-31 19:56:11 +10:00
Nicholas Nethercote
507dec4dc3 Make const bound handling more like types/regions.
Currently there is `Ty` and `BoundTy`, and `Region` and `BoundRegion`,
and `Const` and... `BoundVar`. An annoying inconsistency.

This commit repurposes the existing `BoundConst`, which was barely used,
so it's the partner to `Const`. Unlike `BoundTy`/`BoundRegion` it lacks
a `kind` field but it's still nice to have because it makes the const
code more similar to the ty/region code everywhere.

The commit also removes `impl From<BoundVar> for BoundTy`, which has a
single use and doesn't seem worth it.

These changes fix the "FIXME: We really should have a separate
`BoundConst` for consts".
2025-07-31 19:29:40 +10:00