Skip to content

RPIT hidden types can be ill-formed #114728

@aliemjay

Description

@aliemjay
Member

The following UB shouldn't compile:

type Static<'a> = &'static &'a ();
trait Extend<'a> {
    fn extend(self, _: &'a str) -> &'static str;
}
impl<'a> Extend<'a> for Static<'a> {
    fn extend(self, s: &'a str) -> &'static str {
        s
    }
}
fn boom<'a>(arg: Static<'_>) -> impl Extend<'a> {
    arg
}
fn main() {
    let y = boom(&&()).extend(&String::from("temporary"));
    println!("{}", y);
}

This regressed in v1.61. I guess it is #94081.

Discovered when investigating #114572.

Activity

added
T-typesRelevant to the types team, which will review and decide on the PR/issue.
on Aug 11, 2023
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 11, 2023
added
regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
C-bugCategory: This is a bug.
E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Aug 11, 2023
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Aug 11, 2023
added
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
on Aug 11, 2023
removed
E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
on Aug 11, 2023

25 remaining items

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

Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh 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

Status

Completed

Milestone

No milestone

Relationships

None yet

    Participants

    @lqd@compiler-errors@apiraino@aliemjay@rustbot

    Issue actions

      RPIT hidden types can be ill-formed · Issue #114728 · rust-lang/rust