Skip to content

Make unnameable tests an error #52917

Description

@djrenren

Right now the compiler will simply allow tests that cannot be run. The following will compile but will not run any tests.

fn foo() {
  #[test]
  fn bar(){}
}

This constitutes a silent failure and should probably be a hard error (or at least a warning). There's a lint for it: UnnameableTestFunctions but it isn't run by default.

Activity

  1. changed the title [-]Make unnameable tests an incomptability lint[/-] [+]Make unnameable tests an error[/+] on Jul 31, 2018
  2. estebank commented on Jul 31, 2018

    @estebank
    Contributor

    In nightly, introduced in #51450:

    warning: cannot test inner function
     --> src/main.rs:2:3
      |
    2 |   #[test]
      |   ^^^^^^^
      |
      = note: #[warn(unnameable_test_functions)] on by default
    

    It warns by default, it just hasn't landed in stable yet.

  3. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    on Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions