Skip to content

impl const wrongly accepts impl with non-const provided methods #79450

@jonas-schievink

Description

@jonas-schievink
Contributor

This prints no error, but prov is not const-safe, so the impl const Tr should not be accepted:

#![feature(const_trait_impl)]

trait Tr {
    fn req(&self);
    
    fn prov(&self) {
        println!("lul");
        self.req();
    }
}

struct S;

impl const Tr for S {
    fn req(&self) {}
}

Activity

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
requires-nightlyThis issue requires a nightly compiler in some way.
on Nov 26, 2020
added
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
on Nov 26, 2020
oli-obk

oli-obk commented on Nov 27, 2020

@oli-obk
Contributor

I guess for impl const blocks we need to enforce that no defaulted fallbacks are used at all. This is discussed a bit in the RFC, but for now we should just disallow this entirely

added a commit that references this issue on Jul 3, 2021

Auto merge of rust-lang#86571 - fee1-dead:const-trait-impl-fix, r=jac…

7014963
kadiwa4

kadiwa4 commented on Jul 25, 2022

@kadiwa4
Contributor

This issue applies again, it seems that the part of the test that checked this was removed in #96964.

Or is this intentionally accepted without an error now?

self-assigned this
on Jul 25, 2022

7 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-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_trait_impl`#![feature(const_trait_impl)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @oli-obk@jonas-schievink@kadiwa4@camelid

    Issue actions

      `impl const` wrongly accepts impl with non-const provided methods · Issue #79450 · rust-lang/rust