about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-09-16 00:39:27 -0700
committerGitHub <noreply@github.com>2016-09-16 00:39:27 -0700
commit89500e934134d19b09e51a1f45430ded65e291b4 (patch)
tree311385701b36cb11ee2d68276e7cb5c3a2dc8bb5 /src/rustllvm/RustWrapper.cpp
parenta36e069288141a8bb2d090f65e8c5cd415fb37e9 (diff)
parent68e8624d05bc9b291fc3d945aaf5c1cb24bf015f (diff)
downloadrust-89500e934134d19b09e51a1f45430ded65e291b4.tar.gz
rust-89500e934134d19b09e51a1f45430ded65e291b4.zip
Auto merge of #36338 - estebank:primitive-shadow, r=jseyfried
Be more specific when type parameter shadows primitive type

When a type parameter shadows a primitive type, the error message
was non obvious. For example, given the file `file.rs`:

```rust
trait Parser<T> {
    fn parse(text: &str) -> Option<T>;
}

impl<bool> Parser<bool> for bool {
    fn parse(text: &str) -> Option<bool> {
        Some(true)
    }
}

fn main() {
    println!("{}", bool::parse("ok").unwrap_or(false));
}
```

The output was:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool a
  |
  = note: expected type `bool`
  = note:    found type `bool`

error: aborting due to previous error
```

We now show extra information about the type:

```bash
% rustc file.rs
error[E0308]: mismatched types
 --> file.rs:7:14
  |
7 |         Some(true)
  |              ^^^^ expected type parameter, found bool a
  |
  = note: expected type `bool` (type parameter)
  = note:    found type `bool` (bool)

error: aborting due to previous error
```

Fixes #35030
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions