Commit Graph

41 Commits

Author SHA1 Message Date
Dan Aloni eaefe4a230 path trimming: ignore type aliases 2021-02-06 12:03:48 +02:00
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
Yuki Okushi ec31b4e3a8
Audit uses of `span_suggestion_short` 2020-07-02 15:18:33 +09:00
Bastian Kauschke 06a237fe2c coerce reborrow multi arg test 2020-06-19 11:06:21 +02:00
Bastian Kauschke 0b5007e4b7 merge coercion test folders 2020-06-19 10:55:38 +02:00
Manish Goregaokar 9ca811772c
Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwco
Tweak "non-primitive cast" error

- Suggest borrowing expression if it would allow cast to work.
- Suggest using `<Type>::from(<expr>)` when appropriate.
- Minor tweak to `;` typo suggestion.

Partily address #47136.
2020-06-18 15:20:57 -07:00
Esteban Küber e857696cf8 Tweak "non-primitive cast" error
- Suggest borrowing expression if it would allow cast to work.
- Suggest using `<Type>::from(<expr>)` when appropriate.
- Minor tweak to `;` typo suggestion.

Partily address #47136.
2020-06-15 08:57:20 -07:00
Santiago Pastorino c99164e7a1
Relate existential associated types with variance Invariant 2020-06-09 13:21:27 -03:00
Esteban Küber 5b36c187dc review comments 2020-01-16 09:49:13 -08:00
Niko Matsakis 1719337d02 Revert "Remove `#![feature(never_type)]` from tests."
This reverts commit 8f6197f39f.
2019-12-14 09:01:04 -05:00
Esteban Küber 34f03c01f6 Point at type in `let` assignment on type errors 2019-11-21 19:24:31 -08:00
bors 53712f8637 Auto merge of #66389 - estebank:type-err-labels, r=petrochenkov
Specific labels when referring to "expected" and "found" types
2019-11-21 17:53:19 +00:00
Mazdak Farrokhzad 6eb0627b49 Gate fallback via `#![feature(never_type_fallback)]`. 2019-11-21 14:55:33 +01:00
Mazdak Farrokhzad 8f6197f39f Remove `#![feature(never_type)]` from tests.
Also remove `never_type` the feature-gate test.
2019-11-21 14:55:32 +01: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 b2e6aef073 review comments: tweak prefix strings 2019-11-18 11:02:44 -08:00
Esteban Küber 83ffda5216 Specific labels when referring to "expected" and "found" types 2019-11-18 11:02:22 -08:00
Mazdak Farrokhzad 1fb8cfb481 Organize `never_type` tests
Also move {run-fail -> ui}/never_type
2019-10-15 16:58:14 +02:00
varkor 0b97726e6c Update ui tests 2019-09-06 19:21:26 +01:00
Esteban Küber bc1a4f52e3 review comments: typo and rewording 2019-08-09 07:18:05 -07:00
Esteban Küber 33d1082d6e review comment: review wording or missing return error 2019-08-09 07:18:05 -07:00
Esteban Küber efa62d66e3 Tweak wording of fn without explicit return 2019-08-09 07:18:05 -07:00
Esteban Küber 01a61394f8 Change wording for function without return value
Fix #62677
2019-08-09 07:18:05 -07:00
Yuki Okushi c004451a20 Migrate compile-pass annotations to build-pass 2019-07-03 06:30:28 +09:00
memoryruins eb4580a570 Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
Matthew Jasper 8eef102270 update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
Andy Russell b6f148c8bd
hide `--explain` hint if error has no extended info 2019-04-18 13:29:28 -04:00
Vadim Petrochenkov fa72a81bea Update tests 2019-03-11 23:10:26 +03:00
bors ad9068f874 Auto merge of #57230 - estebank:return-mismatch, r=varkor
Modify mismatched type error for functions with no return

Fix #50009.

```
error[E0308]: mismatched types
  --> $DIR/coercion-missing-tail-expected-type.rs:3:24
   |
LL | fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
   |    --------            ^^^ expected i32, found ()
   |    |
   |    this function's body doesn't return
LL |     x + 1;
   |          - help: consider removing this semicolon
   |
   = note: expected type `i32`
              found type `()`
```

instead of

```
error[E0308]: mismatched types
  --> $DIR/coercion-missing-tail-expected-type.rs:3:28
   |
LL |   fn plus_one(x: i32) -> i32 { //~ ERROR mismatched types
   |  ____________________________^
LL | |     x + 1;
   | |          - help: consider removing this semicolon
LL | | }
   | |_^ expected i32, found ()
   |
   = note: expected type `i32`
              found type `()`
```
2019-01-05 22:25:47 +00:00
Yuning Zhang 710dcbd381 Improve type mismatch error messages
Replace "integral variable" with "integer" and replace
"floating-point variable" with "floating-point number" to make the
message less confusing.
2018-12-31 20:43:08 -05:00
Esteban Küber 5d086c3282 Tweak E0308 error for clarity 2018-12-30 21:59:27 -08:00
Esteban Küber f62f540b4e Point at function name span 2018-12-30 15:41:19 -08:00
Esteban Küber 1f65dc0770 Point at the return type span on type mismatch due to missing return
Do not point at the entire block span on fn return type mismatches
caused by missing return.
2018-12-30 13:55:00 -08:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
Ariel Ben-Yehuda f4dc1c5d64 fix review comments, round 2 2018-12-17 01:59:32 +02:00
Ariel Ben-Yehuda 78f7e854f9 address review comments 2018-12-17 01:59:32 +02:00
Ariel Ben-Yehuda 95bec6ed09 trigger unsized coercions keyed on Sized bounds
This PR causes unsized coercions to not be disabled by `$0: Unsize<dyn
Object>` coercion obligations when we have an `$0: Sized` obligation
somewhere.

Note that `X: Unsize<dyn Object>` obligations can't fail *as
obligations* if `X: Sized` holds, so this still maintains some version
of monotonicity (I think that an unsized coercion can't be converted to
no coercion by unifying type variables).

Fixes #49593 (unblocking never_type).
2018-12-17 01:59:32 +02:00
Matthew Jasper bc4f9b848d Clearer later use messages for calls
Give a special message when the later use is from a call. Use the span
of the callee instead of the whole expression. For conflicting borrow
messages say that the later use is of the first borrow.
2018-10-03 20:32:38 +01:00
David Wood a922642455
Moved tests back to compile-test if they don't work on ui. 2018-08-14 11:12:11 +02:00
David Wood 3fc7ab2373
Merged migrated compile-fail tests and ui tests. Fixes #46841. 2018-08-14 11:12:09 +02:00