70 Commits

Author SHA1 Message Date
bors
ba196bdcb1 Auto merge of #51444 - estebank:impl-static, r=nikomatsakis
Suggestion for 'static impl Trait return

When encountering a named or anonymous sup requirement (for example,
`&'a self`) and a `'static` impl Trait return type, suggest adding the
`'_` lifetime constraing to the return type.

Fix #43719, #51282.

```
error: cannot infer an appropriate lifetime
  --> $DIR/static-return-lifetime-infered.rs:17:16
   |
LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
   |                                   ----------------------- this return type evaluates to the `'static` lifetime...
LL |         self.x.iter().map(|a| a.0)
   |         ------ ^^^^
   |         |
   |         ...but this borrow...
   |
note: ...can't outlive the anonymous lifetime #1 defined on the method body at 16:5
  --> $DIR/static-return-lifetime-infered.rs:16:5
   |
LL | /     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
LL | |         self.x.iter().map(|a| a.0)
LL | |     }
   | |_____^
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 16:5
   |
LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2018-06-28 03:57:28 +00:00
Oliver Schneider
28a76a9000 Don't inspect the generated existential type items 2018-06-26 16:36:32 +02:00
Esteban Küber
612657d9f0 Use lifetime name if available 2018-06-20 15:38:07 -07:00
Esteban Küber
776544f011 Add message to rustc_on_unimplemented attributes in core 2018-06-19 15:19:13 -07:00
bors
862703e05e Auto merge of #51414 - oli-obk:impl_trait_type_def, r=pnkfelix
Add existential type definitions

Note: this does not allow creating named existential types, it just desugars `impl Trait` to a less (but still very) hacky version of actual `existential type` items.

r? @nikomatsakis
2018-06-18 14:34:52 +00:00
Guillaume Gomez
f2349d5ec6 Fix error codes 2018-06-10 14:04:48 +02:00
Esteban Küber
aaf78a5265 Add nll test output 2018-06-08 21:08:29 -07:00
Esteban Küber
6be16baa4a Remove primary label for more readable output 2018-06-08 16:27:07 -07:00
Esteban Küber
82d3a49564 Suggestion for 'static impl Trait return
When encountering a named or anonymous sup requirement (for example,
`&'a self`) and a `'static` impl Trait return type, suggest adding the
`'_` lifetime constraing to the return type.
2018-06-08 15:25:20 -07:00
Oliver Schneider
9b1bd94e37 Add existential type definitons 2018-06-07 17:33:53 +02:00
kennytm
103abdb75c
Rollup merge of #50987 - estebank:underline-multiple-suggestions, r=petrochencov
Underline multiple suggested replacements in the same line

<img width="685" alt="screen shot 2018-05-22 at 21 06 48" src="https://user-images.githubusercontent.com/1606434/40403051-174f3180-5e04-11e8-86b6-261630c5ff80.png">

Follow up to #50943.

Fix #50977.
2018-05-26 19:32:18 +08:00
Niko Matsakis
558cbfb19b prohibit turbofish in impl Trait methods 2018-05-24 18:43:48 -04:00
Esteban Küber
f36c643d4f Fix impl Trait suggestion 2018-05-24 10:01:13 -07:00
Esteban Küber
50eefc0d77 Account for negative offsets in suggestions
When suggesting code that has a shorter span than the current code,
account for this by keeping the offset as a signed value.
2018-05-24 04:16:54 -07:00
Oliver Schneider
849c565e2f Prevent local paths into libstd from leaking into ui tests 2018-05-22 12:00:27 +02:00
Oliver Schneider
af75ebdc3a Improve the diagnostic around impl Trait <-> generic param mismatch 2018-05-21 18:06:28 +02:00
Oliver Schneider
00842d10cd Move a test to ui tests so we can observe the output changes better 2018-05-21 09:59:37 +02:00
Oliver Schneider
0874ba0fe5 Typo caused the wrong "cannot find" error 2018-05-21 09:56:52 +02:00
Aravind Gollakota
bc16b8e92a Port existing callers of evaluate_obligation to the new canonical trait query
Except the one in coherence, which needs support for intercrate mode.
2018-04-26 20:28:30 -05:00
Simon Sapin
70fdd1b5c0 Make the unstable StrExt and SliceExt traits private to libcore in not(stage0)
`Float` still needs to be public for libcore unit tests.
2018-04-21 09:47:38 +02:00
John Kåre Alsaker
9cbe3b749d Update tests 2018-04-16 23:30:36 +02:00
bors
4bf76d6745 Auto merge of #48709 - tinaun:issue48703, r=nikomatsakis
remove erroneous error message when checking impl trait params

fixes #48703
2018-04-05 05:04:27 +00:00
tinaun
97e0dc330f added test 2018-03-28 17:51:57 -04:00
Taylor Cramer
0f5b52e4a8 Stabilize conservative_impl_trait 2018-03-26 10:43:03 +02:00
Taylor Cramer
c393db67ba Stabilize universal_impl_trait 2018-03-26 07:39:38 +02:00
kennytm
9c5f372a9a
Rollup merge of #49046 - Zoxc:error-summary, r=michaelwoerister
Always print `aborting due to n previous error(s)`

r? @michaelwoerister
2018-03-25 01:26:24 +08:00
Niko Matsakis
f71de45b23 use subtyping when we create a closure instead of for upvar types
We used to make the upvar types in the closure `==` but that was
stronger than we needed. Subtyping suffices, since we are copying the
upvar value into the closure field. This in turn allows us to infer
smaller lifetimes in captured values in some cases (like the example
here), avoiding errors.
2018-03-21 05:40:59 -04:00
Niko Matsakis
fc3c90cf8a report an error if we see an unexpected lifetime in impl Trait
But leave closure substs alone.
2018-03-21 05:40:59 -04:00
John Kåre Alsaker
b1d872b38e Update tests 2018-03-16 11:52:46 +01:00
Guillaume Gomez
2e104a77cf update tests 2018-03-14 00:53:24 +01:00
Vadim Petrochenkov
7ba5fd168a Update UI tests 2018-02-26 20:24:42 +03:00
Vadim Petrochenkov
fa2d9fc4b9 Update UI tests 2018-02-26 20:24:02 +03:00
Guillaume Gomez
5747fd6611 Update ui tests 2018-02-25 12:15:05 +01:00
John Kåre Alsaker
46a3f2fa18 Change error message for E0391 to "cyclic dependency detected" 2018-02-10 03:28:15 +01:00
Manish Goregaokar
aee22556a9
Rollup merge of #47613 - estebank:rustc_on_unimplemented, r=nikomatsakis
Add filtering options to `rustc_on_unimplemented`

- Add filtering options to `rustc_on_unimplemented` for local traits, filtering on `Self` and type arguments.
- Add a way to provide custom notes.
- Tweak binops text.
- Add filter to detect wether `Self` is local or belongs to another crate.
- Add filter to `Iterator` diagnostic for `&str`.

Partly addresses #44755 with a different syntax, as a first approach. Fixes #46216, fixes #37522, CC #34297, #46806.
2018-02-07 08:30:47 -08:00
bors
6c15dffc43 Auto merge of #47791 - estebank:mismatched-trait-impl, r=nikomatsakis
Tweak presentation on lifetime trait mismatch

 - On trait/impl method discrepancy, add label pointing at trait signature.
 - Point only at method definition when referring to named lifetimes on lifetime mismatch.
 - When the sub and sup expectations are the same, tweak the output to avoid repeated spans.

Fix #30790, CC #18759.
2018-02-03 01:26:56 +00:00
Esteban Küber
621e61bff9 Add filter to detect local crates for rustc_on_unimplemented 2018-02-01 15:06:21 -08:00
Esteban Küber
4c92a02b64 Change rustc_on_unimplemented for Iterator and binops 2018-02-01 15:06:21 -08:00
Esteban Küber
c1383e4dc4 Add filtering options to rustc_on_unimplemented
- filter error on the evaluated value of `Self`
 - filter error on the evaluated value of the type arguments
 - add argument to include custom note in diagnostic
 - allow the parser to parse `Self` when processing attributes
 - add custom message to binops
2018-02-01 15:06:20 -08:00
Esteban Küber
67696be160 Point only at method signatures and point at trait
- On mismatch between impl and trait method, point at the trait
   signature.
 - Point only at the method signature instead of the whole body on
   trait/impl mismatch errors.
2018-01-28 17:06:30 -08:00
Vadim Petrochenkov
f57ea7cb3d Make + in impl/dyn Trait non-associative 2018-01-27 22:38:28 +03:00
Esteban Küber
4121ddb041 Do not suggest private traits that have missing method
When encountering a method call for an ADT that doesn't have any
implementation of it, we search for traits that could be implemented
that do have that method. Filter out private non-local traits that would
not be able to be implemented.

This doesn't account for public traits that are in a private scope, but
works as a first approximation and is a more correct behavior than the
current one.
2018-01-22 08:29:24 -08:00
Esteban Küber
9b36030a65 On E0283, point at method with the requirements
On required type annotation diagnostic error, point at method with the
requirements if the span is available.
2018-01-15 14:56:32 -08:00
Esteban Küber
3441ffb15e Point at def span in "missing in impl" error 2017-12-19 14:41:03 -08:00
Vadim Petrochenkov
1f5b201aff Remove NOTE/HELP annotations from UI tests 2017-12-14 23:26:39 +03:00
Esteban Küber
8a93deca9a Make main span in impl-trait ciclic reference point to def_span 2017-11-27 06:00:20 -08:00
Esteban Küber
0b2d21e32b Make impl-trait ciclical reference error point to def_span 2017-11-26 12:35:19 -08:00
Esteban Küber
aabb604313 Move "auto trait leak" impl-trait cycle dependency test to ui 2017-11-26 12:32:30 -08:00
Oliver Schneider
8937d6a6cf
Merge cfail and ui tests into ui tests 2017-11-24 11:32:35 +01:00
bors
a6031a2ccf Auto merge of #46024 - estebank:no-variant, r=petrochenkov
Use the proper term when using non-existing variant

When using a non-existing variant, function or associated item, refer to
the proper term, instead of defaulting to "associated item" in
diagnostics.

Fix #28972.

```
error[E0599]: no variant named `Quux` found for type `Foo` in the current scope
 --> file.rs:7:9
  |
7 |         Foo::Quux(..) =>(),
  |         ^^^^^^^^^^^^^
```
2017-11-23 05:53:08 +00:00