Skip to content

Commit 77972d2

Browse files
committed
Auto merge of #97126 - JohnTitor:rollup-7gdt2aw, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #96647 (rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate) - #96651 (Omit unnecessary help to add `#[cfg(test)]` when already annotated) - #96761 (rustdoc: don't build `rayon` for non-windows targets) - #97096 (Types with reachable constructors are reachable) - #97097 (Add tmm_reg clobbers) - #97113 (Search GUI fixes) - #97116 (interpret/validity: reject references to uninhabited types) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4c5f6e6 + 248890c commit 77972d2

File tree

31 files changed

+459
-53
lines changed

31 files changed

+459
-53
lines changed

compiler/rustc_codegen_gcc/src/asm.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
592592
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => unimplemented!(),
593593
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(),
594594
InlineAsmRegClass::X86(
595-
X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg,
595+
X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg | X86InlineAsmRegClass::tmm_reg,
596596
) => unreachable!("clobber-only"),
597597
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
598598
bug!("GCC backend does not support SPIR-V")
@@ -656,6 +656,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
656656
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg) => unimplemented!(),
657657
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => cx.type_i16(),
658658
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => cx.type_i16(),
659+
InlineAsmRegClass::X86(X86InlineAsmRegClass::tmm_reg) => unimplemented!(),
659660
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
660661
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
661662
bug!("LLVM backend does not support SPIR-V")
@@ -787,7 +788,7 @@ fn modifier_to_gcc(arch: InlineAsmArch, reg: InlineAsmRegClass, modifier: Option
787788
},
788789
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => None,
789790
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => None,
790-
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg) => {
791+
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg | X86InlineAsmRegClass::tmm_reg) => {
791792
unreachable!("clobber-only")
792793
}
793794
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(),

compiler/rustc_codegen_llvm/src/asm.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
604604
InlineAsmRegClass::X86(
605605
X86InlineAsmRegClass::x87_reg
606606
| X86InlineAsmRegClass::mmx_reg
607-
| X86InlineAsmRegClass::kreg0,
607+
| X86InlineAsmRegClass::kreg0
608+
| X86InlineAsmRegClass::tmm_reg,
608609
) => unreachable!("clobber-only"),
609610
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r",
610611
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r",
@@ -692,7 +693,8 @@ fn modifier_to_llvm(
692693
InlineAsmRegClass::X86(
693694
X86InlineAsmRegClass::x87_reg
694695
| X86InlineAsmRegClass::mmx_reg
695-
| X86InlineAsmRegClass::kreg0,
696+
| X86InlineAsmRegClass::kreg0
697+
| X86InlineAsmRegClass::tmm_reg,
696698
) => {
697699
unreachable!("clobber-only")
698700
}
@@ -766,7 +768,8 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
766768
InlineAsmRegClass::X86(
767769
X86InlineAsmRegClass::x87_reg
768770
| X86InlineAsmRegClass::mmx_reg
769-
| X86InlineAsmRegClass::kreg0,
771+
| X86InlineAsmRegClass::kreg0
772+
| X86InlineAsmRegClass::tmm_reg,
770773
) => {
771774
unreachable!("clobber-only")
772775
}

compiler/rustc_const_eval/src/interpret/validity.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -412,22 +412,27 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
412412
self.path,
413413
err_ub!(AlignmentCheckFailed { required, has }) =>
414414
{
415-
"an unaligned {} (required {} byte alignment but found {})",
416-
kind,
415+
"an unaligned {kind} (required {} byte alignment but found {})",
417416
required.bytes(),
418417
has.bytes()
419418
},
420419
err_ub!(DanglingIntPointer(0, _)) =>
421-
{ "a null {}", kind },
420+
{ "a null {kind}" },
422421
err_ub!(DanglingIntPointer(i, _)) =>
423-
{ "a dangling {} (address 0x{:x} is unallocated)", kind, i },
422+
{ "a dangling {kind} (address 0x{i:x} is unallocated)" },
424423
err_ub!(PointerOutOfBounds { .. }) =>
425-
{ "a dangling {} (going beyond the bounds of its allocation)", kind },
424+
{ "a dangling {kind} (going beyond the bounds of its allocation)" },
426425
// This cannot happen during const-eval (because interning already detects
427426
// dangling pointers), but it can happen in Miri.
428427
err_ub!(PointerUseAfterFree(..)) =>
429-
{ "a dangling {} (use-after-free)", kind },
428+
{ "a dangling {kind} (use-after-free)" },
430429
);
430+
// Do not allow pointers to uninhabited types.
431+
if place.layout.abi.is_uninhabited() {
432+
throw_validation_failure!(self.path,
433+
{ "a {kind} pointing to uninhabited type {}", place.layout.ty }
434+
)
435+
}
431436
// Recursive checking
432437
if let Some(ref mut ref_tracking) = self.ref_tracking {
433438
// Proceed recursively even for ZST, no reason to skip them!

compiler/rustc_privacy/src/lib.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,14 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
775775
}
776776
// Corner case: if the variant is reachable, but its
777777
// enum is not, make the enum reachable as well.
778-
self.update(item.def_id, variant_level);
778+
self.reach(item.def_id, variant_level).ty();
779+
}
780+
if let Some(hir_id) = variant.data.ctor_hir_id() {
781+
let ctor_def_id = self.tcx.hir().local_def_id(hir_id);
782+
let ctor_level = self.get(ctor_def_id);
783+
if ctor_level.is_some() {
784+
self.reach(item.def_id, ctor_level).ty();
785+
}
779786
}
780787
}
781788
}
@@ -803,6 +810,13 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
803810
}
804811
}
805812
}
813+
if let Some(hir_id) = struct_def.ctor_hir_id() {
814+
let ctor_def_id = self.tcx.hir().local_def_id(hir_id);
815+
let ctor_level = self.get(ctor_def_id);
816+
if ctor_level.is_some() {
817+
self.reach(item.def_id, ctor_level).ty();
818+
}
819+
}
806820
}
807821
}
808822

compiler/rustc_resolve/src/check_unused.rs

+21-14
Original file line numberDiff line numberDiff line change
@@ -315,21 +315,28 @@ impl Resolver<'_> {
315315
"remove the unused import"
316316
};
317317

318-
let parent_module = visitor.r.get_nearest_non_block_module(
319-
visitor.r.local_def_id(unused.use_tree_id).to_def_id(),
320-
);
321-
let test_module_span = match module_to_string(parent_module) {
322-
Some(module)
323-
if module == "test"
324-
|| module == "tests"
325-
|| module.starts_with("test_")
326-
|| module.starts_with("tests_")
327-
|| module.ends_with("_test")
328-
|| module.ends_with("_tests") =>
329-
{
330-
Some(parent_module.span)
318+
// If we are in the `--test` mode, suppress a help that adds the `#[cfg(test)]`
319+
// attribute; however, if not, suggest adding the attribute. There is no way to
320+
// retrieve attributes here because we do not have a `TyCtxt` yet.
321+
let test_module_span = if visitor.r.session.opts.test {
322+
None
323+
} else {
324+
let parent_module = visitor.r.get_nearest_non_block_module(
325+
visitor.r.local_def_id(unused.use_tree_id).to_def_id(),
326+
);
327+
match module_to_string(parent_module) {
328+
Some(module)
329+
if module == "test"
330+
|| module == "tests"
331+
|| module.starts_with("test_")
332+
|| module.starts_with("tests_")
333+
|| module.ends_with("_test")
334+
|| module.ends_with("_tests") =>
335+
{
336+
Some(parent_module.span)
337+
}
338+
_ => None,
331339
}
332-
_ => None,
333340
};
334341

335342
visitor.r.lint_buffer.buffer_lint_with_diagnostic(

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,7 @@ symbols! {
14081408
thread_local_macro,
14091409
thumb2,
14101410
thumb_mode: "thumb-mode",
1411+
tmm_reg,
14111412
todo_macro,
14121413
tool_attributes,
14131414
tool_lints,

compiler/rustc_target/src/asm/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ impl InlineAsmClobberAbi {
912912

913913
mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7,
914914
st0, st1, st2, st3, st4, st5, st6, st7,
915+
tmm0, tmm1, tmm2, tmm3, tmm4, tmm5, tmm6, tmm7,
915916
}
916917
},
917918
InlineAsmClobberAbi::X86_64Win => clobbered_regs! {
@@ -931,6 +932,7 @@ impl InlineAsmClobberAbi {
931932

932933
mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7,
933934
st0, st1, st2, st3, st4, st5, st6, st7,
935+
tmm0, tmm1, tmm2, tmm3, tmm4, tmm5, tmm6, tmm7,
934936
}
935937
},
936938
InlineAsmClobberAbi::AArch64 => clobbered_regs! {

compiler/rustc_target/src/asm/x86.rs

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def_reg_class! {
1717
kreg0,
1818
mmx_reg,
1919
x87_reg,
20+
tmm_reg,
2021
}
2122
}
2223

@@ -41,6 +42,7 @@ impl X86InlineAsmRegClass {
4142
Self::xmm_reg | Self::ymm_reg | Self::zmm_reg => &['x', 'y', 'z'],
4243
Self::kreg | Self::kreg0 => &[],
4344
Self::mmx_reg | Self::x87_reg => &[],
45+
Self::tmm_reg => &[],
4446
}
4547
}
4648

@@ -80,6 +82,7 @@ impl X86InlineAsmRegClass {
8082
},
8183
Self::kreg | Self::kreg0 => None,
8284
Self::mmx_reg | Self::x87_reg => None,
85+
Self::tmm_reg => None,
8386
}
8487
}
8588

@@ -98,6 +101,7 @@ impl X86InlineAsmRegClass {
98101
Self::zmm_reg => Some(('z', "zmm0")),
99102
Self::kreg | Self::kreg0 => None,
100103
Self::mmx_reg | Self::x87_reg => None,
104+
Self::tmm_reg => None,
101105
}
102106
}
103107

@@ -135,6 +139,7 @@ impl X86InlineAsmRegClass {
135139
},
136140
Self::kreg0 => &[],
137141
Self::mmx_reg | Self::x87_reg => &[],
142+
Self::tmm_reg => &[],
138143
}
139144
}
140145
}
@@ -320,6 +325,14 @@ def_regs! {
320325
st5: x87_reg = ["st(5)"],
321326
st6: x87_reg = ["st(6)"],
322327
st7: x87_reg = ["st(7)"],
328+
tmm0: tmm_reg = ["tmm0"] % x86_64_only,
329+
tmm1: tmm_reg = ["tmm1"] % x86_64_only,
330+
tmm2: tmm_reg = ["tmm2"] % x86_64_only,
331+
tmm3: tmm_reg = ["tmm3"] % x86_64_only,
332+
tmm4: tmm_reg = ["tmm4"] % x86_64_only,
333+
tmm5: tmm_reg = ["tmm5"] % x86_64_only,
334+
tmm6: tmm_reg = ["tmm6"] % x86_64_only,
335+
tmm7: tmm_reg = ["tmm7"] % x86_64_only,
323336
#error = ["bp", "bpl", "ebp", "rbp"] =>
324337
"the frame pointer cannot be used as an operand for inline asm",
325338
#error = ["sp", "spl", "esp", "rsp"] =>
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.1
1+
0.9.2

src/librustdoc/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ askama = { version = "0.11", default-features = false, features = ["config"] }
1212
atty = "0.2"
1313
pulldown-cmark = { version = "0.9", default-features = false }
1414
minifier = "0.0.43"
15-
rayon = "1.5.1"
1615
serde = { version = "1.0", features = ["derive"] }
1716
serde_json = "1.0"
1817
smallvec = "1.6.1"
@@ -29,6 +28,9 @@ version = "0.3.3"
2928
default-features = false
3029
features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"]
3130

31+
[target.'cfg(windows)'.dependencies]
32+
rayon = "1.5.1"
33+
3234
[dev-dependencies]
3335
expect-test = "1.0"
3436

src/librustdoc/docfs.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ impl DocFS {
5454
where
5555
E: PathError,
5656
{
57-
if !self.sync_only && cfg!(windows) {
57+
#[cfg(windows)]
58+
if !self.sync_only {
5859
// A possible future enhancement after more detailed profiling would
5960
// be to create the file sync so errors are reported eagerly.
6061
let sender = self.errors.clone().expect("can't write after closing");
@@ -68,6 +69,10 @@ impl DocFS {
6869
} else {
6970
fs::write(&path, contents).map_err(|e| E::new(e, path))?;
7071
}
72+
73+
#[cfg(not(windows))]
74+
fs::write(&path, contents).map_err(|e| E::new(e, path))?;
75+
7176
Ok(())
7277
}
7378
}

src/librustdoc/html/static/css/rustdoc.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ table,
897897
margin-left: 0.25em;
898898
padding-left: 0.3125em;
899899
padding-right: 23px;
900-
border: 0;
900+
border: 1px solid;
901901
border-radius: 4px;
902902
outline: none;
903903
cursor: pointer;
@@ -2010,7 +2010,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
20102010

20112011
#crate-search {
20122012
border-radius: 4px;
2013-
border: 0;
20142013
}
20152014

20162015
.docblock {

src/librustdoc/html/static/css/themes/ayu.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ details.undocumented > summary::before {
236236

237237
#crate-search, .search-input {
238238
background-color: #141920;
239-
border-color: #424c57;
240-
color: #c5c5c5;
239+
/* Without the `!important`, the border-color is ignored for `<select>`... */
240+
border-color: #424c57 !important;
241241
}
242242

243243
.search-input {

src/librustdoc/html/static/css/themes/dark.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ details.undocumented > summary::before {
217217
#crate-search, .search-input {
218218
color: #111;
219219
background-color: #f0f0f0;
220-
border-color: #000;
220+
/* Without the `!important`, the border-color is ignored for `<select>`... */
221+
border-color: #f0f0f0 !important;
221222
}
222223

223224
.search-input {

src/librustdoc/html/static/css/themes/light.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ details.undocumented > summary::before {
209209
}
210210

211211
#crate-search, .search-input {
212-
color: #555;
213212
background-color: white;
214-
border-color: #e0e0e0;
213+
/* Without the `!important`, the border-color is ignored for `<select>`... */
214+
border-color: #e0e0e0 !important;
215215
}
216216

217217
.search-input:focus {

src/librustdoc/html/static/js/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ function initSearch(rawSearchIndex) {
17381738

17391739
let output = "<div id=\"search-settings\">" +
17401740
`<h1 class="search-results-title">Results for ${escape(results.query.userQuery)}` +
1741-
`${typeFilter}</h1> in ${crates} </div>`;
1741+
`${typeFilter}</h1>${crates}</div>`;
17421742
if (results.query.error !== null) {
17431743
output += `<h3>Query parser error: "${results.query.error}".</h3>`;
17441744
output += "<div id=\"titles\">" +

src/librustdoc/json/conversions.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,16 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
350350
fn from_tcx(predicate: clean::WherePredicate, tcx: TyCtxt<'_>) -> Self {
351351
use clean::WherePredicate::*;
352352
match predicate {
353-
BoundPredicate { ty, bounds, .. } => WherePredicate::BoundPredicate {
353+
BoundPredicate { ty, bounds, bound_params } => WherePredicate::BoundPredicate {
354354
type_: ty.into_tcx(tcx),
355355
bounds: bounds.into_iter().map(|x| x.into_tcx(tcx)).collect(),
356-
// FIXME: add `bound_params` to rustdoc-json-params?
356+
generic_params: bound_params
357+
.into_iter()
358+
.map(|x| GenericParamDef {
359+
name: x.0.to_string(),
360+
kind: GenericParamDefKind::Lifetime { outlives: vec![] },
361+
})
362+
.collect(),
357363
},
358364
RegionPredicate { lifetime, bounds } => WherePredicate::RegionPredicate {
359365
lifetime: lifetime.0.to_string(),

0 commit comments

Comments
 (0)