7134: Fix infer error of macro invocation in array expr r=edwin0cheng a=edwin0cheng

Fixed following infer error:

```rust
macro_rules! bar { () => {0u32} }
fn test() {
    let a = [bar!()];   // a : [unknown]
}
```

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2021-01-02 14:16:26 +00:00 committed by GitHub
commit 3b347eaa4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -404,7 +404,7 @@ fn to_fragment_kind(db: &dyn AstDatabase, id: MacroCallId) -> FragmentKind {
TRY_EXPR => FragmentKind::Expr,
TUPLE_EXPR => FragmentKind::Expr,
PAREN_EXPR => FragmentKind::Expr,
ARRAY_EXPR => FragmentKind::Expr,
FOR_EXPR => FragmentKind::Expr,
PATH_EXPR => FragmentKind::Expr,
CLOSURE_EXPR => FragmentKind::Expr,

View File

@ -325,6 +325,24 @@ fn test() {
);
}
#[test]
fn infer_array_macro_call() {
check_infer(
r#"
macro_rules! bar { () => {0u32} }
fn test() {
let a = [bar!()];
}
"#,
expect![[r#"
!0..4 '0u32': u32
44..69 '{ ...()]; }': ()
54..55 'a': [u32; _]
58..66 '[bar!()]': [u32; _]
"#]],
);
}
#[test]
fn bug_1030() {
check_infer(