about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorRyan Cumming <etaoins@gmail.com>2018-01-24 20:31:36 +1100
committerRyan Cumming <etaoins@gmail.com>2018-01-24 20:31:36 +1100
commit65b1e86aed22bfcd3a4ce27da9be2b14c7d5738e (patch)
tree27a0e874b0f07eac3d70874942114c93c2abf7ab /src/rustllvm/RustWrapper.cpp
parenta538fe7ce715c7bd27e2e05329c3d857b9ad92af (diff)
downloadrust-65b1e86aed22bfcd3a4ce27da9be2b14c7d5738e.tar.gz
rust-65b1e86aed22bfcd3a4ce27da9be2b14c7d5738e.zip
Fix into() cast paren check precedence
As discussed in #47699 the logic for determining if an expression needs
parenthesis when suggesting an `.into()` cast is incorrect. Two broken
examples from nightly are:

```
error[E0308]: mismatched types
 --> main.rs:4:10
  |
4 |     test(foo as i8);
  |          ^^^^^^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
  |
4 |     test(foo as i8.into());
  |
```

```
error[E0308]: mismatched types
 --> main.rs:4:10
  |
4 |     test(*foo);
  |          ^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
  |
4 |     test(*foo.into());
  |
```

As suggested by @petrochenkov switch the precedence check to
PREC_POSTFIX. This catches both `as` and unary operators. Fixes #47699.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions