about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/traits
AgeCommit message (Collapse)AuthorLines
2023-09-11split GoalEvaluation and CanonicalGoalEvaluationlcnr-50/+43
the unnormalized goal is in the callers inference context, while anything inside of the `CanonicalGoalEvaluation` is inside of a new one.
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-2/+1
2023-08-14Point at return type when it influences non-first `match` armEsteban Küber-1/+1
When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-14Remove constness from `ImplSource::Param`Deadbeef-7/+8
2023-08-04Rollup merge of #114287 - lcnr:overflow, r=compiler-errorsMichael Goulet-2/+102
update overflow handling in the new trait solver implements https://hackmd.io/QY0dfEOgSNWwU4oiGnVRLw?view. I want to clean up this doc and add it to the rustc-dev-guide, but I think this PR is ready for merge as is, even without the dev-guide entry. r? `@compiler-errors`
2023-08-04Auto merge of #114036 - compiler-errors:upcast-to-fewer-assocs, r=lcnrbors-7/+13
Rework upcasting confirmation to support upcasting to fewer projections in target bounds This PR implements a modified trait upcasting algorithm that is resilient to changes in the number of associated types in the bounds of the source and target trait objects. It does this by equating each bound of the target trait ref individually against the bounds of the source trait ref, rather than doing them all together by constructing a new trait object. #### The new way we do trait upcasting confirmation 1. Equate the target trait object's principal trait ref with one of the supertraits of the source trait object's principal. https://github.com/rust-lang/rust/blob/fdcab310b2a57a4e9cc0b2629abd27afda49cd80/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2509-L2525 2. Make sure that every auto trait in the *target* trait object is present in the source trait ref's bounds. https://github.com/rust-lang/rust/blob/fdcab310b2a57a4e9cc0b2629abd27afda49cd80/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2559-L2562 3. For each projection in the *target* trait object, make sure there is exactly one projection that equates with it in the source trait ref's bound. If there is more than one, bail with ambiguity. https://github.com/rust-lang/rust/blob/fdcab310b2a57a4e9cc0b2629abd27afda49cd80/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2526-L2557 * Since there may be more than one that applies, we probe first to check that there is exactly one, then we equate it outside of a probe once we know that it's unique. 4. Make sure the lifetime of the source trait object outlives the lifetime of the target. <details> <summary>Meanwhile, this is how we used to do upcasting:</summary> 1. For each supertrait of the source trait object, take that supertrait, append the source object's projection bounds, and the *target* trait object's auto trait bounds, and make this into a new object type: https://github.com/rust-lang/rust/blob/d12c6e947ceacf3b22c154caf9532b390d8dc88a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs#L915-L929 2. Then equate it with the target trait object: https://github.com/rust-lang/rust/blob/d12c6e947ceacf3b22c154caf9532b390d8dc88a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs#L936 This will be a type mismatch if the target trait object has fewer projection bounds, since we compare the bounds structurally in relate: https://github.com/rust-lang/rust/blob/d12c6e947ceacf3b22c154caf9532b390d8dc88a/compiler/rustc_middle/src/ty/relate.rs#L696-L698 </details> Fixes #114035 Also fixes #114113, because I added a normalize call in the old solver. r? types
2023-08-03resolve before canonicalization, ICE if unresolvedMichael Goulet-1/+1
2023-08-03Rework upcastingMichael Goulet-7/+13
2023-08-03rewrite stack dependent overflow handlinglcnr-2/+102
2023-07-31Rollup merge of #114169 - lcnr:unsize, r=compiler-errorsMatthias Krüger-1/+2
refactor builtin unsize handling, extend comments r? `@compiler-errors`
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-26/+23
2023-07-28refactor builtin unsize handling, extend commentslcnr-1/+2
2023-07-25Make everything builtin!Michael Goulet-85/+35
2023-07-25Restore tuple unsizing feature gateMichael Goulet-3/+11
2023-07-25Normalize the RHS of an unsize goalMichael Goulet-1/+8
2023-07-24Improve diagnostic for const ctors in array repeat expressionsclubby789-3/+23
2023-07-23match on chars instead of &strs for .split() or .strip_prefix()Matthias Krüger-2/+2
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-9/+11
2023-07-13typolcnr-1/+1
2023-07-13refactor proof tree formattinglcnr-57/+63
2023-07-05Add some extra information to opaque type cycle errorsOli Scherer-0/+4
2023-07-03Remove chalk from the compilerMichael Goulet-401/+0
2023-06-28Rollup merge of #112867 - compiler-errors:more-impl-source-nits, r=lcnrDylan DPC-37/+2
More `ImplSource` nits Even more clean-ups, I'll put this up in parallel with the `select_in_new_trait_solver` PR. r? ``@lcnr``
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-4/+2
2023-06-20yeet upcast_trait_def_id from ImplSourceObjectDataMichael Goulet-6/+2
2023-06-20yeet ImplSource::TraitAlias tooMichael Goulet-31/+0
2023-06-20cleanup importslcnr-8/+12
2023-06-19move to nested moduleBoxy-130/+134
2023-06-19show normalizes-to hack and response instantiation goalsBoxy-2/+28
2023-06-19introduce a separate set of types for finalized proof treesBoxy-28/+39
2023-06-19say what kind of cache hitBoxy-3/+10
2023-06-19initial info dumpBoxy-11/+181
2023-06-17Remove even more redundant builtin candidatesMichael Goulet-45/+4
2023-06-17Simplify even more candidatesMichael Goulet-111/+26
2023-06-17Simplify an ObjectData fieldMichael Goulet-6/+6
2023-06-17Simplify some impl source candidatesMichael Goulet-57/+0
2023-06-17Remove some ImplSource candidatesMichael Goulet-31/+10
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-0/+3
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-02Rollup merge of #112165 - fee1-dead-contrib:rn-defualtness, r=compiler-errorsMatthias Krüger-1/+1
Rename `impl_defaultness` to `defaultness` Since this isn't just about the `impl`.
2023-06-01Implement custom diagnostic for ConstParamTyMichael Goulet-0/+3
2023-06-01Rename `impl_defaultness` to `defaultness`Deadbeef-1/+1
2023-05-25Fallible<_> -> Result<_, NoSolution>Michael Goulet-2/+0
2023-05-25Prepopulate opaques in canonical inputMichael Goulet-3/+64
2023-05-25Move DefiningAnchorMichael Goulet-0/+11
2023-05-22Auto merge of #111754 - lcnr:recursion-depth, r=matthewjasperbors-3/+20
fix recursion depth handling after confirmation fixes #111729 I think having to use `Obligation::with_depth` correctly everywhere is very hard because e.g. the nested obligations from `eq` currently do not have the correct obligation depth. The new solver [completely removes `recursion_depth` from obligations](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/traits/solve/struct.Goal.html) and instead tracks the depth in the solver itself which is far easier to get right. Moving the old solver towards this shouldn't be that hard but is probably somewhat annoying. r? `@matthewjasper`
2023-05-20Rollup merge of #111450 - compiler-errors:opaque-ty-key, r=oli-obkGuillaume Gomez-1/+1
Use `OpaqueTypeKey` in query response Makes it a bit clearer that at least one of the types being returned from a canonical query is an opaque.
2023-05-19update recursion depth in `confirm_candidate`lcnr-3/+20
2023-05-12Note base types of coercionMichael Goulet-3/+0
2023-05-10Use OpaqueTypeKey in query responseMichael Goulet-1/+1
2023-05-09Shrink `SelectionError` a lotNilstrieb-5/+8
`SelectionError` used to be 80 bytes (on 64 bit). That's quite big. Especially because the selection cache contained `Result<_, SelectionError>. The Ok type is only 32 bytes, so the 80 bytes significantly inflate the size of the cache. Most variants of the `SelectionError` seem to be hard errors, only `Unimplemented` shows up in practice (for cranelift-codegen, it occupies 23.4% of all cache entries). We can just box away the biggest variant, `OutputTypeParameterMismatch`, to get the size down to 16 bytes, well within the size of the Ok type inside the cache.