Skip to content

trait method calls on ~const bounded types should not be allowed in generic const exprs #102498

Closed
@fee1-dead

Description

@fee1-dead

playground

#![feature(const_trait_impl, generic_const_exprs)]

#[const_trait]
pub trait Tr {
    fn a() -> usize;
}

impl Tr for () {
    fn a() -> usize {
        1
    }
}

const fn foo<T: ~const Tr>() -> [u8; T::a()] {
    [0; T::a()]
}

fn huh() {
    foo::<()>();
}

If we remove the huh definition, it compiles. This fix would involve treating caller bounds differently and would probably come with the addition of "always const" bounds.

This is an interaction with generic_const_exprs and const_trait_impl, but does not block the stabilization of generic_const_exprs as this is only allowed if someone enables the feature const_trait_impl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`requires-incomplete-featuresThis issue requires the use of incomplete features.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions