Skip to content

we find a issue, I don't konw is there a bug? #49865

Closed
@driftluo

Description

@driftluo

the function like this is ok:

fn test() -> bool {
    let a = {true} && true;
    a 
}

but when is become this, there is an error:

fn test() -> bool {
    {
    // this is some thing return bool
    true
    } && true
}

the error is:

error[E0308]: mismatched types
 --> src/main.rs:4:5
  |
4 |     true
  |     ^^^^ expected (), found bool
  |
  = note: expected type `()`
             found type `bool`

error[E0308]: mismatched types
 --> src/main.rs:6:7
  |
1 | fn test() -> bool {
  |              ---- expected `bool` because of return type
...
6 |     } && true
  |       ^^^^^^^ expected bool, found &&bool
  |
  = note: expected type `bool`
             found type `&&bool`

error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions