about summary refs log tree commit diff
path: root/tests/ui/abi/unsupported-in-impls.rs
blob: 71797954865a30a79085dc25b71c2eb16d29e40c (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
// Test for https://github.com/rust-lang/rust/issues/86232
// Due to AST-to-HIR lowering nuances, we used to allow unsupported ABIs to "leak" into the HIR
// without being checked, as we would check after generating the ExternAbi.
// Checking afterwards only works if we examine every HIR construct that contains an ExternAbi,
// and those may be very different in HIR, even if they read the same in source.
// This made it very easy to make mistakes.
//
// Here we test that an unsupported ABI in various impl-related positions will be rejected,
// both in the original declarations and the actual implementations.

#![feature(rustc_attrs)]
//@ compile-flags: --crate-type lib

pub struct FnPtrBearer {
    pub ptr: extern "rust-invalid" fn(),
    //~^ ERROR: is not a supported ABI
}

impl FnPtrBearer {
    pub extern "rust-invalid" fn inherent_fn(self) {
        //~^ ERROR: is not a supported ABI
        (self.ptr)()
    }
}

pub trait Trait {
    extern "rust-invalid" fn trait_fn(self);
    //~^ ERROR: is not a supported ABI
}

impl Trait for FnPtrBearer {
    extern "rust-invalid" fn trait_fn(self) {
        //~^ ERROR: is not a supported ABI
        self.inherent_fn()
    }
}