f09576c4a4
Better closure error message Use tracked data introduced in #42196 to provide a better closure error message by showing why a closure implements `FnOnce`. ``` error[E0525]: expected a closure that implements the `Fn` trait, but this closure only implements `FnOnce` --> $DIR/issue_26046.rs:4:19 | 4 | let closure = move || { | ___________________^ 5 | | vec 6 | | }; | |_____^ | note: closure is `FnOnce` because it moves the variable `vec` out of its environment --> $DIR/issue_26046.rs:5:9 | 5 | vec | ^^^ error: aborting due to previous error(s) ``` Fixes #26046 r? @nikomatsakis cc @doomrobo |
||
---|---|---|
.. | ||
borrowck | ||
check_match | ||
closure_context | ||
codemap_tests | ||
compare-method | ||
cross-crate-macro-backtrace | ||
did_you_mean | ||
dropck | ||
fmt | ||
hello_world | ||
impl-trait | ||
interior-mutability | ||
invalid-module-declaration | ||
issue-37311-type-length-limit | ||
issue-40402-ref-hints | ||
issue-41652 | ||
lifetime-errors | ||
lifetimes | ||
lint | ||
macros | ||
mismatched_types | ||
missing-items | ||
print_type_sizes | ||
print-fuel | ||
pub | ||
reachable | ||
resolve | ||
span | ||
suggestions | ||
token | ||
type-check | ||
coercion-missing-tail-expected-type.rs | ||
coercion-missing-tail-expected-type.stderr | ||
deprecated-macro_escape-inner.rs | ||
deprecated-macro_escape-inner.stderr | ||
deprecated-macro_escape.rs | ||
deprecated-macro_escape.stderr | ||
deriving-meta-empty-trait-list.rs | ||
deriving-meta-empty-trait-list.stderr | ||
enum-size-variance.rs | ||
enum-size-variance.stderr | ||
issue-19100.rs | ||
issue-19100.stderr | ||
issue-26548.rs | ||
issue-26548.stderr | ||
loop-break-value-no-repeat.rs | ||
loop-break-value-no-repeat.stderr | ||
path-lookahead.rs | ||
path-lookahead.stderr | ||
README.md | ||
regions-fn-subtyping-return-static.rs | ||
regions-fn-subtyping-return-static.stderr | ||
static-lifetime.rs | ||
static-lifetime.stderr | ||
test-should-panic-attr.rs | ||
test-should-panic-attr.stderr | ||
update-all-references.sh | ||
update-references.sh |
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)