From cf4bc3405873a4eff0d47d5d89f9aa02c3af1c23 Mon Sep 17 00:00:00 2001 From: Alexander Regueiro Date: Sat, 9 Feb 2019 22:22:49 +0000 Subject: [PATCH] tools: comments --- src/tools/compiletest/src/common.rs | 62 ++++----- src/tools/compiletest/src/header.rs | 8 +- src/tools/compiletest/src/json.rs | 8 +- src/tools/compiletest/src/main.rs | 12 +- src/tools/compiletest/src/read2.rs | 6 +- src/tools/compiletest/src/runtest.rs | 189 ++++++++++++++------------- src/tools/linkchecker/main.rs | 2 +- src/tools/tidy/src/cargo.rs | 2 +- src/tools/tidy/src/features.rs | 4 +- 9 files changed, 149 insertions(+), 144 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 6b3117a1f74f4..042caf444ee7e 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -145,101 +145,101 @@ pub struct Config { pub force_valgrind: bool, /// The path to the Clang executable to run Clang-based tests with. If - /// `None` then these tests will be ignored. + /// `None`, then these tests will be ignored. pub run_clang_based_tests_with: Option, - /// The directory containing the tests to run + /// The directory containing the tests to run. pub src_base: PathBuf, - /// The directory where programs should be built + /// The directory where programs should be built. pub build_base: PathBuf, - /// The name of the stage being built (stage1, etc) + /// The name of the stage being built (stage1, etc.) pub stage_id: String, - /// The test mode, compile-fail, run-fail, run-pass + /// The test mode, compile-fail, run-fail, run-pass. pub mode: Mode, - /// Run ignored tests + /// Run ignored tests. pub run_ignored: bool, - /// Only run tests that match this filter + /// Only run tests that match this filter. pub filter: Option, - /// Exactly match the filter, rather than a substring + /// Exactly match the filter, rather than a substring. pub filter_exact: bool, - /// Write out a parseable log of tests that were run + /// Write out a parseable log of tests that were run. pub logfile: Option, /// A command line to prefix program execution with, - /// for running under valgrind + /// for running under valgrind. pub runtool: Option, /// Flags to pass to the compiler when building for the host pub host_rustcflags: Option, - /// Flags to pass to the compiler when building for the target + /// Flags to pass to the compiler when building for the target. pub target_rustcflags: Option, - /// Target system to be tested + /// Target system to be tested. pub target: String, - /// Host triple for the compiler being invoked + /// Host triple for the compiler being invoked. pub host: String, - /// Path to / name of the GDB executable + /// Path to / name of the GDB executable. pub gdb: Option, - /// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch + /// Version of GDB, encoded as `((major * 1000) + minor) * 1000 + patch`. pub gdb_version: Option, - /// Whether GDB has native rust support + /// Whether GDB has native rust support. pub gdb_native_rust: bool, - /// Version of LLDB + /// Version of LLDB. pub lldb_version: Option, - /// Whether LLDB has native rust support + /// `true` if LLDB has native rust support. pub lldb_native_rust: bool, - /// Version of LLVM + /// Version of LLVM. pub llvm_version: Option, - /// Is LLVM a system LLVM + /// `true` if LLVM is system LLVM. pub system_llvm: bool, - /// Path to the android tools + /// Path to the Android tools. pub android_cross_path: PathBuf, - /// Extra parameter to run adb on arm-linux-androideabi + /// Extra parameter to run adb on arm-linux-androideabi. pub adb_path: String, - /// Extra parameter to run test suite on arm-linux-androideabi + /// Extra parameter to run test suite on arm-linux-androideabi. pub adb_test_dir: String, - /// status whether android device available or not + /// Status whether android device available or not. pub adb_device_status: bool, - /// the path containing LLDB's Python module + /// Path containing LLDB's Python module. pub lldb_python_dir: Option, - /// Explain what's going on + /// `true` to enable verbose output. pub verbose: bool, - /// Print one character per test instead of one line + /// Print one character per test instead of one line. pub quiet: bool, - /// Whether to use colors in test. + /// `true` to use colors in test. pub color: ColorConfig, - /// where to find the remote test client process, if we're using it + /// Where to find the remote test client process, if we're using it. pub remote_test_client: Option, - /// mode describing what file the actual ui output will be compared to + /// Mode describing what file the actual ui output will be compared to. pub compare_mode: Option, - // Configuration for various run-make tests frobbing things like C compilers + // Configuration for various run-make tests-frobbing things like C compilers, // or querying about various LLVM component information. pub cc: String, pub cxx: String, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index c2c4a6b69cca5..7cd9284fa9160 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -304,7 +304,7 @@ pub struct TestProps { pub dont_check_compiler_stderr: bool, // Don't force a --crate-type=dylib flag on the command line pub no_prefer_dynamic: bool, - // Run --pretty expanded when running pretty printing tests + // Run --pretty expanded when running pretty-printing tests pub pretty_expanded: bool, // Which pretty mode are we testing with, default to 'normal' pub pretty_mode: String, @@ -314,7 +314,7 @@ pub struct TestProps { pub forbid_output: Vec, // Revisions to test for incremental compilation. pub revisions: Vec, - // Directory (if any) to use for incremental compilation. This is + // Directory (if any) to use for incremental compilation. This is // not set by end-users; rather it is set by the incremental // testing harness and used when generating compilation // arguments. (In particular, it propagates to the aux-builds.) @@ -678,7 +678,7 @@ impl Config { fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> { self.parse_name_value_directive(line, name).map(|nv| { - // nv is either FOO or FOO=BAR + // `nv` is either `"FOO"` or `"FOO=BAR"`. let mut strs: Vec = nv.splitn(2, '=').map(str::to_owned).collect(); match strs.len() { @@ -867,7 +867,7 @@ fn expand_variables(mut value: String, config: &Config) -> String { /// assert_eq!(s, " -> \"something ($WORD bits)\"."); /// ``` fn parse_normalization_string(line: &mut &str) -> Option { - // FIXME support escapes in strings. + // FIXME: support escapes in strings. let begin = line.find('"')? + 1; let end = line[begin..].find('"')? + begin; let result = line[begin..end].to_owned(); diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 12aae303f29aa..eb6031d0d65ea 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -93,7 +93,7 @@ pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec Vec { // The compiler sometimes intermingles non-JSON stuff into the - // output. This hack just skips over such lines. Yuck. + // output. This hack just skips over such lines. Yuck. if line.starts_with('{') { match serde_json::from_str::(line) { Ok(diagnostic) => { @@ -147,7 +147,7 @@ fn push_expected_errors( }; // We break the output into multiple lines, and then append the - // [E123] to every line in the output. This may be overkill. The + // [E123] to every line in the output. This may be overkill. The // intention was to match existing tests that do things like "//| // found `i32` [E123]" and expect to match that somewhere, and yet // also ensure that `//~ ERROR E123` *always* works. The @@ -156,7 +156,7 @@ fn push_expected_errors( let with_code = |span: &DiagnosticSpan, text: &str| { match diagnostic.code { Some(ref code) => - // FIXME(#33000) -- it'd be better to use a dedicated + // FIXME(#33000): it'd be better to use a dedicated // UI harness than to include the line/col number like // this, but some current tests rely on it. // @@ -169,7 +169,7 @@ fn push_expected_errors( span.line_end, span.column_end, text, code.code.clone()), None => - // FIXME(#33000) -- it'd be better to use a dedicated UI harness + // FIXME(#33000): it'd be better to use a dedicated UI harness. format!("{}:{}: {}:{}: {}", span.line_start, span.column_start, span.line_end, span.column_end, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 86cdadade108f..e4753faf811fd 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -470,14 +470,14 @@ pub fn run_tests(config: &Config) { _ => { /* proceed */ } } - // FIXME(#33435) Avoid spurious failures in codegen-units/partitioning tests. + // FIXME(#33435): avoid spurious failures in codegen-units/partitioning tests. if let Mode::CodegenUnits = config.mode { let _ = fs::remove_dir_all("tmp/partitioning-tests"); } let opts = test_opts(config); let tests = make_tests(config); - // sadly osx needs some file descriptor limits raised for running tests in + // sadly macOS needs some file descriptor limits raised for running tests in // parallel (especially when we have lots and lots of child processes). // For context, see #8904 unsafe { @@ -619,7 +619,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec test::ShouldPanic::No, @@ -640,7 +640,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec) -> (Option, b // There doesn't seem to be a way to correlate the Apple version // with the upstream version, and since the tests were originally // written against Apple versions, we make a fake Apple version by - // multiplying the first number by 100. This is a hack, but + // multiplying the first number by 100. This is a hack, but // normally fine because the only non-Apple version we test is // rust-enabled. diff --git a/src/tools/compiletest/src/read2.rs b/src/tools/compiletest/src/read2.rs index 6dfd8e97c636d..63287f2281a85 100644 --- a/src/tools/compiletest/src/read2.rs +++ b/src/tools/compiletest/src/read2.rs @@ -1,5 +1,5 @@ -// FIXME: This is a complete copy of `cargo/src/cargo/util/read2.rs` -// Consider unify the read2() in libstd, cargo and this to prevent further code duplication. +// FIXME: this is a complete copy of `cargo/src/cargo/util/read2.rs` +// Consider unifying the `read2()` in libstd, cargo and this to prevent further code duplication. pub use self::imp::read2; @@ -56,7 +56,7 @@ mod imp { let mut errfd = 1; while nfds > 0 { - // wait for either pipe to become readable using `select` + // Wait for either pipe to become readable using `select`. let r = unsafe { libc::poll(fds.as_mut_ptr(), nfds, -1) }; if r == -1 { let err = io::Error::last_os_error(); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index bac41a7c57904..5c61fefcad9e0 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -394,7 +394,7 @@ impl<'test> TestCx<'test> { self.fatal_proc_rec("compilation failed!", &proc_res); } - // FIXME(#41968): Move this check to tidy? + // FIXME(#41968): move this check to *tidy*? let expected_errors = errors::load_errors(&self.testpaths.file, self.revision); assert!( expected_errors.is_empty(), @@ -496,7 +496,7 @@ impl<'test> TestCx<'test> { let mut actual = srcs[srcs.len() - 1].clone(); if self.props.pp_exact.is_some() { - // Now we have to care about line endings + // Now we have to care about line endings. let cr = "\r".to_owned(); actual = actual.replace(&cr, "").to_owned(); expected = expected.replace(&cr, "").to_owned(); @@ -504,12 +504,12 @@ impl<'test> TestCx<'test> { self.compare_source(&expected, &actual); - // If we're only making sure that the output matches then just stop here + // If we're only making sure that the output matches then just stop here. if self.props.pretty_compare_only { return; } - // Finally, let's make sure it actually appears to remain valid code + // Finally, let's make sure it actually appears to remain valid code. let proc_res = self.typecheck_source(actual); if !proc_res.status.success() { self.fatal_proc_rec("pretty-printed source does not typecheck", &proc_res); @@ -519,7 +519,7 @@ impl<'test> TestCx<'test> { return; } - // additionally, run `--pretty expanded` and try to build it. + // Additionally, run `--pretty expanded` and try to build it. let proc_res = self.print_source(ReadFrom::Path, "expanded"); if !proc_res.status.success() { self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res); @@ -650,12 +650,12 @@ impl<'test> TestCx<'test> { fn run_debuginfo_gdb_test_no_opt(&self) { let prefixes = if self.config.gdb_native_rust { - // GDB with Rust + // GDB with Rust. static PREFIXES: &'static [&'static str] = &["gdb", "gdbr"]; println!("NOTE: compiletest thinks it is using GDB with native rust support"); PREFIXES } else { - // Generic GDB + // Generic GDB. static PREFIXES: &'static [&'static str] = &["gdb", "gdbg"]; println!("NOTE: compiletest thinks it is using GDB without native rust support"); PREFIXES @@ -668,7 +668,7 @@ impl<'test> TestCx<'test> { } = self.parse_debugger_commands(prefixes); let mut cmds = commands.join("\n"); - // compile test file (it should have 'compile-flags:-g' in the header) + // Compile test file (it should have `compile-flags:-g` in the header). let compiler_run_result = self.compile_test(); if !compiler_run_result.status.success() { self.fatal_proc_rec("compilation failed!", &compiler_run_result); @@ -685,7 +685,7 @@ impl<'test> TestCx<'test> { None => self.fatal("cannot find android cross path"), }; - // write debugger script + // Write debugger script. let mut script_str = String::with_capacity(2048); script_str.push_str(&format!("set charset {}\n", Self::charset())); script_str.push_str(&format!("set sysroot {}\n", tool_path)); @@ -819,7 +819,7 @@ impl<'test> TestCx<'test> { ); if version > extract_gdb_version("7.4").unwrap() { - // Add the directory containing the pretty printers to + // Add the directory containing the pretty-printers to // GDB's script auto loading safe path script_str.push_str(&format!( "add-auto-load-safe-path {}\n", @@ -835,14 +835,14 @@ impl<'test> TestCx<'test> { } } - // The following line actually doesn't have to do anything with - // pretty printing, it just tells GDB to print values on one line: + // Theis doesn't actually have to do anything with pretty-printing, + // it just tells GDB to print values on one line. script_str.push_str("set print pretty off\n"); - // Add the pretty printer directory to GDB's source-file search path + // Add the pretty-printer directory to GDB's source-file search path. script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)); - // Load the target executable + // Load the target executable. script_str.push_str(&format!( "file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\") @@ -853,7 +853,7 @@ impl<'test> TestCx<'test> { script_str.push_str("set language rust\n"); } - // Add line breakpoints + // Add line breakpoints. for line in &breakpoint_lines { script_str.push_str(&format!( "break '{}':{}\n", @@ -920,7 +920,7 @@ impl<'test> TestCx<'test> { } fn run_debuginfo_lldb_test_no_opt(&self) { - // compile test file (it should have 'compile-flags:-g' in the header) + // Compile test file (it should have `compile-flags:-g` in the header). let compile_result = self.compile_test(); if !compile_result.status.success() { self.fatal_proc_rec("compilation failed!", &compile_result); @@ -953,7 +953,7 @@ impl<'test> TestCx<'test> { PREFIXES }; - // Parse debugger commands etc from test files + // Parse debugger commands, etc., from test files. let DebuggerCommands { commands, check_lines, @@ -961,14 +961,14 @@ impl<'test> TestCx<'test> { .. } = self.parse_debugger_commands(prefixes); - // Write debugger script: - // We don't want to hang when calling `quit` while the process is still running + // Write debugger script. + // We don't want to hang when calling `quit` while the process is still running. let mut script_str = String::from("settings set auto-confirm true\n"); - // Make LLDB emit its version, so we have it documented in the test output + // Make LLDB emit its version, so we have it documented in the test output. script_str.push_str("version\n"); - // Switch LLDB into "Rust mode" + // Switch LLDB into "Rust mode". let rust_src_root = self .config .find_rust_src_root() @@ -987,7 +987,7 @@ impl<'test> TestCx<'test> { script_str.push_str("-x \".*\" --category Rust\n"); script_str.push_str("type category enable Rust\n"); - // Set breakpoints on every line that contains the string "#break" + // Set breakpoints on every line that contains the string `"#break"`. let source_file_name = self.testpaths.file.file_name().unwrap().to_string_lossy(); for line in &breakpoint_lines { script_str.push_str(&format!( @@ -996,21 +996,21 @@ impl<'test> TestCx<'test> { )); } - // Append the other commands + // Append the other commands. for line in &commands { script_str.push_str(line); script_str.push_str("\n"); } - // Finally, quit the debugger + // Finally, quit the debugger. script_str.push_str("\nquit\n"); - // Write the script into a file + // Write the script into a file. debug!("script_str = {}", script_str); self.dump_output_file(&script_str, "debugger.script"); let debugger_script = self.make_out_name("debugger.script"); - // Let LLDB execute the script via lldb_batchmode.py + // Let LLDB execute the script via `lldb_batchmode.py`. let debugger_run_result = self.run_lldb(&exe_file, &debugger_script, &rust_src_root); if !debugger_run_result.status.success() { @@ -1026,7 +1026,7 @@ impl<'test> TestCx<'test> { debugger_script: &Path, rust_src_root: &Path, ) -> ProcRes { - // Prepare the lldb_batchmode which executes the debugger script + // Prepare the lldb_batchmode which executes the debugger script. let lldb_script_path = rust_src_root.join("src/etc/lldb_batchmode.py"); self.cmd2procres( Command::new(&self.config.lldb_python) @@ -1115,7 +1115,8 @@ impl<'test> TestCx<'test> { return None; } - // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS. + // Remove options that are either unwanted (`-O`) or may lead to duplicates due to + // `RUSTFLAGS`. let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()]; let new_options = self .split_maybe_args(options) @@ -1180,7 +1181,7 @@ impl<'test> TestCx<'test> { fn check_single_line(line: &str, check_line: &str) -> bool { // Allow check lines to leave parts unspecified (e.g., uninitialized - // bits in the wrong case of an enum) with the notation "[...]". + // bits in the wrong case of an enum) with the notation `[...]`. let line = line.trim(); let check_line = check_line.trim(); let can_start_anywhere = check_line.starts_with("[...]"); @@ -1287,11 +1288,11 @@ impl<'test> TestCx<'test> { self.fatal_proc_rec("process did not return an error status", proc_res); } - // On Windows, keep all '\' path separators to match the paths reported in the JSON output - // from the compiler + // On Windows, keep all `\` path separators to match the paths reported in the JSON output + // from the compiler. let os_file_name = self.testpaths.file.display().to_string(); - // on windows, translate all '\' path separators to '/' + // On windows, translate all `\` path separators to `/`. let file_name = format!("{}", self.testpaths.file.display()).replace(r"\", "/"); // If the testcase being checked contains at least one expected "help" @@ -1321,7 +1322,7 @@ impl<'test> TestCx<'test> { match opt_index { Some(index) => { - // found a match, everybody is happy + // Found a match; everybody is happy. assert!(!found[index]); found[index] = true; } @@ -1345,7 +1346,7 @@ impl<'test> TestCx<'test> { } let mut not_found = Vec::new(); - // anything not yet found is a problem + // Anything not yet found is a problem. for (index, expected_error) in expected_errors.iter().enumerate() { if !found[index] { self.error(&format!( @@ -1535,7 +1536,7 @@ impl<'test> TestCx<'test> { }; if proc_res.status.success() { - // delete the executable after running it to save space. + // Delete the executable after running it to save space. // it is ok if the deletion failed. let _ = fs::remove_file(self.make_exe_name()); } @@ -1678,7 +1679,7 @@ impl<'test> TestCx<'test> { } path.insert(0, PathBuf::from(lib_path)); - // Add the new dylib search path var + // Add the new dylib search path var. let newpath = env::join_paths(&path).unwrap(); command.env(dylib_env_var(), newpath); @@ -1724,13 +1725,13 @@ impl<'test> TestCx<'test> { .expect("no rustdoc built yet"), ) }; - // FIXME Why is -L here? + // FIXME: why is `-L` here? rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base); - // Use a single thread for efficiency and a deterministic error message order + // Use a single thread for efficiency and a deterministic error message order. rustc.arg("-Zthreads=1"); - // Optionally prevent default --target if specified in test compile-flags. + // Optionally prevent default `--target` if specified in test compile-flags. let custom_target = self .props .compile_flags @@ -1865,11 +1866,11 @@ impl<'test> TestCx<'test> { fn make_exe_name(&self) -> PathBuf { // Using a single letter here to keep the path length down for - // Windows. Some test names get very long. rustc creates `rcgu` + // Windows. Some test names get very long. rustc creates `rcgu` // files with the module name appended to it which can more than // double the length. let mut f = self.output_base_dir().join("a"); - // FIXME: This is using the host architecture exe suffix, not target! + // FIXME: this is using the host architecture `exe` suffix, not target! if self.config.target.contains("emscripten") { f = f.with_extra_extension("js"); } else if self.config.target.contains("wasm32") { @@ -1910,10 +1911,10 @@ impl<'test> TestCx<'test> { let exe_file = self.make_exe_name(); - // FIXME (#9639): This needs to handle non-utf8 paths + // FIXME(#9639): This needs to handle non-UTF8 paths. args.push(exe_file.to_str().unwrap().to_owned()); - // Add the arguments in the run_flags directive + // Add the arguments in the `run_flags` directive. args.extend(self.split_maybe_args(&self.props.run_flags)); let prog = args.remove(0); @@ -1939,12 +1940,12 @@ impl<'test> TestCx<'test> { fn make_cmdline(&self, command: &Command, libpath: &str) -> String { use crate::util; - // Linux and mac don't require adjusting the library search path + // Linux and macOS don't require adjusting the library search path. if cfg!(unix) { format!("{:?}", command) } else { - // Build the LD_LIBRARY_PATH variable as it would be seen on the command line - // for diagnostic purposes + // Build the `LD_LIBRARY_PATH` variable as it would be seen on the command line + // for diagnostic purposes. fn lib_path_cmd_prefix(path: &str) -> String { format!( "{}=\"{}\"", @@ -2046,8 +2047,8 @@ impl<'test> TestCx<'test> { proc_res.fatal(None); } - // This function is a poor man's attempt to debug rust-lang/rust#38620, if - // that's closed then this should be deleted + // This function is a poor man's attempt to debug issue #38620 -- + // when that's closed, this should be deleted. // // This is a very "opportunistic" debugging attempt, so we ignore all // errors here. @@ -2085,7 +2086,7 @@ impl<'test> TestCx<'test> { println!("---------------------------------------------------"); } - // codegen tests (using FileCheck) + // Codegen tests (using `FileCheck`) fn compile_test_and_save_ir(&self) -> ProcRes { let aux_dir = self.aux_output_dir_name(); @@ -2133,7 +2134,7 @@ impl<'test> TestCx<'test> { } fn charset() -> &'static str { - // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset + // FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset. if cfg!(target_os = "bitrig") { "auto" } else if cfg!(target_os = "freebsd") { @@ -2321,7 +2322,7 @@ impl<'test> TestCx<'test> { if let Some(actual_item) = actual_item_with_same_name { if !expected_item.codegen_units.is_empty() && - // Also check for codegen units + // Also check for codegen units. expected_item.codegen_units != actual_item.codegen_units { wrong_cgus.push((expected_item.clone(), actual_item.clone())); @@ -2394,7 +2395,7 @@ impl<'test> TestCx<'test> { string: String, } - // [MONO_ITEM] name [@@ (cgu)+] + // `[MONO_ITEM] name [@@ (cgu)+]` fn str_to_mono_item(s: &str, cgu_has_crate_disambiguator: bool) -> MonoItem { let s = if s.starts_with(PREFIX) { (&s[PREFIX.len()..]).trim() @@ -2451,8 +2452,8 @@ impl<'test> TestCx<'test> { string } - // Given a cgu-name-prefix of the form . or - // the form .-in-., + // Given a cgu-name-prefix of the form `.` or + // `.-in-.`, // remove all crate-disambiguators. fn remove_crate_disambiguator_from_cgu(cgu: &str) -> String { lazy_static! { @@ -2479,16 +2480,16 @@ impl<'test> TestCx<'test> { } fn init_incremental_test(&self) { - // (See `run_incremental_test` for an overview of how incremental tests work.) + // See `run_incremental_test` for an overview of how incremental tests work. // Before any of the revisions have executed, create the - // incremental workproduct directory. Delete any old + // incremental workproduct directory. Delete any old // incremental work products that may be there from prior // runs. let incremental_dir = self.incremental_dir(); if incremental_dir.exists() { - // Canonicalizing the path will convert it to the //?/ format - // on Windows, which enables paths longer than 260 character + // Canonicalizing the path will convert it to the `//?/` format + // on Windows, which enables paths longer than 260 characters. let canonicalized = incremental_dir.canonicalize().unwrap(); fs::remove_dir_all(canonicalized).unwrap(); } @@ -2503,24 +2504,24 @@ impl<'test> TestCx<'test> { } fn run_incremental_test(&self) { - // Basic plan for a test incremental/foo/bar.rs: - // - load list of revisions rpass1, cfail2, rpass3 + // Basic plan for a test `incremental/foo/bar.rs`: + // - load list of revisions `rpass1`, `cfail2`, `rpass3` // - each should begin with `rpass`, `cfail`, or `rfail` // - if `rpass`, expect compile and execution to succeed // - if `cfail`, expect compilation to fail // - if `rfail`, expect execution to fail - // - create a directory build/foo/bar.incremental - // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C rpass1 - // - because name of revision starts with "rpass", expect success - // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C cfail2 - // - because name of revision starts with "cfail", expect an error + // - create a directory `build/foo/bar.incremental` + // - compile `foo/bar.rs` with `-Z incremental=.../foo/bar.incremental` and `-C rpass1` + // - because name of revision starts with `rpass`, expect success + // - compile `foo/bar.rs` with `-Z incremental=.../foo/bar.incremental` and `-C cfail2` + // - because name of revision starts with `cfail`, expect an error // - load expected errors as usual, but filter for those that end in `[rfail2]` - // - compile foo/bar.rs with -Z incremental=.../foo/bar.incremental and -C rpass3 - // - because name of revision starts with "rpass", expect success - // - execute build/foo/bar.exe and save output + // - compile `foo/bar.rs` with `-Z incremental=.../foo/bar.incremental` and `-C rpass3` + // - because name of revision starts with `rpass`, expect success + // - execute `build/foo/bar` and save output // - // FIXME -- use non-incremental mode as an oracle? That doesn't apply - // to #[rustc_dirty] and clean tests I guess + // FIXME: use non-incremental mode as an oracle? That doesn't apply + // to `#[rustc_dirty]` and clean tests, I guess. let revision = self .revision @@ -2637,8 +2638,8 @@ impl<'test> TestCx<'test> { cmd.env("CLANG", clang); } - // We don't want RUSTFLAGS set from the outside to interfere with - // compiler flags set in the test cases: + // We don't want `RUSTFLAGS` set from the outside to interfere with + // compiler flags set in the test cases. cmd.env_remove("RUSTFLAGS"); if self.config.target.contains("msvc") && self.config.cc != "" { @@ -2694,7 +2695,7 @@ impl<'test> TestCx<'test> { if entry.file_type()?.is_dir() { self.aggressive_rm_rf(&path)?; } else { - // Remove readonly files as well on windows (by default we can't) + // Remove read-only files as well, on Windows (by default we can't). fs::remove_file(&path).or_else(|e| { if cfg!(windows) && e.kind() == io::ErrorKind::PermissionDenied { let mut meta = entry.metadata()?.permissions(); @@ -2711,9 +2712,9 @@ impl<'test> TestCx<'test> { } fn run_ui_test(&self) { - // if the user specified a format in the ui test + // If the user specified a format in the ui test // print the output to the stderr file, otherwise extract - // the rendered error messages from json and print them + // the rendered error messages from the JSON and print them. let explicit = self .props .compile_flags @@ -2749,9 +2750,9 @@ impl<'test> TestCx<'test> { self.prune_duplicate_outputs(&modes_to_prune); if self.config.compare_mode.is_some() { - // don't test rustfix with nll right now + // Don't test rustfix with NLL right now. } else if self.props.run_rustfix { - // Apply suggestions from rustc to the code itself + // Apply suggestions from rustc to the code itself. let unfixed_code = self .load_expected_output_from_path(&self.testpaths.file) .unwrap(); @@ -2968,7 +2969,7 @@ impl<'test> TestCx<'test> { }; // We expect each non-empty line to appear consecutively, non-consecutive lines - // must be separated by at least one Elision + // must be separated by at least one elision. let mut start_block_line = None; while let Some(dumped_line) = dumped_lines.next() { match expected_lines.next() { @@ -2993,7 +2994,7 @@ impl<'test> TestCx<'test> { } } Some(&ExpectedLine::Elision) => { - // skip any number of elisions in a row. + // Skip any number of elisions in a row. while let Some(&&ExpectedLine::Elision) = expected_lines.peek() { expected_lines.next(); } @@ -3041,7 +3042,7 @@ impl<'test> TestCx<'test> { let mut normalized = output.replace(&parent_dir_str, "$DIR"); - // Paths into the libstd/libcore + // Paths into the libstd/libcore. let src_dir = self.config.src_base.parent().unwrap().parent().unwrap(); let src_dir_str = if json { src_dir.display().to_string().replace("\\", "\\\\") @@ -3050,39 +3051,43 @@ impl<'test> TestCx<'test> { }; normalized = normalized.replace(&src_dir_str, "$SRC_DIR"); - // Paths into the build directory + // Paths into the build directory. let test_build_dir = &self.config.build_base; let parent_build_dir = test_build_dir.parent().unwrap().parent().unwrap().parent().unwrap(); - // eg. /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui + // E.g., `/home/user/rust/build/x86_64-unknown-linux-gnu/test/ui`. normalized = normalized.replace(test_build_dir.to_str().unwrap(), "$TEST_BUILD_DIR"); - // eg. /home/user/rust/build + // E.g., `/home/user/rust/build`. normalized = normalized.replace(&parent_build_dir.to_str().unwrap(), "$BUILD_DIR"); - // Paths into lib directory. + // Paths into `lib` directory. let mut lib_dir = parent_build_dir.parent().unwrap().to_path_buf(); lib_dir.push("lib"); normalized = normalized.replace(&lib_dir.to_str().unwrap(), "$LIB_DIR"); if json { - // escaped newlines in json strings should be readable - // in the stderr files. There's no point int being correct, + // Escaped newlines in JSON strings should be readable + // in the stderr files. There's no point in being correct, // since only humans process the stderr files. - // Thus we just turn escaped newlines back into newlines. + // Thus, we just turn escaped newlines back into newlines. normalized = normalized.replace("\\n", "\n"); } // If there are `$SRC_DIR` normalizations with line and column numbers, then replace them // with placeholders as we do not want tests needing updated when compiler source code // changes. - // eg. $SRC_DIR/libcore/mem.rs:323:14 becomes $SRC_DIR/libcore/mem.rs:LL:COL + // E.g., `$SRC_DIR/libcore/mem.rs:323:14` becomes `$SRC_DIR/libcore/mem.rs:LL:COL`. normalized = Regex::new("SRC_DIR(.+):\\d+:\\d+").unwrap() .replace_all(&normalized, "SRC_DIR$1:LL:COL").into_owned(); - normalized = normalized.replace("\\\\", "\\") // denormalize for paths on windows - .replace("\\", "/") // normalize for paths on windows - .replace("\r\n", "\n") // normalize for linebreaks on windows - .replace("\t", "\\t"); // makes tabs visible + // Denormalize for paths on Windows. + normalized = normalized.replace("\\\\", "\\") + // Normalize for paths on windows. + .replace("\\", "/") + // Normalize for line breaks on windows. + .replace("\r\n", "\n") + // Makes tabs visible. + .replace("\t", "\\t"); for rule in custom_rules { let re = Regex::new(&rule.0).expect("bad regex in custom normalization rule"); normalized = re.replace_all(&normalized, &rule.1[..]).into_owned(); diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index af704ce260dc4..7dde5026d9520 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -86,7 +86,7 @@ impl FileEntry { *errors = true; println!("{}:{}: id is not unique: `{}`", file.display(), i, fragment); } - // Just in case, we also add the encoded id. + // Just in case, we also add the encoded ID. self.ids.insert(encoded); }); } diff --git a/src/tools/tidy/src/cargo.rs b/src/tools/tidy/src/cargo.rs index 26ced7fc8297a..0e432fd1a68d5 100644 --- a/src/tools/tidy/src/cargo.rs +++ b/src/tools/tidy/src/cargo.rs @@ -41,7 +41,7 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) { // // We just look for: // - // ```` + // ```toml // [dependencies] // name = ... // name2 = ... diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 7126c0c2f6ecf..2e44c4dd3d141 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -173,7 +173,7 @@ pub fn collect_lang_features(base_src_path: &Path, bad: &mut bool) -> Features { let contents = t!(fs::read_to_string(base_src_path.join("libsyntax/feature_gate.rs"))); // We allow rustc-internal features to omit a tracking issue. - // These features must be marked with a `// rustc internal` in its own group. + // These features must be marked with `// rustc internal` in its own group. let mut next_feature_is_rustc_internal = false; contents.lines().zip(1..) @@ -327,7 +327,7 @@ fn map_lib_features(base_src_path: &Path, } becoming_feature = None; if line.contains("rustc_const_unstable(") { - // `const fn` features are handled specially. + // Const fn features are handled specially. let feature_name = match find_attr_val(line, "feature") { Some(name) => name, None => err!("malformed stability attribute"),