Skip to content

Commit

Permalink
Auto merge of rust-lang#97126 - JohnTitor:rollup-7gdt2aw, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#96647 (rustdoc-json: Fix HRTBs for WherePredicate::BoundPredicate)
 - rust-lang#96651 (Omit unnecessary help to add `#[cfg(test)]` when already annotated)
 - rust-lang#96761 (rustdoc: don't build `rayon` for non-windows targets)
 - rust-lang#97096 (Types with reachable constructors are reachable)
 - rust-lang#97097 (Add tmm_reg clobbers)
 - rust-lang#97113 (Search GUI fixes)
 - rust-lang#97116 (interpret/validity: reject references to uninhabited types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed May 18, 2022
2 parents 4c5f6e6 + 248890c commit 77972d2
Show file tree
Hide file tree
Showing 31 changed files with 459 additions and 53 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_gcc/src/asm.rs
Expand Up @@ -592,7 +592,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => unimplemented!(),
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(),
InlineAsmRegClass::X86(
X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg,
X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg | X86InlineAsmRegClass::tmm_reg,
) => unreachable!("clobber-only"),
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("GCC backend does not support SPIR-V")
Expand Down Expand Up @@ -656,6 +656,7 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg) => unimplemented!(),
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => cx.type_i16(),
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => cx.type_i16(),
InlineAsmRegClass::X86(X86InlineAsmRegClass::tmm_reg) => unimplemented!(),
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
Expand Down Expand Up @@ -787,7 +788,7 @@ fn modifier_to_gcc(arch: InlineAsmArch, reg: InlineAsmRegClass, modifier: Option
},
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg) => None,
InlineAsmRegClass::X86(X86InlineAsmRegClass::kreg0) => None,
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg) => {
InlineAsmRegClass::X86(X86InlineAsmRegClass::x87_reg | X86InlineAsmRegClass::mmx_reg | X86InlineAsmRegClass::tmm_reg) => {
unreachable!("clobber-only")
}
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => unimplemented!(),
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_codegen_llvm/src/asm.rs
Expand Up @@ -604,7 +604,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
InlineAsmRegClass::X86(
X86InlineAsmRegClass::x87_reg
| X86InlineAsmRegClass::mmx_reg
| X86InlineAsmRegClass::kreg0,
| X86InlineAsmRegClass::kreg0
| X86InlineAsmRegClass::tmm_reg,
) => unreachable!("clobber-only"),
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r",
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r",
Expand Down Expand Up @@ -692,7 +693,8 @@ fn modifier_to_llvm(
InlineAsmRegClass::X86(
X86InlineAsmRegClass::x87_reg
| X86InlineAsmRegClass::mmx_reg
| X86InlineAsmRegClass::kreg0,
| X86InlineAsmRegClass::kreg0
| X86InlineAsmRegClass::tmm_reg,
) => {
unreachable!("clobber-only")
}
Expand Down Expand Up @@ -766,7 +768,8 @@ fn dummy_output_type<'ll>(cx: &CodegenCx<'ll, '_>, reg: InlineAsmRegClass) -> &'
InlineAsmRegClass::X86(
X86InlineAsmRegClass::x87_reg
| X86InlineAsmRegClass::mmx_reg
| X86InlineAsmRegClass::kreg0,
| X86InlineAsmRegClass::kreg0
| X86InlineAsmRegClass::tmm_reg,
) => {
unreachable!("clobber-only")
}
Expand Down
17 changes: 11 additions & 6 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Expand Up @@ -412,22 +412,27 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
self.path,
err_ub!(AlignmentCheckFailed { required, has }) =>
{
"an unaligned {} (required {} byte alignment but found {})",
kind,
"an unaligned {kind} (required {} byte alignment but found {})",
required.bytes(),
has.bytes()
},
err_ub!(DanglingIntPointer(0, _)) =>
{ "a null {}", kind },
{ "a null {kind}" },
err_ub!(DanglingIntPointer(i, _)) =>
{ "a dangling {} (address 0x{:x} is unallocated)", kind, i },
{ "a dangling {kind} (address 0x{i:x} is unallocated)" },
err_ub!(PointerOutOfBounds { .. }) =>
{ "a dangling {} (going beyond the bounds of its allocation)", kind },
{ "a dangling {kind} (going beyond the bounds of its allocation)" },
// This cannot happen during const-eval (because interning already detects
// dangling pointers), but it can happen in Miri.
err_ub!(PointerUseAfterFree(..)) =>
{ "a dangling {} (use-after-free)", kind },
{ "a dangling {kind} (use-after-free)" },
);
// Do not allow pointers to uninhabited types.
if place.layout.abi.is_uninhabited() {
throw_validation_failure!(self.path,
{ "a {kind} pointing to uninhabited type {}", place.layout.ty }
)
}
// Recursive checking
if let Some(ref mut ref_tracking) = self.ref_tracking {
// Proceed recursively even for ZST, no reason to skip them!
Expand Down
16 changes: 15 additions & 1 deletion compiler/rustc_privacy/src/lib.rs
Expand Up @@ -775,7 +775,14 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
}
// Corner case: if the variant is reachable, but its
// enum is not, make the enum reachable as well.
self.update(item.def_id, variant_level);
self.reach(item.def_id, variant_level).ty();
}
if let Some(hir_id) = variant.data.ctor_hir_id() {
let ctor_def_id = self.tcx.hir().local_def_id(hir_id);
let ctor_level = self.get(ctor_def_id);
if ctor_level.is_some() {
self.reach(item.def_id, ctor_level).ty();
}
}
}
}
Expand Down Expand Up @@ -803,6 +810,13 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> {
}
}
}
if let Some(hir_id) = struct_def.ctor_hir_id() {
let ctor_def_id = self.tcx.hir().local_def_id(hir_id);
let ctor_level = self.get(ctor_def_id);
if ctor_level.is_some() {
self.reach(item.def_id, ctor_level).ty();
}
}
}
}

