Skip to content

No universe checks for ty/const infer vars and placeholders #109505

Closed
@BoxyUwU

Description

@BoxyUwU

rustc currently lacks any checks to ensure that relating ty/const infer vars with ty/const placeholders in higher universes fails. I am not entirely sure whether this is problematic for stable rust or just feature(non_lifetime_binders) I think exploiting this would require us to create obligations with type/const binders. We currently create param envs with for<T> predicates on stable for checking gat bounds, but I couldn't find anywhere that we create obligations with type/const bound vars.

Code

#![feature(non_lifetime_binders)]
#![allow(incomplete_features)]

trait Other<U: ?Sized> {}

impl<U: ?Sized> Other<U> for U {}

//  - o: `for<T> T: Trait<?0>`
//    - c: `for<U> U: Trait<U>`
//      - U = ?1
//      - T = ?1
//      - ?0 = ?1

#[rustfmt::skip]
fn foo<U: ?Sized>()
where
    for<T> T: Other<U> {}

fn bar() {
    foo::<_>();
}

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (8a73f50d8 2023-03-11)
binary: rustc
commit-hash: 8a73f50d875840b8077b8ec080fa41881d7ce40d
commit-date: 2023-03-11
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Error output

Backtrace

no backtrace because github claims "Comment is too long" 🙄

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-non_lifetime_binders`#![feature(non_lifetime_binders)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions