Commit Graph

374 Commits

Author SHA1 Message Date
marmeladema
f1878d19fa Move from {{closure}}#0 syntax to {closure#0} for (def) path components 2020-09-25 22:46:14 +01:00
Esteban Küber
5d2a935e6c Make suggestion more complete 2020-09-11 17:05:18 -07:00
Esteban Küber
ff297fafbf Make suggestion have a more targetted underline 2020-09-11 17:05:18 -07:00
Esteban Küber
c8ee33714b Use structured suggestion for impl T to Box<dyn T> 2020-09-11 17:05:18 -07:00
Tyler Mandry
5ea55518bc
Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasper
Improve unresolved use error message

"use of undeclared type or module `foo`" doesn't mention that it could be a crate.

This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate.

I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-09 15:05:45 -07:00
Bastian Kauschke
c81935e6df make ConstEvaluatable more strict 2020-09-08 16:39:12 +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
Kornel
7ec1de062a Clarify message about unresolved use 2020-09-01 18:38:14 +01:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00
Yuki Okushi
8dcf86887c
Add test for issue-72911 2020-07-26 18:54:54 +09:00
Esteban Küber
7bf39fa9d9 Further tweak wording of E0759 and introduce E0767 2020-07-22 12:25:54 -07:00
Esteban Küber
b7db6bb5af Remove Sized on_unimplemented note 2020-07-14 10:50:24 -07:00
Dylan DPC
45de677b1e
Rollup merge of #73646 - JohnTitor:add-tests, r=Dylan-DPC
Add some regression tests

Closes #44861
Closes #51506
Closes #59435
Closes #69840
2020-06-24 14:28:41 +02:00
Yuki Okushi
814782b4c6
Add test for issue-69840 2020-06-23 17:52:51 +09:00
Manish Goregaokar
cd18ac1ce8
Rollup merge of #73496 - estebank:opaque-missing-lts-in-fn-3, r=nikomatsakis
Account for multiple impl/dyn Trait in return type when suggesting `'_`

Make `impl` and `dyn` Trait lifetime suggestions a bit more resilient.

Follow up to #72804.

r? @nikomatsakis
2020-06-23 00:33:58 -07:00
Manish Goregaokar
203305d095
Rollup merge of #71420 - RalfJung:specialization-incomplete, r=matthewjasper
Specialization is unsound

As discussed in https://github.com/rust-lang/rust/issues/31844#issuecomment-617013949, it might be a good idea to warn users of specialization that the feature they are using is unsound.

I also expanded the "incomplete feature" warning to link the user to the tracking issue.
2020-06-19 19:42:43 -07:00
Esteban Küber
562f4967b4 Account for multiple impl/dyn Trait in return type when suggesting '_ 2020-06-19 13:40:51 -07:00
Manish Goregaokar
b443a107f8
Rollup merge of #73382 - Aaron1011:fix/self-receiver-candidates, r=petrochenkov
Only display other method receiver candidates if they actually apply

Previously, we would suggest `Box<Self>` as a valid receiver, even if
method resolution only succeeded due to an autoderef (e.g. to `&self`)
2020-06-19 09:15:16 -07:00
Manish Goregaokar
40fd2bdcfe
Rollup merge of #72804 - estebank:opaque-missing-lts-in-fn-2, r=nikomatsakis
Further tweak lifetime errors involving `dyn Trait` and `impl Trait` in return position

* Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static` instead of `Trait + 'static + '_`
* When `'static` is explicit, also suggest constraining argument with it
* Reduce verbosity of suggestion message and mention lifetime in label
* Tweak output for overlapping required/captured spans
* Give these errors an error code

Follow up to #72543.

