Skip to content

fn try_merge_responses behavior #53

Open
@lcnr

Description

@lcnr
Contributor

whenever we have multiple candidates we use fn try_merge_responses to try and merge them. This function is supposed to be complete.

We currently merge responses if they are all equal or alternatively if one of them has no external constraints.

This is quite fragile because it breaks the moment there are any region constraints as these sometimes contain '0: '0 constraints. We should remove those. We currently only opportunistically resolve region vars during canonicalization but the filtering should happen before then 🤔 It also does not work for any normalizes-to goal as their whole point is to constrain the term.

I feel like we should replace this with a proper subset check instead.

Activity

compiler-errors

compiler-errors commented on Jul 28, 2023

@compiler-errors
Member

(cc rust-lang/rust#112875 (comment), where this is needed because of some trivial '0: '0 region that should be filtered during compute_external_query_constraints, but can't be currently.)

lcnr

lcnr commented on Jan 29, 2024

@lcnr
ContributorAuthor

This currently has some non-trivial interactions with the ParamEnv candidate incompleteness: https://rust.godbolt.org/z/bq7K3zox3

cc #12

trait Trait<'a> {
    type Assoc;
}

impl<'a, T> Trait<'a> for T {
    type Assoc = ();
}

fn impls<'a, T: Trait<'a>>() {}
fn projects<'a, T: Trait<'a, Assoc = ()>>() {} 

// normalizing requires `'a == 'static`, the trait bound does not.
fn foo<'a, T: Trait<'static, Assoc = ()>>() {
    impls::<'a, T>(); // ok, no constraints from impl, prefer that one
    projects::<'a, T>();
    // lifetime error, projection candidates always have inference constraints
    // 2 candidates -> prefer `param_env` candidate
}
added a commit that references this issue on Apr 4, 2024

Auto merge of rust-lang#119820 - lcnr:leak-check-2, r=jackh726

added a commit that references this issue on Apr 6, 2024
lcnr

lcnr commented on Jan 29, 2025

@lcnr
ContributorAuthor

related to #127, we will likely end up supporting OR-region constraints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @compiler-errors@lcnr

        Issue actions

          `fn try_merge_responses` behavior · Issue #53 · rust-lang/trait-system-refactor-initiative