Skip to content

implied bounds from impl header are not used in associated functions/consts #98852

Closed

Description

The following fails to compile although it shouldn't: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f7287b6897a385360f7190001b58348d

/// A type with an implied bound `'b: 'a`
struct Ty<'a, 'b>(&'a &'b ());

impl<'a, 'b> Ty<'a, 'b> // <- tait or inherent impl
where
    //'b: 'a, // <- fixed by an explicit bound
{
    fn f() { // <- no `Self` in signature
        Self;
        //~^ ERROR lifetime bound not satisfied
        // Cannot prove WF of `Self` because `'b: 'a` is not known to hold
    }
}

Another repro:

struct Ty<'a, 'b>(&'a &'b ());

impl<'a, 'b> Ty<'a, 'b>{
    fn f() {
        None::<&'a &'b ()>;
        //~^ ERROR lifetime bound not satisfied
    }
}

The first repro regressed in 1.43 while the second one is as old as implied bounds.

@rustbot label A-implied-bounds A-associated-items regression-from-stable-to-stable T-types

Meta

Nightly version: 1.64.0-nightly

(2022-07-01 46b8c23)

Backtrace

<backtrace>

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

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.P-mediumMedium priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions