]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #35611 - jonathandturner:ptr-helper, r=nikomatsakis
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Sun, 14 Aug 2016 17:29:51 +0000 (20:29 +0300)
committerGitHub <noreply@github.com>
Sun, 14 Aug 2016 17:29:51 +0000 (20:29 +0300)
commit80510b800a633895247811049faef321bd6bff92
treed786d4926ce44aa5785c8487aacbd4fd7d4ae2ef
parent7aaa83a7d8da9fcc3f9f1e017041e5adf9919799
parent42247372c6c507beed4d309ea5867579d5b65511
Rollup merge of #35611 - jonathandturner:ptr-helper, r=nikomatsakis

Improve &-ptr printing

This PR replaces printing `&-ptr` with a more readable description.  To do so it uses a few heuristics.

If the name of the type is unknown, too long (longer than just saying "reference"), or too complex (a type with explicit lifetime annotations), it will instead opt to print either "reference" or "mutable reference", depending on the mutability of the type.

Before:

```
error[E0308]: mismatched types
  --> src/test/compile-fail/issue-7061.rs:14:46
   |
14 |     fn foo(&'a mut self) -> Box<BarStruct> { self }
   |                                              ^^^^ expected box, found &-ptr
   |
   = note: expected type `Box<BarStruct>`
   = note:    found type `&'a mut BarStruct`

error: aborting due to previous error
```

After:

```
error[E0308]: mismatched types
  --> src/test/compile-fail/issue-7061.rs:14:46
   |
14 |     fn foo(&'a mut self) -> Box<BarStruct> { self }
   |                                              ^^^^ expected box, found mutable reference
   |
   = note: expected type `Box<BarStruct>`
   = note:    found type `&'a mut BarStruct`

error: aborting due to previous error
```
src/librustc/ty/error.rs