about summary refs log tree commit diff
path: root/tests/ui/traits/const-traits/minicore-drop-fail.rs
blob: 274e5db21c4f6b7ab1cf3037697841e4f5f4aee5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//@ aux-build:minicore.rs
//@ compile-flags: --crate-type=lib -Znext-solver

#![feature(no_core, const_trait_impl, const_destruct)]
#![no_std]
#![no_core]

extern crate minicore;
use minicore::*;

struct Contains<T>(T);

struct NotDropImpl;
impl Drop for NotDropImpl {
    fn drop(&mut self) {}
}

#[const_trait] trait Foo {}
impl Foo for () {}

struct Conditional<T: Foo>(T);
impl<T> const Drop for Conditional<T> where T: ~const Foo {
    fn drop(&mut self) {}
}

const fn test() {
    let _ = NotDropImpl;
    //~^ ERROR destructor of `NotDropImpl` cannot be evaluated at compile-time
    let _ = Contains(NotDropImpl);
    //~^ ERROR destructor of `Contains<NotDropImpl>` cannot be evaluated at compile-time
    let _ = Conditional(());
    //~^ ERROR destructor of `Conditional<()>` cannot be evaluated at compile-time
}

const fn drop_arbitrary<T>(_: T) {
    //~^ ERROR destructor of `T` cannot be evaluated at compile-time
}