Skip to content

negative_impls doesn't seem to agree with const_trait_impl #98834

Open
@SohumB

Description

@SohumB
#![feature(const_trait_impl)]
#![feature(auto_traits, negative_impls)]

auto trait NotPartialOrd {}
impl<T: ~const PartialOrd> const !NotPartialOrd for T {}

const fn foo<T: ~const PartialOrd>(_t: &T) { }
const fn bar<T: ~const NotPartialOrd>(_t: &T) { }

const b1: () = foo(&4_u32);
const b2: () = bar(&4_u32);

This fails compilation on both consts; the first because the trait ~const PartialOrd is not implemented for u32 (note: the trait PartialOrd is implemented for u32, but that implementation is not const), and the second because the trait bound u32: ~const NotPartialOrd is not satisfied.

I tried with_negative_coherence too, but it did not impact this test case.

Meta

Playground link

$ rustc --version --verbose`:
rustc 1.64.0-nightly (c80c4b8fd 2022-06-26)
binary: rustc
commit-hash: c80c4b8fdcf3da69cd483e2fec172c9b1f95842c
commit-date: 2022-06-26
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-negative_impls#![feature(negative_impls)]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

    Development

    No branches or pull requests

    Issue actions