Commit Graph

5412 Commits

Author SHA1 Message Date
Michael Goulet
e3f104608c Don't normalize higher-ranked assumptions if they're not used 2025-10-03 10:32:23 -04:00
bors
4b9c62b4da Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnr
Split Bound index into Canonical and Bound

See [#t-types/trait-system-refactor > perf `async-closures/post-mono-higher-ranked-hang.rs`](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/perf.20.60async-closures.2Fpost-mono-higher-ranked-hang.2Ers.60/with/541535613) for context

Things compile and tests pass, but not sure if this actually solves the perf issue (edit: it does). Opening up this to do a perf (and maybe crater) run.

r? lcnr
2025-10-02 08:09:33 +00:00
Stuart Cook
d4a0f21290 Rollup merge of #147199 - jdonszelmann:outdated-comment-infctx, r=lcnr
remove outdated comment in (inner) `InferCtxt`

This comment seems to have stopped being relevant around 3 years ago after 9f95c605f8. A map? what map? :P

r? `@lcnr`
2025-10-01 22:15:01 +10:00
Jana Dönszelmann
bdebd479ac remove outdated context (inner) infctx 2025-09-30 21:56:06 +02:00
Matthias Krüger
598ba1f65f Rollup merge of #147184 - jdonszelmann:bevy-outlives-bound, r=lcnr
Fix the bevy implied bounds hack for the next solver

The diff is trivial, of course, and basically what you already suggested. Mostly dug around a bunch to learn. I hope this is roughly what you had in mind.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/236.

r? `@lcnr`
2025-09-30 21:53:35 +02:00
Matthias Krüger
014e0af149 Rollup merge of #146617 - Jules-Bertholet:E0277-NOFORN, r=SparrowLii
Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics

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

``@rustbot`` label A-diagnostics T-compiler
2025-09-30 21:53:34 +02:00
Jana Dönszelmann
80e598bb12 clone region obligations instead of taking in implied bounds hack 2025-09-30 21:48:55 +02:00
jackh726
d1bbd39c59 Split Bound into Canonical and Bound 2025-09-30 12:58:28 -04:00
Stuart Cook
156d150381 Rollup merge of #147109 - BoxyUwU:rename_concrete_opaques, r=lcnr
Rename various "concrete opaque type" things to say "hidden type"

r? lcnr

I've found "concrete opaque type" terminology to be somewhat confusing as in conversation and when explaining opaque type stuff to people I always just talk about things in terms of hidden types. Also the hidden types of opaques are very much not *concrete* in the same sense that a type without any generic parameters is concrete which is an unfortunate overlap in terminology.

I've tried to update comments to also stop referring to things as concrete opaque types but this is mostly best effort as it difficult to find all such cases amongst the massive amounts of uses of "concrete" or "hidden" across the whole compiler.
2025-09-30 22:25:17 +10:00
Tomoaki Kobayashi
b13b87a1c3 Fix unuseful span in type error in some format_args!() invocations 2025-09-30 17:20:51 +09:00
Boxy Uwu
4d41177513 Rename various "concrete opaque type" terminology to say "hidden type" 2025-09-27 22:58:02 +01:00
lcnr
148fd9ad3c allow method calls on opaques 2025-09-26 16:33:15 +02:00
bors
b733736ea2 Auto merge of #146919 - lcnr:yeet-fast-path, r=fee1-dead
remove incorrect fast path

Using `tcx.is_copy_modulo_regions` drops information from the current `typing_env`. Writing a regression test for this is really hard. We need to prove `Copy` of something that doesn't directly reference a coroutine or an opaque, but does so indirectly.

cc rust-lang/rust#146813.
2025-09-25 23:50:40 +00:00
Matthias Krüger
57ee169ff2 Rollup merge of #146971 - lcnr:fix-writeback, r=BoxyUwU
fix ICE in writeback due to bound regions

fixes rust-lang/rust#117808

r? `@BoxyUwU`
2025-09-24 23:33:29 +02:00
tiif
30289353e8 Improve derive suggestion of const param
Make the suggestion not to remove the adt and use the name of the adt
variant
2025-09-24 13:29:23 +00:00
lcnr
2886ca496a imrpove type_op failure ICE 2025-09-24 13:08:25 +02:00
lcnr
4fcafc9daa yeet fastpath 2025-09-23 17:02:55 +02:00
lcnr
a08e6499e6 move mod canonical out of eval_ctxt 2025-09-18 23:56:20 +02:00
bors
0c0c58b8e4 Auto merge of #146727 - matthiaskrgr:rollup-98812uj, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#146434 (c-variadic: allow c-variadic inherent and trait methods)
 - rust-lang/rust#146487 (Improve `core::num` coverage)
 - rust-lang/rust#146597 (Add span for struct tail recursion limit error)
 - rust-lang/rust#146622 (Add regression test for issue rust-lang/rust#91831)
 - rust-lang/rust#146717 (Clean up universe evaluation during type test evaluation)
 - rust-lang/rust#146723 (Include patch in release notes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-18 16:55:05 +00:00
Matthias Krüger
b7ab58eb4d Rollup merge of #146597 - modhanami:add-struct-tail-recursion-limit-span, r=oli-obk
Add span for struct tail recursion limit error

Fixes rust-lang/rust#135629

Changes
1. Add span to RecursionLimitReached
2. Add ObligationCause parameter to struct_tail_raw
4. Update call sites to pass nearby ObligationCause or create one
5. Update affected .stderr
2025-09-18 17:20:57 +02:00
Matthias Krüger
185926c99f Rollup merge of #146434 - folkertdev:c-variadic-inherent-methods, r=workingjubilee
c-variadic: allow c-variadic inherent and trait methods

tracking issue: https://github.com/rust-lang/rust/issues/44930

Continuing the work of https://github.com/rust-lang/rust/pull/146342, allow inherent and trait methods to be c-variadic. However, a trait that contains a c-variadic method is no longer dyn-compatible.

There is, presumably, some way to make c-variadic methods dyn-compatible. However currently, we don't have confidence that it'll work reliably: when methods from a `dyn` object are cast to a function pointer, a `ReifyShim` is created. If that shim is c-variadic, it would need to forward the C variable argument list.

That does appear to work, because the `va_list` is not represented in MIR at all in this case, so the registers from the call site are untouched by the shim and can be read by the actual implementation. That just does not seem like a solid implementation.

Also, intuitively, why would c-variadic function, primarily needed for FFI, need to be used with `dyn` objects at all? We can revisit this limitation if a need arises.

r? `@workingjubilee`
2025-09-18 17:20:56 +02:00
bors
4cd91ef822 Auto merge of #145993 - lcnr:allow-calling-opaques, r=BoxyUwU
`-Znext-solver` allow `ExprKind::Call` for not-yet defined opaques

Based on https://github.com/rust-lang/rust/pull/146329. Revival of rust-lang/rust#140496. See the comment on `OpaqueTypesJank`. I've used the following document while working on this https://hackmd.io/Js61f8PRTcyaiyqS-fH9iQ.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/181. It does introduce one subtle footgun we may want to handle before stabilization, opened https://github.com/rust-lang/trait-system-refactor-initiative/issues/230 for that. Also cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/231 for deref and index operations

r? `@BoxyUwU`
2025-09-18 13:49:53 +00:00
lcnr
f4e19c6878 support calls on opaque types :< 2025-09-18 12:58:38 +02:00
Stuart Cook
540fd20ba6 Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmann
Clean up `ty::Dynamic`

1. As a follow-up to PR rust-lang/rust#143036, remove `DynKind` entirely.
2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait`
   * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types
   * `lint` contained dyn-Trait-specific diagnostics+lints only
2025-09-18 11:48:51 +10:00
Stuart Cook
61f53585aa Rollup merge of #146581 - estebank:issue-146489, r=lcnr
Detect attempt to use var-args in closure

```
error: unexpected `...`
  --> $DIR/no-closure.rs:11:14
   |
LL |     let f = |...| {};
   |              ^^^ not a valid pattern
   |
   = note: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list

error: unexpected `...`
  --> $DIR/no-closure.rs:16:17
   |
LL |     let f = |_: ...| {};
   |                 ^^^
   |
   = note: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
```

Fix rust-lang/rust#146489, when trying to use c-style var-args in a closure. We emit a more targeted message. We also silence inference errors when the pattern is `PatKind::Err`.
2025-09-17 14:56:48 +10:00
León Orell Valerian Liehr
26f3337d4e Remove DynKind 2025-09-17 04:46:46 +02:00
Esteban Küber
c916e8886b fmt 2025-09-16 11:08:43 -07:00
Tawan Muadmuenwai
6912631d3e Add span for struct tail recursion limit error 2025-09-16 23:04:59 +07:00
Jules Bertholet
9e2f9edd7f Don’t suggest foreign doc(hidden) types in E0277 diagnostics 2025-09-15 21:52:56 -04:00
Stuart Cook
edd6721583 Rollup merge of #145095 - tiif:unstable_const_param, r=BoxyUwU
Migrate `UnsizedConstParamTy`  to unstable impl of `ConstParamTy_`

Now that we have ``#[unstable_feature_bound]``, we can remove ``UnsizedConstParamTy`` that was meant to be an unstable impl of stable type and ``ConstParamTy_`` trait.

r? `@BoxyUwU`
2025-09-16 10:25:38 +10:00
Esteban Küber
0e290e4228 Silence inference error on PatKind::Err 2025-09-15 03:06:16 -07:00
tiif
1a02cd531d Add check to make sure ConstParamTy impls of certain types are gated with #[unstable_feature_bound(unsized_const_params)] 2025-09-15 08:59:19 +00:00
bors
637b50be01 Auto merge of #145186 - camsteffen:assoc-impl-kind, r=petrochenkov
Make `AssocItem` aware of its impl kind

The general goal is to have fewer query dependencies by making `AssocItem` aware of its parent impl kind (inherent vs. trait) without having to query the parent def_kind.

See individual commits.
2025-09-13 13:59:48 +00:00
Jana Dönszelmann
5dd5264d14 Rollup merge of #146403 - cyrgani:array-sugg-sorting, r=fee1-dead
sort array trait implementation suggestions correctly

Fixes rust-lang/rust#135098.
Previously tried in rust-lang/rust#137428.
2025-09-13 02:40:44 +02:00
Cameron Steffen
9615ec7d10 Split AssocContainer::{InherentImpl,TraitImpl} 2025-09-12 15:14:15 -05:00
Cameron Steffen
88a8bfcaf0 Introduce hir::ImplItemImplKind 2025-09-12 15:14:15 -05:00
Cameron Steffen
5590e55b03 Rename AssocItemContainer -> AssocContainer 2025-09-12 15:10:30 -05:00
cyrgani
889be7860b sort array trait implementation suggestions correctly 2025-09-12 12:12:06 +02:00
Folkert de Vries
01e83adc88 c-variadic: allow trait methods to be c-variadic
but a C-variadic method makes a trait dyn-incompatible. That is because
methods from dyn traits, when cast to a function pointer, create a shim.
That shim can't really forward the c-variadic arguments.
2025-09-11 10:27:28 +02:00
Jieyou Xu
b38a86f4d7 Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov"
This reverts commit 1eeb8e8b15, reversing
changes made to 324bf2b9fd.

Unfortunately the assert desugaring change is not backwards compatible,
see RUST-145770.

Code such as

```rust
#[derive(Debug)]
struct F {
    data: bool
}

impl std::ops::Not for F {
  type Output = bool;
  fn not(self) -> Self::Output { !self.data }
}

fn main() {
  let f = F { data: true };

  assert!(f);
}
```

would be broken by the assert desugaring change. We may need to land
the change over an edition boundary, or limit the editions that the
desugaring change impacts.
2025-09-11 09:10:46 +08: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
332d8d6235 Driveby fixes 2025-09-09 14:49:16 +02:00
Boxy
e379c77586 erase_regions to erase_and_anonymize_regions 2025-09-09 14:49:16 +02:00
Stuart Cook
33318ed207 Rollup merge of #145819 - jdonszelmann:convert-limits, r=fmease
Port limit attributes to the new attribute parsing infrastructure

Doesn't pass tests, to be rebased on https://github.com/rust-lang/rust/pull/145792 which will solve that

r? `@fmease`
2025-09-09 14:35:01 +10:00
Jana Dönszelmann
6087d89004 fixup limit handling code 2025-09-08 15:07:12 -07:00
lcnr
b51a3a565a review 2025-09-08 14:17:56 +02:00
lcnr
f514586408 optimize CanonicalVarValues::instantiate 2025-09-08 14:17:56 +02:00
lcnr
28a0e77d13 pass sub_relations into canonical queries 2025-09-08 14:17:56 +02:00
lcnr
67965f817d eagerly compute sub_relations again 2025-09-08 14:17:56 +02:00
Matthias Krüger
bc0dfaa048 Rollup merge of #144801 - estebank:issue-144734, r=spastorino
Suggest bounds in more cases, accounting for type parameters referenced in predicate

Use a `ty::Visitor` to see if the failed predicate references a type parameter. If it does, then we only suggest adding a bound to an (associated) item only if the referenced parameter is present in its generics.

Provide adding bound suggestion in trait and impl associated functions in cases we previously weren't:

```
error[E0277]: `?` couldn't convert the error to `ApplicationError`
  --> $DIR/suggest-complex-bound-on-method.rs:18:16
   |
LL |         t.run()?;
   |           -----^ the trait `From<<T as Trait>::Error>` is not implemented for `ApplicationError`
   |           |
   |           this can't be annotated with `?` because it has type `Result<_, <T as Trait>::Error>`
   |
note: `ApplicationError` needs to implement `From<<T as Trait>::Error>`
  --> $DIR/suggest-complex-bound-on-method.rs:12:1
   |
LL | enum ApplicationError {
   | ^^^^^^^^^^^^^^^^^^^^^
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
   |
LL |     fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> {
   |                                                                     +++++++++++++++++++++++++++++++++++++++++++++++++
```

Fix rust-lang/rust#144734.
2025-09-06 13:03:15 +02:00