r? @nikomatsakis
2020-06-18 15:20:43 -07:00
Ralf Jung
5fbef22a44 warn against 'specialization' feature 2020-06-16 09:39:34 +02:00
Aaron Hill
8956a7f581
Only display other method receiver candidates if they actually apply
Previously, we would suggest `Box<Self>` as a valid receiver, even if
method resolution only succeeded due to an autoderef (e.g. to `&self`)
2020-06-15 15:15:35 -04:00
Esteban Küber
8f12485335 review comments 2020-06-15 12:11:28 -07:00
Esteban Küber
96f5584b80 Expand "recursive opaque type" diagnostic
Fix #70968, partially address #66523.
2020-06-15 11:08:43 -07:00
Esteban Küber
f7a1f97307 Change E0758 to E0759 to avoid conflict with #72912 2020-06-15 09:06:58 -07:00
Esteban Küber
e31367de6b small tweaks 2020-06-15 09:06:58 -07:00
Esteban Küber
34d8692262 Register new eror code 2020-06-15 09:06:58 -07:00
Esteban Küber
10d9bf1767 Use note for requirement source span 2020-06-15 09:06:58 -07:00
Esteban Küber
31ea589a06 review comments: wording 2020-06-15 09:06:58 -07:00
Esteban Küber
539e9783df Tweak wording and add error code 2020-06-15 09:06:57 -07:00
Esteban Küber
bc15790609 Tweak output for overlapping required/captured spans 2020-06-15 09:06:57 -07:00
Esteban Küber
e75588934c Move overlapping span to a note 2020-06-15 09:06:57 -07:00
Esteban Küber
921f35fe73 Reduce verbosity of suggestion message and mention lifetime in label 2020-06-15 09:06:57 -07:00
Esteban Küber
4e90f177cc When 'static is explicit, suggest constraining argument with it 2020-06-15 09:06:57 -07:00
Esteban Küber
81c909488e Suggest substituting 'static lifetime in impl/dyn Trait + 'static return types 2020-06-15 09:06:57 -07:00
Matthew Jasper
f97070db90 Forbid lifetime elision in let position impl Trait
This is consistent with types.
2020-06-11 16:24:01 +01:00
Matthew Jasper
4e49e67c44 Stop special casing top level TAIT 2020-06-11 16:24:01 +01:00
Dylan DPC
024f025934
Rollup merge of #73005 - Aaron1011:fix/error-overflow, r=estebank
Don't create impl candidates when obligation contains errors

Fixes #72839

In PR #72621, trait selection was modified to no longer bail out early
when an error type was encountered. This allowed us treat `ty::Error` as
`Sized`, causing us to avoid emitting a spurious "not sized" error after
a type error had already occured.

However, this means that we may now try to match an impl candidate
against the error type. Since the error type will unify with almost
anything, this can cause us to infinitely recurse (eventually triggering
an overflow) when trying to verify certain `where` clauses.

This commit causes us to skip generating any impl candidates when an
error type is involved.
2020-06-10 11:03:43 +02:00
Dylan DPC
14dc34dd89
Rollup merge of #72260 - csmoe:issue-69276, r=estebank
Spell out `Self` in async function return

Closes #69276
r? @tmandry
2020-06-05 13:07:03 +02:00
Aaron Hill
3295c262ae
Treat selection error as ambiguous when error type is present 2020-06-04 21:09:31 -04:00
csmoe
9be635306c resolve error code e0760 2020-06-04 09:37:32 +08:00
Matthew Jasper
8894bd220b Add descriptions for all queries 2020-05-31 20:15:32 +01:00
Esteban Küber
83f6f22358 Tweak wording and spans of 'static dyn Trait/impl Trait requirements 2020-05-30 10:22:27 -07:00
Esteban Küber
8f7ee34379 Tweak type parameter errors to reduce verbosity 2020-05-30 10:22:26 -07:00
Esteban Küber
731ea85f21 review comment: tweak wording and account for span overlap 2020-05-30 10:22:26 -07:00
Esteban Küber
65f492be12 Account for returned dyn Trait evaluating to 'static lifetime
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30 10:22:26 -07:00
Yuki Okushi
125f0abb42
Add test for #68532 2020-05-27 00:48:37 +09:00
Yuki Okushi
ca722b9358
Add test for #56445 2020-05-27 00:48:37 +09:00
Matthew Jasper
f9f3063cfa Update tests 2020-05-22 18:03:08 +01:00
csmoe
2f311b07c8 Merge branch 'master' into issue-69276 2020-05-19 11:02:29 +08:00
csmoe
8841ede364 bless suggestion on spell out 2020-05-18 08:44:38 +08:00