about summary refs log tree commit diff
path: root/tests/ui/force-inlining
diff options
context:
space:
mode:
authorJana Dönszelmann <jana@donsz.nl>2025-03-04 14:17:06 +0100
committerJana Dönszelmann <jana@donsz.nl>2025-06-17 23:19:31 +0200
commitee976bbbcaf85390a00f03dedacd035e7e274e8e (patch)
treeac9ac3364e06bc17d8aec7742493ebeff2ab3c92 /tests/ui/force-inlining
parent566f691374bff0461f2992e381e58539b0e5ae8a (diff)
downloadrust-ee976bbbcaf85390a00f03dedacd035e7e274e8e.tar.gz
rust-ee976bbbcaf85390a00f03dedacd035e7e274e8e.zip
fix bugs in inline/force_inline and diagnostics of all attr parsers
Diffstat (limited to 'tests/ui/force-inlining')
-rw-r--r--tests/ui/force-inlining/invalid.rs1
-rw-r--r--tests/ui/force-inlining/invalid.stderr134
2 files changed, 72 insertions, 63 deletions
diff --git a/tests/ui/force-inlining/invalid.rs b/tests/ui/force-inlining/invalid.rs
index 7574078b245..e9f5712413e 100644
--- a/tests/ui/force-inlining/invalid.rs
+++ b/tests/ui/force-inlining/invalid.rs
@@ -9,7 +9,6 @@
 // Test that invalid force inlining attributes error as expected.
 
 #[rustc_force_inline("foo")]
-//~^ ERROR malformed `rustc_force_inline` attribute input
 pub fn forced1() {
 }
 
diff --git a/tests/ui/force-inlining/invalid.stderr b/tests/ui/force-inlining/invalid.stderr
index 92b3c314bad..26259a4d61f 100644
--- a/tests/ui/force-inlining/invalid.stderr
+++ b/tests/ui/force-inlining/invalid.stderr
@@ -1,71 +1,80 @@
-error: malformed `rustc_force_inline` attribute input
-  --> $DIR/invalid.rs:11:1
-   |
-LL | #[rustc_force_inline("foo")]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-help: the following are the possible correct uses
-   |
-LL - #[rustc_force_inline("foo")]
-LL + #[rustc_force_inline = "reason"]
-   |
-LL - #[rustc_force_inline("foo")]
-LL + #[rustc_force_inline]
+error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
+  --> $DIR/invalid.rs:132:11
    |
