Skip to content

false positive implied_bounds_entailment lint #108544

Closed
@aliemjay

Description

@aliemjay

The lint is triggered by the following code (from #108345, cc @EqualMa) :

use std::borrow::Cow;

pub trait Trait {
    fn method(self) -> Option<Cow<'static, str>>
    where
        Self: Sized;
}

impl<'a> Trait for Cow<'a, str> {
    fn method(self) -> Option<Cow<'static, str>> {
        None
    }
}

In the environment <'a> where Cow<'a, str>: Sized, the type Option<Cow<'static, str>> surprisingly requires 'a == 'static for well-formedness (see #108345 (comment)), but this constraint is not used in implied bounds, so I believe it can't be exploited for unsoundness.

The lint was upgraded to deny-by-default in the current beta (1.68.0-beta.5 2023-02-15 003b6f2). So this counts as regression?

cc @compiler-errors.

@rustbot label C-bug T-types T-compiler regression-from-stable-to-beta

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions