Skip to content

NLL and closures: higher-ranked lifetime bounds are not enforced in type tests #98693

Description

@aliemjay

This code compiles after #95565 although it shouldn't: (playground)

fn assert_static<T>() where for<'a> T: 'a, {}

fn test<T>() {
    || {
        assert_static::<T>();
    };
}

This is similar to #98095 in that we're not taking into account placeholder regions when "promoting" type-tests from the closure to its caller:

for ur in self.scc_values.universal_regions_outlived_by(r_scc) {

@rustbot label T-types regression-from-stable-to-beta C-bug A-NLL I-unsound

Activity

  1. added
    A-NLLArea: Non-lexical lifetimes (NLL)
    C-bugCategory: This is a bug.
    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jun 29, 2022
  2. aliemjay commented on Jun 29, 2022

    @aliemjay
    ContributorAuthor

    I guess it would be an easy fix
    @rustbot claim

  3. steffahn commented on Jun 30, 2022

    @steffahn
    Member

    The unsoundness exploitation in #98095 can easily be adapted for this issue, so it is in fact a soundness issue: playground

  4. added this to the 1.63.0 milestone on Jun 30, 2022
  5. apiraino commented on Jun 30, 2022

    @apiraino
    Contributor

    issue touched in today's T-compiler meeting, notes from Zulip chat. Will also be discussed tomorrow during the T-types meeting.

  6. apiraino commented on Jul 4, 2022

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    @rustbot label -I-prioritize +P-critical

  7. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 4, 2022
  8. added 2 commits that reference this issue on Jul 10, 2022
    377b92a
    2cb7d1c
  9. removed
    I-types-nominatedNominated for discussion during a types team meeting.
    on Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-criticalCritical priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions