Closed
Description
The NLL team has been trying to find a good workflow for evaluating the discrepancies between AST borrowck and NLL-based borrowck.
- Past workflows have developed and used things like
-Z borrowck=compare
and the https://github.com/pnkfelix/nll-probe tool, but here I'm going to try to avoid a deep dive into how those have failed to satisfy our needs.
Our goal here: We want a way to track the current state of NLL, including the cases where there are known deviations, in a manner that allows immediate analysis of that state to determine things like:
- "how many test cases does NLL deviate from AST borrowck",
- "what do the deviations look like", or
- "does this deviation represent a bug that needs to be fix? Or is it an improvement on the AST borrowck?"
Here's a new proposal for a (hopefully) relatively small change to compiletest
that should yield an easier workflow to answer questions like those above, at least for the ui/
subset of our tests.
- Context: The
ui/
tests are set up so that each test consists of an input$file.rs
, and a set of expected outputs in$file.stderr
(compilation error messages) and$file.stdout
(non erroneous compiler output; rarely used). (For more info, see this chapter in the rustc-guide.) - Add a "mode" argument to
compiletest
, encoded either as a command line parameter or as an environment variable, or both. (The first mode we'll support will be "nll", which tellscompiletest
to pass-Z nll
in addition to any other flags when invokingrustc
, at least for theui/
tests). - When running under a particular mode, if there is
$file.$mode.stderr
file, then this file will be used as the source of "acceptable output". If there is no such file, thencompiletest
will fallback to the regular filename$file.stderr
. - One complication: UI tests also include "inline" comments of the form
//~ ERROR
that indicate what error is expected on which line (these are mildly redundant with the stderr files above). Because messages may differ in the mode M, but we don't want to edit the sources too much, compiletest should just ignore the//~ ERROR
annotations when running in a particular mode. We will still see the errors that occur from the stderr output, it's just less convenient. - To ensure that we are tracking discrepancies somewhere, whenever there is a
$file.$mode.stderr
, then some tool (probablycompiletest
, but maybetidy
?) will be responsible to checking that$file.rs
somewhere contains a comment that explains the source of the discrepancy. This could be a specially formatted FIXME, if the new behavior seems worse than before:
// $mode FIXME(#123) -- summary of discrepancy caused by NLL bug with corresponding issue num
or a "YAYME" comment for when the new behavior is an improvement:
// $mode YAYME(#123) -- summary of a beneficial discrepancy
(presumably the ticket linked by YAYME would just be the tracking issue for NLL or whatever other mode is being tested).
Benefits of the proposed system:
- To find the cases that have discrepancies for nll, one can use
ls *.nll.stderr
- To find what a given discrepancy looks like, one can use
diff onetest.stderr onetest.nll.stderr
- To see if a discrepancy is a bug or not, grep for FIXME or YAYME in the .rs files.
- This workflow is perhaps not ideal; @nikomatsakis has pointed out that it might be nicer if these comments somehow lived in the
*.$mode.stderr
files.
- This workflow is perhaps not ideal; @nikomatsakis has pointed out that it might be nicer if these comments somehow lived in the
Open Questions (to be resolved by implementor)
- What should
compiletest
do about occurrences of//~ ERROR
in the source text? In particular, should it check that the error output still has those cases, even when running under a given mode?- The current inclination of @pnkfelix and @nikomatsakis is that it is actually okay for
compiletest
to ignore the//~ ERROR
annotations when running under a given mode. The reasoning here is this: the//~ ERROR
annotations will already get checked by compiletest runs that don't have a mode. We probably don't want to force an error when there's a discrepancy when running under a given mode; any discrepancies, including any of those errors disappearing, should be accounted for in the linked// $mode FIXME/YAYME
issue, and we want to allow them to disappear or differ.
- The current inclination of @pnkfelix and @nikomatsakis is that it is actually okay for
Metadata
Metadata
Assignees
Labels
Area: The compiletest test runnerArea: compiletest compare-modesArea: The testsuite used to check the correctness of rustcCategory: An issue proposing an enhancement or a PR with one.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Working towards the "diagnostic parity" goalRelevant to the compiler team, which will review and decide on the PR/issue.Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804