Skip to content

Commit de977a5

Browse files
committed
Auto merge of rust-lang#131970 - matthiaskrgr:rollup-nr32ksd, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#121560 (Allow `#[deny]` inside `#[forbid]` as a no-op) - rust-lang#131365 (Fix missing rustfmt in msi installer rust-lang#101993) - rust-lang#131647 (Register `src/tools/unicode-table-generator` as a runnable tool) - rust-lang#131843 (compiler: Error on layout of enums with invalid reprs) - 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`) - rust-lang#131964 (add latest crash tests) - rust-lang#131965 (remove outdated comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents bfab34a + a860657 commit de977a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+606
-83
lines changed

Cargo.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -5570,13 +5570,6 @@ dependencies = [
55705570
"version_check",
55715571
]
55725572

5573-
[[package]]
5574-
name = "unicode-bdd"
5575-
version = "0.1.0"
5576-
dependencies = [
5577-
"ucd-parse",
5578-
]
5579-
55805573
[[package]]
55815574
name = "unicode-bidi"
55825575
version = "0.3.15"
@@ -5626,6 +5619,13 @@ version = "1.12.0"
56265619
source = "registry+https://github.com/rust-lang/crates.io-index"
56275620
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
56285621

5622+
[[package]]
5623+
name = "unicode-table-generator"
5624+
version = "0.1.0"
5625+
dependencies = [
5626+
"ucd-parse",
5627+
]
5628+
56295629
[[package]]
56305630
name = "unicode-width"
56315631
version = "0.1.14"

compiler/rustc_abi/src/layout.rs

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pub enum LayoutCalculatorError<F> {
5454

5555
/// A union had no fields.
5656
EmptyUnion,
57+
58+
/// The fields or variants have irreconcilable reprs
59+
ReprConflict,
5760
}
5861

5962
impl<F> LayoutCalculatorError<F> {
@@ -64,6 +67,7 @@ impl<F> LayoutCalculatorError<F> {
6467
}
6568
LayoutCalculatorError::SizeOverflow => LayoutCalculatorError::SizeOverflow,
6669
LayoutCalculatorError::EmptyUnion => LayoutCalculatorError::EmptyUnion,
70+
LayoutCalculatorError::ReprConflict => LayoutCalculatorError::ReprConflict,
6771
}
6872
}
6973

@@ -77,6 +81,7 @@ impl<F> LayoutCalculatorError<F> {
7781
}
7882
LayoutCalculatorError::SizeOverflow => "size overflow",
7983
LayoutCalculatorError::EmptyUnion => "type is a union with no fields",
84+
LayoutCalculatorError::ReprConflict => "type has an invalid repr",
8085
})
8186
}
8287
}
@@ -514,6 +519,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
514519
}
515520

516521
let dl = self.cx.data_layout();
522+
// bail if the enum has an incoherent repr that cannot be computed
523+
if repr.packed() {
524+
return Err(LayoutCalculatorError::ReprConflict);
525+
}
517526

518527
let calculate_niche_filling_layout = || -> Option<TmpLayout<FieldIdx, VariantIdx>> {
519528
if dont_niche_optimize_enum {

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

compiler/rustc_lint/src/levels.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
493493
//
494494
// This means that this only errors if we're truly lowering the lint
495495
// level from forbid.
496-
if self.lint_added_lints && level != Level::Forbid && old_level == Level::Forbid {
496+
if self.lint_added_lints && level == Level::Deny && old_level == Level::Forbid {
497+
// Having a deny inside a forbid is fine and is ignored, so we skip this check.
498+
return;
499+
} else if self.lint_added_lints && level != Level::Forbid && old_level == Level::Forbid {
497500
// Backwards compatibility check:
498501
//
499502
// We used to not consider `forbid(lint_group)`

compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ declare_lint! {
156156
///
157157
/// ```rust
158158
/// #![forbid(warnings)]
159-
/// #![deny(bad_style)]
159+
/// #![warn(bad_style)]
160160
///
161161
/// fn main() {}
162162
/// ```

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

-3
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ provide! { tcx, def_id, other, cdata,
437437

438438
pub(in crate::rmeta) fn provide(providers: &mut Providers) {
439439
provide_cstore_hooks(providers);
440-
// FIXME(#44234) - almost all of these queries have no sub-queries and
441-
// therefore no actual inputs, they're just reading tables calculated in
442-
// resolve! Does this work? Unsure! That's what the issue is about
443440
providers.queries = rustc_middle::query::Providers {
444441
allocator_kind: |tcx, ()| CStore::from_tcx(tcx).allocator_kind(),
445442
alloc_error_handler_kind: |tcx, ()| CStore::from_tcx(tcx).alloc_error_handler_kind(),

compiler/rustc_ty_utils/src/layout.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ use {rustc_abi as abi, rustc_hir as hir};
3030
use crate::errors::{
3131
MultipleArrayFieldsSimdType, NonPrimitiveSimdType, OversizedSimdType, ZeroLengthSimdType,
3232
};
33-
use crate::layout_sanity_check::sanity_check_layout;
33+
34+
mod invariant;
3435

3536
pub(crate) fn provide(providers: &mut Providers) {
3637
*providers = Providers { layout_of, ..*providers };
@@ -79,7 +80,7 @@ fn layout_of<'tcx>(
7980
record_layout_for_printing(&cx, layout);
8081
}
8182

82-
sanity_check_layout(&cx, &layout);
83+
invariant::partially_check_layout(&cx, &layout);
8384

8485
Ok(layout)
8586
}
@@ -115,6 +116,11 @@ fn map_error<'tcx>(
115116
cx.tcx().dcx().delayed_bug(format!("computed layout of empty union: {ty:?}"));
116117
LayoutError::Unknown(ty)
117118
}
119+
LayoutCalculatorError::ReprConflict => {
120+
// packed enums are the only known trigger of this, but others might arise
121+
cx.tcx().dcx().delayed_bug(format!("computed impossible repr (packed enum?): {ty:?}"));
122+
LayoutError::Unknown(ty)
123+
}
118124
};
119125
error(cx, err)
120126
}

compiler/rustc_ty_utils/src/layout_sanity_check.rs compiler/rustc_ty_utils/src/layout/invariant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, TyAndLayout};
55
use rustc_target::abi::*;
66

77
/// Enforce some basic invariants on layouts.
8-
pub(super) fn sanity_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayout<'tcx>) {
8+
pub(super) fn partially_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayout<'tcx>) {
99
let tcx = cx.tcx();
1010

1111
// Type-level uninhabitedness should always imply ABI uninhabitedness.

compiler/rustc_ty_utils/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod errors;
2929
mod implied_bounds;
3030
mod instance;
3131
mod layout;
32-
mod layout_sanity_check;
3332
mod needs_drop;
3433
mod opaque_types;
3534
mod representability;

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/bootstrap/src/core/build_steps/dist.rs

+39-4
Original file line numberDiff line numberDiff line change
@@ -1591,9 +1591,15 @@ impl Step for Extended {
15911591
prepare("cargo");
15921592
prepare("rust-std");
15931593
prepare("rust-analysis");
1594-
prepare("clippy");
1595-
prepare("rust-analyzer");
1596-
for tool in &["rust-docs", "miri", "rustc-codegen-cranelift"] {
1594+
1595+
for tool in &[
1596+
"clippy",
1597+
"rustfmt",
1598+
"rust-analyzer",
1599+
"rust-docs",
1600+
"miri",
1601+
"rustc-codegen-cranelift",
1602+
] {
15971603
if built_tools.contains(tool) {
15981604
prepare(tool);
15991605
}
@@ -1633,6 +1639,8 @@ impl Step for Extended {
16331639
"rust-analyzer-preview".to_string()
16341640
} else if name == "clippy" {
16351641
"clippy-preview".to_string()
1642+
} else if name == "rustfmt" {
1643+
"rustfmt-preview".to_string()
16361644
} else if name == "miri" {
16371645
"miri-preview".to_string()
16381646
} else if name == "rustc-codegen-cranelift" {
@@ -1652,7 +1660,7 @@ impl Step for Extended {
16521660
prepare("cargo");
16531661
prepare("rust-analysis");
16541662
prepare("rust-std");
1655-
for tool in &["clippy", "rust-analyzer", "rust-docs", "miri"] {
1663+
for tool in &["clippy", "rustfmt", "rust-analyzer", "rust-docs", "miri"] {
16561664
if built_tools.contains(tool) {
16571665
prepare(tool);
16581666
}
@@ -1770,6 +1778,24 @@ impl Step for Extended {
17701778
.arg(etc.join("msi/remove-duplicates.xsl"))
17711779
.run(builder);
17721780
}
1781+
if built_tools.contains("rustfmt") {
1782+
command(&heat)
1783+
.current_dir(&exe)
1784+
.arg("dir")
1785+
.arg("rustfmt")
1786+
.args(heat_flags)
1787+
.arg("-cg")
1788+
.arg("RustFmtGroup")
1789+
.arg("-dr")
1790+
.arg("RustFmt")
1791+
.arg("-var")
1792+
.arg("var.RustFmtDir")
1793+
.arg("-out")
1794+
.arg(exe.join("RustFmtGroup.wxs"))
1795+
.arg("-t")
1796+
.arg(etc.join("msi/remove-duplicates.xsl"))
1797+
.run(builder);
1798+
}
17731799
if built_tools.contains("miri") {
17741800
command(&heat)
17751801
.current_dir(&exe)
@@ -1841,6 +1867,9 @@ impl Step for Extended {
18411867
if built_tools.contains("clippy") {
18421868
cmd.arg("-dClippyDir=clippy");
18431869
}
1870+
if built_tools.contains("rustfmt") {
1871+
cmd.arg("-dRustFmtDir=rustfmt");
1872+
}
18441873
if built_tools.contains("rust-docs") {
18451874
cmd.arg("-dDocsDir=rust-docs");
18461875
}
@@ -1867,6 +1896,9 @@ impl Step for Extended {
18671896
if built_tools.contains("clippy") {
18681897
candle("ClippyGroup.wxs".as_ref());
18691898
}
1899+
if built_tools.contains("rustfmt") {
1900+
candle("RustFmtGroup.wxs".as_ref());
1901+
}
18701902
if built_tools.contains("miri") {
18711903
candle("MiriGroup.wxs".as_ref());
18721904
}
@@ -1905,6 +1937,9 @@ impl Step for Extended {
19051937
if built_tools.contains("clippy") {
19061938
cmd.arg("ClippyGroup.wixobj");
19071939
}
1940+
if built_tools.contains("rustfmt") {
1941+
cmd.arg("RustFmtGroup.wixobj");
1942+
}
19081943
if built_tools.contains("miri") {
19091944
cmd.arg("MiriGroup.wixobj");
19101945
}

src/bootstrap/src/core/build_steps/run.rs

+22
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,25 @@ impl Step for GenerateCompletions {
283283
run.builder.ensure(GenerateCompletions);
284284
}
285285
}
286+
287+
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
288+
pub struct UnicodeTableGenerator;
289+
290+
impl Step for UnicodeTableGenerator {
291+
type Output = ();
292+
const ONLY_HOSTS: bool = true;
293+
294+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
295+
run.path("src/tools/unicode-table-generator")
296+
}
297+
298+
fn make_run(run: RunConfig<'_>) {
299+
run.builder.ensure(UnicodeTableGenerator);
300+
}
301+
302+
fn run(self, builder: &Builder<'_>) {
303+
let mut cmd = builder.tool_cmd(Tool::UnicodeTableGenerator);
304+
cmd.arg(builder.src.join("library/core/src/unicode/unicode_data.rs"));
305+
cmd.run(builder);
306+
}
307+
}

src/bootstrap/src/core/build_steps/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ bootstrap_tool!(
360360
CoverageDump, "src/tools/coverage-dump", "coverage-dump";
361361
RustcPerfWrapper, "src/tools/rustc-perf-wrapper", "rustc-perf-wrapper";
362362
WasmComponentLd, "src/tools/wasm-component-ld", "wasm-component-ld", is_unstable_tool = true, allow_features = "min_specialization";
363+
UnicodeTableGenerator, "src/tools/unicode-table-generator", "unicode-table-generator";
363364
);
364365

365366
/// These are the submodules that are required for rustbook to work due to

src/bootstrap/src/core/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,7 @@ impl<'a> Builder<'a> {
10101010
run::GenerateCopyright,
10111011
run::GenerateWindowsSys,
10121012
run::GenerateCompletions,
1013+
run::UnicodeTableGenerator,
10131014
),
10141015
Kind::Setup => {
10151016
describe!(setup::Profile, setup::Hook, setup::Link, setup::Editor)

0 commit comments

Comments
 (0)