File tree Expand file tree Collapse file tree 2 files changed +99
-0
lines changed Expand file tree Collapse file tree 2 files changed +99
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ edition:2024
2
+ #![ crate_type = "lib" ]
3
+ #![ feature( macro_metavar_expr) ]
4
+ #![ allow( incomplete_features) ]
5
+ #![ feature( macro_fragment_fields) ]
6
+ #![ feature( macro_fragments_more) ]
7
+
8
+ macro_rules! bad1 {
9
+ ( $f: fn ) => { ${ f. unknown_field} } ;
10
+ //~^ ERROR: expression of type `fn` has no field `unknown_field`
11
+ }
12
+
13
+ bad1 ! { fn f( ) { } }
14
+
15
+ macro_rules! bad2 {
16
+ ( $f: fn ) => { ${ f. name. unknown_field} } ;
17
+ //~^ ERROR: expression of type `ident` has no field `unknown_field`
18
+ }
19
+
20
+ bad2 ! { fn f( ) { } }
21
+
22
+ macro_rules! bad3 {
23
+ ( $f: fn ) => { ${ f. name. unknown_field. unknown_field} } ;
24
+ //~^ ERROR: expression of type `ident` has no field `unknown_field`
25
+ }
26
+
27
+ bad3 ! { fn f( ) { } }
28
+
29
+ macro_rules! bad4 {
30
+ ( $f: item) => { ${ f. name} } ;
31
+ //~^ ERROR: expression of type `item` has no field `name`
32
+ }
33
+
34
+ bad4 ! { fn f( ) { } }
35
+
36
+ macro_rules! bad5 {
37
+ ( $f: block) => { ${ f. unknown_field} } ;
38
+ //~^ ERROR: expression of type `block` has no field `unknown_field`
39
+ }
40
+
41
+ bad5 ! { { 42 ; } }
42
+
43
+ macro_rules! bad6 {
44
+ ( $a: adt) => { ${ a. unknown_field} } ;
45
+ //~^ ERROR: expression of type `adt` has no field `unknown_field`
46
+ }
47
+
48
+ bad6 ! { struct S ; }
49
+
50
+ macro_rules! bad7 {
51
+ ( $a: adt) => { ${ a. name. unknown_field} } ;
52
+ //~^ ERROR: expression of type `ident` has no field `unknown_field`
53
+ }
54
+
55
+ bad7 ! { struct S ; }
Original file line number Diff line number Diff line change
1
+ error: expression of type `fn` has no field `unknown_field`
2
+ --> $DIR/macro-fragment-fields-errors.rs:9:22
3
+ |
4
+ LL | ($f:fn) => { ${f.unknown_field} };
5
+ | ^^^^^^^^^^^^^
6
+
7
+ error: expression of type `ident` has no field `unknown_field`
8
+ --> $DIR/macro-fragment-fields-errors.rs:16:27
9
+ |
10
+ LL | ($f:fn) => { ${f.name.unknown_field} };
11
+ | ^^^^^^^^^^^^^
12
+
13
+ error: expression of type `ident` has no field `unknown_field`
14
+ --> $DIR/macro-fragment-fields-errors.rs:23:27
15
+ |
16
+ LL | ($f:fn) => { ${f.name.unknown_field.unknown_field} };
17
+ | ^^^^^^^^^^^^^
18
+
19
+ error: expression of type `item` has no field `name`
20
+ --> $DIR/macro-fragment-fields-errors.rs:30:24
21
+ |
22
+ LL | ($f:item) => { ${f.name} };
23
+ | ^^^^
24
+
25
+ error: expression of type `block` has no field `unknown_field`
26
+ --> $DIR/macro-fragment-fields-errors.rs:37:25
27
+ |
28
+ LL | ($f:block) => { ${f.unknown_field} };
29
+ | ^^^^^^^^^^^^^
30
+
31
+ error: expression of type `adt` has no field `unknown_field`
32
+ --> $DIR/macro-fragment-fields-errors.rs:44:23
33
+ |
34
+ LL | ($a:adt) => { ${a.unknown_field} };
35
+ | ^^^^^^^^^^^^^
36
+
37
+ error: expression of type `ident` has no field `unknown_field`
38
+ --> $DIR/macro-fragment-fields-errors.rs:51:28
39
+ |
40
+ LL | ($a:adt) => { ${a.name.unknown_field} };
41
+ | ^^^^^^^^^^^^^
42
+
43
+ error: aborting due to 7 previous errors
44
+
You can’t perform that action at this time.
0 commit comments