Skip to content

Soundness hole: We don't catch non-const assoc fns in const contexts if the trait isn't #[const_trait] #12

Closed
rust-lang/rust
#132169
@fmease

Description

@fmease

Uplifted from rust-lang/rust#125831 cuz I consider this pretty important.

MCVE:

//@ compile-flags: -Znext-solver
#![feature(effects, const_trait_impl)]
#![crate_type = "lib"]

// #[const_trait] // <-- intentionally absent
trait NonConstTrait {
    fn something();
}

impl NonConstTrait for () {
    fn something() {}
}

const fn f() { <()>::something() } // wrongfully accepted!
                                   // should've raised Unimplemented( (): ~const NonConstTrait )
                                   // or at least rejected this call some other way

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions