Skip to content

Add "modes" to compiletest, for running all tests with NLL enabled and comparing with master #48879

Closed
@pnkfelix

Description

@pnkfelix

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.

  1. 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.)
  2. 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).
  3. 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.
  4. 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.
  5. 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)

  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-compiletestArea: The compiletest test runnerA-compiletest-compare-modesArea: compiletest compare-modesA-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.NLL-diagnosticsWorking towards the "diagnostic parity" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-traitsWorking group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions