Commit Graph

9 Commits

Author SHA1 Message Date
Dan Aloni
07e7823c01 pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.
2020-09-02 22:26:37 +03:00
Esteban Küber
34f03c01f6 Point at type in let assignment on type errors 2019-11-21 19:24:31 -08:00
Esteban Küber
6f8f70624b Surround types with backticks in type errors 2019-11-18 11:03:04 -08:00
Esteban Küber
94c6425464 Remove E0308 note when primary label has all info 2019-11-18 11:03:03 -08:00
Esteban Küber
83ffda5216 Specific labels when referring to "expected" and "found" types 2019-11-18 11:02:22 -08:00
Dan Robertson
285d4a7eb6
suggestion-diagnostics: as_ref improve snippet
Improve the code snippet suggested in suggestion-diagnostics when
suggesting the use of as_ref.
2019-02-13 17:52:22 +00:00
Esteban Küber
8da6727e96 Suggest .as_ref() when appropriate for Option and Result 2018-12-28 11:16:23 -08:00
Oliver Schneider
53d2ebb0ad Implement existential types 2018-07-18 10:53:08 +02:00
Esteban Küber
a19a03a31f Suggest using as_ref on some borrow errors [hack]
When encountering the following code:

```rust
struct Foo;
fn takes_ref(_: &Foo) {}
let ref opt = Some(Foo);

opt.map(|arg| takes_ref(arg));
```

Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead.

This is a stop gap solution until we expand typeck to deal with these
cases in a more graceful way.
2018-05-30 09:47:09 -07:00