1
Fork 0

Auto merge of #103264 - matthiaskrgr:rollup-3ja4spo, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #103211 (rustdoc: remove class name `location` from sidebar sibling nav)
 - #103223 (Use already checked RHS ty for LHS deref suggestions)
 - #103237 (Clean up codeblock-tooltip rustdoc-gui test)
 - #103239 (Allow #[unstable] impls for fn() with unstable abi.)
 - #103246 (Mark `rust-analyzer` as a host-only tool)
 - #103257 (rustdoc: move `setting-line` color CSS to settings.css)
 - #103258 (Make miri read_dir test a little more robust)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-10-19 21:17:09 +00:00
commit 57781b24c5
20 changed files with 517 additions and 323 deletions

View file

@ -1130,11 +1130,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
}; };
self.check_lhs_assignable(lhs, "E0070", span, |err| {
let rhs_ty = self.check_expr(&rhs);
suggest_deref_binop(err, rhs_ty);
});
// This is (basically) inlined `check_expr_coercable_to_type`, but we want // This is (basically) inlined `check_expr_coercable_to_type`, but we want
// to suggest an additional fixup here in `suggest_deref_binop`. // to suggest an additional fixup here in `suggest_deref_binop`.
let rhs_ty = self.check_expr_with_hint(&rhs, lhs_ty); let rhs_ty = self.check_expr_with_hint(&rhs, lhs_ty);
@ -1145,6 +1140,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
diag.emit(); diag.emit();
} }
self.check_lhs_assignable(lhs, "E0070", span, |err| {
if let Some(rhs_ty) = self.typeck_results.borrow().expr_ty_opt(rhs) {
suggest_deref_binop(err, rhs_ty);
}
});
self.require_type_is_sized(lhs_ty, lhs.span, traits::AssignmentLhsSized); self.require_type_is_sized(lhs_ty, lhs.span, traits::AssignmentLhsSized);
if lhs_ty.references_error() || rhs_ty.references_error() { if lhs_ty.references_error() || rhs_ty.references_error() {

View file

@ -891,8 +891,25 @@ impl<'tcx> Visitor<'tcx> for CheckTraitImplStable<'tcx> {
if let TyKind::Never = t.kind { if let TyKind::Never = t.kind {
self.fully_stable = false; self.fully_stable = false;
} }
if let TyKind::BareFn(f) = t.kind {
if rustc_target::spec::abi::is_stable(f.abi.name()).is_err() {
self.fully_stable = false;
}
}
intravisit::walk_ty(self, t) intravisit::walk_ty(self, t)
} }
fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl<'tcx>) {
for ty in fd.inputs {
self.visit_ty(ty)
}
if let hir::FnRetTy::Return(output_ty) = fd.output {
match output_ty.kind {
TyKind::Never => {} // `-> !` is stable
_ => self.visit_ty(output_ty),
}
}
}
} }
/// Given the list of enabled features that were not language features (i.e., that /// Given the list of enabled features that were not language features (i.e., that

View file

@ -109,175 +109,125 @@ pub enum AbiDisabled {
Unrecognized, Unrecognized,
} }
fn gate_feature_post(
features: &rustc_feature::Features,
feature: Symbol,
span: Span,
explain: &'static str,
) -> Result<(), AbiDisabled> {
if !features.enabled(feature) && !span.allows_unstable(feature) {
Err(AbiDisabled::Unstable { feature, explain })
} else {
Ok(())
}
}
pub fn is_enabled( pub fn is_enabled(
features: &rustc_feature::Features, features: &rustc_feature::Features,
span: Span, span: Span,
name: &str, name: &str,
) -> Result<(), AbiDisabled> { ) -> Result<(), AbiDisabled> {
let s = is_stable(name);
if let Err(AbiDisabled::Unstable { feature, .. }) = s {
if features.enabled(feature) || span.allows_unstable(feature) {
return Ok(());
}
}
s
}
pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
match name { match name {
// Stable // Stable
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64" "Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
| "system" => Ok(()), | "system" => Ok(()),
"rust-intrinsic" => { "rust-intrinsic" => Err(AbiDisabled::Unstable {
gate_feature_post(features, sym::intrinsics, span, "intrinsics are subject to change") feature: sym::intrinsics,
} explain: "intrinsics are subject to change",
"platform-intrinsic" => gate_feature_post( }),
features, "platform-intrinsic" => Err(AbiDisabled::Unstable {
sym::platform_intrinsics, feature: sym::platform_intrinsics,
span, explain: "platform intrinsics are experimental and possibly buggy",
"platform intrinsics are experimental and possibly buggy", }),
), "vectorcall" => Err(AbiDisabled::Unstable {
"vectorcall" => gate_feature_post( feature: sym::abi_vectorcall,
features, explain: "vectorcall is experimental and subject to change",
sym::abi_vectorcall, }),
span, "thiscall" => Err(AbiDisabled::Unstable {
"vectorcall is experimental and subject to change", feature: sym::abi_thiscall,
), explain: "thiscall is experimental and subject to change",
"thiscall" => gate_feature_post( }),
features, "rust-call" => Err(AbiDisabled::Unstable {
sym::abi_thiscall, feature: sym::unboxed_closures,
span, explain: "rust-call ABI is subject to change",
"thiscall is experimental and subject to change", }),
), "rust-cold" => Err(AbiDisabled::Unstable {
"rust-call" => gate_feature_post( feature: sym::rust_cold_cc,
features, explain: "rust-cold is experimental and subject to change",
sym::unboxed_closures, }),
span, "ptx-kernel" => Err(AbiDisabled::Unstable {
"rust-call ABI is subject to change", feature: sym::abi_ptx,
), explain: "PTX ABIs are experimental and subject to change",
"rust-cold" => gate_feature_post( }),
features, "unadjusted" => Err(AbiDisabled::Unstable {
sym::rust_cold_cc, feature: sym::abi_unadjusted,
span, explain: "unadjusted ABI is an implementation detail and perma-unstable",
"rust-cold is experimental and subject to change", }),
), "msp430-interrupt" => Err(AbiDisabled::Unstable {
"ptx-kernel" => gate_feature_post( feature: sym::abi_msp430_interrupt,
features, explain: "msp430-interrupt ABI is experimental and subject to change",
sym::abi_ptx, }),
span, "x86-interrupt" => Err(AbiDisabled::Unstable {
"PTX ABIs are experimental and subject to change", feature: sym::abi_x86_interrupt,
), explain: "x86-interrupt ABI is experimental and subject to change",
"unadjusted" => gate_feature_post( }),
features, "amdgpu-kernel" => Err(AbiDisabled::Unstable {
sym::abi_unadjusted, feature: sym::abi_amdgpu_kernel,
span, explain: "amdgpu-kernel ABI is experimental and subject to change",
"unadjusted ABI is an implementation detail and perma-unstable", }),
), "avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable {
"msp430-interrupt" => gate_feature_post( feature: sym::abi_avr_interrupt,
features, explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
sym::abi_msp430_interrupt, }),
span, "efiapi" => Err(AbiDisabled::Unstable {
"msp430-interrupt ABI is experimental and subject to change", feature: sym::abi_efiapi,
), explain: "efiapi ABI is experimental and subject to change",
"x86-interrupt" => gate_feature_post( }),
features, "C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable {
sym::abi_x86_interrupt, feature: sym::abi_c_cmse_nonsecure_call,
span, explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
"x86-interrupt ABI is experimental and subject to change", }),
), "C-unwind" => Err(AbiDisabled::Unstable {
"amdgpu-kernel" => gate_feature_post( feature: sym::c_unwind,
features, explain: "C-unwind ABI is experimental and subject to change",
sym::abi_amdgpu_kernel, }),
span, "stdcall-unwind" => Err(AbiDisabled::Unstable {
"amdgpu-kernel ABI is experimental and subject to change", feature: sym::c_unwind,
), explain: "stdcall-unwind ABI is experimental and subject to change",
"avr-interrupt" | "avr-non-blocking-interrupt" => gate_feature_post( }),
features, "system-unwind" => Err(AbiDisabled::Unstable {
sym::abi_avr_interrupt, feature: sym::c_unwind,
span, explain: "system-unwind ABI is experimental and subject to change",
"avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change", }),
), "thiscall-unwind" => Err(AbiDisabled::Unstable {
"efiapi" => gate_feature_post( feature: sym::c_unwind,
features, explain: "thiscall-unwind ABI is experimental and subject to change",
sym::abi_efiapi, }),
span, "cdecl-unwind" => Err(AbiDisabled::Unstable {
"efiapi ABI is experimental and subject to change", feature: sym::c_unwind,
), explain: "cdecl-unwind ABI is experimental and subject to change",
"C-cmse-nonsecure-call" => gate_feature_post( }),
features, "fastcall-unwind" => Err(AbiDisabled::Unstable {
sym::abi_c_cmse_nonsecure_call, feature: sym::c_unwind,
span, explain: "fastcall-unwind ABI is experimental and subject to change",
"C-cmse-nonsecure-call ABI is experimental and subject to change", }),
), "vectorcall-unwind" => Err(AbiDisabled::Unstable {
"C-unwind" => gate_feature_post( feature: sym::c_unwind,
features, explain: "vectorcall-unwind ABI is experimental and subject to change",
sym::c_unwind, }),
span, "aapcs-unwind" => Err(AbiDisabled::Unstable {
"C-unwind ABI is experimental and subject to change", feature: sym::c_unwind,
), explain: "aapcs-unwind ABI is experimental and subject to change",
"stdcall-unwind" => gate_feature_post( }),
features, "win64-unwind" => Err(AbiDisabled::Unstable {
sym::c_unwind, feature: sym::c_unwind,
span, explain: "win64-unwind ABI is experimental and subject to change",
"stdcall-unwind ABI is experimental and subject to change", }),
), "sysv64-unwind" => Err(AbiDisabled::Unstable {
"system-unwind" => gate_feature_post( feature: sym::c_unwind,
features, explain: "sysv64-unwind ABI is experimental and subject to change",
sym::c_unwind, }),
span, "wasm" => Err(AbiDisabled::Unstable {
"system-unwind ABI is experimental and subject to change", feature: sym::wasm_abi,
), explain: "wasm ABI is experimental and subject to change",
"thiscall-unwind" => gate_feature_post( }),
features,
sym::c_unwind,
span,
"thiscall-unwind ABI is experimental and subject to change",
),
"cdecl-unwind" => gate_feature_post(
features,
sym::c_unwind,
span,
"cdecl-unwind ABI is experimental and subject to change",
),
"fastcall-unwind" => gate_feature_post(
features,
sym::c_unwind,
span,
"fastcall-unwind ABI is experimental and subject to change",
),
"vectorcall-unwind" => gate_feature_post(
features,
sym::c_unwind,
span,
"vectorcall-unwind ABI is experimental and subject to change",
),
"aapcs-unwind" => gate_feature_post(
features,
sym::c_unwind,
span,
"aapcs-unwind ABI is experimental and subject to change",
),
"win64-unwind" => gate_feature_post(
features,
sym::c_unwind,
span,
"win64-unwind ABI is experimental and subject to change",
),
"sysv64-unwind" => gate_feature_post(
features,
sym::c_unwind,
span,
"sysv64-unwind ABI is experimental and subject to change",
),
"wasm" => gate_feature_post(
features,
sym::wasm_abi,
span,
"wasm ABI is experimental and subject to change",
),
_ => Err(AbiDisabled::Unrecognized), _ => Err(AbiDisabled::Unrecognized),
} }
} }

View file

@ -698,7 +698,7 @@ pub struct RustAnalyzer {
impl Step for RustAnalyzer { impl Step for RustAnalyzer {
type Output = Option<PathBuf>; type Output = Option<PathBuf>;
const DEFAULT: bool = true; const DEFAULT: bool = true;
const ONLY_HOSTS: bool = false; const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder; let builder = run.builder;
@ -742,7 +742,7 @@ pub struct RustAnalyzerProcMacroSrv {
impl Step for RustAnalyzerProcMacroSrv { impl Step for RustAnalyzerProcMacroSrv {
type Output = Option<PathBuf>; type Output = Option<PathBuf>;
const DEFAULT: bool = true; const DEFAULT: bool = true;
const ONLY_HOSTS: bool = false; const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder; let builder = run.builder;

View file

@ -1884,7 +1884,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
if !it.is_mod() { if !it.is_mod() {
let path: String = cx.current.iter().map(|s| s.as_str()).intersperse("::").collect(); let path: String = cx.current.iter().map(|s| s.as_str()).intersperse("::").collect();
write!(buffer, "<h2 class=\"location\"><a href=\"index.html\">In {}</a></h2>", path); write!(buffer, "<h2><a href=\"index.html\">In {}</a></h2>", path);
} }
// Closes sidebar-elems div. // Closes sidebar-elems div.

View file

@ -171,7 +171,7 @@ h1.fqn {
Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc) Rustdoc-generated h2 section headings (e.g. "Implementations", "Required Methods", etc)
Underlines elsewhere in the documentation break up visual flow and tend to invert Underlines elsewhere in the documentation break up visual flow and tend to invert
section hierarchies. */ section hierarchies. */
h2, .content h2,
.top-doc .docblock > h3, .top-doc .docblock > h3,
.top-doc .docblock > h4 { .top-doc .docblock > h4 {
border-bottom: 1px solid var(--headings-border-bottom-color); border-bottom: 1px solid var(--headings-border-bottom-color);
@ -397,15 +397,6 @@ img {
left: 0; left: 0;
} }
.sidebar-elems,
.sidebar > .location {
padding-left: 24px;
}
.sidebar .location {
overflow-wrap: anywhere;
}
.rustdoc.source .sidebar { .rustdoc.source .sidebar {
width: 50px; width: 50px;
min-width: 0px; min-width: 0px;
@ -505,8 +496,8 @@ ul.block, .block li {
} }
.block a, .block a,
.sidebar h3 a, .sidebar h2 a,
h2.location a { .sidebar h3 a {
display: block; display: block;
padding: 0.25rem; padding: 0.25rem;
margin-left: -0.25rem; margin-left: -0.25rem;
@ -516,8 +507,7 @@ h2.location a {
} }
.sidebar h2 { .sidebar h2 {
border-bottom: none; overflow-wrap: anywhere;
font-weight: 500;
padding: 0; padding: 0;
margin: 0; margin: 0;
margin-top: 0.7rem; margin-top: 0.7rem;
@ -526,11 +516,15 @@ h2.location a {
.sidebar h3 { .sidebar h3 {
font-size: 1.125rem; /* 18px */ font-size: 1.125rem; /* 18px */
font-weight: 500;
padding: 0; padding: 0;
margin: 0; margin: 0;
} }
.sidebar-elems,
.sidebar > h2 {
padding-left: 24px;
}
.sidebar a, .sidebar .current { .sidebar a, .sidebar .current {
color: var(--sidebar-link-color); color: var(--sidebar-link-color);
} }
@ -1474,25 +1468,6 @@ h3.variant {
animation: rotating 2s linear infinite; animation: rotating 2s linear infinite;
} }
.setting-line .radio-line input:checked {
box-shadow: inset 0 0 0 3px var(--main-background-color);
background-color: var(--settings-input-color);
}
.setting-line .radio-line input:focus {
box-shadow: 0 0 1px 1px var(--settings-input-color);
}
/* In here we combine both `:focus` and `:checked` properties. */
.setting-line .radio-line input:checked:focus {
box-shadow: inset 0 0 0 3px var(--main-background-color),
0 0 2px 2px var(--settings-input-color);
}
.setting-line .radio-line input:hover {
border-color: var(--settings-input-color) !important;
}
input:checked + .slider {
background-color: var(--settings-input-color);
}
#help-button > a { #help-button > a {
text-align: center; text-align: center;
/* Rare exception to specifying font sizes in rem. Since this is acting /* Rare exception to specifying font sizes in rem. Since this is acting
@ -1788,18 +1763,10 @@ in storage.js
width: 0; width: 0;
} }
.mobile-topbar .location a { .mobile-topbar h2 {
padding: 0; padding-bottom: 0;
margin: 0;
}
.mobile-topbar .location {
border: none;
padding: 0;
margin: auto 0.5em auto auto; margin: auto 0.5em auto auto;
text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
white-space: nowrap;
/* Rare exception to specifying font sizes in rem. Since the topbar /* Rare exception to specifying font sizes in rem. Since the topbar
height is specified in pixels, this also has to be specified in height is specified in pixels, this also has to be specified in
pixels to avoid overflowing the topbar when the user sets a bigger pixels to avoid overflowing the topbar when the user sets a bigger
@ -1807,6 +1774,13 @@ in storage.js
font-size: 24px; font-size: 24px;
} }
.mobile-topbar h2 a {
display: block;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.mobile-topbar .logo-container { .mobile-topbar .logo-container {
max-height: 45px; max-height: 45px;
} }

View file

@ -89,3 +89,22 @@ input:checked + .slider:before {
#settings .setting-line { #settings .setting-line {
margin: 1.2em 0.6em; margin: 1.2em 0.6em;
} }
.setting-line .radio-line input:checked {
box-shadow: inset 0 0 0 3px var(--main-background-color);
background-color: var(--settings-input-color);
}
.setting-line .radio-line input:focus {
box-shadow: 0 0 1px 1px var(--settings-input-color);
}
/* In here we combine both `:focus` and `:checked` properties. */
.setting-line .radio-line input:checked:focus {
box-shadow: inset 0 0 0 3px var(--main-background-color),
0 0 2px 2px var(--settings-input-color);
}
.setting-line .radio-line input:hover {
border-color: var(--settings-input-color) !important;
}
input:checked + .slider {
background-color: var(--settings-input-color);
}

View file

@ -55,7 +55,7 @@ function blurHandler(event, parentElem, hideCallback) {
function setMobileTopbar() { function setMobileTopbar() {
// FIXME: It would be nicer to generate this text content directly in HTML, // FIXME: It would be nicer to generate this text content directly in HTML,
// but with the current code it's hard to get the right information in the right place. // but with the current code it's hard to get the right information in the right place.
const mobileLocationTitle = document.querySelector(".mobile-topbar h2.location"); const mobileLocationTitle = document.querySelector(".mobile-topbar h2");
const locationTitle = document.querySelector(".sidebar h2.location"); const locationTitle = document.querySelector(".sidebar h2.location");
if (mobileLocationTitle && locationTitle) { if (mobileLocationTitle && locationTitle) {
mobileLocationTitle.innerHTML = locationTitle.innerHTML; mobileLocationTitle.innerHTML = locationTitle.innerHTML;

View file

@ -85,7 +85,7 @@
{%- endif -%} {%- endif -%}
</div> {#- -#} </div> {#- -#}
</a> {#- -#} </a> {#- -#}
<h2 class="location"></h2> {#- -#} <h2></h2> {#- -#}
</nav> {#- -#} </nav> {#- -#}
{%- endif -%} {%- endif -%}
<nav class="sidebar"> {#- -#} <nav class="sidebar"> {#- -#}

View file

@ -2,95 +2,79 @@
goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
show-text: true show-text: true
// Dark theme. define-function: (
local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"} "check-colors",
reload: (theme),
[
// Setting the theme.
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
("reload"),
// compile_fail block // compile_fail block
assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) ("assert-css", (
assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) ".docblock .example-wrap.compile_fail .tooltip",
{"color": "rgba(255, 0, 0, 0.5)"},
)),
("assert-css", (
".docblock .example-wrap.compile_fail",
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
)),
move-cursor-to: ".docblock .example-wrap.compile_fail" ("move-cursor-to", ".docblock .example-wrap.compile_fail"),
assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"}) ("assert-css", (
assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"}) ".docblock .example-wrap.compile_fail .tooltip",
{"color": "rgb(255, 0, 0)"},
)),
("assert-css", (
".docblock .example-wrap.compile_fail",
{"border-left": "2px solid rgb(255, 0, 0)"},
)),
// should_panic block // should_panic block
assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"}) ("assert-css", (
assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"}) ".docblock .example-wrap.should_panic .tooltip",
{"color": "rgba(255, 0, 0, 0.5)"},
)),
("assert-css", (
".docblock .example-wrap.should_panic",
{"border-left": "2px solid rgba(255, 0, 0, 0.5)"},
)),
move-cursor-to: ".docblock .example-wrap.should_panic" ("move-cursor-to", ".docblock .example-wrap.should_panic"),
assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"}) ("assert-css", (
assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"}) ".docblock .example-wrap.should_panic .tooltip",
{"color": "rgb(255, 0, 0)"},
)),
("assert-css", (
".docblock .example-wrap.should_panic",
{"border-left": "2px solid rgb(255, 0, 0)"},
)),
// ignore block // ignore block
assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"}) ("assert-css", (
assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"}) ".docblock .example-wrap.ignore .tooltip",
{"color": "rgba(255, 142, 0, 0.6)"},
)),
("assert-css", (
".docblock .example-wrap.ignore",
{"border-left": "2px solid rgba(255, 142, 0, 0.6)"},
)),
move-cursor-to: ".docblock .example-wrap.ignore" ("move-cursor-to", ".docblock .example-wrap.ignore"),
assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"}) ("assert-css", (
assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"}) ".docblock .example-wrap.ignore .tooltip",
{"color": "rgb(255, 142, 0)"},
)),
("assert-css", (
".docblock .example-wrap.ignore",
{"border-left": "2px solid rgb(255, 142, 0)"},
)),
],
)
call-function: ("check-colors", ("ayu"))
// Light theme. call-function: ("check-colors", ("dark"))
local-storage: {"rustdoc-theme": "light"} call-function: ("check-colors", ("light"))
reload:
assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"})
assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"})
move-cursor-to: ".docblock .example-wrap.compile_fail"
assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"})
assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"})
// should_panic block
assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"})
assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"})
move-cursor-to: ".docblock .example-wrap.should_panic"
assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"})
assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"})
// ignore block
assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"})
assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"})
move-cursor-to: ".docblock .example-wrap.ignore"
assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"})
assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"})
// Ayu theme.
local-storage: {"rustdoc-theme": "ayu"}
reload:
assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgba(255, 0, 0, 0.5)"})
assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"})
move-cursor-to: ".docblock .example-wrap.compile_fail"
assert-css: (".docblock .example-wrap.compile_fail .tooltip", {"color": "rgb(255, 0, 0)"})
assert-css: (".docblock .example-wrap.compile_fail", {"border-left": "2px solid rgb(255, 0, 0)"})
// should_panic block
assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgba(255, 0, 0, 0.5)"})
assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgba(255, 0, 0, 0.5)"})
move-cursor-to: ".docblock .example-wrap.should_panic"
assert-css: (".docblock .example-wrap.should_panic .tooltip", {"color": "rgb(255, 0, 0)"})
assert-css: (".docblock .example-wrap.should_panic", {"border-left": "2px solid rgb(255, 0, 0)"})
// ignore block
assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgba(255, 142, 0, 0.6)"})
assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgba(255, 142, 0, 0.6)"})
move-cursor-to: ".docblock .example-wrap.ignore"
assert-css: (".docblock .example-wrap.ignore .tooltip", {"color": "rgb(255, 142, 0)"})
assert-css: (".docblock .example-wrap.ignore", {"border-left": "2px solid rgb(255, 142, 0)"})

View file

@ -12,7 +12,7 @@ assert-css: (".main-heading", {
"flex-direction": "column" "flex-direction": "column"
}) })
assert-property: (".mobile-topbar h2.location", {"offsetHeight": 36}) assert-property: (".mobile-topbar h2", {"offsetHeight": 36})
// Note: We can't use assert-text here because the 'Since' is set by CSS and // Note: We can't use assert-text here because the 'Since' is set by CSS and
// is therefore not part of the DOM. // is therefore not part of the DOM.

View file

@ -23,6 +23,11 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
click: ".sidebar-menu-toggle" click: ".sidebar-menu-toggle"
assert-css: (".sidebar", {"left": "0px"}) assert-css: (".sidebar", {"left": "0px"})
// Make sure the "struct Foo" header is hidden, since the mobile topbar already does it.
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='Foo']/parent::h2", {"display": "none"})
// Make sure the global navigation is still here.
assert-css: ("//nav[contains(@class, 'sidebar')]//h2/a[text()='In test_docs']/parent::h2", {"display": "block"})
// Click elsewhere. // Click elsewhere.
click: "body" click: "body"
assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
@ -39,7 +44,7 @@ assert-position: ("#method\.must_use", {"y": 45})
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view. // Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
click: ".sidebar-menu-toggle" click: ".sidebar-menu-toggle"
scroll-to: ".block.keyword li:nth-child(1)" scroll-to: ".block.keyword li:nth-child(1)"
compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543}) compare-elements-position-near: (".block.keyword li:nth-child(1)", ".mobile-topbar", {"y": 543.19})
// Now checking the background color of the sidebar. // Now checking the background color of the sidebar.
show-text: true show-text: true

View file

@ -9,6 +9,7 @@ reload:
assert-text: (".sidebar > .location", "Crate test_docs") assert-text: (".sidebar > .location", "Crate test_docs")
// In modules, we only have one "location" element. // In modules, we only have one "location" element.
assert-count: (".sidebar .location", 1) assert-count: (".sidebar .location", 1)
assert-count: (".sidebar h2", 1)
assert-text: ("#all-types", "All Items") assert-text: ("#all-types", "All Items")
assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"}) assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
// We check that we have the crates list and that the "current" on is "test_docs". // We check that we have the crates list and that the "current" on is "test_docs".
@ -28,7 +29,8 @@ assert-text: ("#structs + .item-table .item-left > a", "Foo")
click: "#structs + .item-table .item-left > a" click: "#structs + .item-table .item-left > a"
// PAGE: struct.Foo.html // PAGE: struct.Foo.html
assert-count: (".sidebar .location", 2) assert-count: (".sidebar .location", 1)
assert-count: (".sidebar h2", 2)
// We check that there is no crate listed outside of the top level. // We check that there is no crate listed outside of the top level.
assert-false: ".sidebar-elems > .crate" assert-false: ".sidebar-elems > .crate"
@ -60,10 +62,11 @@ assert-text: ("#functions + .item-table .item-left > a", "foobar")
click: "#functions + .item-table .item-left > a" click: "#functions + .item-table .item-left > a"
// PAGE: fn.foobar.html // PAGE: fn.foobar.html
// In items containing no items (like functions or constants) and in modules, we have one // In items containing no items (like functions or constants) and in modules, we have no
// "location" elements. // "location" elements. Only the parent module h2.
assert-count: (".sidebar .location", 1) assert-count: (".sidebar .location", 0)
assert-text: (".sidebar .sidebar-elems .location", "In lib2") assert-count: (".sidebar h2", 1)
assert-text: (".sidebar .sidebar-elems h2", "In lib2")
// We check that we don't have the crate list. // We check that we don't have the crate list.
assert-false: ".sidebar-elems > .crate" assert-false: ".sidebar-elems > .crate"

View file

@ -32,6 +32,6 @@ assert-property: (".item-decl pre", {"scrollWidth": "950"})
size: (600, 600) size: (600, 600)
goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html" goto: "file://" + |DOC_PATH| + "/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html"
// It shouldn't have an overflow in the topbar either. // It shouldn't have an overflow in the topbar either.
store-property: (scrollWidth, ".mobile-topbar .location", "scrollWidth") store-property: (scrollWidth, ".mobile-topbar h2", "scrollWidth")
assert-property: (".mobile-topbar .location", {"clientWidth": |scrollWidth|}) assert-property: (".mobile-topbar h2", {"clientWidth": |scrollWidth|})
assert-css: (".mobile-topbar .location", {"overflow-x": "hidden"}) assert-css: (".mobile-topbar h2", {"overflow-x": "hidden"})

View file

@ -1,4 +1,4 @@
#![feature(staged_api)] #![feature(staged_api, never_type, c_unwind)]
//~^ ERROR module has missing stability attribute //~^ ERROR module has missing stability attribute
#[stable(feature = "a", since = "1")] #[stable(feature = "a", since = "1")]
@ -23,7 +23,21 @@ impl StableTrait for UnstableType {}
impl UnstableTrait for StableType {} impl UnstableTrait for StableType {}
#[unstable(feature = "h", issue = "none")] #[unstable(feature = "h", issue = "none")]
impl StableTrait for ! {}
// Note: If C-unwind is stabilized, switch this to another (unstable) ABI.
#[unstable(feature = "i", issue = "none")]
impl StableTrait for extern "C-unwind" fn() {}
#[unstable(feature = "j", issue = "none")]
//~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl] //~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl]
impl StableTrait for StableType {} impl StableTrait for StableType {}
#[unstable(feature = "k", issue = "none")]
//~^ ERROR an `#[unstable]` annotation here has no effect [ineffective_unstable_trait_impl]
impl StableTrait for fn() -> ! {}
#[unstable(feature = "l", issue = "none")]
impl StableTrait for fn() -> UnstableType {}
fn main() {} fn main() {}

View file

@ -1,16 +1,24 @@
error: an `#[unstable]` annotation here has no effect error: an `#[unstable]` annotation here has no effect
--> $DIR/stability-attribute-trait-impl.rs:25:1 --> $DIR/stability-attribute-trait-impl.rs:32:1
| |
LL | #[unstable(feature = "h", issue = "none")] LL | #[unstable(feature = "j", issue = "none")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information = note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information
= note: `#[deny(ineffective_unstable_trait_impl)]` on by default = note: `#[deny(ineffective_unstable_trait_impl)]` on by default
error: an `#[unstable]` annotation here has no effect
--> $DIR/stability-attribute-trait-impl.rs:36:1
|
LL | #[unstable(feature = "k", issue = "none")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #55436 <https://github.com/rust-lang/rust/issues/55436> for more information
error: module has missing stability attribute error: module has missing stability attribute
--> $DIR/stability-attribute-trait-impl.rs:1:1 --> $DIR/stability-attribute-trait-impl.rs:1:1
| |
LL | / #![feature(staged_api)] LL | / #![feature(staged_api, never_type, c_unwind)]
LL | | LL | |
LL | | LL | |
LL | | #[stable(feature = "a", since = "1")] LL | | #[stable(feature = "a", since = "1")]
@ -19,5 +27,5 @@ LL | |
LL | | fn main() {} LL | | fn main() {}
| |____________^ | |____________^
error: aborting due to 2 previous errors error: aborting due to 3 previous errors

View file

@ -0,0 +1,26 @@
fn main() {
1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
//~^ ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
//~| ERROR invalid left-hand side of assignment
}

View file

@ -0,0 +1,187 @@
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:95
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:91
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:87
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:83
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:79
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:75
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:71
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:67
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:63
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:59
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:55
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:51
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:47
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:43
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:39
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:35
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:31
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:27
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:23
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:19
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:15
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:11
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error[E0070]: invalid left-hand side of assignment
--> $DIR/slow-lhs-suggestion.rs:2:7
|
LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
| - ^
| |
| cannot assign to this expression
error: aborting due to 23 previous errors
For more information about this error, try `rustc --explain E0070`.

View file

@ -4,7 +4,8 @@
#![feature(io_error_more)] #![feature(io_error_more)]
#![feature(io_error_uncategorized)] #![feature(io_error_uncategorized)]
use std::ffi::CString; use std::collections::HashMap;
use std::ffi::{CString, OsString};
use std::fs::{ use std::fs::{
create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename, File, create_dir, read_dir, read_link, remove_dir, remove_dir_all, remove_file, rename, File,
OpenOptions, OpenOptions,
@ -394,29 +395,34 @@ fn test_directory() {
// Creating a directory when it already exists should fail. // Creating a directory when it already exists should fail.
assert_eq!(ErrorKind::AlreadyExists, create_dir(&dir_path).unwrap_err().kind()); assert_eq!(ErrorKind::AlreadyExists, create_dir(&dir_path).unwrap_err().kind());
// Create some files inside the directory // Create some files and dirs inside the directory
let path_1 = dir_path.join("test_file_1"); let path_1 = dir_path.join("test_file_1");
drop(File::create(&path_1).unwrap()); drop(File::create(&path_1).unwrap());
let path_2 = dir_path.join("test_file_2"); let path_2 = dir_path.join("test_file_2");
drop(File::create(&path_2).unwrap()); drop(File::create(&path_2).unwrap());
// Test that the files are present inside the directory let dir_1 = dir_path.join("test_dir_1");
let dir_iter = read_dir(&dir_path).unwrap(); create_dir(&dir_1).unwrap();
let mut file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();
file_names.sort_unstable();
assert_eq!(file_names, vec!["test_file_1", "test_file_2"]);
// Test that read_dir metadata calls succeed // Test that read_dir metadata calls succeed
assert_eq!( assert_eq!(
&[true, true], HashMap::from([
&*read_dir(&dir_path) (OsString::from("test_file_1"), true),
(OsString::from("test_file_2"), true),
(OsString::from("test_dir_1"), false)
]),
read_dir(&dir_path)
.unwrap() .unwrap()
.map(|e| e.unwrap().metadata().unwrap().is_file()) .map(|e| {
.collect::<Vec<_>>() let e = e.unwrap();
(e.file_name(), e.metadata().unwrap().is_file())
})
.collect::<HashMap<_, _>>()
); );
// Deleting the directory should fail, since it is not empty. // Deleting the directory should fail, since it is not empty.
assert_eq!(ErrorKind::DirectoryNotEmpty, remove_dir(&dir_path).unwrap_err().kind()); assert_eq!(ErrorKind::DirectoryNotEmpty, remove_dir(&dir_path).unwrap_err().kind());
// Clean up the files in the directory // Clean up the files in the directory
remove_file(&path_1).unwrap(); remove_file(&path_1).unwrap();
remove_file(&path_2).unwrap(); remove_file(&path_2).unwrap();
remove_dir(&dir_1).unwrap();
// Now there should be nothing left in the directory. // Now there should be nothing left in the directory.
let dir_iter = read_dir(&dir_path).unwrap(); let dir_iter = read_dir(&dir_path).unwrap();
let file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>(); let file_names = dir_iter.map(|e| e.unwrap().file_name()).collect::<Vec<_>>();