rust-lang / rust-lang/rust

Normalization can indirectly observe a method's own predicates in method probing

Open
#162,633 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-method-lookup C-cleanup T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

cc https://github.com/rust-lang/rust/pull/133519

Method probing in the old solver is stronger than the new solver because eagerly normalizing types causes us to check their corresponding trait goals. This is important because we don't end up checking all of the where clauses of a method when method probing; just the where clauses of the impl. i.e., for:

impl Foo
where
   WC1,
{
    fn method()
    where
        WC2,
    {}
}

We only check WC1 and not WC2. This is because at this point in probing the method is instantiated w/ infer vars, and checking the where clauses in WC2 will lead to cycles if we were to check them (at least that's my understanding; I could investigate changing that in general, incl. in the old solver, but I don't have much confidence that it won't lead to really bad overflows.)


Currently, we're checking the xform_ret_ty for WF to emulate this behavior in the new solver. However, we should probably eventually move onto just checking all the method predicates in consider_probe, probably once we've moved onto the new solver for good.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the new solver's method-probing path, especially consider_probe and the xform_ret_ty WF check described here. Compare how the old and new solvers handle method predicates and cycles; done means deciding how to check all method predicates without introducing problematic overflows.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.