about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2025-09-30Rollup merge of #147184 - jdonszelmann:bevy-outlives-bound, r=lcnrMatthias Krüger-1/+7
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-30Rollup merge of #146617 - Jules-Bertholet:E0277-NOFORN, r=SparrowLiiMatthias Krüger-1/+16
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-30clone region obligations instead of taking in implied bounds hackJana Dönszelmann-1/+7
2025-09-30Rollup merge of #147109 - BoxyUwU:rename_concrete_opaques, r=lcnrStuart Cook-1/+1
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-30Fix unuseful span in type error in some format_args!() invocationsTomoaki Kobayashi-8/+37
2025-09-27Rename various "concrete opaque type" terminology to say "hidden type"Boxy Uwu-1/+1
2025-09-26allow method calls on opaqueslcnr-2/+9
2025-09-25Auto merge of #146919 - lcnr:yeet-fast-path, r=fee1-deadbors-13/+1
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-24Rollup merge of #146971 - lcnr:fix-writeback, r=BoxyUwUMatthias Krüger-3/+3
fix ICE in writeback due to bound regions fixes rust-lang/rust#117808 r? `@BoxyUwU`
2025-09-24Improve derive suggestion of const paramtiif-4/+7
Make the suggestion not to remove the adt and use the name of the adt variant
2025-09-24imrpove type_op failure ICElcnr-3/+3
2025-09-23yeet fastpathlcnr-13/+1
2025-09-18move `mod canonical` out of `eval_ctxt`lcnr-2/+2
2025-09-18Auto merge of #146727 - matthiaskrgr:rollup-98812uj, r=matthiaskrgrbors-0/+4
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-18Rollup merge of #146597 - modhanami:add-struct-tail-recursion-limit-span, ↵Matthias Krüger-0/+1
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-18Rollup merge of #146434 - folkertdev:c-variadic-inherent-methods, ↵Matthias Krüger-0/+3
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-18Auto merge of #145993 - lcnr:allow-calling-opaques, r=BoxyUwUbors-17/+38
`-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-18support calls on opaque types :<lcnr-17/+38
2025-09-18Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmannStuart Cook-31/+25
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-17Rollup merge of #146581 - estebank:issue-146489, r=lcnrStuart Cook-3/+10
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-17Remove `DynKind`León Orell Valerian Liehr-31/+25
2025-09-16fmtEsteban Küber-2/+3
2025-09-16Add span for struct tail recursion limit errorTawan Muadmuenwai-0/+1
2025-09-15Don’t suggest foreign `doc(hidden)` types in E0277 diagnosticsJules Bertholet-1/+16
2025-09-16Rollup merge of #145095 - tiif:unstable_const_param, r=BoxyUwUStuart Cook-15/+23
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-15Silence inference error on `PatKind::Err`Esteban Küber-2/+8
2025-09-15Add check to make sure ConstParamTy impls of certain types are gated with ↵tiif-15/+23
#[unstable_feature_bound(unsized_const_params)]
2025-09-13Auto merge of #145186 - camsteffen:assoc-impl-kind, r=petrochenkovbors-12/+10
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-13Rollup merge of #146403 - cyrgani:array-sugg-sorting, r=fee1-deadJana Dönszelmann-3/+15
sort array trait implementation suggestions correctly Fixes rust-lang/rust#135098. Previously tried in rust-lang/rust#137428.
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-8/+6
2025-09-12Introduce hir::ImplItemImplKindCameron Steffen-1/+1
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-6/+6
2025-09-12sort array trait implementation suggestions correctlycyrgani-3/+15
2025-09-11c-variadic: allow trait methods to be c-variadicFolkert de Vries-0/+3
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-11Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov"Jieyou Xu-36/+4
This reverts commit 1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28, reversing changes made to 324bf2b9fd8bf9661e7045c8a93f5ff0ec1a8ca5. 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-09Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnrbors-16/+23
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-09Driveby fixesBoxy-0/+2
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-16/+21
2025-09-09Rollup merge of #145819 - jdonszelmann:convert-limits, r=fmeaseStuart Cook-2/+2
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-08fixup limit handling codeJana Dönszelmann-2/+2
2025-09-08reviewlcnr-2/+3
2025-09-08optimize `CanonicalVarValues::instantiate`lcnr-3/+2
2025-09-08pass `sub_relations` into canonical querieslcnr-2/+3
2025-09-08eagerly compute `sub_relations` againlcnr-98/+7
2025-09-06Rollup merge of #144801 - estebank:issue-144734, r=spastorinoMatthias Krüger-10/+68
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-05remove couple of clonesMatthias Krüger-1/+1
2025-09-02Auto merge of #145951 - lcnr:proof-tree-as-query, r=compiler-errorsbors-12/+22
cleanup and cache proof tree building There's some cruft left over from when we had deep proof trees. We never encounter overflow when evaluating proof trees. Even if the recursion limit is `0`, we still only hit the overflow limit when evaluating nested goals of the root. The root goal simply inherits the `root_depth` of the `SearchGraph`. Split `evaluate_root_goal_for_proof_tree` from the rest of the trait solver. This enables us to simplify the implementation of `evaluate_goal_raw` and the `ProofTreeBuilder` as we no longer need to manually track the state of the builder and can instead use separate types for that. It does require making a few internal methods into associated functions taking a `delegate` and a `span` instead of the `EvalCtxt` itself. I've also split `SearchGraph::evaluate_goal` and `SearchGraph::evaluate_root_goal_for_proof_tree` for the same reason. Both functions don't actually share too much code, so by splitting them each version gets significantly easier to read. Add a `query evaluate_root_goal_for_proof_tree_raw` to cache proof tree building. This requires arena allocating `inspect::Probe`. I've added a new type alias `I::ProbeRef` for this. We may need to adapt this for rust-analyzer? It would definitely be easy to remove the `Copy` bound here :thinking:
2025-09-02Revert introduction of `[workspace.dependencies]`.Nicholas Nethercote-3/+3
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-08-31Split `ObligationCauseCode::BinOp` for unops to `UnOp`Esteban Küber-19/+12
2025-08-30Detect negative literal inferred to unsigned integerEsteban Küber-1/+40
``` error[E0277]: the trait bound `usize: Neg` is not satisfied --> $DIR/negative-literal-infered-to-unsigned.rs:2:14 | LL | for x in -5..5 { | ^^ the trait `Neg` is not implemented for `usize` | help: consider specifying an integer type that can be negative | LL | for x in -5isize..5 { | +++++ ```