+LL | fn barqux(#[rustc_force_inline] _x: u32) {}
+   |           ^^^^^^^^^^^^^^^^^^^^^
 
-error: malformed `rustc_force_inline` attribute input
-  --> $DIR/invalid.rs:16:1
+error[E0539]: malformed `rustc_force_inline` attribute input
+  --> $DIR/invalid.rs:15:1
    |
 LL | #[rustc_force_inline(bar, baz)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: the following are the possible correct uses
+note: expected a single argument here
+  --> $DIR/invalid.rs:15:21
+   |
+LL | #[rustc_force_inline(bar, baz)]
+   |                     ^^^^^^^^^^
+help: the following are possible correct uses
    |
 LL - #[rustc_force_inline(bar, baz)]
 LL + #[rustc_force_inline = "reason"]
    |
 LL - #[rustc_force_inline(bar, baz)]
+LL + #[rustc_force_inline(reason)]
+   |
+LL - #[rustc_force_inline(bar, baz)]
 LL + #[rustc_force_inline]
    |
 
-error: malformed `rustc_force_inline` attribute input
-  --> $DIR/invalid.rs:21:1
+error[E0539]: malformed `rustc_force_inline` attribute input
+  --> $DIR/invalid.rs:20:1
    |
 LL | #[rustc_force_inline(2)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: the following are the possible correct uses
+note: expected a string literal here
+  --> $DIR/invalid.rs:20:22
+   |
+LL | #[rustc_force_inline(2)]
+   |                      ^
+help: the following are possible correct uses
    |
 LL - #[rustc_force_inline(2)]
 LL + #[rustc_force_inline = "reason"]
    |
 LL - #[rustc_force_inline(2)]
+LL + #[rustc_force_inline(reason)]
+   |
+LL - #[rustc_force_inline(2)]
 LL + #[rustc_force_inline]
    |
 
-error: malformed `rustc_force_inline` attribute input
-  --> $DIR/invalid.rs:26:1
+error[E0539]: malformed `rustc_force_inline` attribute input
+  --> $DIR/invalid.rs:25:1
    |
 LL | #[rustc_force_inline = 2]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: the following are the possible correct uses
+note: expected a string literal here
+  --> $DIR/invalid.rs:25:24
+   |
+LL | #[rustc_force_inline = 2]
+   |                        ^
+help: the following are possible correct uses
    |
 LL - #[rustc_force_inline = 2]
 LL + #[rustc_force_inline = "reason"]
    |
 LL - #[rustc_force_inline = 2]
-LL + #[rustc_force_inline]
+LL + #[rustc_force_inline(reason)]
    |
-
-error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
-  --> $DIR/invalid.rs:133:11
+LL - #[rustc_force_inline = 2]
+LL + #[rustc_force_inline]
    |
-LL | fn barqux(#[rustc_force_inline] _x: u32) {}
-   |           ^^^^^^^^^^^^^^^^^^^^^
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:31:1
+  --> $DIR/invalid.rs:30:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -74,7 +83,7 @@ LL | extern crate std as other_std;
    | ------------------------------ not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:35:1
+  --> $DIR/invalid.rs:34:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -83,7 +92,7 @@ LL | use std::collections::HashMap;
    | ------------------------------ not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:39:1
+  --> $DIR/invalid.rs:38:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -92,7 +101,7 @@ LL | static _FOO: &'static str = "FOO";
    | ---------------------------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:43:1
+  --> $DIR/invalid.rs:42:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -101,7 +110,7 @@ LL | const _BAR: u32 = 3;
    | -------------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:47:1
+  --> $DIR/invalid.rs:46:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -110,7 +119,7 @@ LL | mod foo { }
    | ----------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:51:1
+  --> $DIR/invalid.rs:50:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -125,7 +134,7 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:67:1
+  --> $DIR/invalid.rs:66:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -134,7 +143,7 @@ LL | type Foo = u32;
    | --------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:71:1
+  --> $DIR/invalid.rs:70:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -147,13 +156,13 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:73:10
+  --> $DIR/invalid.rs:72:10
    |
 LL | enum Bar<#[rustc_force_inline] T> {
    |          ^^^^^^^^^^^^^^^^^^^^^ - not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:75:5
+  --> $DIR/invalid.rs:74:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -162,7 +171,7 @@ LL |     Baz(std::marker::PhantomData<T>),
    |     -------------------------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:80:1
+  --> $DIR/invalid.rs:79:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -175,7 +184,7 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:83:5
+  --> $DIR/invalid.rs:82:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -184,7 +193,7 @@ LL |     field: u32,
    |     ---------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:88:1
+  --> $DIR/invalid.rs:87:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -196,7 +205,7 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:95:1
+  --> $DIR/invalid.rs:94:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -211,7 +220,7 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:110:1
+  --> $DIR/invalid.rs:109:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -220,7 +229,7 @@ LL | trait FooQux = FooBaz;
    | ---------------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:114:1
+  --> $DIR/invalid.rs:113:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -233,7 +242,7 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:122:1
+  --> $DIR/invalid.rs:121:1
    |
 LL |   #[rustc_force_inline]
    |   ^^^^^^^^^^^^^^^^^^^^^
@@ -245,7 +254,7 @@ LL | | }
    | |_- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:129:1
+  --> $DIR/invalid.rs:128:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -254,7 +263,7 @@ LL | macro_rules! barqux { ($foo:tt) => { $foo }; }
    | ---------------------------------------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:133:11
+  --> $DIR/invalid.rs:132:11
    |
 LL | fn barqux(#[rustc_force_inline] _x: u32) {}
    |           ^^^^^^^^^^^^^^^^^^^^^--------
@@ -262,7 +271,7 @@ LL | fn barqux(#[rustc_force_inline] _x: u32) {}
    |           not a function definition
 
 error: attribute cannot be applied to a `async`, `gen` or `async gen` function
-  --> $DIR/invalid.rs:137:1
+  --> $DIR/invalid.rs:136:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -271,7 +280,7 @@ LL | async fn async_foo() {}
    | -------------------- `async`, `gen` or `async gen` function
 
 error: attribute cannot be applied to a `async`, `gen` or `async gen` function
-  --> $DIR/invalid.rs:141:1
+  --> $DIR/invalid.rs:140:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -280,7 +289,7 @@ LL | gen fn gen_foo() {}
    | ---------------- `async`, `gen` or `async gen` function
 
 error: attribute cannot be applied to a `async`, `gen` or `async gen` function
-  --> $DIR/invalid.rs:145:1
+  --> $DIR/invalid.rs:144:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -289,19 +298,19 @@ LL | async gen fn async_gen_foo() {}
    | ---------------------------- `async`, `gen` or `async gen` function
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:150:14
+  --> $DIR/invalid.rs:149:14
    |
 LL |     let _x = #[rustc_force_inline] || { };
    |              ^^^^^^^^^^^^^^^^^^^^^ ------ not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:152:14
+  --> $DIR/invalid.rs:151:14
    |
 LL |     let _y = #[rustc_force_inline] 3 + 4;
    |              ^^^^^^^^^^^^^^^^^^^^^ - not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:154:5
+  --> $DIR/invalid.rs:153:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -310,7 +319,7 @@ LL |     let _z = 3;
    |     ----------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:159:9
+  --> $DIR/invalid.rs:158:9
    |
 LL |         #[rustc_force_inline]
    |         ^^^^^^^^^^^^^^^^^^^^^
@@ -319,7 +328,7 @@ LL |         1 => (),
    |         ------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:98:5
+  --> $DIR/invalid.rs:97:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -328,7 +337,7 @@ LL |     type Foo;
    |     --------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:101:5
+  --> $DIR/invalid.rs:100:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -337,7 +346,7 @@ LL |     const Bar: i32;
    |     --------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:105:5
+  --> $DIR/invalid.rs:104:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -346,7 +355,7 @@ LL |     fn foo() {}
    |     ----------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:117:5
+  --> $DIR/invalid.rs:116:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -355,7 +364,7 @@ LL |     fn foo() {}
    |     ----------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:54:5
+  --> $DIR/invalid.rs:53:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -364,7 +373,7 @@ LL |     static X: &'static u32;
    |     ----------------------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:58:5
+  --> $DIR/invalid.rs:57:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -373,7 +382,7 @@ LL |     type Y;
    |     ------- not a function definition
 
 error: attribute should be applied to a function
-  --> $DIR/invalid.rs:62:5
+  --> $DIR/invalid.rs:61:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
@@ -381,5 +390,6 @@ LL |
 LL |     fn foo();
    |     --------- not a function definition
 
-error: aborting due to 38 previous errors
+error: aborting due to 37 previous errors
 
+For more information about this error, try `rustc --explain E0539`.