246 Commits

Author SHA1 Message Date
Zack M. Davis
4b1808578a add dyn to display of dynamic (trait) type names
The `dyn Trait` syntax was stabilized in 199ee327. Resolves .
2018-06-23 18:10:25 -07:00
Santiago Pastorino
f4fc43cb20
Suggest that values are dropped in the opposite order they are defined 2018-06-19 21:21:50 -03:00
Felix S. Klock II
2d4df5b53e NLL: Updates to diagnostic output in test/ui. 2018-06-19 19:38:37 +02:00
Esteban Küber
59b03b16b9 Fix typo 2018-05-29 14:48:23 -07:00
Esteban Küber
b169cf1128 Add primary span label 2018-05-28 10:29:49 -07:00
Esteban Küber
6c7a5ba020 Only suggest assoc fn when sure about the type 2018-05-28 10:18:34 -07:00
Esteban Küber
447d894edf Use suggestion for assoc fn called like method
When encountering an unexisting method for a given trait where an
associated function has the same name, suggest using the appropriate
syntax, instead of using `help` text.

When only one candidate is found, do not call it "candidate ", just
call it "the candidate".
2018-05-27 13:30:16 -07:00
Felix S. Klock II
d8bd5336c9 : improve test robustness so that they work under NLL too. 2018-05-25 13:00:51 +02:00
leonardo.yvens
87890561f3 Improve eager type resolution error message
This PR improves the span of eager resolution type errors referring to indexing and field access to use the base span rather than the whole expression.

Also a note "Type must be known at this point." is added to where we at some point in the past emitted the "type must be known at this context" error, so that early failures can be differentiated and will hopefully be less surprising.

Fixes  (or at least does the best we can for the moment)

r? @estebank
2018-05-13 13:02:34 -03:00
Esteban Küber
85f57389bf Fix tuple struct field spans 2018-05-10 09:15:47 -07:00
Zack M. Davis
3dbdccc6a9 stabilize #[must_use] for functions and must-use operators
This is in the matter of RFC 1940 and tracking issue .
2018-04-28 20:32:49 -07:00
Felix S. Klock II
1a4326d3fb Workaround by opting into experimental -Z nll-subminimal-causes flag
This commit only applies the flag to the one test case,
ui/span/dropck_vec_cycle_checked.rs, that absolutely needs it. Without
the flag, that test takes an unknown amount of time (greater than 1
minute) to compile. But its possible that other tests would also
benefit from the flag, and we may want to make it the default (after
evaluating its impact on other tests).

In terms of its known impact on other tests, I have only evaluated the
ui tests, and the *only* ui test I have found that the flag impacts
(running under NLL mode, of course), is src/test/ui/nll/issue-31567.rs

In particular:

```
% ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/nll/issue-31567.rs
error[E0597]: `*v.0` does not live long enough
  --> ../src/test/ui/nll/issue-31567.rs:22:26
   |
22 |     let s_inner: &'a S = &*v.0; //~ ERROR `*v.0` does not live long enough
   |                          ^^^^^ borrowed value does not live long enough
23 |     &s_inner.0
24 | }
   | - borrowed value only lives until here
   |
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:1...
  --> ../src/test/ui/nll/issue-31567.rs:21:1
   |
21 | fn get_dangling<'a>(v: VecWrapper<'a>) -> &'a u32 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
% ./build/x86_64-unknown-linux-gnu/stage1/bin/rustc ../src/test/ui/nll/issue-31567.rs  -Z nll-subminimal-causes
error[E0597]: `*v.0` does not live long enough
  --> ../src/test/ui/nll/issue-31567.rs:22:26
   |
22 |     let s_inner: &'a S = &*v.0; //~ ERROR `*v.0` does not live long enough
   |                          ^^^^^ borrowed value does not live long enough
23 |     &s_inner.0
24 | }
   | -
   | |
   | borrowed value only lives until here
   | borrow later used here, when `v` is dropped

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
%
```
2018-04-18 15:37:30 +02:00
Felix S. Klock II
ea454746b3 Update the previously checkpointed (but unused by bors) tests to reflect current reality. 2018-04-18 15:37:18 +02:00
Guillaume Gomez
812656dc95 Rename must-compile-successfully into compile-pass 2018-04-13 23:28:03 +02:00
Felix S. Klock II
746d63a203 Checkpoint the current status of NLL on ui tests via compare-mode=nll. 2018-04-11 00:38:35 +02:00
Felix S. Klock II
1c8d2bdda1 Workaround by forcing rustc_error in any mode, including NLL.
NOTE: I was careful to make each change in a manner that preserves the
existing diagnostic output (usually by ensuring that no lines were
added or removed). This means that the resulting source files are not
as nice to read as they were at the start. But we will have to review
these cases by hand anyway as follow-up work, so cleanup could
reasonably happen then (or not at all).
2018-04-11 00:20:05 +02:00
kennytm
297a6e580d
Rollup merge of - SimonSapin:ubiquity, r=nikomatsakis
Stabilize the copy_closures and clone_closures features

In addition to the `Fn*` family of traits, closures now implement `Copy` (and similarly `Clone`) if all of the captures do.

Tracking issue: https://github.com/rust-lang/rust/issues/44490
2018-03-25 01:30:12 +08:00
Simon Sapin
ee67e14034 Stabilize the copy_closures and clone_closures features
In addition to the `Fn*` family of traits, closures now implement `Copy` (and similarly `Clone`) if all of the captures do.
2018-03-23 11:37:07 +01:00
John Kåre Alsaker
b1d872b38e Update tests 2018-03-16 11:52:46 +01:00
kennytm
55a0075a20
Rollup merge of - kennytm:fix-e0307-typo, r=rkruppe
Remove unnecessary "`" in error message E0307 (invalid self type).
2018-03-16 05:35:20 +08:00
kennytm
b6ec75fe62
Remove unnecessary "`" in error message E0307 (invalid self type). 2018-03-15 17:59:17 +08:00
Eric Huss
6aa4dcb9cf Add empty main() to tests where it is missing. 2018-03-14 12:23:28 -07:00
Eric Huss
b4b7ccbd1c Add crate name to "main function not found" error message.
Fixes  and .
2018-03-14 11:40:13 -07:00
Guillaume Gomez
2e104a77cf update tests 2018-03-14 00:53:24 +01:00
Vadim Petrochenkov
c1a73d2f4a tidy: Add a check for stray .stderr and .stdout files in UI test directories 2018-03-09 17:27:22 +03:00
Vadim Petrochenkov
9f9183d34d Fix rebase 2018-02-26 21:20:31 +03: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
16fb6b082d Reduce error codes length when too much are thrown 2018-02-25 12:15:05 +01:00
Guillaume Gomez
5747fd6611 Update ui tests 2018-02-25 12:15:05 +01:00
Manish Goregaokar
7738eb4ddb
Rollup merge of - estebank:string, r=petrochenkov
Handle custom diagnostic for `&str + String`

Now all of `&str + &str`, `&str + String` and `String + String` have relevant diagnostic output.
2018-02-24 15:52:09 -08:00
Esteban Küber
20bc72e693 Handle custom diagnostic for &str + String 2018-02-20 22:46:51 -08:00
csmoe
0be2dc8d9b fix stderr 2018-02-17 14:18:53 +00:00
csmoe
20dcc72127 inform type annotations 2018-02-14 11:06:08 +08:00
Manish Goregaokar
732c83007c
Rollup merge of - zackmdavis:and_the_span_of_the_unknown_type, r=estebank
correct E0619 span re method call receivers whose type must be known

Previously, when the type of a method receiver could not be determined,
the error message would, potentially confusingly, highlight the span of
the entire method call.

![unknown_receiver_type](https://user-images.githubusercontent.com/1076988/35838930-a595b17c-0aa2-11e8-9364-6b8e2329f051.png)

Resolves , resolves .
2018-02-07 08:30:58 -08:00
Manish Goregaokar
0ba871254e
Rollup merge of - zackmdavis:and_the_case_of_the_unused_field_pattern, r=estebank
correct unused field pattern suggestions

![unused_field_pattern_local](https://user-images.githubusercontent.com/1076988/35662336-7a69488a-06cc-11e8-9901-8d22b5cf924f.png)

r? @estebank
2018-02-07 08:30:52 -08:00
Manish Goregaokar
aee22556a9
Rollup merge of - 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  with a different syntax, as a first approach. Fixes , fixes , CC , .
2018-02-07 08:30:47 -08:00
Zack M. Davis
b55e07ee50 correct E0619 span re method call receivers whose type must be known
Previously, when the type of a method receiver could not be determined,
the error message would, potentially confusingly, highlight the span of
the entire method call.

Resolves , resolves .
2018-02-05 18:09:51 -08: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
aaec608367 Minimize weird spans involving macro context
Sometimes the parser attempts to synthesize spans from within a macro
context with the span for the captured argument, leading to non-sensical
spans with very bad output. Given that an incorrect span is worse than
a partially incomplete span, when detecting this situation return only
one of the spans without mergin them.
2018-02-01 11:51:49 -08:00
Zack M. Davis
e4b1a7971d concerning well-formed suggestions for unused shorthand field patterns
Previously, unused variables would get a note that the warning could be
silenced by prefixing the variable with an underscore, but that doesn't
work for field shorthand patterns, which the liveness analysis didn't
know about.

The "to avoid this warning" verbiage seemed unnecessary.

Resolves .
2018-01-31 21:27:16 -08:00
Cameron Hart
651ea8ea44 Stabilized #[repr(align(x))] attribute (RFC 1358) 2018-01-23 08:36:13 +11:00
Guillaume Gomez
009bc2a3aa Rollup merge of - estebank:point-to-method-e0283, r=pnkfelix
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.

CC .
2018-01-17 23:43:30 +01: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
Guillaume Gomez
c8a110ed63 Add error code for unstable feature errors 2018-01-15 10:28:00 +01:00
Vadim Petrochenkov
d19e4c4a85 syntax: Rewrite parsing of impls
Properly parse impls for the never type `!`
Recover from missing `for` in `impl Trait for Type`
Prohibit inherent default impls and default impls of auto traits
Change wording in more diagnostics to use "auto traits"
Some minor code cleanups in the parser
2018-01-14 18:10:05 +03:00
Zack M. Davis
aba56ddd05 type error method suggestions use whitelisted identity-like conversions
Previously, on a type mismatch (and if this wasn't preëmpted by a
higher-priority suggestion), we would look for argumentless methods
returning the expected type, and list them in a `help` note.

This had two major shortcomings. Firstly, a lot of the suggestions didn't
really make sense (if you used a &str where a String was expected,
`.to_ascii_uppercase()` is probably not the solution you were hoping
for). Secondly, we weren't generating suggestions from the most useful
traits!

We address the first problem with an internal
`#[rustc_conversion_suggestion]` attribute meant to mark methods that keep
the "same value" in the relevant sense, just converting the type. We
address the second problem by making `FnCtxt.probe_for_return_type` pass
the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe
because grep reveals no other callers of `probe_for_return_type`.

Also, structured suggestions are preferred (because they're pretty, but
also for RLS and friends).

Also also, we make the E0055 autoderef recursion limit error use the
one-time-diagnostics set, because we can potentially hit the limit a lot
during probing. (Without this,
test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to
51 errors").

Unfortunately, the trait probing is still not all one would hope for: at a
minimum, we don't know how to rule out `into()` in cases where it wouldn't
actually work, and we don't know how to rule in `.to_owned()` where it
would. Issues  and  have been filed and are ref'd in a FIXME.

This is hoped to resolve , , and .
2018-01-06 17:15:59 -08:00
bors
d96cc6e286 Auto merge of - EdSchouten:cloudabi-tests, r=kennytm
First cut at getting some part of the test suite working for CloudABI

I am currently working on creating a Docker container for automated CI for CloudABI. Here are some of the trivial changes that need to land to make tests pass.
2018-01-03 17:00:24 +00:00