Repository: rust
Issue: Name collision for unit struct for different crate bad error
Labels: A-diagnostics,T-compiler,D-terse

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code: (change the `src/bin/init.rs` from https://github.com/pickfire/diesel-multi-join-play)

```rust
fn main() {
    use hello::models::*;
    use hello::schema::users::dsl::*;

    let users = vec![NewUser { name: "John" }, NewUser { name: "Jane" }];
}
```

I expected to see this happen:

I wanted to make a minimal reproduction for this issue but I see a better error message which it should be like that. So here is the minimal reproduction code that works.

```rust
#[macro_use]
extern crate diesel;

mod schema {
    table! {
        users (id) {
            id -> Integer,
            name -> Text,
        }
    }
}

use schema::users;

#[derive(Insertable, Debug)]
#[table_name = "users"]
pub struct NewUser<'a> {
    pub name: &'a str,
}

fn t() {
    use schema::users::dsl::*;

    let users = vec![NewUser { name: "John" }, NewUser { name: "Jane" }];
}
```

```rust
error[E0308]: mismatched types
  --> src/lib.rs:24:9
   |
5  | /     table! {
6  | |         users (id) {
7  | |             id -> Integer,
8  | |             name -> Text,
9  | |         }
10 | |     }
   | |_____- unit struct defined here
...
24 |       let users = vec![NewUser { name: "John" }, NewUser { name: "Jane" }];
   |           ^^^^^   -------------------------------------------------------- this expression has type `Vec<NewUser<'_>>`
   |           |
   |           expected struct `Vec`, found struct `table`
   |           `users` is interpreted as a unit struct, not a new binding
   |           help: introduce a new binding instead: `other_users`
   |
   = note: expected struct `Vec<NewUser<'_>>`
              found struct `table`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `hello`

To learn more, run the command again with --verbose.
```

Instead, this happened (on the first code that I showed):

```rust
 --> src/bin/init.rs:5:9
  |
5 |     let users = vec![NewUser { name: "John" }, NewUser { name: "Jane" }];
  |         ^^^^^   -------------------------------------------------------- this expression has type `Vec<hello::models::NewUser<'_>>`
  |         |
  |         expected struct `Vec`, found struct `hello::schema::users::table`
  |
  = note: expected struct `Vec<hello::models::NewUser<'_>>`
             found struct `hello::schema::users::table`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `hello`

To learn more, run the command again with --verbose.
```

My guess is that a different error is being shown for unit struct for different crate since I didn't get to reproduce it within a single file.

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0
```

Discussed in https://github.com/diesel-rs/diesel/issues/151#issuecomment-753959576