Skip to content

Commit 2cd5ed4

Browse files
committed
Auto merge of #61778 - petrochenkov:pass, r=Mark-Simulacrum
compiletest: Introduce `// {check,build,run}-pass` pass modes Pass UI tests now have three modes ``` // check-pass // build-pass // run-pass ``` mirroring equivalent well-known `cargo` commands. `// check-pass` will compile the test skipping codegen (which is expensive and isn't supposed to fail in most cases). `// build-pass` will compile and link the test without running it. `// run-pass` will compile, link and run the test. Tests without a "pass" annotation are still considered "fail" tests. Most UI tests would probably want to switch to `check-pass`. Tests validating codegen would probably want to run the generated code as well and use `run-pass`. `build-pass` should probably be rare (linking tests?). #61755 will provide a way to run the tests with any mode, e.g. bump `check-pass` tests to `run-pass` to satisfy especially suspicious people, and be able to make sure that codegen doesn't breaks in some entirely unexpected way. Tests marked with any mode are expected to pass with any other mode, if that's not the case for some legitimate reason, then the test should be made a "fail" test rather than a "pass" test. Perhaps some secondary CI can verify this invariant, but that's not super urgent. `// compile-pass` still works and is equivalent to `build-pass`. Why is `// compile-pass` bad - 1) it gives an impression that the test is only compiled, but not linked, 2) it doesn't mirror a cargo command. It can be removed some time in the future in a separate PR. cc #61712
2 parents 5d677b2 + 0886bc4 commit 2cd5ed4

File tree

67 files changed

+389
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+389
-478
lines changed

src/test/incremental/issue-59523-on-implemented-is-not-unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// rustc_on_unimplemented, but with this bug we are seeing it fire (on
33
// subsequent runs) if incremental compilation is enabled.
44

5-
// revisions: rpass1 rpass2
5+
// revisions: cfail1 cfail2
66
// compile-pass
77

88
#![feature(on_unimplemented)]

src/test/incremental/issue-59524-layout-scalar-valid-range-is-not-unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// seeing it fire (on subsequent runs) if incremental compilation is
44
// enabled.
55

6-
// revisions: rpass1 rpass2
6+
// revisions: cfail1 cfail2
77
// compile-pass
88

99
#![feature(rustc_attrs)]

src/test/incremental/no_mangle.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// revisions:rpass1 rpass2
1+
// revisions:cfail1 cfail2
2+
// check-pass
23
// compile-flags: --crate-type cdylib
3-
// skip-codegen
44

55
#![deny(unused_attributes)]
66

src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-pass
1+
// error-pattern:returned Box<dyn Error> from main()
22
// failure-status: 1
33

44
use std::error::Error;

src/test/run-fail/rfc-1937-termination-trait/termination-trait-for-result-box-error_err.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-pass
1+
// error-pattern:returned Box<Error> from main()
22
// failure-status: 1
33

44
use std::io::{Error, ErrorKind};

src/test/run-pass/compiletest-skip-codegen.rs

-7
This file was deleted.

src/test/ui/asm/asm-misplaced-option.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// check-pass
12
// ignore-android
23
// ignore-arm
34
// ignore-aarch64
@@ -11,14 +12,11 @@
1112
// ignore-mips
1213
// ignore-mips64
1314

14-
// compile-pass
15-
// skip-codegen
1615
#![feature(asm)]
17-
#![allow(dead_code, non_upper_case_globals)]
1816

1917
#[cfg(any(target_arch = "x86",
2018
target_arch = "x86_64"))]
21-
pub fn main() {
19+
fn main() {
2220
// assignment not dead
2321
let mut x: isize = 0;
2422
unsafe {

src/test/ui/asm/asm-misplaced-option.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
warning: unrecognized option
2-
--> $DIR/asm-misplaced-option.rs:26:64
2+
--> $DIR/asm-misplaced-option.rs:24:64
33
|
44
LL | asm!("mov $1, $0" : "=r"(x) : "r"(5_usize), "0"(x) : : "cc");
55
| ^^^^
66

77
warning: expected a clobber, found an option
8-
--> $DIR/asm-misplaced-option.rs:33:80
8+
--> $DIR/asm-misplaced-option.rs:31:80
99
|
1010
LL | asm!("add $2, $1; mov $1, $0" : "=r"(x) : "r"(x), "r"(8_usize) : "cc", "volatile");
1111
| ^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// compile-pass
2-
// skip-codegen
3-
#![allow(warnings)]
1+
// check-pass
2+
43
pub type ParseResult<T> = Result<T, ()>;
54

6-
pub enum Item<'a> { Literal(&'a str),
7-
}
5+
pub enum Item<'a> {
6+
Literal(&'a str)
7+
}
88

99
pub fn colon_or_space(s: &str) -> ParseResult<&str> {
1010
unimplemented!()
@@ -20,10 +20,9 @@ pub fn parse<'a, I>(mut s: &str, items: I) -> ParseResult<()>
2020
macro_rules! try_consume {
2121
($e:expr) => ({ let (s_, v) = try!($e); s = s_; v })
2222
}
23-
let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space));
24-
let offset = try_consume!(timezone_offset_zulu(s.trim_left(), colon_or_space));
23+
let offset = try_consume!(timezone_offset_zulu(s.trim_start(), colon_or_space));
24+
let offset = try_consume!(timezone_offset_zulu(s.trim_start(), colon_or_space));
2525
Ok(())
2626
}
2727

28-
29-
fn main() { }
28+
fn main() {}

src/test/ui/associated-types/cache/elision.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// compile-pass
2-
// skip-codegen
3-
#![allow(warnings)]
41
// Check that you are allowed to implement using elision but write
52
// trait without elision (a bug in this cropped up during
63
// bootstrapping, so this is a regression test).
74

5+
// check-pass
6+
87
pub struct SplitWhitespace<'a> {
98
x: &'a u8
109
}

src/test/ui/bad/bad-lint-cap3.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
// check-pass
12
// compile-flags: --cap-lints warn
23

34
#![warn(unused)]
45
#![deny(warnings)]
5-
// compile-pass
6-
// skip-codegen
7-
use std::option; //~ WARN
86

7+
use std::option; //~ WARN
98

109
fn main() {}

src/test/ui/bad/bad-lint-cap3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | use std::option;
55
| ^^^^^^^^^^^
66
|
77
note: lint level defined here
8-
--> $DIR/bad-lint-cap3.rs:4:9
8+
--> $DIR/bad-lint-cap3.rs:5:9
99
|
1010
LL | #![deny(warnings)]
1111
| ^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
// compile-pass
2-
// skip-codegen
1+
// Here we do not get a coherence conflict because `Baz: Iterator`
2+
// does not hold and (due to the orphan rules), we can rely on that.
3+
4+
// check-pass
35
// revisions: old re
46

57
#![cfg_attr(re, feature(re_rebalance_coherence))]
6-
#![allow(dead_code)]
7-
// Here we do not get a coherence conflict because `Baz: Iterator`
8-
// does not hold and (due to the orphan rules), we can rely on that.
98

109
pub trait Foo<P> {}
1110

@@ -18,5 +17,4 @@ impl Foo<i32> for Baz { }
1817

1918
impl<A:Iterator> Foo<A::Item> for A { }
2019

21-
2220
fn main() {}

src/test/ui/coherence/coherence-projection-ok.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// compile-pass
2-
// skip-codegen
1+
// check-pass
32
// revisions: old re
43

54
#![cfg_attr(re, feature(re_rebalance_coherence))]
5+
66
pub trait Foo<P> {}
77

88
pub trait Bar {
@@ -17,5 +17,4 @@ impl Bar for i32 {
1717
type Output = u32;
1818
}
1919

20-
2120
fn main() {}

src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Test that we are able to introduce a negative constraint that
22
// `MyType: !MyTrait` along with other "fundamental" wrappers.
33

4+
// check-pass
45
// aux-build:coherence_copy_like_lib.rs
5-
// compile-pass
6-
// skip-codegen
76
// revisions: old re
87

98
#![cfg_attr(re, feature(re_rebalance_coherence))]
10-
#![allow(dead_code)]
119

1210
extern crate coherence_copy_like_lib as lib;
1311

@@ -23,5 +21,4 @@ impl<T: lib::MyCopy> MyTrait for T { }
2321
// Huzzah.
2422
impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { }
2523

26-
2724
fn main() { }

src/test/ui/coherence/coherence_local.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Test that we are able to introduce a negative constraint that
22
// `MyType: !MyTrait` along with other "fundamental" wrappers.
33

4+
// check-pass
45
// aux-build:coherence_copy_like_lib.rs
5-
// compile-pass
6-
// skip-codegen
76
// revisions: old re
87

98
#![cfg_attr(re, feature(re_rebalance_coherence))]
10-
#![allow(dead_code)]
119

1210
extern crate coherence_copy_like_lib as lib;
1311

@@ -22,5 +20,4 @@ impl lib::MyCopy for Box<MyType> { }
2220
impl lib::MyCopy for lib::MyFundamentalStruct<MyType> { }
2321
impl lib::MyCopy for lib::MyFundamentalStruct<Box<MyType>> { }
2422

25-
26-
fn main() { }
23+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Test that we are able to introduce a negative constraint that
22
// `MyType: !MyTrait` along with other "fundamental" wrappers.
33

4+
// check-pass
45
// aux-build:coherence_copy_like_lib.rs
5-
// compile-pass
6-
// skip-codegen
76
// revisions: old re
87

98
#![cfg_attr(re, feature(re_rebalance_coherence))]
10-
#![allow(dead_code)]
119

1210
extern crate coherence_copy_like_lib as lib;
1311

@@ -16,5 +14,4 @@ struct MyType { x: i32 }
1614
// naturally, legal
1715
impl lib::MyCopy for MyType { }
1816

19-
2017
fn main() { }

src/test/ui/conditional-compilation/cfg_attr_path.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// compile-pass
2-
// skip-codegen
3-
#![allow(dead_code)]
1+
// check-pass
2+
43
#![deny(unused_attributes)] // c.f #35584
4+
55
mod auxiliary {
66
#[cfg_attr(any(), path = "nonexistent_file.rs")] pub mod namespaced_enums;
77
#[cfg_attr(all(), path = "namespaced_enums.rs")] pub mod nonexistent_file;
88
}
99

10-
1110
fn main() {
1211
let _ = auxiliary::namespaced_enums::Foo::A;
1312
let _ = auxiliary::nonexistent_file::Foo::A;

src/test/ui/consts/const-eval/const_transmute.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// compile-pass
21
// run-pass
32

43
#![feature(const_fn_union)]

src/test/ui/consts/const-eval/enum_discr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// compile-pass
21
// run-pass
32

43
enum Foo {
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
// Test use of const fn from another crate without a feature gate.
22

3-
// compile-pass
4-
// skip-codegen
5-
#![allow(unused_variables)]
3+
// check-pass
64
// aux-build:const_fn_lib.rs
75

86
extern crate const_fn_lib;
97

108
use const_fn_lib::foo;
119

12-
1310
fn main() {
1411
let x = foo(); // use outside a constant is ok
1512
}

src/test/ui/expanded-cfg.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// skip-codegen
2-
// compile-pass
1+
// check-pass
32

43
macro_rules! mac {
54
{} => {
@@ -19,5 +18,4 @@ macro_rules! mac {
1918

2019
mac! {}
2120

22-
2321
fn main() {}

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
// inputs are handled by each, and (2.) to ease searching for related
3131
// occurrences in the source text.
3232

33+
// check-pass
34+
3335
#![warn(unused_attributes, unknown_lints)]
34-
#![allow(stable_features)]
3536

3637
// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
3738

@@ -75,7 +76,7 @@
7576
// see issue-43106-gating-of-stable.rs
7677
// see issue-43106-gating-of-unstable.rs
7778
// see issue-43106-gating-of-deprecated.rs
78-
#![windows_subsystem = "1000"]
79+
#![windows_subsystem = "windows"]
7980

8081
// UNGATED CRATE-LEVEL BUILT-IN ATTRIBUTES
8182

@@ -539,7 +540,7 @@ mod export_name {
539540
#[export_name = "2200"] impl S { }
540541
}
541542

542-
// Note that this test has a `skip-codegen`, so it
543+
// Note that this is a `check-pass` test, so it
543544
// will never invoke the linker. These are here nonetheless to point
544545
// out that we allow them at non-crate-level (though I do not know
545546
// whether they have the same effect here as at crate-level).
@@ -611,17 +612,17 @@ mod must_use {
611612
#[must_use] impl S { }
612613
}
613614

614-
#[windows_subsystem = "1000"]
615+
#[windows_subsystem = "windows"]
615616
mod windows_subsystem {
616-
mod inner { #![windows_subsystem="1000"] }
617+
mod inner { #![windows_subsystem="windows"] }
617618

618-
#[windows_subsystem = "1000"] fn f() { }
619+
#[windows_subsystem = "windows"] fn f() { }
619620

620-
#[windows_subsystem = "1000"] struct S;
621+
#[windows_subsystem = "windows"] struct S;
621622

622-
#[windows_subsystem = "1000"] type T = S;
623+
#[windows_subsystem = "windows"] type T = S;
623624

624-
#[windows_subsystem = "1000"] impl S { }
625+
#[windows_subsystem = "windows"] impl S { }
625626
}
626627

627628
// BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES

0 commit comments

Comments
 (0)