Skip to content

Commit

Permalink
Tidy up some awkwardly-placed comments in tests
Browse files Browse the repository at this point in the history
Prior to rust-lang#114875, these tests were very sensitive to lines being added/removed,
so the migration to `run-coverage` in rust-lang#112300 tried hard to avoid disturbing
the existing line numbers. That resulted in some awkward reshuffling when
certain comments/directives needed to be added or moved.

Now that we don't have to worry about preserving line numbers, we can rearrange
those comments into a more conventional layout.
  • Loading branch information
Zalathar committed Aug 26, 2023
1 parent 72b721f commit 4da38c3
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 10 deletions.
4 changes: 3 additions & 1 deletion tests/run-coverage-rustdoc/doctest.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ $DIR/auxiliary/doctest_crate.rs:
LL| 3|}

$DIR/doctest.rs:
LL| |// aux-build:doctest_crate.rs
LL| |
LL| |//! This test ensures that code from doctests is properly re-mapped.
LL| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
LL| |//!
Expand Down Expand Up @@ -78,7 +80,7 @@ $DIR/doctest.rs:
LL| |//! doctest_main()
LL| |//! }
LL| |//! ```
LL| |// aux-build:doctest_crate.rs
LL| |
LL| |/// doctest attached to fn testing external code:
LL| |/// ```
LL| 1|/// extern crate doctest_crate;
Expand Down
4 changes: 3 additions & 1 deletion tests/run-coverage-rustdoc/doctest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// aux-build:doctest_crate.rs

//! This test ensures that code from doctests is properly re-mapped.
//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
//!
Expand Down Expand Up @@ -63,7 +65,7 @@
//! doctest_main()
//! }
//! ```
// aux-build:doctest_crate.rs

/// doctest attached to fn testing external code:
/// ```
/// extern crate doctest_crate;
Expand Down
4 changes: 3 additions & 1 deletion tests/run-coverage/auxiliary/used_crate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![allow(unused_assignments, unused_variables)]
// Verify that coverage works with optimizations:
// compile-flags: -C opt-level=3
use std::fmt::Debug; // ^^ validates coverage now works with optimizations

use std::fmt::Debug;

pub fn used_function() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure
Expand Down
4 changes: 2 additions & 2 deletions tests/run-coverage/auxiliary/used_inline_crate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused_assignments, unused_variables)]

// Verify that coverage works with optimizations:
// compile-flags: -C opt-level=3
// ^^ validates coverage now works with optimizations

use std::fmt::Debug;

pub fn used_function() {
Expand Down
7 changes: 6 additions & 1 deletion tests/run-coverage/closure.coverage
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
LL| |#![allow(unused_assignments, unused_variables)]
LL| |// compile-flags: -C opt-level=2
LL| 1|fn main() { // ^^ fix described in rustc_middle/mir/mono.rs
LL| |
LL| |// This test used to be sensitive to certain coverage-specific hacks in
LL| |// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by
LL| |// <https://github.com/rust-lang/rust/pull/83666>.
LL| |
LL| 1|fn main() {
LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
LL| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
LL| 1| // dependent conditions.
Expand Down
7 changes: 6 additions & 1 deletion tests/run-coverage/closure.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#![allow(unused_assignments, unused_variables)]
// compile-flags: -C opt-level=2
fn main() { // ^^ fix described in rustc_middle/mir/mono.rs

// This test used to be sensitive to certain coverage-specific hacks in
// `rustc_middle/mir/mono.rs`, but those hacks were later cleaned up by
// <https://github.com/rust-lang/rust/pull/83666>.

fn main() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure
// rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
// dependent conditions.
Expand Down
1 change: 1 addition & 0 deletions tests/run-coverage/issue-85461.coverage
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $DIR/auxiliary/inline_always_with_dead_code.rs:

$DIR/issue-85461.rs:
LL| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
LL| |
LL| |// aux-build:inline_always_with_dead_code.rs
LL| |extern crate inline_always_with_dead_code;
LL| |
Expand Down
1 change: 1 addition & 0 deletions tests/run-coverage/issue-85461.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]

// aux-build:inline_always_with_dead_code.rs
extern crate inline_always_with_dead_code;

Expand Down
4 changes: 3 additions & 1 deletion tests/run-coverage/uses_crate.coverage
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
$DIR/auxiliary/used_crate.rs:
LL| |#![allow(unused_assignments, unused_variables)]
LL| |// Verify that coverage works with optimizations:
LL| |// compile-flags: -C opt-level=3
LL| |use std::fmt::Debug; // ^^ validates coverage now works with optimizations
LL| |
LL| |use std::fmt::Debug;
LL| |
LL| 1|pub fn used_function() {
LL| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
Expand Down
4 changes: 2 additions & 2 deletions tests/run-coverage/uses_inline_crate.coverage
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
$DIR/auxiliary/used_inline_crate.rs:
LL| |#![allow(unused_assignments, unused_variables)]
LL| |
LL| |// Verify that coverage works with optimizations:
LL| |// compile-flags: -C opt-level=3
LL| |// ^^ validates coverage now works with optimizations
LL| |
LL| |use std::fmt::Debug;
LL| |
LL| 1|pub fn used_function() {
Expand Down

0 comments on commit 4da38c3

Please sign in to comment.