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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
//@ edition: 2024
#![allow(internal_features, unused_imports, unused_macros)]
#![feature(extern_types)]
#![feature(gen_blocks)]
#![feature(rustc_attrs)]
#![feature(stmt_expr_attributes)]
#![feature(trait_alias)]
// Test that invalid force inlining attributes error as expected.
#[rustc_force_inline("foo")]
//~^ ERROR malformed `rustc_force_inline` attribute input
pub fn forced1() {
}
#[rustc_force_inline(bar, baz)]
//~^ ERROR malformed `rustc_force_inline` attribute input
pub fn forced2() {
}
#[rustc_force_inline(2)]
//~^ ERROR malformed `rustc_force_inline` attribute input
pub fn forced3() {
}
#[rustc_force_inline = 2]
//~^ ERROR malformed `rustc_force_inline` attribute input
pub fn forced4() {
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
extern crate std as other_std;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
use std::collections::HashMap;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
static _FOO: &'static str = "FOO";
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
const _BAR: u32 = 3;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
mod foo { }
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
unsafe extern "C" {
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
static X: &'static u32;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
type Y;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
fn foo();
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
type Foo = u32;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
enum Bar<#[rustc_force_inline] T> {
//~^ ERROR attribute should be applied to a function
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
Baz(std::marker::PhantomData<T>),
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
struct Qux {
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
field: u32,
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
union FooBar {
x: u32,
y: u32,
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
trait FooBaz {
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
type Foo;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
const Bar: i32;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
fn foo() {}
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
trait FooQux = FooBaz;
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
impl<T> Bar<T> {
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
fn foo() {}
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
impl<T> FooBaz for Bar<T> {
type Foo = u32;
const Bar: i32 = 3;
}
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
macro_rules! barqux { ($foo:tt) => { $foo }; }
fn barqux(#[rustc_force_inline] _x: u32) {}
//~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
//~^^ ERROR attribute should be applied to a function
#[rustc_force_inline]
//~^ ERROR attribute cannot be applied to a `async`, `gen` or `async gen` function
async fn async_foo() {}
#[rustc_force_inline]
//~^ ERROR attribute cannot be applied to a `async`, `gen` or `async gen` function
gen fn gen_foo() {}
#[rustc_force_inline]
//~^ ERROR attribute cannot be applied to a `async`, `gen` or `async gen` function
async gen fn async_gen_foo() {}
fn main() {
let _x = #[rustc_force_inline] || { };
//~^ ERROR attribute should be applied to a function
let _y = #[rustc_force_inline] 3 + 4;
//~^ ERROR attribute should be applied to a function
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
let _z = 3;
match _z {
#[rustc_force_inline]
//~^ ERROR attribute should be applied to a function
1 => (),
_ => (),
}
}
|