about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-04-03Never consider int and float vars for `FnPtr` candidatesNilstrieb-8/+14
This solves a regression where `0.0.cmp()` was ambiguous when a custom trait with a `cmp` method was in scope. FOr integers it shouldn't be a problem in practice so I wasn't able to add a test.
2023-04-02Rollup merge of #109846 - matthiaskrgr:clippy2023_04_III, r=NilstriebNilstrieb-3/+1
more clippy::complexity fixes (iter_kv_map, map_flatten, nonminimal_bool)
2023-04-01use and_then/flat_map for map().flatten()Matthias Krüger-3/+1
2023-04-01a couple clippy::complexity fixesMatthias Krüger-3/+2
map_identity filter_next option_as_ref_deref unnecessary_find_map redundant_slicing unnecessary_unwrap bool_comparison derivable_impls manual_flatten needless_borrowed_reference
2023-03-31Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkinbors-1/+3
Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>` And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Rollup merge of #109739 - compiler-errors:new-solver-closure-fnonce, r=lcnrMichael Goulet-3/+14
Closures always implement `FnOnce` in new solver We should process `[closure]: FnOnce(Tys...) -> Ty` obligations *before* fallback and closure analysis. We can do this by taking advantage of the fact that `FnOnce` is always implemented by closures, even before we definitely know the closure kind. Fixes compiler-errors/next-solver-hir-issues#15 r? ``@oli-obk`` (trying to spread the reviewer load for new trait solver prs, and this one is pretty self-contained, though feel free to reassign 😸)
2023-03-30Rollup merge of #109679 - compiler-errors:normalizes-to-hack-2, r=lcnr,BoxyUwUMichael Goulet-43/+70
Freshen normalizes-to hack goal RHS in the evaluate loop Ensure that we repeatedly equate the unconstrained RHS of the normalizes-to hack goal with the *actual* RHS of the goal, even if the normalizes-to goal loops several times and thus we replace the unconstrained RHS var repeatedly. Alternative to #109583.
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-1/+3
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-30Closures always implement FnOnce in new solverMichael Goulet-3/+14
2023-03-30Rollup merge of #109749 - compiler-errors:new-solver-float-var, r=lcnrYuki Okushi-1/+1
Canonicalize float var as float in new solver Typo in new canonicalizer -- we should be canonicalizing float vars as `CanonicalTyVarKind::Float`, not `CanonicalTyVarKind::Int`. Fixes compiler-errors/next-solver-hir-issues#9
2023-03-30Rollup merge of #109748 - compiler-errors:new-solver-discr-kind-ice, r=lcnrYuki Okushi-5/+43
Don't ICE on `DiscriminantKind` projection in new solver As title says, since we now actually call `Ty::discriminant_kind` on placeholder types 😃 Also drive-by simplify `Pointee::Metadata` projection logic, and fix the UI test because the `<T as Pointee>::Metadata` tests weren't actually exercising the new projection logic, since we still eagerly normalize (which hits `project.rs` in the old solver) in HIR typeck. r? `@lcnr` tho feel free to re-roll, this pr is very low-priority and not super specific to the new trait solver. Fixes compiler-errors/next-solver-hir-issues#14
2023-03-30canonicalize float var as float in new solverMichael Goulet-1/+1
2023-03-30Check pointee metadata correctly in ui testMichael Goulet-3/+1
2023-03-30Don't ICE on DiscriminantKind projection in new solverMichael Goulet-2/+42
2023-03-29Rollup merge of #109675 - compiler-errors:object-heck, r=lcnrMatthias Krüger-3/+16
Do not consider elaborated projection predicates for objects in new solver Object types have projection bounds which are elaborated during astconv. There's no need to do it again for projection goals, since that'll give us duplicate projection candidatesd that are distinct up to regions due to the fact that we canonicalize every region to a separate variable. See quick example below the break for a better explanation. Discussed this with lcnr, and adding a stop-gap until we get something like intersection region constraints (or modify canonicalization to canonicalize identical regions to the same canonical regions) -- after which, this will hopefully not matter and may be removed. r? `@lcnr` --- See `tests/ui/traits/new-solver/more-object-bound.rs`: Consider a goal: `<dyn Iter<'a, ()> as Iterator>::Item = &'a ()`. After canonicalization: `<dyn Iter<'!0r, (), Item = '!1r ()> as Iterator>::Item == &!'2r ()` * First object candidate comes from the item bound in the dyn's bounds itself, giving us `<dyn Iter<'!0r, (), Item = '?!r ()> as Iterator>::Item == &!'1r ()`. This gives us one region constraint: `!'1r == !'2r`. * Second object candidate comes from elaborating the principal trait ref, gives us `<dyn Iter<'!0r, (), Item = '!1r ()> as Iterator>::Item == &!'0r ()`. This gives us one region constraint: `!'0r == !'2r`. * Oops! Ambiguity!
2023-03-29Rollup merge of #109511 - compiler-errors:eval-ctxt-infcx-private, r=lcnrMatthias Krüger-50/+84
Make `EvalCtxt`'s `infcx` private To better protect against people doing bad things with the inner `InferCtxt` r? `@lcnr`
2023-03-29Freshen normalizes-to hack goal RHS in the evaluate loopMichael Goulet-43/+70
2023-03-29Move canonicalization code aroundMichael Goulet-72/+47
2023-03-29Do not consider elaborated projection predicates for objects in new solverMichael Goulet-3/+16
2023-03-29Rollup merge of #109718 - scottmcm:indexvec-last, r=NilstriebDylan DPC-1/+1
Rename `IndexVec::last` → `last_index` As I've been trying to replace a `Vec` with an `IndexVec`, having `last` exist on both but returning very different types makes the transition a bit awkward -- the errors are later, where you get things like "there's no `ty` method on `mir::Field`" rather than a more localized error like "hey, there's no `last` on `IndexVec`". So I propose renaming `last` to `last_index` to help distinguish `Vec::last`, which returns an element, and `IndexVec::last_index`, which returns an index. (Similarly, `Iterator::last` also returns an element, not an index.)
2023-03-29Rollup merge of #109683 - compiler-errors:self-ty-overflow, r=lcnrDylan DPC-18/+53
Check for overflow in `assemble_candidates_after_normalizing_self_ty` Prevents a stack overflow (:warning: :exclamation:) in the new solver when we have param-env candidates that look like: `T: Trait<Assoc = <T as Trait>::Assoc>` The current error message looks bad, but that's because we don't distinguish overflow and other ambiguity errors. I'll break that out into a separate PR since the fix may be controversial. r? `@lcnr`
2023-03-29Rename `IndexVec::last` → `last_index`Scott McMurray-1/+1
As I've been trying to replace a `Vec` with an `IndexVec`, having `last` exist on both but returning very different types makes the transition a bit awkward -- the errors are later, where you get things like "there's no `ty` method on `mir::Field`" rather than a more localized error like "hey, there's no `last` on `IndexVec`". So I propose renaming `last` to `last_index` to help distinguish `Vec::last`, which returns an element, and `IndexVec::last_index`, which returns an index. (Similarly, `Iterator::last` also returns an element, not an index.)
2023-03-29Rollup merge of #109705 - lcnr:coherence-caching, r=compiler-errorsMatthias Krüger-5/+22
new solver: check for intercrate mode when accessing the cache r? ``@compiler-errors``
2023-03-29Inline and remove `SelectionContext::fast_reject_trait_refs`.Nicholas Nethercote-18/+4
Because it has a single call site, and it lets us move a small amount of the work outside the loop.
2023-03-29Introduce `DeepRejectCtxt::substs_refs_may_unify`.Nicholas Nethercote-13/+12
It factors out a repeated code pattern.
2023-03-28check for intercrate mode when accessing the cachelcnr-5/+22
2023-03-28Check for overflow in assemble_candidates_after_normalizing_self_tyMichael Goulet-18/+53
2023-03-28Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstriebbors-85/+93
Rollup of 8 pull requests Successful merges: - #91793 (socket ancillary data implementation for FreeBSD (from 13 and above).) - #92284 (Change advance(_back)_by to return the remainder instead of the number of processed elements) - #102472 (stop special-casing `'static` in evaluation) - #108480 (Use Rayon's TLV directly) - #109321 (Erase impl regions when checking for impossible to eagerly monomorphize items) - #109470 (Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds`) - #109562 (Update ar_archive_writer to 0.1.3) - #109629 (remove obsolete `givens` from regionck) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-28Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnrbors-15/+190
Add a builtin `FnPtr` trait that is implemented for all function pointers r? `@ghost` Rebased version of https://github.com/rust-lang/rust/pull/99531 (plus adjustments mentioned in the PR). If perf is happy with this version, I would like to land it, even if the diagnostics fix in 9df8e1befb5031a5bf9d8dfe25170620642d3c59 only works for `FnPtr` specifically, and does not generally improve blanket impls.
2023-03-28Rollup merge of #109629 - aliemjay:remove-givens, r=lcnrnils-7/+7
remove obsolete `givens` from regionck Revives #107376. The only change is the last commit (https://github.com/rust-lang/rust/pull/109629/commits/2a3177a8bcc4c5a5285dc2908a0f1ce98e9a6377) which should fix the regression. Fixes https://github.com/rust-lang/rust/issues/106567 r? `@lcnr`
2023-03-28Rollup merge of #102472 - lcnr:static-in-eval, r=jackh726nils-78/+86
stop special-casing `'static` in evaluation fixes #102360 I have no idea whether this actually removed all places where `'static` matters. Without canonicalization it's very easy to accidentally rely on `'static` again. Blocked on changing the `order_dependent_trait_objects` future-compat lint to a hard error r? `@nikomatsakis`
2023-03-27Rollup merge of #109580 - compiler-errors:new-solver-fixmes, r=lcnrMatthias Krüger-6/+0
Remove some stale FIXMEs in new solver Some FIXMEs are no longer needed
2023-03-27Some tracing/instrument cleanupsOli Scherer-6/+3
2023-03-27Add a builtin `FnPtr` traitlcnr-9/+187
2023-03-27Rollup merge of #109641 - compiler-errors:dont-elaborate-non-obl, r=oli-obkMatthias Krüger-39/+34
Don't elaborate non-obligations into obligations It's suspicious to elaborate a `PolyTraitRef` or `Predicate` into an `Obligation`, since the former does not have a param-env associated with it, but the latter does. This is a footgun that, while not being misused *currently* in the compiler, easily could be misused by someone less familiar with the elaborator's inner workings. This PR just changes the API -- ideally, the elaborator wouldn't even have to deal with obligations if we're not elaborating obligations, but that would require a bit more abstraction than I could be bothered with today.
2023-03-26Don't elaborate non-obligations into obligationsMichael Goulet-39/+34
2023-03-26resolve regions before implied boundsAli MJ Al-Nasrawy-5/+7
2023-03-26remove obsolete `givens` from regionckAli MJ Al-Nasrawy-2/+0
2023-03-25Still-further-specializable projections are ambiguousMichael Goulet-1/+1
2023-03-25Remove some stale FIXMEs in new solverMichael Goulet-6/+0
2023-03-24Make EvalCtxt's infcx privateMichael Goulet-75/+134
2023-03-24Rollup merge of #109495 - compiler-errors:new-solver-destruct, r=eholk,lcnrMatthias Krüger-0/+28
Implement non-const `Destruct` trait in new solver Makes it so that we can call stdlib methods like `Option::map` in **non-const** environments, since *many* stdlib methods have `Destruct` bounds 😅 This doesn't bother to implement `const Destruct` yet, but it shouldn't be too hard to do so. Just didn't bother since we already don't have much support for const traits in the new solver anyways. I'd be happy to add skeleton support for `const Destruct`, though, if the reviewer desires.
2023-03-24Auto merge of #109547 - matthiaskrgr:rollup-zczqgdk, r=matthiaskrgrbors-48/+56
Rollup of 9 pull requests Successful merges: - #108629 (rustdoc: add support for type filters in arguments and generics) - #108924 (panic_immediate_abort requires abort as a panic strategy) - #108961 (Refine error spans for const args in hir typeck) - #108986 (sync LVI tests) - #109142 (Add block-based mutex unlocking example) - #109368 (fix typo in the creation of OpenOption for RustyHermit) - #109493 (Return nested obligations from canonical response var unification) - #109515 (Add AixLinker to support linking on AIX) - #109536 (resolve: Rename some cstore methods to match queries and add comments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-24Rollup merge of #109493 - compiler-errors:new-solver-vars-obligations, r=lcnrMatthias Krüger-46/+44
Return nested obligations from canonical response var unification Handle alias-eq obligations being emitted from `instantiate_and_apply_query_response` in: * `EvalCtxt` - by processing the nested obligations in the next loop by `new_goals` * `FulfillCtxt` - by adding the nested obligations to the fulfillment's pending obligations * `InferCtxt::evaluate_obligation` - ~~by returning `EvaluationResult::EvaluatedToAmbig` (boo :-1:, see the FIXME)~~ same behavior as above, since we use fulfillment and `select_where_possible` The only one that's truly sketchy is `evaluate_obligation`, but it's not hard to modify this behavior moving forward. From #109037, I think a smaller repro could be crafted if I were smarter, but I am not, so I just took this from #105878. r? `@lcnr` cc `@BoxyUwU`
2023-03-24Rollup merge of #108961 - compiler-errors:refine-ct-errors, r=BoxyUwUMatthias Krüger-2/+12
Refine error spans for const args in hir typeck Improve just a couple of error messages having to do with mismatched consts. r? `@ghost` i'll put this up when the dependent commits are merged
2023-03-23Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnrbors-19/+9
Don't pass `TreatProjections` separately to `fast_reject` Don't pass `TreatProjections` separately to `fast_reject`, and instead use the original approach of switching on two variants of `TreatParams` (undoes this: https://github.com/rust-lang/rust/pull/108830#pullrequestreview-1330371417). Fixes the regression introduced in https://github.com/rust-lang/rust/pull/108830#issuecomment-1468116419
2023-03-23Use fulfillment in InferCtxt::evaluate_obligationMichael Goulet-30/+15
2023-03-23Note type mismatch on ConstArgHasTypeMichael Goulet-2/+12
2023-03-23Return nested obligations from canonical response var unificationMichael Goulet-25/+38
2023-03-23Don't split up TreatProjections and TreatParams anymoreMichael Goulet-19/+9