Skip to content

Commit d954b06

Browse files
committed
Auto merge of rust-lang#131963 - matthiaskrgr:rollup-4oapxk5, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - rust-lang#131926 (Align boolean option descriptions in `configure.py`) - rust-lang#131961 (compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated) - rust-lang#131962 (Make `llvm::set_section` take a `&CStr`) Failed merges: - rust-lang#131181 (Compiletest: Custom differ) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bfab34a + 29f9964 commit d954b06

File tree

8 files changed

+23
-23
lines changed

8 files changed

+23
-23
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::ffi::CStr;
2+
13
use itertools::Itertools as _;
24
use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, ConstCodegenMethods};
35
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
@@ -305,7 +307,7 @@ fn generate_coverage_map<'ll>(
305307
/// specific, well-known section and name.
306308
fn save_function_record(
307309
cx: &CodegenCx<'_, '_>,
308-
covfun_section_name: &str,
310+
covfun_section_name: &CStr,
309311
mangled_function_name: &str,
310312
source_hash: u64,
311313
filenames_ref: u64,

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::cell::RefCell;
2-
use std::ffi::CString;
2+
use std::ffi::{CStr, CString};
33

44
use libc::c_uint;
55
use rustc_codegen_ssa::traits::{
@@ -292,10 +292,10 @@ pub(crate) fn save_cov_data_to_mod<'ll, 'tcx>(
292292
.unwrap();
293293
debug!("covmap var name: {:?}", covmap_var_name);
294294

295-
let covmap_section_name = llvm::build_string(|s| unsafe {
295+
let covmap_section_name = CString::new(llvm::build_byte_buffer(|s| unsafe {
296296
llvm::LLVMRustCoverageWriteMapSectionNameToString(cx.llmod, s);
297-
})
298-
.expect("Rust Coverage section name failed UTF-8 conversion");
297+
}))
298+
.expect("covmap section name should not contain NUL");
299299
debug!("covmap section name: {:?}", covmap_section_name);
300300

301301
let llglobal = llvm::add_global(cx.llmod, cx.val_ty(cov_data_val), &covmap_var_name);
@@ -310,7 +310,7 @@ pub(crate) fn save_cov_data_to_mod<'ll, 'tcx>(
310310

311311
pub(crate) fn save_func_record_to_mod<'ll, 'tcx>(
312312
cx: &CodegenCx<'ll, 'tcx>,
313-
covfun_section_name: &str,
313+
covfun_section_name: &CStr,
314314
func_name_hash: u64,
315315
func_record_val: &'ll llvm::Value,
316316
is_used: bool,
@@ -354,9 +354,9 @@ pub(crate) fn save_func_record_to_mod<'ll, 'tcx>(
354354
/// - `__llvm_covfun` on Linux
355355
/// - `__LLVM_COV,__llvm_covfun` on macOS (includes `__LLVM_COV,` segment prefix)
356356
/// - `.lcovfun$M` on Windows (includes `$M` sorting suffix)
357-
pub(crate) fn covfun_section_name(cx: &CodegenCx<'_, '_>) -> String {
358-
llvm::build_string(|s| unsafe {
357+
pub(crate) fn covfun_section_name(cx: &CodegenCx<'_, '_>) -> CString {
358+
CString::new(llvm::build_byte_buffer(|s| unsafe {
359359
llvm::LLVMRustCoverageWriteFuncSectionNameToString(cx.llmod, s);
360-
})
361-
.expect("Rust Coverage function record section name failed UTF-8 conversion")
360+
}))
361+
.expect("covfun section name should not contain NUL")
362362
}

compiler/rustc_codegen_llvm/src/llvm/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,9 @@ impl MemoryEffects {
210210
}
211211
}
212212

213-
pub fn set_section(llglobal: &Value, section_name: &str) {
214-
let section_name_cstr = CString::new(section_name).expect("unexpected CString error");
213+
pub fn set_section(llglobal: &Value, section_name: &CStr) {
215214
unsafe {
216-
LLVMSetSection(llglobal, section_name_cstr.as_ptr());
215+
LLVMSetSection(llglobal, section_name.as_ptr());
217216
}
218217
}
219218

src/bootstrap/configure.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def is_value_list(key):
193193
if option.value:
194194
print('\t{:30} {}'.format('--{}=VAL'.format(option.name), option.desc))
195195
else:
196-
print('\t{:30} {}'.format('--enable-{} OR --disable-{}'.format(option.name, option.name), option.desc))
196+
print('\t--enable-{:25} OR --disable-{}'.format(option.name, option.name))
197+
print('\t\t' + option.desc)
197198
print('')
198199
print('This configure script is a thin configuration shim over the true')
199200
print('configuration system, `config.toml`. You can explore the comments')

src/tools/compiletest/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ pub struct Config {
338338
/// created in `/<build_base>/rustfix_missing_coverage.txt`
339339
pub rustfix_coverage: bool,
340340

341-
/// whether to run `tidy` when a rustdoc test fails
342-
pub has_tidy: bool,
341+
/// whether to run `tidy` (html-tidy) when a rustdoc test fails
342+
pub has_html_tidy: bool,
343343

344344
/// whether to run `enzyme` autodiff tests
345345
pub has_enzyme: bool,

src/tools/compiletest/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ pub fn parse_config(args: Vec<String>) -> Config {
230230
let run_ignored = matches.opt_present("ignored");
231231
let with_debug_assertions = matches.opt_present("with-debug-assertions");
232232
let mode = matches.opt_str("mode").unwrap().parse().expect("invalid mode");
233-
let has_tidy = if mode == Mode::Rustdoc {
233+
let has_html_tidy = if mode == Mode::Rustdoc {
234234
Command::new("tidy")
235235
.arg("--version")
236236
.stdout(Stdio::null())
237237
.status()
238238
.map_or(false, |status| status.success())
239239
} else {
240-
// Avoid spawning an external command when we know tidy won't be used.
240+
// Avoid spawning an external command when we know html-tidy won't be used.
241241
false
242242
};
243243
let has_enzyme = matches.opt_present("has-enzyme");
@@ -336,7 +336,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
336336
.opt_str("compare-mode")
337337
.map(|s| s.parse().expect("invalid --compare-mode provided")),
338338
rustfix_coverage: matches.opt_present("rustfix-coverage"),
339-
has_tidy,
339+
has_html_tidy,
340340
has_enzyme,
341341
channel: matches.opt_str("channel").unwrap(),
342342
git_hash: matches.opt_present("git-hash"),

src/tools/compiletest/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() {
1818

1919
let config = Arc::new(parse_config(env::args().collect()));
2020

21-
if !config.has_tidy && config.mode == Mode::Rustdoc {
21+
if !config.has_html_tidy && config.mode == Mode::Rustdoc {
2222
eprintln!("warning: `tidy` (html-tidy.org) is not installed; diffs will not be generated");
2323
}
2424

src/tools/compiletest/src/runtest.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore-tidy-filelength
2-
31
use std::borrow::Cow;
42
use std::collections::{HashMap, HashSet};
53
use std::ffi::OsString;
@@ -1897,7 +1895,7 @@ impl<'test> TestCx<'test> {
18971895
}
18981896

18991897
fn compare_to_default_rustdoc(&mut self, out_dir: &Path) {
1900-
if !self.config.has_tidy {
1898+
if !self.config.has_html_tidy {
19011899
return;
19021900
}
19031901
println!("info: generating a diff against nightly rustdoc");

0 commit comments

Comments
 (0)