about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2016-09-07 18:40:31 -0700
committerEsteban Küber <esteban@kuber.com.ar>2016-09-15 20:06:29 -0700
commit68e8624d05bc9b291fc3d945aaf5c1cb24bf015f (patch)
tree4ab82df7b25b87e929bdd75af2b4c515a2499bf7 /src/rustllvm/RustWrapper.cpp
parentc87ba3f1222ba20d491e8ed76a04977283280742 (diff)
downloadrust-68e8624d05bc9b291fc3d945aaf5c1cb24bf015f.tar.gz
rust-68e8624d05bc9b291fc3d945aaf5c1cb24bf015f.zip
Specify 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
  |
  = 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
  |
  = 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