File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -370,3 +370,37 @@ fn f(a: i32, b: u32) -> String {
370
370
}"# ] ]
371
371
. assert_eq ( & body. pretty_print ( & db, def, Edition :: CURRENT ) )
372
372
}
373
+
374
+ #[ test]
375
+ fn destructuring_assignment_tuple_macro ( ) {
376
+ // This is a funny one. `let m!()() = Bar()` is an error in rustc, because `m!()()` isn't a valid pattern,
377
+ // but in destructuring assignment it is valid, because `m!()()` is a valid expression, and destructuring
378
+ // assignments start their lives as expressions. So we have to do the same.
379
+
380
+ let ( db, body, def) = lower (
381
+ r#"
382
+ struct Bar();
383
+
384
+ macro_rules! m {
385
+ () => { Bar };
386
+ }
387
+
388
+ fn foo() {
389
+ m!()() = Bar();
390
+ }
391
+ "# ,
392
+ ) ;
393
+
394
+ let ( _, source_map) = db. body_with_source_map ( def) ;
395
+ assert_eq ! ( source_map. diagnostics( ) , & [ ] ) ;
396
+
397
+ for ( _, def_map) in body. blocks ( & db) {
398
+ assert_eq ! ( def_map. diagnostics( ) , & [ ] ) ;
399
+ }
400
+
401
+ expect ! [ [ r#"
402
+ fn foo() -> () {
403
+ Bar() = Bar();
404
+ }"# ] ]
405
+ . assert_eq ( & body. pretty_print ( & db, def, Edition :: CURRENT ) )
406
+ }
You can’t perform that action at this time.
0 commit comments