about summary refs log tree commit diff
path: root/tests/ui/darwin-objc/darwin-objc-bad-arg.rs
blob: 70eb83aa052d11b45e3ff48b94594495823cf6f5 (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 that `objc::class!` and `objc::selector!` only take string literals.

//@ edition: 2024
//@ only-apple

#![feature(darwin_objc)]

use std::os::darwin::objc;

pub fn main() {
    let s = "NSObject";
    objc::class!(s);
    //~^ ERROR attribute value must be a literal

    objc::class!(NSObject);
    //~^ ERROR attribute value must be a literal

    objc::class!(123);
    //~^ ERROR `objc::class!` expected a string literal

    objc::class!("NSObject\0");
    //~^ ERROR `objc::class!` may not contain null characters

    let s = "alloc";
    objc::selector!(s);
    //~^ ERROR attribute value must be a literal

    objc::selector!(alloc);
    //~^ ERROR attribute value must be a literal

    objc::selector!(123);
    //~^ ERROR `objc::selector!` expected a string literal

    objc::selector!("alloc\0");
    //~^ ERROR `objc::selector!` may not contain null characters
}