repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/read2/tests.rs | src/tools/compiletest/src/read2/tests.rs | use std::io::Write;
use crate::read2::{FILTERED_PATHS_PLACEHOLDER_LEN, MAX_OUT_LEN, ProcOutput};
#[test]
fn test_abbreviate_short_string() {
let mut out = ProcOutput::new();
out.extend(b"Hello world!", &[]);
assert_eq!(b"Hello world!", &*out.into_bytes());
}
#[test]
fn test_abbreviate_short_string_multip... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/coverage.rs | src/tools/compiletest/src/runtest/coverage.rs | //! Code specific to the coverage test suites.
use std::ffi::OsStr;
use std::process::Command;
use camino::{Utf8Path, Utf8PathBuf};
use glob::glob;
use crate::common::{TestSuite, UI_COVERAGE, UI_COVERAGE_MAP};
use crate::runtest::{Emit, ProcRes, TestCx, WillExecute};
use crate::util::static_regex;
impl<'test> TestC... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/tests.rs | src/tools/compiletest/src/runtest/tests.rs | use super::*;
#[test]
fn normalize_platform_differences() {
assert_eq!(TestCx::normalize_platform_differences(r"$DIR\foo.rs"), "$DIR/foo.rs");
assert_eq!(
TestCx::normalize_platform_differences(r"$BUILD_DIR\..\parser.rs"),
"$BUILD_DIR/../parser.rs"
);
assert_eq!(
TestCx::normali... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/crashes.rs | src/tools/compiletest/src/runtest/crashes.rs | use super::{TestCx, WillExecute};
impl TestCx<'_> {
pub(super) fn run_crash_test(&self) {
let pm = self.pass_mode();
let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm));
if std::env::var("COMPILETEST_VERBOSE_CRASHES").is_ok() {
writeln!(self.stderr,... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/mir_opt.rs | src/tools/compiletest/src/runtest/mir_opt.rs | use std::fs;
use camino::{Utf8Path, Utf8PathBuf};
use glob::glob;
use miropt_test_tools::{MiroptTest, MiroptTestFile, files_for_miropt_test};
use tracing::debug;
use super::{Emit, TestCx, WillExecute};
use crate::runtest::compute_diff::write_diff;
impl TestCx<'_> {
pub(super) fn run_mir_opt_test(&self) {
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/assembly.rs | src/tools/compiletest/src/runtest/assembly.rs | use camino::Utf8PathBuf;
use super::{AllowUnused, Emit, LinkToAux, ProcRes, TargetLocation, TestCx};
impl TestCx<'_> {
pub(super) fn run_assembly_test(&self) {
if self.config.llvm_filecheck.is_none() {
self.fatal("missing --llvm-filecheck");
}
let (proc_res, output_path) = sel... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/run_make.rs | src/tools/compiletest/src/runtest/run_make.rs | use std::process::{Command, Output, Stdio};
use std::{env, fs};
use build_helper::fs::{ignore_not_found, recursive_remove};
use camino::{Utf8Path, Utf8PathBuf};
use super::{ProcRes, TestCx, disable_error_reporting};
use crate::common::TestSuite;
use crate::util::{copy_dir_all, dylib_env_var};
impl TestCx<'_> {
p... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/js_doc.rs | src/tools/compiletest/src/runtest/js_doc.rs | use std::process::Command;
use super::{DocKind, TestCx};
impl TestCx<'_> {
pub(super) fn run_rustdoc_js_test(&self) {
if let Some(nodejs) = &self.config.nodejs {
let out_dir = self.output_base_dir();
self.document(&out_dir, DocKind::Html);
let file_stem = self.testpat... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/rustdoc.rs | src/tools/compiletest/src/runtest/rustdoc.rs | use std::process::Command;
use super::{DocKind, TestCx, remove_and_create_dir_all};
impl TestCx<'_> {
pub(super) fn run_rustdoc_test(&self) {
assert!(self.revision.is_none(), "revisions not supported in this test suite");
let out_dir = self.output_base_dir();
remove_and_create_dir_all(&ou... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/rustdoc_json.rs | src/tools/compiletest/src/runtest/rustdoc_json.rs | use std::process::Command;
use super::{DocKind, TestCx, remove_and_create_dir_all};
impl TestCx<'_> {
pub(super) fn run_rustdoc_json_test(&self) {
//FIXME: Add bless option.
assert!(self.revision.is_none(), "revisions not supported in this test suite");
let out_dir = self.output_base_dir... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/compute_diff.rs | src/tools/compiletest/src/runtest/compute_diff.rs | use std::collections::VecDeque;
#[derive(Debug, PartialEq)]
pub enum DiffLine {
Context(String),
Expected(String),
Resulting(String),
}
#[derive(Debug, PartialEq)]
pub struct Mismatch {
pub line_number: u32,
pub lines: Vec<DiffLine>,
}
impl Mismatch {
fn new(line_number: u32) -> Mismatch {
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/ui.rs | src/tools/compiletest/src/runtest/ui.rs | use std::collections::HashSet;
use std::fs::OpenOptions;
use std::io::Write;
use rustfix::{Filter, apply_suggestions, get_suggestions_from_json};
use tracing::debug;
use super::{
AllowUnused, Emit, FailMode, LinkToAux, PassMode, RunFailMode, RunResult, TargetLocation,
TestCx, TestOutput, Truncated, UI_FIXED, ... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/codegen.rs | src/tools/compiletest/src/runtest/codegen.rs | use super::{PassMode, TestCx};
impl TestCx<'_> {
pub(super) fn run_codegen_test(&self) {
if self.config.llvm_filecheck.is_none() {
self.fatal("missing --llvm-filecheck");
}
let (proc_res, output_path) = self.compile_test_and_save_ir();
if !proc_res.status.success() {
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/codegen_units.rs | src/tools/compiletest/src/runtest/codegen_units.rs | use std::collections::HashSet;
use super::{Emit, TestCx, WillExecute};
use crate::util::static_regex;
use crate::{errors, fatal};
impl TestCx<'_> {
pub(super) fn run_codegen_units_test(&self) {
assert!(self.revision.is_none(), "revisions not relevant here");
let proc_res = self.compile_test(WillE... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/debuginfo.rs | src/tools/compiletest/src/runtest/debuginfo.rs | use std::ffi::{OsStr, OsString};
use std::fs::File;
use std::io::{BufRead, BufReader, Read};
use std::process::{Command, Output, Stdio};
use camino::Utf8Path;
use tracing::debug;
use super::debugger::DebuggerCommands;
use super::{Debugger, Emit, ProcRes, TestCx, Truncated, WillExecute};
use crate::debuggers::extract_... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/pretty.rs | src/tools/compiletest/src/runtest/pretty.rs | use std::fs;
use super::{ProcRes, ReadFrom, TestCx};
impl TestCx<'_> {
pub(super) fn run_pretty_test(&self) {
if self.props.pp_exact.is_some() {
self.logv("testing for exact pretty-printing");
} else {
self.logv("testing for converging pretty-printing");
}
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/incremental.rs | src/tools/compiletest/src/runtest/incremental.rs | use super::{FailMode, TestCx, WillExecute};
use crate::errors;
impl TestCx<'_> {
pub(super) fn run_incremental_test(&self) {
// Basic plan for a test incremental/foo/bar.rs:
// - load list of revisions rpass1, cfail2, rpass3
// - each should begin with `cpass`, `rpass`, `cfail`, or `rfail... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/runtest/debugger.rs | src/tools/compiletest/src/runtest/debugger.rs | use std::fmt::Write;
use std::fs::File;
use std::io::{BufRead, BufReader};
use camino::{Utf8Path, Utf8PathBuf};
use crate::directives::LineNumber;
use crate::runtest::ProcRes;
/// Representation of information to invoke a debugger and check its output
pub(super) struct DebuggerCommands {
/// Commands for the deb... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/directive_names.rs | src/tools/compiletest/src/directives/directive_names.rs | use std::collections::HashSet;
use std::sync::LazyLock;
pub(crate) static KNOWN_DIRECTIVE_NAMES_SET: LazyLock<HashSet<&str>> =
LazyLock::new(|| KNOWN_DIRECTIVE_NAMES.iter().copied().collect());
/// This was originally generated by collecting directives from ui tests and then extracting their
/// directive names. ... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/tests.rs | src/tools/compiletest/src/directives/tests.rs | use std::collections::BTreeSet;
use camino::Utf8Path;
use semver::Version;
use crate::common::{Config, Debugger, TestMode};
use crate::directives::{
self, AuxProps, DIRECTIVE_HANDLERS_MAP, DirectivesCache, EarlyProps, Edition, EditionRange,
FileDirectives, KNOWN_DIRECTIVE_NAMES_SET, LineNumber, extract_llvm_v... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | true |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/handlers.rs | src/tools/compiletest/src/directives/handlers.rs | use std::collections::HashMap;
use std::sync::{Arc, LazyLock};
use crate::common::Config;
use crate::directives::{
DirectiveLine, NormalizeKind, NormalizeRule, TestProps, parse_and_update_aux,
parse_edition_range, split_flags,
};
use crate::errors::ErrorKind;
pub(crate) static DIRECTIVE_HANDLERS_MAP: LazyLock... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/file.rs | src/tools/compiletest/src/directives/file.rs | use camino::Utf8Path;
use crate::directives::LineNumber;
use crate::directives::line::{DirectiveLine, line_directive};
pub(crate) struct FileDirectives<'a> {
pub(crate) path: &'a Utf8Path,
pub(crate) lines: Vec<DirectiveLine<'a>>,
}
impl<'a> FileDirectives<'a> {
pub(crate) fn from_file_contents(path: &'a... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/line_number.rs | src/tools/compiletest/src/directives/line_number.rs | /// A line number in a file. Internally the first line has index 1.
/// If it is 0 it means "no specific line" (used e.g. for implied directives).
/// When `Display`:ed, the first line is `1`.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct LineNumber(usize);
impl LineNumber {
/// Th... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/auxiliary.rs | src/tools/compiletest/src/directives/auxiliary.rs | //! Code for dealing with test directives that request an "auxiliary" crate to
//! be built and made available to the test in some way.
use std::iter;
use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC_MACRO};
use crate::common::Config;
use crate::directives::DirectiveLine;
/// Properti... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/needs.rs | src/tools/compiletest/src/directives/needs.rs | use crate::common::{
Config, KNOWN_CRATE_TYPES, KNOWN_TARGET_HAS_ATOMIC_WIDTHS, Sanitizer, query_rustc_output,
};
use crate::directives::{DirectiveLine, IgnoreDecision};
pub(super) fn handle_needs(
cache: &CachedNeedsConditions,
config: &Config,
ln: &DirectiveLine<'_>,
) -> IgnoreDecision {
// Note... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/line.rs | src/tools/compiletest/src/directives/line.rs | use std::fmt;
use camino::Utf8Path;
use crate::directives::LineNumber;
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<'a>(
file_path: ... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/cfg.rs | src/tools/compiletest/src/directives/cfg.rs | use std::collections::{HashMap, HashSet};
use std::sync::{Arc, LazyLock};
use crate::common::{CompareMode, Config, Debugger};
use crate::directives::{DirectiveLine, IgnoreDecision};
const EXTRA_ARCHS: &[&str] = &["spirv"];
const EXTERNAL_IGNORES_LIST: &[&str] = &[
// tidy-alphabetical-start
"ignore-backends"... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/test-auxillary/unknown_directive.rs | src/tools/compiletest/src/directives/test-auxillary/unknown_directive.rs | //@ needs-headpat
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/test-auxillary/known_directive.rs | src/tools/compiletest/src/directives/test-auxillary/known_directive.rs | //! ignore-wasm
//@ ignore-wasm
//@ check-pass
// regular comment
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/compiletest/src/directives/test-auxillary/error_annotation.rs | src/tools/compiletest/src/directives/test-auxillary/error_annotation.rs | //@ check-pass
//~ HELP
fn main() {} //~ERROR
//~^ ERROR
//~| ERROR
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/lib.rs | src/tools/run-make-support/src/lib.rs | //! `run-make-support` is a support library for run-make tests. It provides command wrappers and
//! convenience utility functions to help test writers reduce duplication. The support library
//! notably is built via bootstrap cargo: this means that if your test wants some non-trivial
//! utility, such as `object` or `... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/command.rs | src/tools/run-make-support/src/command.rs | use std::ffi::OsStr;
use std::io::Write;
use std::path::Path;
use std::process::{Command as StdCommand, ExitStatus, Output, Stdio};
use std::{ffi, panic};
use build_helper::drop_bomb::DropBomb;
use crate::util::handle_failed_output;
use crate::{
assert_contains, assert_contains_regex, assert_equals, assert_not_co... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/targets.rs | src/tools/run-make-support/src/targets.rs | use std::panic;
use crate::command::Command;
use crate::env_var;
use crate::util::handle_failed_output;
/// `TARGET`
#[must_use]
pub fn target() -> String {
env_var("TARGET")
}
/// Check if target is windows-like.
#[must_use]
pub fn is_windows() -> bool {
target().contains("windows")
}
/// Check if target i... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/string.rs | src/tools/run-make-support/src/string.rs | use std::path::Path;
use crate::fs;
use crate::path_helpers::{cwd, has_extension, shallow_find_files};
/// Gathers all files in the current working directory that have the extension `ext`, and counts
/// the number of lines within that contain a match with the regex pattern `re`.
pub fn count_regex_matches_in_files_w... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/fs.rs | src/tools/run-make-support/src/fs.rs | use std::fs::FileType;
use std::io;
use std::path::{Path, PathBuf};
/// Given a symlink at `src`, read its target, then create a new symlink at `dst` also pointing to
/// target.
pub fn copy_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
let src = src.as_ref();
let dst = dst.as_ref();
let metadata... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/env.rs | src/tools/run-make-support/src/env.rs | use std::ffi::OsString;
#[track_caller]
#[must_use]
pub fn env_var(name: &str) -> String {
match std::env::var(name) {
Ok(v) => v,
Err(err) => panic!("failed to retrieve environment variable {name:?}: {err:?}"),
}
}
#[track_caller]
#[must_use]
pub fn env_var_os(name: &str) -> OsString {
ma... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/symbols.rs | src/tools/run-make-support/src/symbols.rs | use std::collections::BTreeSet;
use std::path::Path;
use object::{self, Object, ObjectSymbol};
/// Given an [`object::File`], find the exported dynamic symbol names via
/// [`object::Object::exports`]. This does not distinguish between which section the symbols appear
/// in.
#[track_caller]
pub fn exported_dynamic_s... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/artifact_names.rs | src/tools/run-make-support/src/artifact_names.rs | //! A collection of helpers to construct artifact names, such as names of dynamic or static
//! libraries which are target-dependent.
use crate::target;
use crate::targets::is_windows_msvc;
/// Construct the static library name based on the target.
#[track_caller]
#[must_use]
pub fn static_lib_name(name: &str) -> Str... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/util.rs | src/tools/run-make-support/src/util.rs | use std::path::PathBuf;
use crate::command::{Command, CompletedProcess};
use crate::env::env_var;
use crate::path_helpers::cwd;
/// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the
/// executed command, failure location, output status and stdout/stderr, and abort the process... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/macros.rs | src/tools/run-make-support/src/macros.rs | /// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct
/// containing a `cmd: Command` field. The provided helpers are:
///
/// 1. Generic argument acceptors: `arg` and `args` (delegated to [`Command`]). These are intended
/// to be *fallback* argument acceptors, when sp... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/run.rs | src/tools/run-make-support/src/run.rs | use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use std::{env, panic};
use crate::command::{Command, CompletedProcess};
use crate::util::handle_failed_output;
use crate::{cwd, env_var};
#[track_caller]
fn run_common(name: &str, args: Option<&[&str]>) -> Command {
let mut bin_path = PathBuf::new();
bi... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/linker.rs | src/tools/run-make-support/src/linker.rs | use regex::Regex;
use crate::{Rustc, is_windows_msvc};
/// Asserts that `rustc` uses LLD for linking when executed.
pub fn assert_rustc_uses_lld(rustc: &mut Rustc) {
let stderr = get_stderr_with_linker_messages(rustc);
assert!(
has_lld_version_in_logs(&stderr),
"LLD version should be present i... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/path_helpers.rs | src/tools/run-make-support/src/path_helpers.rs | //! Collection of path-related helpers.
use std::path::{Path, PathBuf};
use crate::env::env_var;
use crate::rfs;
/// Return the current working directory.
///
/// This forwards to [`std::env::current_dir`], please see its docs regarding platform-specific
/// behavior.
#[must_use]
pub fn cwd() -> PathBuf {
std::e... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/scoped_run.rs | src/tools/run-make-support/src/scoped_run.rs | //! Collection of helpers that try to maintain certain properties while running a test closure.
use std::path::Path;
use crate::fs;
use crate::path_helpers::cwd;
use crate::targets::is_windows;
/// Ensure that the path P is read-only while the test runs, and restore original permissions at the
/// end so compiletest... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/assertion_helpers/tests.rs | src/tools/run-make-support/src/assertion_helpers/tests.rs | //! Basic sanity checks for assertion helpers.
use super::*;
mod test_assert_equals {
use super::*;
#[test]
fn assert_equals_same() {
assert_equals("foo", "foo");
assert_equals("", "");
}
#[test]
#[should_panic]
fn assert_equals_different() {
assert_equals("foo", "... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/assertion_helpers/mod.rs | src/tools/run-make-support/src/assertion_helpers/mod.rs | //! Collection of assertions and assertion-related helpers.
#[cfg(test)]
mod tests;
use std::panic;
use std::path::Path;
use crate::{fs, regex};
/// Assert that `actual` is equal to `expected`.
#[track_caller]
pub fn assert_equals<A: AsRef<str>, E: AsRef<str>>(actual: A, expected: E) {
let actual = actual.as_re... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/rustc.rs | src/tools/run-make-support/src/external_deps/rustc.rs | use std::ffi::{OsStr, OsString};
use std::path::{Path, PathBuf};
use std::str::FromStr as _;
use crate::command::Command;
use crate::env::env_var;
use crate::path_helpers::cwd;
use crate::util::set_host_compiler_dylib_path;
use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname};
/// Construct a ne... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/clang.rs | src/tools/run-make-support/src/external_deps/clang.rs | use std::path::Path;
use crate::command::Command;
use crate::{bin_name, cwd, env_var};
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
#[track_caller]
pub fn clang() -> Clang {
Clang::new()
}
/// A `clang` invocation builder.
#[derive(Debug)]
#[must_use]
pub struct Clang ... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/c_build.rs | src/tools/run-make-support/src/external_deps/c_build.rs | use std::path::PathBuf;
use crate::artifact_names::{dynamic_lib_name, static_lib_name};
use crate::external_deps::c_cxx_compiler::{cc, cxx};
use crate::external_deps::llvm::llvm_ar;
use crate::path_helpers::path;
use crate::targets::{is_darwin, is_windows, is_windows_msvc};
// FIXME(Oneirical): These native build fun... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/llvm.rs | src/tools/run-make-support/src/external_deps/llvm.rs | use std::path::{Path, PathBuf};
use crate::command::Command;
use crate::env::env_var;
/// Construct a new `llvm-readobj` invocation with the `GNU` output style.
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.
#[track_caller]
pub fn llvm_readobj() -> LlvmReadobj {
LlvmReadobj::ne... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/python.rs | src/tools/run-make-support/src/external_deps/python.rs | use crate::command::Command;
use crate::env::env_var;
/// Obtain path of python as provided by the `PYTHON` environment variable. It is up to the caller
/// to document and check if the python version is compatible with its intended usage.
#[track_caller]
#[must_use]
pub fn python_command() -> Command {
let python... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/rustdoc.rs | src/tools/run-make-support/src/external_deps/rustdoc.rs | use std::ffi::OsStr;
use std::path::Path;
use crate::command::Command;
use crate::env::env_var;
use crate::target;
use crate::util::set_host_compiler_dylib_path;
/// Construct a new `rustdoc` invocation with target automatically set to cross-compile target and
/// with host compiler runtime libs configured. Use [`bar... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/mod.rs | src/tools/run-make-support/src/external_deps/mod.rs | //! This module contains external tool dependencies that we assume are available in the environment,
//! such as `cc` or `python`.
pub mod c_build;
pub mod c_cxx_compiler;
pub mod cargo;
pub mod clang;
pub mod htmldocck;
pub mod llvm;
pub mod python;
pub mod rustc;
pub mod rustdoc;
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/cargo.rs | src/tools/run-make-support/src/external_deps/cargo.rs | use crate::command::Command;
use crate::util::set_host_compiler_dylib_path;
/// Returns a command that can be used to invoke in-tree cargo. The cargo is provided by compiletest
/// through the `CARGO` env var, and is **only** available for the `run-make-cargo` test suite.
pub fn cargo() -> Command {
let cargo_path... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/htmldocck.rs | src/tools/run-make-support/src/external_deps/htmldocck.rs | use super::python::python_command;
use crate::command::Command;
use crate::source_root;
/// `htmldocck` is a python script which is used for rustdoc test suites, it is assumed to be
/// available at `$SOURCE_ROOT/src/etc/htmldocck.py`.
#[track_caller]
#[must_use]
pub fn htmldocck() -> Command {
let mut python = py... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs | src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs | use std::path::Path;
use crate::command::Command;
use crate::{env_var, is_windows_msvc};
/// Construct a new platform-specific C compiler invocation.
///
/// WARNING: This means that what flags are accepted by the underlying C compiler is
/// platform- AND compiler-specific. Consult the relevant docs for `gcc`, `clan... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/c_cxx_compiler/gcc.rs | src/tools/run-make-support/src/external_deps/c_cxx_compiler/gcc.rs | use std::path::Path;
use crate::command::Command;
/// Construct a gcc invocation.
///
/// WARNING: This assumes *a* `gcc` exists in the environment and is suitable for use.
#[track_caller]
pub fn gcc() -> Gcc {
Gcc::new()
}
/// A specific `gcc`.
#[derive(Debug)]
#[must_use]
pub struct Gcc {
cmd: Command,
}
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs | src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs | use crate::{is_arm64ec, is_win7, is_windows, is_windows_msvc, target, uname};
fn get_windows_msvc_libs() -> Vec<&'static str> {
let mut libs =
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
if is_win7() {
libs.push("advapi32.lib");
}
libs
}
/// `EX... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/external_deps/c_cxx_compiler/mod.rs | src/tools/run-make-support/src/external_deps/c_cxx_compiler/mod.rs | mod cc;
mod extras;
mod gcc;
pub use cc::*;
pub use extras::*;
pub use gcc::*;
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/diff/tests.rs | src/tools/run-make-support/src/diff/tests.rs | use crate::diff;
#[test]
fn test_diff() {
let expected = "foo\nbar\nbaz\n";
let actual = "foo\nbar\nbaz\n";
diff().expected_text("EXPECTED_TEXT", expected).actual_text("ACTUAL_TEXT", actual).run();
}
#[test]
fn test_should_panic() {
let expected = "foo\nbar\nbaz\n";
let actual = "foo\nbaz\nbar\n";... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/run-make-support/src/diff/mod.rs | src/tools/run-make-support/src/diff/mod.rs | use std::path::{Path, PathBuf};
use build_helper::drop_bomb::DropBomb;
use regex::Regex;
use similar::TextDiff;
use crate::fs;
#[cfg(test)]
mod tests;
#[track_caller]
pub fn diff() -> Diff {
Diff::new()
}
#[derive(Debug)]
#[must_use]
pub struct Diff {
expected: Option<String>,
expected_name: Option<Str... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/x/src/main.rs | src/tools/x/src/main.rs | //! Run bootstrap from any subdirectory of a rust compiler checkout.
//!
//! We prefer `exec`, to avoid adding an extra process in the process tree.
//! However, since `exec` isn't available on Windows, we indirect through
//! `exec_or_status`, which will call `exec` on unix and `status` on Windows.
//!
//! We use `pow... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/llvm-bitcode-linker/src/lib.rs | src/tools/llvm-bitcode-linker/src/lib.rs | mod linker;
mod opt;
mod target;
pub use linker::Session;
pub use opt::Optimization;
pub use target::Target;
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/llvm-bitcode-linker/src/target.rs | src/tools/llvm-bitcode-linker/src/target.rs | #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, clap::ValueEnum)]
pub enum Target {
Nvptx64NvidiaCuda,
}
#[derive(Debug, Clone, Copy, thiserror::Error)]
/// The target is not supported by this linker
#[error("unsupported target")]
pub struct UnsupportedTarget;
impl std::str::FromStr for Target {
type Err = ... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/llvm-bitcode-linker/src/opt.rs | src/tools/llvm-bitcode-linker/src/opt.rs | use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, Copy, Default, Hash, Eq, PartialEq, clap::ValueEnum)]
pub enum Optimization {
#[default]
#[value(name = "0")]
O0,
#[value(name = "1")]
O1,
#[value(name = "2")]
O2,
#[value(name = "3")]
O3,
#[value(name = "s")]
Os,
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/llvm-bitcode-linker/src/linker.rs | src/tools/llvm-bitcode-linker/src/linker.rs | use std::path::PathBuf;
use anyhow::Context;
use crate::{Optimization, Target};
#[derive(Debug)]
pub struct Session {
target: Target,
cpu: Option<String>,
feature: Option<String>,
symbols: Vec<String>,
/// A file that `llvm-link` supports, like a bitcode file or an archive.
files: Vec<PathBu... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs | src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs | use std::path::PathBuf;
use clap::Parser;
use llvm_bitcode_linker::{Optimization, Session, Target};
#[derive(Debug, Parser)]
/// Linker for embedded code without any system dependencies
pub struct Args {
/// Input files - objects, archives and static libraries.
///
/// An archive can be, but not required ... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/error_index_generator/main.rs | src/tools/error_index_generator/main.rs | #![feature(rustc_private)]
extern crate rustc_driver;
extern crate rustc_log;
extern crate rustc_session;
extern crate rustc_errors;
use std::env;
use std::error::Error;
use std::fs::{self, File};
use std::io::Write;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use mdbook_driver::MDBook;
use mdbook_driver:... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustdoc/main.rs | src/tools/rustdoc/main.rs | // We need this feature as it changes `dylib` linking behavior and allows us to link to `rustc_driver`.
#![feature(rustc_private)]
fn main() {
rustdoc::main()
}
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/nix-dev-shell/x/x.rs | src/tools/nix-dev-shell/x/x.rs | // git clone https://github.com/rust-lang/rust/blob/0ea7ddcc35a2fcaa5da8a7dcfc118c9fb4a63b95/src/tools/x/src/main.rs
// patched to stop doing python probing, stop the probe, please dont, i have a python
//! Run bootstrap from any subdirectory of a rust compiler checkout.
//!
//! We prefer `exec`, to avoid adding an ext... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustdoc-themes/main.rs | src/tools/rustdoc-themes/main.rs | use std::env::args;
use std::fs::{File, create_dir_all};
use std::io::{BufRead, BufReader, BufWriter, Write};
use std::path::Path;
use std::process::{Command, exit};
fn get_themes<P: AsRef<Path>>(style_path: P) -> Vec<String> {
let mut ret = Vec::with_capacity(10);
const BEGIN_THEME_MARKER: &'static str = "/*... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustdoc-gui-test/src/config.rs | src/tools/rustdoc-gui-test/src/config.rs | use std::env;
use std::path::PathBuf;
use getopts::Options;
pub(crate) struct Config {
pub(crate) nodejs: PathBuf,
pub(crate) yarn: PathBuf,
pub(crate) rust_src: PathBuf,
pub(crate) out_dir: PathBuf,
pub(crate) initial_cargo: PathBuf,
pub(crate) jobs: String,
pub(crate) test_args: Vec<Path... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustdoc-gui-test/src/main.rs | src/tools/rustdoc-gui-test/src/main.rs | use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::sync::Arc;
use build_helper::npm;
use build_helper::util::try_run;
use compiletest::rustdoc_gui_test::RustdocGuiTestProps;
use config::Config;
mod config;
fn find_librs<P: AsRef<Path>>(path: P) -> Option<PathBuf> {
for entry in wal... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/wasm-component-ld/src/main.rs | src/tools/wasm-component-ld/src/main.rs | // See the `README.md` in this directory for what this tool is.
// The source for this crate lives at
// https://github.com/bytecodealliance/wasm-component-ld and the binary is
// independently used in other projects such as `wasi-sdk` so the `main`
// function is just reexported here to delegate. A Cargo dependency i... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/build.rs | src/tools/rustfmt/build.rs | use std::env;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;
fn main() {
// Only check .git/HEAD dirty status if it exists - doing so when
// building dependent crates may lead to false positives and rebuilds
if Path::new(".git/HEAD").exists() {
pr... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/check_diff/src/lib.rs | src/tools/rustfmt/check_diff/src/lib.rs | use std::env;
use std::io;
use std::path::Path;
use std::process::Command;
use tracing::info;
pub enum GitError {
FailedClone { stdout: Vec<u8>, stderr: Vec<u8> },
IO(std::io::Error),
}
impl From<io::Error> for GitError {
fn from(error: io::Error) -> Self {
GitError::IO(error)
}
}
/// Clone a... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/check_diff/src/main.rs | src/tools/rustfmt/check_diff/src/main.rs | use clap::Parser;
/// Inputs for the check_diff script
#[derive(Parser)]
struct CliInputs {
/// Git url of a rustfmt fork to compare against the latest master rustfmt
remote_repo_url: String,
/// Name of the feature branch on the forked repo
feature_branch: String,
/// Optional commit hash from the... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/check_diff/tests/git.rs | src/tools/rustfmt/check_diff/tests/git.rs | use check_diff::clone_git_repo;
use tempfile::Builder;
#[test]
fn clone_repo_test() {
// Creates an empty directory in the current working directory
let dir = Builder::new().tempdir_in("").unwrap();
let sample_repo = "https://github.com/rust-lang/rustfmt.git";
let dest_path = dir.path();
let resul... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/check_diff/tests/bash_commands.rs | src/tools/rustfmt/check_diff/tests/bash_commands.rs | use check_diff::change_directory_to_path;
use std::env;
use tempfile::Builder;
#[test]
fn cd_test() {
// Creates an empty directory in the current working directory
let dir = Builder::new().tempdir_in("").unwrap();
let dest_path = dir.path();
change_directory_to_path(dest_path).unwrap();
assert_eq!... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/source_map.rs | src/tools/rustfmt/src/source_map.rs | //! This module contains utilities that work with the `SourceMap` from `libsyntax`/`syntex_syntax`.
//! This includes extension traits and methods for looking up spans and line ranges for AST nodes.
use rustc_span::{BytePos, Span};
use crate::comment::FindUncommented;
use crate::config::file_lines::LineRange;
use cra... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/coverage.rs | src/tools/rustfmt/src/coverage.rs | use crate::{Config, EmitMode};
use std::borrow::Cow;
pub(crate) fn transform_missing_snippet<'a>(config: &Config, string: &'a str) -> Cow<'a, str> {
match config.emit_mode() {
EmitMode::Coverage => Cow::from(replace_chars(string)),
_ => Cow::from(string),
}
}
fn replace_chars(s: &str) -> Strin... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/ignore_path.rs | src/tools/rustfmt/src/ignore_path.rs | use ignore::gitignore;
use crate::config::{FileName, IgnoreList};
pub(crate) struct IgnorePathSet {
ignore_set: gitignore::Gitignore,
}
impl IgnorePathSet {
pub(crate) fn from_ignore_list(ignore_list: &IgnoreList) -> Result<Self, ignore::Error> {
let mut ignore_builder = gitignore::GitignoreBuilder::... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/imports.rs | src/tools/rustfmt/src/imports.rs | use std::borrow::Cow;
use std::cmp::Ordering;
use std::fmt;
use core::hash::{Hash, Hasher};
use itertools::Itertools;
use rustc_ast::ast::{self, UseTreeKind};
use rustc_span::{
BytePos, DUMMY_SP, Span,
symbol::{self, sym},
};
use crate::comment::combine_strs_with_missing_comments;
use crate::config::ImportG... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | true |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/expr.rs | src/tools/rustfmt/src/expr.rs | use std::borrow::Cow;
use std::cmp::min;
use itertools::Itertools;
use rustc_ast::token::{Delimiter, Lit, LitKind};
use rustc_ast::{ForLoopKind, MatchKind, ast, token};
use rustc_span::{BytePos, Span};
use tracing::debug;
use crate::chains::rewrite_chain;
use crate::closures;
use crate::comment::{
CharClasses, Fi... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | true |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/visitor.rs | src/tools/rustfmt/src/visitor.rs | use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::sync::Arc;
use rustc_ast::{ast, token::Delimiter, visit};
use rustc_span::{BytePos, Ident, Pos, Span, symbol};
use tracing::debug;
use crate::attr::*;
use crate::comment::{CodeCharKind, CommentCodeSlices, contains_comment, rewrite_comment};
use crate::config::... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | true |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/attr.rs | src/tools/rustfmt/src/attr.rs | //! Format attributes and meta items.
use rustc_ast::HasAttrs;
use rustc_ast::ast;
use rustc_span::{Span, symbol::sym};
use tracing::debug;
use self::doc_comment::DocCommentFormatter;
use crate::comment::{CommentStyle, contains_comment, rewrite_doc_comment};
use crate::config::IndentStyle;
use crate::config::lists::*... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/shape.rs | src/tools/rustfmt/src/shape.rs | use std::borrow::Cow;
use std::cmp::min;
use std::ops::{Add, Sub};
use crate::Config;
#[derive(Copy, Clone, Debug)]
pub(crate) struct Indent {
// Width of the block indent, in characters. Must be a multiple of
// Config::tab_spaces.
pub(crate) block_indent: usize,
// Alignment in characters.
pub(c... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/lib.rs | src/tools/rustfmt/src/lib.rs | #![feature(rustc_private)]
#![deny(rust_2018_idioms)]
#![warn(unreachable_pub)]
#![recursion_limit = "256"]
#![allow(clippy::match_like_matches_macro)]
#![allow(unreachable_pub)]
// N.B. these crates are loaded from the sysroot, so they need extern crate.
extern crate rustc_ast;
extern crate rustc_ast_pretty;
extern c... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/syntux.rs | src/tools/rustfmt/src/syntux.rs | //! This module defines a thin abstract layer on top of the rustc's parser and syntax libraries.
pub(crate) mod parser;
pub(crate) mod session;
| rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/items.rs | src/tools/rustfmt/src/items.rs | // Formatting top-level items - functions, structs, enums, traits, impls.
use std::borrow::Cow;
use std::cmp::{Ordering, max, min};
use regex::Regex;
use rustc_ast::ast;
use rustc_ast::visit;
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, symbol};
use tracing::debug;
use crate::attr::filter_inline_attrs;
use crate... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | true |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/overflow.rs | src/tools/rustfmt/src/overflow.rs | //! Rewrite a list some items with overflow.
use std::cmp::min;
use itertools::Itertools;
use rustc_ast::ast;
use rustc_ast::token::Delimiter;
use rustc_span::Span;
use tracing::debug;
use crate::closures;
use crate::config::StyleEdition;
use crate::config::{Config, lists::*};
use crate::expr::{
can_be_overflowe... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/string.rs | src/tools/rustfmt/src/string.rs | // Format string literals.
use regex::Regex;
use unicode_properties::{GeneralCategory, UnicodeGeneralCategory};
use unicode_segmentation::UnicodeSegmentation;
use crate::config::Config;
use crate::shape::Shape;
use crate::utils::{unicode_str_width, wrap_str};
const MIN_STRING: usize = 10;
/// Describes the layout o... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/sort.rs | src/tools/rustfmt/src/sort.rs | use itertools::EitherOrBoth;
use itertools::Itertools;
/// Iterator which breaks an identifier into various [VersionChunk]s.
struct VersionChunkIter<'a> {
ident: &'a str,
start: usize,
}
impl<'a> VersionChunkIter<'a> {
pub(crate) fn new(ident: &'a str) -> Self {
Self { ident, start: 0 }
}
... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/modules.rs | src/tools/rustfmt/src/modules.rs | use std::borrow::Cow;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use rustc_ast::ast;
use rustc_ast::visit::Visitor;
use rustc_span::Span;
use rustc_span::symbol::{self, Symbol, sym};
use thin_vec::ThinVec;
use thiserror::Error;
use crate::attr::MetaVisitor;
use crate::config::FileName;
use crate:... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/rewrite.rs | src/tools/rustfmt/src/rewrite.rs | // A generic trait to abstract the rewriting of an element (of the AST).
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use rustc_span::Span;
use thiserror::Error;
use crate::FormatReport;
use crate::config::{Config, IndentStyle};
use crate::parse::session::ParseSess;
use crate::shape::Shape;
use crate::skip::Skip... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/chains.rs | src/tools/rustfmt/src/chains.rs | //! Formatting of chained expressions, i.e., expressions that are chained by
//! dots: struct and enum field access, method calls, and try shorthand (`?`).
//!
//! Instead of walking these subexpressions one-by-one, as is our usual strategy
//! for expression formatting, we collect maximal sequences of these expression... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | true |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/emitter.rs | src/tools/rustfmt/src/emitter.rs | pub(crate) use self::checkstyle::*;
pub(crate) use self::diff::*;
pub(crate) use self::files::*;
pub(crate) use self::files_with_backup::*;
pub(crate) use self::json::*;
pub(crate) use self::modified_lines::*;
pub(crate) use self::stdout::*;
use crate::FileName;
use std::io::{self, Write};
use std::path::Path;
mod che... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/matches.rs | src/tools/rustfmt/src/matches.rs | //! Format match expression.
use std::iter::repeat;
use rustc_ast::{MatchKind, ast};
use rustc_span::{BytePos, Span};
use tracing::debug;
use crate::comment::{FindUncommented, combine_strs_with_missing_comments, rewrite_comment};
use crate::config::lists::*;
use crate::config::{Config, ControlBraceStyle, IndentStyle... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/vertical.rs | src/tools/rustfmt/src/vertical.rs | // Format with vertical alignment.
use std::cmp;
use itertools::Itertools;
use rustc_ast::ast;
use rustc_span::{BytePos, Span};
use crate::comment::combine_strs_with_missing_comments;
use crate::config::lists::*;
use crate::expr::rewrite_field;
use crate::items::{rewrite_struct_field, rewrite_struct_field_prefix};
u... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
rust-lang/rust | https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/rustfmt/src/pairs.rs | src/tools/rustfmt/src/pairs.rs | use rustc_ast::{ast, token};
use rustc_span::Span;
use crate::config::IndentStyle;
use crate::config::lists::*;
use crate::rewrite::{Rewrite, RewriteContext, RewriteErrorExt, RewriteResult};
use crate::shape::Shape;
use crate::spanned::Spanned;
use crate::utils::{
first_line_width, is_single_line, last_line_width,... | rust | Apache-2.0 | f8b1d59a81c700cb7aa25cf69e3032b3ce333150 | 2026-01-04T15:31:58.503980Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.