Skip to content

Non-#[test] fns calling #[test] fns passes compiler with --test flag #2858

Closed
@Havvy

Description

@Havvy
use std;

fn main () {
    nonTest()
}

fn nonTest() {
    anotherTest ()
}

#[test]
fn test () {
    nonTest()
}

#[test]
fn anotherTest () {

}

This code obviously doesn't compile without any flags, but it does compile with rustc --test.

From my perspective I cannot see why the parser allows nonTest to call anotherTest. Ever. Except in an example to show that it doesn't work.

Though, this is probably low priority.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-testsuiteArea: The testsuite used to check the correctness of rustc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions