Skip to content

implied bounds from impl header are not used when comparing trait and impl methods #105495

Open
@aliemjay

Description

@aliemjay

This doesn't compile:

trait Trait {
    fn get();
}
impl<'a, 'b> Trait for &'a &'b () { // There is an implied bound 'b: 'a
    fn get() where 'b: 'a, {}
    //~^ ERROR impl has stricter requirements than trait
}

Although it should for the same reason it compiles with the following change:

- impl<'a, 'b> Trait for &'a &'b () {
+ impl<'a, 'b> Trait for &'a &'b () where 'b: 'a, {

There should be no difference in behavior between implied and explicit bounds on impl header.

This is because we're not adding sufficient implied bounds in compare_predicate_entailment() here:

let mut wf_tys = FxIndexSet::default();

@rustbot label T-types A-implied-bounds A-associated-items C-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-implied-boundsArea: Implied bounds / inferred outlives-boundsC-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions