rust/src/test/ui
Guillaume Gomez fc0fb0328b Rollup merge of #42669 - gaurikholkar:master, r=nikomatsakis
Adding diagnostic code 0611 for lifetime errors with one named, one anonymous lifetime parameter

This is a fix for #42517
Note that this only handles the above case for **function declarations** and **traits**.
`impl items` and `closures` will be handled in a later PR.
Example
```
fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
    if x > y { x } else { y }
}
```
now displays the following error message. ui tests have been added for the same.
```
error[E0611]: explicit lifetime required in the type of `x`
11 | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
   |                     ^ consider changing the type of `x` to `&'a i32`
12 |     if x > y { x } else { y }
   |                  - lifetime `'a` required
```
#42516
r? @nikomatsakis
2017-06-30 22:44:43 +02:00
..
block-result Review comments 2017-06-27 13:34:56 -07:00
borrowck Change error count messages 2017-05-24 16:14:38 +07:00
check_match Change error count messages 2017-05-24 16:14:38 +07:00
closure_context Cover all cases in closure errors 2017-06-07 21:26:28 +01:00
codemap_tests Add invalid unary operator usage error code 2017-05-27 21:34:59 +02:00
compare-method Change error count messages 2017-05-24 16:14:38 +07:00
cross-crate-macro-backtrace Change error count messages 2017-05-24 16:14:38 +07:00
did_you_mean Add E0609 2017-06-11 19:48:53 +02:00
dropck Add new error codes and update tests 2017-05-27 19:58:52 +02:00
fmt Change error count messages 2017-05-24 16:14:38 +07:00
hello_world add UI testing framework 2016-05-13 15:22:45 -07:00
impl-trait Don't naively point to return type on type error 2017-06-24 19:28:43 -07:00
interior-mutability Changing error message for interior mutability, adding ui test 2017-06-07 01:38:05 +05:30
invalid-module-declaration Change error count messages 2017-05-24 16:14:38 +07:00
issue-37311-type-length-limit Change error count messages 2017-05-24 16:14:38 +07:00
issue-38875 External spans: Added a test for #38875. 2017-06-13 14:46:35 +02:00
issue-40402-ref-hints Change error count messages 2017-05-24 16:14:38 +07:00
issue-41652 Updated UI tests to include rendered external spans. 2017-06-11 15:09:49 +02:00
lifetime-errors adding compile-fail test 2017-06-29 14:13:53 -07:00
lifetimes Add new error codes and update tests 2017-05-27 19:58:52 +02:00
lint Rollup merge of #42919 - zackmdavis:once_again_we_heard_you_the_first_time, r=eddyb 2017-06-29 08:40:07 +00:00
macros Add E0613 2017-06-15 10:14:29 +02:00
mismatched_types Auto merge of #42807 - arielb1:consistent-coercion, r=eddyb 2017-06-30 13:39:25 +00:00
missing-items Add new error code 2017-05-30 19:19:34 +02:00
print-fuel UI test for -Z print-fuel=foo 2017-04-11 14:36:08 +03:00
print_type_sizes Stabilize unions with Copy fields and no destructor 2017-05-27 00:52:20 +03:00
pub Change error count messages 2017-05-24 16:14:38 +07:00
reachable Add invalid unary operator usage error code 2017-05-27 21:34:59 +02:00
resolve Don't naively point to return type on type error 2017-06-24 19:28:43 -07:00
span make lint on-by-default/implied-by messages appear only once 2017-06-26 16:10:06 -07:00
suggestions Add new error codes and update tests 2017-05-27 19:58:52 +02:00
token Add new error code 2017-05-30 19:19:34 +02:00
transmute Update UI tests to be platform independent 2017-06-18 11:35:37 -06:00
type-check Auto merge of #42649 - estebank:if-cond, r=nikomatsakis 2017-06-17 16:54:07 +00:00
coercion-missing-tail-expected-type.rs Add test for #24889 2017-06-18 14:30:33 +02:00
coercion-missing-tail-expected-type.stderr Suggest removal of semicolon (instead of being help) 2017-06-24 10:08:51 -07:00
deprecated-macro_escape-inner.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
deprecated-macro_escape-inner.stderr Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
deprecated-macro_escape.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
deprecated-macro_escape.stderr Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
deriving-meta-empty-trait-list.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
deriving-meta-empty-trait-list.stderr Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
enum-size-variance.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
enum-size-variance.stderr Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
explain.rs Modify --explain to handle hidden code (# ...) and indented code blocks. 2017-06-23 15:31:53 +08:00
explain.stdout Modify --explain to handle hidden code (# ...) and indented code blocks. 2017-06-23 15:31:53 +08:00
issue-19100.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
issue-19100.stderr Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
issue-22644.rs Suggest non-ambiguous comparison after cast 2017-06-11 23:47:26 -07:00
issue-22644.stderr Review comments 2017-06-15 08:45:24 -07:00
issue-26548.rs remove layout_cache and fix -Z print-type-sizes 2017-06-01 13:31:11 -04:00
issue-26548.stderr fix ui reference 2017-06-01 13:31:12 -04:00
loop-break-value-no-repeat.rs Stabilize the loop_break_value feature 2017-05-17 21:34:37 +02:00
loop-break-value-no-repeat.stderr Rollup merge of #42150 - citizen428:feature/error-count-messages, r=Mark-Simulacrum 2017-05-24 19:50:05 -06:00
path-lookahead.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
path-lookahead.stderr make lint on-by-default/implied-by messages appear only once 2017-06-26 16:10:06 -07:00
README.md add UI testing framework 2016-05-13 15:22:45 -07:00
regions-fn-subtyping-return-static.rs make lifetimes that only appear in return type early-bound 2017-02-05 16:30:03 -05:00
regions-fn-subtyping-return-static.stderr Change error count messages 2017-05-24 16:14:38 +07:00
shadowed-type-parameter.rs Move type parameter shadowing test to ui 2017-06-28 15:11:05 -07:00
shadowed-type-parameter.stderr Move type parameter shadowing test to ui 2017-06-28 15:11:05 -07:00
static-lifetime.rs Improve E0477 error message 2017-05-09 20:51:18 +02:00
static-lifetime.stderr Change error count messages 2017-05-24 16:14:38 +07:00
test-should-panic-attr.rs Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
test-should-panic-attr.stderr Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516. 2017-06-02 23:28:22 +08:00
update-all-references.sh pacify the mercilous tidy 2016-05-16 16:48:48 -04:00
update-references.sh cleanup error reporting and add ui tests 2016-11-01 14:04:14 -04:00

Guide to the UI Tests

The UI tests are intended to capture the compiler's complete output, so that we can test all aspects of the presentation. They work by compiling a file (e.g., hello_world/main.rs), capturing the output, and then applying some normalization (see below). This normalized result is then compared against reference files named hello_world/main.stderr and hello_world/main.stdout. If either of those files doesn't exist, the output must be empty. If the test run fails, we will print out the current output, but it is also saved in build/<target-triple>/test/ui/hello_world/main.stdout (this path is printed as part of the test failure mesage), so you can run diff and so forth.

Editing and updating the reference files

If you have changed the compiler's output intentionally, or you are making a new test, you can use the script update-references.sh to update the references. When you run the test framework, it will report various errors: in those errors is a command you can use to run the update-references.sh script, which will then copy over the files from the build directory and use them as the new reference. You can also just run update-all-references.sh. In both cases, you can run the script with --help to get a help message.

Normalization

The normalization applied is aimed at filenames:

  • the test directory is replaced with $DIR
  • all backslashes () are converted to forward slashes (/) (for windows)