File tree Expand file tree Collapse file tree 2 files changed +80
-0
lines changed
ide-diagnostics/src/handlers Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Original file line number Diff line number Diff line change @@ -1274,3 +1274,64 @@ impl S {
1274
1274
"# ] ] ,
1275
1275
) ;
1276
1276
}
1277
+
1278
+ fn infer_in_unexpandable_attr_proc_macro_1 ( ) {
1279
+ check_types (
1280
+ r#"
1281
+ //- /main.rs crate:main deps:mac
1282
+ #[mac::attr_macro]
1283
+ fn foo() {
1284
+ let xxx = 1;
1285
+ //^^^ i32
1286
+ }
1287
+
1288
+ //- /mac.rs crate:mac
1289
+ #![crate_type="proc-macro"]
1290
+ #[proc_macro_attribute]
1291
+ pub fn attr_macro() {}
1292
+ "# ,
1293
+ ) ;
1294
+ }
1295
+
1296
+ #[ test]
1297
+ fn infer_in_unexpandable_attr_proc_macro_in_impl ( ) {
1298
+ check_types (
1299
+ r#"
1300
+ //- /main.rs crate:main deps:mac
1301
+ struct Foo;
1302
+ impl Foo {
1303
+ #[mac::attr_macro]
1304
+ fn foo() {
1305
+ let xxx = 1;
1306
+ //^^^ i32
1307
+ }
1308
+ }
1309
+
1310
+ //- /mac.rs crate:mac
1311
+ #![crate_type="proc-macro"]
1312
+ #[proc_macro_attribute]
1313
+ pub fn attr_macro() {}
1314
+ "# ,
1315
+ ) ;
1316
+ }
1317
+
1318
+ #[ test]
1319
+ fn infer_in_unexpandable_attr_proc_macro_in_trait ( ) {
1320
+ check_types (
1321
+ r#"
1322
+ //- /main.rs crate:main deps:mac
1323
+ trait Foo {
1324
+ #[mac::attr_macro]
1325
+ fn foo() {
1326
+ let xxx = 1;
1327
+ //^^^ i32
1328
+ }
1329
+ }
1330
+
1331
+ //- /mac.rs crate:mac
1332
+ #![crate_type="proc-macro"]
1333
+ #[proc_macro_attribute]
1334
+ pub fn attr_macro() {}
1335
+ "# ,
1336
+ ) ;
1337
+ }
Original file line number Diff line number Diff line change @@ -104,6 +104,25 @@ fn f() {
104
104
) ;
105
105
}
106
106
107
+ #[ test]
108
+ #[ should_panic] // currently doesn't work
109
+ fn inactive_assoc_item ( ) {
110
+ check (
111
+ r#"
112
+ struct Foo;
113
+ impl Foo {
114
+ #[cfg(any())] pub fn f() {}
115
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives
116
+ }
117
+
118
+ trait Bar {
119
+ #[cfg(any())] pub fn f() {}
120
+ //^^^^^^^^^^^^^^^^^^^^^^^^^^^ weak: code is inactive due to #[cfg] directives
121
+ }
122
+ "# ,
123
+ ) ;
124
+ }
125
+
107
126
/// Tests that `cfg` attributes behind `cfg_attr` is handled properly.
108
127
#[ test]
109
128
fn inactive_via_cfg_attr ( ) {
You can’t perform that action at this time.
0 commit comments