Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions library/std/src/sys/thread/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,10 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
target_os = "vxworks" => {
// Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF
// expectations than the actual cores availability.
unsafe extern "C" {
fn vxCpuEnabledGet() -> libc::cpuset_t;
}

// SAFETY: `vxCpuEnabledGet` always fetches a mask with at least one bit set
unsafe{
let set = vxCpuEnabledGet();
let set = libc::vxCpuEnabledGet();
Ok(NonZero::new_unchecked(set.count_ones() as usize))
}
}
Expand Down
140 changes: 51 additions & 89 deletions src/tools/compiletest/src/directives.rs

Large diffs are not rendered by default.

17 changes: 5 additions & 12 deletions src/tools/compiletest/src/directives/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

use std::iter;

use camino::Utf8Path;

use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC_MACRO};
use crate::common::Config;
use crate::directives::DirectiveLine;
Expand Down Expand Up @@ -47,7 +45,6 @@ impl AuxProps {
pub(super) fn parse_and_update_aux(
config: &Config,
directive_line: &DirectiveLine<'_>,
testfile: &Utf8Path,
aux: &mut AuxProps,
) {
if !(directive_line.name.starts_with("aux-") || directive_line.name == "proc-macro") {
Expand All @@ -56,16 +53,12 @@ pub(super) fn parse_and_update_aux(

let ln = directive_line;

config.push_name_value_directive(ln, AUX_BUILD, testfile, &mut aux.builds, |r| {
r.trim().to_string()
});
config.push_name_value_directive(ln, AUX_BUILD, &mut aux.builds, |r| r.trim().to_string());
config.push_name_value_directive(ln, AUX_BIN, &mut aux.bins, |r| r.trim().to_string());
config.push_name_value_directive(ln, AUX_CRATE, &mut aux.crates, parse_aux_crate);
config
.push_name_value_directive(ln, AUX_BIN, testfile, &mut aux.bins, |r| r.trim().to_string());
config.push_name_value_directive(ln, AUX_CRATE, testfile, &mut aux.crates, parse_aux_crate);
config.push_name_value_directive(ln, PROC_MACRO, testfile, &mut aux.proc_macros, |r| {
r.trim().to_string()
});
if let Some(r) = config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND, testfile) {
.push_name_value_directive(ln, PROC_MACRO, &mut aux.proc_macros, |r| r.trim().to_string());
if let Some(r) = config.parse_name_value_directive(ln, AUX_CODEGEN_BACKEND) {
aux.codegen_backend = Some(r.trim().to_owned());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/directives/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<'a> FileDirectives<'a> {
for (line_number, ln) in (1..).zip(file_contents.lines()) {
let ln = ln.trim();

if let Some(directive_line) = line_directive(line_number, ln) {
if let Some(directive_line) = line_directive(path, line_number, ln) {
lines.push(directive_line);
}
}
Expand Down
24 changes: 16 additions & 8 deletions src/tools/compiletest/src/directives/line.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use std::fmt;

use camino::Utf8Path;

const COMPILETEST_DIRECTIVE_PREFIX: &str = "//@";

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

Some(DirectiveLine { line_number, revision, raw_directive, name })
Some(DirectiveLine { file_path, line_number, revision, raw_directive, name })
}

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

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

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

/// Name of the directive.
///
/// Invariant: `self.raw_directive.starts_with(self.name)`
pub(crate) name: &'ln str,
pub(crate) name: &'a str,
}

impl<'ln> DirectiveLine<'ln> {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/compiletest/src/directives/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,9 +956,9 @@ fn parse_edition_range(line: &str) -> Option<EditionRange> {
let config = cfg().build();

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

super::parse_edition_range(&config, &line, "tmp.rs".into())
super::parse_edition_range(&config, &line)
}

#[test]
Expand Down
6 changes: 6 additions & 0 deletions triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,12 @@ cc = ["@rust-lang/clippy"]
[mentions."src/tools/compiletest"]
cc = ["@jieyouxu"]

[mentions."src/tools/compiletest/src/directives"]
message = """
`compiletest` directives have been modified. Please add or update docs for the
new or modified directive in `src/doc/rustc-dev-guide/`.
"""

[mentions."src/tools/miri"]
message = "The Miri subtree was changed"
cc = ["@rust-lang/miri"]
Expand Down
Loading