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 tells compiletest to pass -Z nll in addition to any other flags when invoking rustc, at least for the ui/ 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, then compiletest 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 (probably compiletest, but maybe tidy?) 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.
Open Questions (to be resolved by implementor)
The NLL team has been trying to find a good workflow for evaluating the discrepancies between AST borrowck and NLL-based borrowck.
-Z borrowck=compareand 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:
Here's a new proposal for a (hopefully) relatively small change to
compiletestthat should yield an easier workflow to answer questions like those above, at least for theui/subset of our tests.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.)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 tellscompiletestto pass-Z nllin addition to any other flags when invokingrustc, at least for theui/tests).$file.$mode.stderrfile, then this file will be used as the source of "acceptable output". If there is no such file, thencompiletestwill fallback to the regular filename$file.stderr.//~ ERRORthat 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//~ ERRORannotations when running in a particular mode. We will still see the errors that occur from the stderr output, it's just less convenient.$file.$mode.stderr, then some tool (probablycompiletest, but maybetidy?) will be responsible to checking that$file.rssomewhere 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 numor 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:
ls *.nll.stderrdiff onetest.stderr onetest.nll.stderr*.$mode.stderrfiles.Open Questions (to be resolved by implementor)
compiletestdo about occurrences of//~ ERRORin the source text? In particular, should it check that the error output still has those cases, even when running under a given mode?compiletestto ignore the//~ ERRORannotations when running under a given mode. The reasoning here is this: the//~ ERRORannotations 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/YAYMEissue, and we want to allow them to disappear or differ.