Commit Graph

398 Commits

Author SHA1 Message Date
ms2300 f4d4faaeed Fixing tests from anon -> opaque 2018-09-06 11:43:31 -06:00
Basile Desloges b01550a718 Update tests 2018-09-01 12:58:18 +02:00
Mark Mansi 15b2640e70 fix another 2018-08-27 12:40:16 -05:00
David Wood 6e24868384
Normalize source line and column numbers.
This commit adds a normalization for line and column numbers in stderr
files where the line/col is from the source directory rather than
the test itself - thereby removing the need to update tests as
compiler source changes.
2018-08-21 12:59:42 +02:00
Matthew Jasper a19db49c86 Update former compile-fail tests 2018-08-14 21:26:33 +01:00
David Wood 3fc7ab2373
Merged migrated compile-fail tests and ui tests. Fixes #46841. 2018-08-14 11:12:09 +02:00
David Wood 2488cb6b10
Explicitly label any named lifetimes mentioned in error messages. 2018-08-02 12:00:15 +02:00
bors b6cbc1e147 Auto merge of #52648 - davidtwco:issue-52533, r=nikomatsakis
[nll] improve the "fully elaborated type" case in region errors

Fixes #52533.

r? @nikomatsakis
2018-07-27 13:01:48 +00:00
David Wood 2e4224a998
Region inference error messages no longer start with 'free region' 2018-07-27 13:14:56 +02:00
David Wood b377e7bbfb
Change label from closure to function where appropriate. 2018-07-27 12:48:47 +02:00
bors 7c2aeb9d97 Auto merge of #52650 - oli-obk:associated_existential_types, r=nikomatsakis
Implement associated existential types

r? @nikomatsakis

no idea if these work with generic traits. I'm going home for the day 🤣
2018-07-27 07:16:12 +00:00
bors bfbf8375d7 Auto merge of #52488 - nikomatsakis:nll-issue-48071-universe-and-sub, r=pnkfelix
introduce universes to NLL type check

This branch aims to fix #48071 and also advance chalk integration a bit at the same time. It re-implements the subtyping/type-equating check so that NLL doesn't "piggy back" on the subtyping code of the old type checker.

This new code uses the "universe-based" approach to handling higher-ranked lifetimes, which sidesteps some of the limitations of the current "leak-based" scheme. This avoids the ICE in #48071.

At the same time, I aim for this to potentially be a kind of optimization. This NLL code is (currently) not cached, but it also generates constraints without doing as much instantiation, substitution, and folding. Right now, though, it still piggy backs on the `relate_tys` trait, which is a bit unfortunate -- it means we are doing more hashing and things than we have to. I want to measure the see the perf. Refactoring that trait is something I'd prefer to leave for follow-up work.

r? @pnkfelix -- but I want to measure perf etc first
2018-07-26 15:23:50 +00:00
Niko Matsakis 0d918a8575 improve heuristics for what makes an interesting constraint 2018-07-25 16:36:03 +03:00
Oliver Schneider 93974cb09e Fix associated existentials for generic traits 2018-07-25 10:47:59 +02:00
Oliver Schneider 2e33a557de Allow declaring existential types inside blocks 2018-07-24 10:07:45 +02:00
Oliver Schneider 9130efdad3 Implement associated existential types 2018-07-23 17:38:45 +02:00
Oliver Schneider 35351591af Move some tests around 2018-07-18 10:53:09 +02:00
Oliver Schneider 4e8cc76a91 Add test for using existential types in associated types 2018-07-18 10:53:08 +02:00
Oliver Schneider 3e215a3c87 Typeck existential types properly 2018-07-18 10:53:08 +02:00
Oliver Schneider 61414fd6c1 Use the correct visibility 2018-07-13 20:45:23 +02:00
Niko Matsakis a6adb1ebff find and highlight the `&` or `'_` in `region_name` 2018-07-09 00:20:36 -04:00
Niko Matsakis 727f01700b write code to extract region names and emit new style message 2018-07-04 05:09:33 -04:00
bors 8772747c5f Auto merge of #51862 - estebank:lifetime-spans, r=nikomatsakis
Point to lifetime spans on lifetime errors
2018-06-30 16:52:12 +00:00
bors acf50b79be Auto merge of #51806 - oli-obk:lowering_cleanups1, r=cramertj
Lowering cleanups [1/N]
2018-06-30 07:10:18 +00:00
Esteban Küber 8449c5ab8a Fix rebase 2018-06-28 12:52:58 -07:00
Esteban Küber 5436a5c55a Point to lifetime in fn definition on lifetime error note 2018-06-28 11:12:42 -07:00
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 99575b5cac Update ui tests 2018-06-27 12:03:59 +02:00
Oliver Schneider 1b202426dc fixup 2018-06-27 11:17:55 +02: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
Oliver Schneider a24edb9bce
Add structured suggestions for trait imports 2017-11-20 09:17:27 +01:00
Esteban Küber 055910779a Use local spans only 2017-11-16 16:21:24 -08:00
Oliver Schneider 47c7e430d3
Remove left over dead code from suggestion diagnostic refactoring 2017-11-16 16:36:49 +01:00
Esteban Küber f796fcd623 Point to ADT definition when not finding variant, method, assoc type 2017-11-15 23:24:58 -08:00
Niko Matsakis 98d5db3350 add a new test featuring two impl traits to show what it looks like 2017-11-15 15:46:01 -05:00
Christopher Vittal f710d41f77 Add/Fix stderr references for impl Trait ui tests 2017-11-15 15:46:01 -05:00
Niko Matsakis 2786ea662d some tests featuring multiple bounds, other errors 2017-11-15 15:46:01 -05:00
Niko Matsakis 15001ee336 add a UI test showing the current output from an impl trait type 2017-11-15 15:46:01 -05:00
Ariel Ben-Yehuda 9be155d88e remove the hacky selection impl in `method::probe` 2017-08-29 14:34:43 +03:00
Ariel Ben-Yehuda fb7ab9e43d report the total number of errors on compilation failure
Prior to this PR, when we aborted because a "critical pass" failed, we
displayed the number of errors from that critical pass. While that's the
number of errors that caused compilation to abort in *that place*,
that's not what people really want to know. Instead, always report the
total number of errors, and don't bother to track the number of errors
from the last pass that failed.

This changes the compiler driver API to handle errors more smoothly,
and therefore is a compiler-api-[breaking-change].

Fixes #42793.
2017-07-02 16:16:44 +03:00
Ariel Ben-Yehuda 77f4022303 Revert "Change error count messages"
This reverts commit 5558c64f33.
2017-07-02 13:49:30 +03:00
bors 13eb0ec9f1 Auto merge of #42383 - estebank:candidate-newline, r=arielb1
Use multiline note for trait suggestion
2017-06-05 13:07:38 +00:00
Esteban Küber 397972f5b0 Separate suggestion in a `help` and a `note` 2017-06-04 12:56:57 -07:00
Esteban Küber e324919ec5 Show trait method signature when impl differs
When the trait's span is available, it is already being used, add a
`note` for the cases where the span isn't available:

```
error[E0053]: method `fmt` has an incompatible type for trait
  --> $DIR/trait_type.rs:17:4
   |
17 |    fn fmt(&self, x: &str) -> () { }
   |    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability
   |
   = note: expected type `fn(&MyType, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
              found type `fn(&MyType, &str)`

error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2
  --> $DIR/trait_type.rs:21:11
   |
21 |    fn fmt(&self) -> () { }
   |           ^^^^^ expected 2 parameters, found 1
   |
   = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`

error[E0186]: method `fmt` has a `&self` declaration in the trait, but not in the impl
  --> $DIR/trait_type.rs:25:4
   |
25 |    fn fmt() -> () { }
   |    ^^^^^^^^^^^^^^^^^^ expected `&self` in impl
   |
   = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`

error[E0046]: not all trait items implemented, missing: `fmt`
  --> $DIR/trait_type.rs:28:1
   |
28 | impl std::fmt::Display for MyType4 {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation
   |
   = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
```
2017-06-04 12:52:55 -07:00
Esteban Küber e935acfa5c Use multiline note for trait suggestion 2017-06-02 10:15:13 -07:00
Eduard-Mihai Burtescu 5fb37beecd tests: fix fallout from changing the span of binop errors. 2017-06-01 08:59:47 +03:00
Mark Simulacrum d64dddbeaf Rollup merge of #42150 - citizen428:feature/error-count-messages, r=Mark-Simulacrum
Change error count messages

See #33525 for details. r? @Mark-Simulacrum
2017-05-24 19:50:05 -06:00
Michael Kohl 5558c64f33 Change error count messages
See #33525 for details.
2017-05-24 16:14:38 +07:00
Guillaume Gomez 747287a2b3 Add better error message when == operator is badly used 2017-05-17 22:17:53 +02:00
Esteban Küber be8787dfe5 Explicit help message for binop type missmatch
When trying to do a binary operation with missing implementation, for
example `1 + Some(2)`, provide an explicit help message:

```
note: no implementation for `{integer} + std::option::Option<{integer}>`
```

Use `rustc_on_unimplemented` for the suggestions. Move cfail test to ui.
2017-04-10 14:28:38 -07:00