about summary refs log tree commit diff
path: root/tests/ui/darwin-objc/darwin-objc-bad-ref.rs
blob: fb1437366dd43afd981187d650077aaf308d2e58 (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
// Test that `objc::class!` and `objc::selector!` can't be returned by reference.
// A single instance may have multiple addresses (e.g. across dylib boundaries).

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

#![feature(darwin_objc)]

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

pub fn class_ref<'a>() -> &'a objc::Class {
    &objc::class!("NSObject")
    //~^ ERROR cannot return reference to temporary value [E0515]
}

pub fn class_ref_static() -> &'static objc::Class {
    &objc::class!("NSObject")
    //~^ ERROR cannot return reference to temporary value [E0515]
}

pub fn selector_ref<'a>() -> &'a objc::SEL {
    &objc::selector!("alloc")
    //~^ ERROR cannot return reference to temporary value [E0515]
}

pub fn selector_ref_static() -> &'static objc::SEL {
    &objc::selector!("alloc")
    //~^ ERROR cannot return reference to temporary value [E0515]
}

pub fn main() {}