Skip to content

rustc_typeck::check::compare_method::compare_const_impl doesn't drain its fullfillment context nor invoke regionck. #41323

Closed
@eddyb

Description

@eddyb

UPDATE: Mentoring instructions for fixing this bug can be found here.


There are some calls to add obligations to a fulfillment context but it's never checked.

Some examples of code that shouldn't compile:

trait TransmuteTarget: Sized {
    type Out: Sized;
}

// Can't use generic impl here.
impl TransmuteTarget for String {
    type Out = String;
}

trait Transmute: TransmuteTarget {
    const FROM: Self::Out;
}

impl<T: TransmuteTarget> Transmute for T {
    // Associated type projections aren't checked (obligation fulfillment).
    const FROM: &'static str = "foo";
}
trait Foo {
    const NAME: &'static str;
}

impl<'a> Foo for &'a () {
    // Lifetimes aren't checked (regionck).
    const NAME: &'a str = "unit";
}

cc @rust-lang/compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-type-systemArea: Type systemE-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityT-compilerRelevant to the compiler 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