Expand Down
35 changes: 21 additions & 14 deletions compiler/rustc_resolve/src/check_unused.rs
Expand Up @@ -315,21 +315,28 @@ impl Resolver<'_> {
"remove the unused import"
};

let parent_module = visitor.r.get_nearest_non_block_module(
visitor.r.local_def_id(unused.use_tree_id).to_def_id(),
);
let test_module_span = match module_to_string(parent_module) {
Some(module)
if module == "test"
|| module == "tests"
|| module.starts_with("test_")
|| module.starts_with("tests_")
|| module.ends_with("_test")
|| module.ends_with("_tests") =>
{
Some(parent_module.span)
// If we are in the `--test` mode, suppress a help that adds the `#[cfg(test)]`
// attribute; however, if not, suggest adding the attribute. There is no way to
// retrieve attributes here because we do not have a `TyCtxt` yet.
let test_module_span = if visitor.r.session.opts.test {
None
} else {
let parent_module = visitor.r.get_nearest_non_block_module(
visitor.r.local_def_id(unused.use_tree_id).to_def_id(),
);
match module_to_string(parent_module) {
Some(module)
if module == "test"
|| module == "tests"
|| module.starts_with("test_")
|| module.starts_with("tests_")
|| module.ends_with("_test")
|| module.ends_with("_tests") =>
{
Some(parent_module.span)
}
_ => None,
}
_ => None,
};

visitor.r.lint_buffer.buffer_lint_with_diagnostic(
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Expand Up @@ -1408,6 +1408,7 @@ symbols! {
thread_local_macro,
thumb2,
thumb_mode: "thumb-mode",
tmm_reg,
todo_macro,
tool_attributes,
tool_lints,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/asm/mod.rs
Expand Up @@ -912,6 +912,7 @@ impl InlineAsmClobberAbi {

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

mm0, mm1, mm2, mm3, mm4, mm5, mm6, mm7,
st0, st1, st2, st3, st4, st5, st6, st7,
tmm0, tmm1, tmm2, tmm3, tmm4, tmm5, tmm6, tmm7,
}
},
InlineAsmClobberAbi::AArch64 => clobbered_regs! {
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_target/src/asm/x86.rs
Expand Up @@ -17,6 +17,7 @@ def_reg_class! {
kreg0,
mmx_reg,
x87_reg,
tmm_reg,
}
}

Expand All @@ -41,6 +42,7 @@ impl X86InlineAsmRegClass {
Self::xmm_reg | Self::ymm_reg | Self::zmm_reg => &['x', 'y', 'z'],
Self::kreg | Self::kreg0 => &[],
Self::mmx_reg | Self::x87_reg => &[],
Self::tmm_reg => &[],
}
}

Expand Down Expand Up @@ -80,6 +82,7 @@ impl X86InlineAsmRegClass {
},
Self::kreg | Self::kreg0 => None,
Self::mmx_reg | Self::x87_reg => None,
Self::tmm_reg => None,
}
}

Expand All @@ -98,6 +101,7 @@ impl X86InlineAsmRegClass {
Self::zmm_reg => Some(('z', "zmm0")),
Self::kreg | Self::kreg0 => None,
Self::mmx_reg | Self::x87_reg => None,
Self::tmm_reg => None,
}
}

Expand Down Expand Up @@ -135,6 +139,7 @@ impl X86InlineAsmRegClass {
},
Self::kreg0 => &[],
Self::mmx_reg | Self::x87_reg => &[],
Self::tmm_reg => &[],
}
}
}
Expand Down Expand Up @@ -320,6 +325,14 @@ def_regs! {
st5: x87_reg = ["st(5)"],
st6: x87_reg = ["st(6)"],
st7: x87_reg = ["st(7)"],
tmm0: tmm_reg = ["tmm0"] % x86_64_only,
tmm1: tmm_reg = ["tmm1"] % x86_64_only,
tmm2: tmm_reg = ["tmm2"] % x86_64_only,
tmm3: tmm_reg = ["tmm3"] % x86_64_only,
tmm4: tmm_reg = ["tmm4"] % x86_64_only,
tmm5: tmm_reg = ["tmm5"] % x86_64_only,
tmm6: tmm_reg = ["tmm6"] % x86_64_only,
tmm7: tmm_reg = ["tmm7"] % x86_64_only,
#error = ["bp", "bpl", "ebp", "rbp"] =>
"the frame pointer cannot be used as an operand for inline asm",
#error = ["sp", "spl", "esp", "rsp"] =>
Expand Down
@@ -1 +1 @@
0.9.1
0.9.2
4 changes: 3 additions & 1 deletion src/librustdoc/Cargo.toml
Expand Up @@ -12,7 +12,6 @@ askama = { version = "0.11", default-features = false, features = ["config"] }
atty = "0.2"
pulldown-cmark = { version = "0.9", default-features = false }
minifier = "0.0.43"
rayon = "1.5.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
smallvec = "1.6.1"
Expand All @@ -29,6 +28,9 @@ version = "0.3.3"
default-features = false
features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"]

[target.'cfg(windows)'.dependencies]
rayon = "1.5.1"

[dev-dependencies]
expect-test = "1.0"

Expand Down
7 changes: 6 additions & 1 deletion src/librustdoc/docfs.rs
Expand Up @@ -54,7 +54,8 @@ impl DocFS {
where
E: PathError,
{
if !self.sync_only && cfg!(windows) {
#[cfg(windows)]
if !self.sync_only {
// A possible future enhancement after more detailed profiling would
// be to create the file sync so errors are reported eagerly.
let sender = self.errors.clone().expect("can't write after closing");
Expand All @@ -68,6 +69,10 @@ impl DocFS {
} else {
fs::write(&path, contents).map_err(|e| E::new(e, path))?;
}

#[cfg(not(windows))]
fs::write(&path, contents).map_err(|e| E::new(e, path))?;

Ok(())
}
}
3 changes: 1 addition & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Expand Up @@ -897,7 +897,7 @@ table,
margin-left: 0.25em;
padding-left: 0.3125em;
padding-right: 23px;
border: 0;
border: 1px solid;
border-radius: 4px;
outline: none;
cursor: pointer;
Expand Down Expand Up @@ -2010,7 +2010,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {

#crate-search {
border-radius: 4px;
border: 0;
}

.docblock {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/themes/ayu.css
Expand Up @@ -236,8 +236,8 @@ details.undocumented > summary::before {

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

.search-input {
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/css/themes/dark.css
Expand Up @@ -217,7 +217,8 @@ details.undocumented > summary::before {
#crate-search, .search-input {
color: #111;
background-color: #f0f0f0;
border-color: #000;
/* Without the `!important`, the border-color is ignored for `<select>`... */
border-color: #f0f0f0 !important;
}

.search-input {
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/css/themes/light.css
Expand Up @@ -209,9 +209,9 @@ details.undocumented > summary::before {
}

#crate-search, .search-input {
color: #555;
background-color: white;
border-color: #e0e0e0;
/* Without the `!important`, the border-color is ignored for `<select>`... */
border-color: #e0e0e0 !important;
}

.search-input:focus {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/search.js
Expand Up @@ -1738,7 +1738,7 @@ function initSearch(rawSearchIndex) {

let output = "<div id=\"search-settings\">" +
`<h1 class="search-results-title">Results for ${escape(results.query.userQuery)}` +
`${typeFilter}</h1> in ${crates} </div>`;
`${typeFilter}</h1>${crates}</div>`;
if (results.query.error !== null) {
output += `<h3>Query parser error: "${results.query.error}".</h3>`;
output += "<div id=\"titles\">" +
Expand Down
10 changes: 8 additions & 2 deletions src/librustdoc/json/conversions.rs
Expand Up @@ -350,10 +350,16 @@ impl FromWithTcx<clean::WherePredicate> for WherePredicate {
fn from_tcx(predicate: clean::WherePredicate, tcx: TyCtxt<'_>) -> Self {
use clean::WherePredicate::*;
match predicate {
BoundPredicate { ty, bounds, .. } => WherePredicate::BoundPredicate {
BoundPredicate { ty, bounds, bound_params } => WherePredicate::BoundPredicate {
type_: ty.into_tcx(tcx),
bounds: bounds.into_iter().map(|x| x.into_tcx(tcx)).collect(),
// FIXME: add `bound_params` to rustdoc-json-params?
generic_params: bound_params
.into_iter()
.map(|x| GenericParamDef {
name: x.0.to_string(),
kind: GenericParamDefKind::Lifetime { outlives: vec![] },
})
.collect(),
},
RegionPredicate { lifetime, bounds } => WherePredicate::RegionPredicate {
lifetime: lifetime.0.to_string(),
Expand Down

0 comments on commit 77972d2

Please sign in to comment.