Skip to content

Commit c0c37ca

Browse files
committed
Auto merge of #147892 - Zalathar:rollup-kfcbfex, r=Zalathar
Rollup of 3 pull requests Successful merges: - #147870 (`std::thread::available_parallelism()` vxworks libc symbol usage.) - #147879 (compiletest: Include a file path in `DirectiveLine`) - #147880 (Add a triagebot reminder to update rustc-dev-guide docs when modifying compiletest directives) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f04e3df + fc2f6dd commit c0c37ca

File tree

7 files changed

+82
-116
lines changed

7 files changed

+82
-116
lines changed

library/std/src/sys/thread/unix.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,13 +314,10 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
314314
target_os = "vxworks" => {
315315
// Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF
316316
// expectations than the actual cores availability.
317-
unsafe extern "C" {
318-
fn vxCpuEnabledGet() -> libc::cpuset_t;
319-
}
320317

321318
// SAFETY: `vxCpuEnabledGet` always fetches a mask with at least one bit set
322319
unsafe{
323-
let set = vxCpuEnabledGet();
320+
let set = libc::vxCpuEnabledGet();
324321
Ok(NonZero::new_unchecked(set.count_ones() as usize))
325322
}
326323
}

src/tools/compiletest/src/directives.rs

Lines changed: 51 additions & 89 deletions
Large diffs are not rendered by default.

src/tools/compiletest/src/directives/auxiliary.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
use std::iter;
55

6-
use camino::Utf8Path;
7-
86
use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC_MACRO};
97
use crate::common::Config;
108
use crate::directives::DirectiveLine;
@@ -47,7 +45,6 @@ impl AuxProps {
4745
pub(super) fn parse_and_update_aux(
4846
config: &Config,
4947
directive_line: &DirectiveLine<'_>,
50-
testfile: &Utf8Path,
5148
aux: &mut AuxProps,
5249
) {
5350
if !(directive_line.name.starts_with("aux-") || directive_line.name == "proc-macro") {
@@ -56,16 +53,12 @@ pub(super) fn parse_and_update_aux(
5653

5754
let ln = directive_line;
5855

59-
config.push_name_value_directive(ln, AUX_BUILD, testfile, &mut aux.builds, |r| {
60-
r.trim().to_string()
61-
});
56+
config.push_name_value_directive(ln, AUX_BUILD, &mut aux.builds, |r| r.trim().to_string());
57+
config.push_name_value_directive(ln, AUX_BIN, &mut aux.bins, |r| r.trim().to_string());
58+
config.push_name_value_directive(ln, AUX_CRATE, &mut aux.crates, parse_aux_crate);
6259
config
63-
.push_name_value_directive(ln, AUX_BIN, testfile, &mut aux.bins, |r| r.trim().to_string());
64-
config.push_name_value_directive(ln, AUX_CRATE, testfile, &mut aux.crates, parse_aux_crate);
65-
config.push_name_value_directive(ln, PROC_MACRO, testfile, &mut aux.proc_macros, |r| {
66-
r.trim().to_string()
67-
});
68-
if let Some(r) = config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND, testfile) {
60+
.push_name_value_directive(ln, PROC_MACRO, &mut aux.proc_macros, |r| r.trim().to_string());
61+
if let Some(r) = config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND) {
6962
aux.codegen_backend = Some(r.trim().to_owned());
7063
}
7164
}

src/tools/compiletest/src/directives/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl<'a> FileDirectives<'a> {
1414
for (line_number, ln) in (1..).zip(file_contents.lines()) {
1515
let ln = ln.trim();
1616

17-
if let Some(directive_line) = line_directive(line_number, ln) {
17+
if let Some(directive_line) = line_directive(path, line_number, ln) {
1818
lines.push(directive_line);
1919
}
2020
}

src/tools/compiletest/src/directives/line.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
use std::fmt;
22

3+
use camino::Utf8Path;
4+
35
const COMPILETEST_DIRECTIVE_PREFIX: &str = "//@";
46

57
/// If the given line begins with the appropriate comment prefix for a directive,
68
/// returns a struct containing various parts of the directive.
7-
pub(crate) fn line_directive<'line>(
9+
pub(crate) fn line_directive<'a>(
10+
file_path: &'a Utf8Path,
811
line_number: usize,
9-
original_line: &'line str,
10-
) -> Option<DirectiveLine<'line>> {
12+
original_line: &'a str,
13+
) -> Option<DirectiveLine<'a>> {
1114
// Ignore lines that don't start with the comment prefix.
1215
let after_comment =
1316
original_line.trim_start().strip_prefix(COMPILETEST_DIRECTIVE_PREFIX)?.trim_start();
@@ -33,7 +36,7 @@ pub(crate) fn line_directive<'line>(
3336
// The directive name ends at the first occurrence of colon, space, or end-of-string.
3437
let name = raw_directive.split([':', ' ']).next().expect("split is never empty");
3538

36-
Some(DirectiveLine { line_number, revision, raw_directive, name })
39+
Some(DirectiveLine { file_path, line_number, revision, raw_directive, name })
3740
}
3841

3942
/// The (partly) broken-down contents of a line containing a test directive,
@@ -51,25 +54,30 @@ pub(crate) fn line_directive<'line>(
5154
/// ^^^^^^^^^^^^^^^^^ raw_directive
5255
/// ^^^^^^^^^^^^^ name
5356
/// ```
54-
pub(crate) struct DirectiveLine<'ln> {
57+
pub(crate) struct DirectiveLine<'a> {
58+
/// Path of the file containing this line.
59+
///
60+
/// Mostly used for diagnostics, but some directives (e.g. `//@ pp-exact`)
61+
/// also use it to compute a value based on the filename.
62+
pub(crate) file_path: &'a Utf8Path,
5563
pub(crate) line_number: usize,
5664

5765
/// Some test directives start with a revision name in square brackets
5866
/// (e.g. `[foo]`), and only apply to that revision of the test.
5967
/// If present, this field contains the revision name (e.g. `foo`).
60-
pub(crate) revision: Option<&'ln str>,
68+
pub(crate) revision: Option<&'a str>,
6169

6270
/// The main part of the directive, after removing the comment prefix
6371
/// and the optional revision specifier.
6472
///
6573
/// This is "raw" because the directive's name and colon-separated value
6674
/// (if present) have not yet been extracted or checked.
67-
raw_directive: &'ln str,
75+
raw_directive: &'a str,
6876

6977
/// Name of the directive.
7078
///
7179
/// Invariant: `self.raw_directive.starts_with(self.name)`
72-
pub(crate) name: &'ln str,
80+
pub(crate) name: &'a str,
7381
}
7482

7583
impl<'ln> DirectiveLine<'ln> {

src/tools/compiletest/src/directives/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,9 +956,9 @@ fn parse_edition_range(line: &str) -> Option<EditionRange> {
956956
let config = cfg().build();
957957

958958
let line_with_comment = format!("//@ {line}");
959-
let line = line_directive(0, &line_with_comment).unwrap();
959+
let line = line_directive(Utf8Path::new("tmp.rs"), 0, &line_with_comment).unwrap();
960960

961-
super::parse_edition_range(&config, &line, "tmp.rs".into())
961+
super::parse_edition_range(&config, &line)
962962
}
963963

964964
#[test]

triagebot.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,12 @@ cc = ["@rust-lang/clippy"]
10501050
[mentions."src/tools/compiletest"]
10511051
cc = ["@jieyouxu"]
10521052

1053+
[mentions."src/tools/compiletest/src/directives"]
1054+
message = """
1055+
`compiletest` directives have been modified. Please add or update docs for the
1056+
new or modified directive in `src/doc/rustc-dev-guide/`.
1057+
"""
1058+
10531059
[mentions."src/tools/miri"]
10541060
message = "The Miri subtree was changed"
10551061
cc = ["@rust-lang/miri"]

0 commit comments

Comments
 (0)