Skip to content

Commit 8991768

Browse files
committed
Auto merge of rust-lang#110736 - matthiaskrgr:rollup-gorv8zp, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#110661 (rustdoc: clean up settings.css and settings.js) - rust-lang#110663 (Add note about change in bootstrap defaults) - rust-lang#110664 (stop `x fmt` formatting untracked directories) - rust-lang#110668 (Fix printing native CPU on cross-compiled compiler.) - rust-lang#110689 (Fix grammar in core::hint::unreachable_unchecked() docs) - rust-lang#110700 (Don't infer fn return type to return itself) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7f94b31 + 12858d9 commit 8991768

File tree

10 files changed

+68
-38
lines changed

10 files changed

+68
-38
lines changed

RELEASES.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ Compatibility Notes
8888
- [When `default-features` is set to false of a workspace dependency, and an inherited dependency of a member has `default-features = true`, Cargo will enable default features of that dependency.](https://github.com/rust-lang/cargo/pull/11409/)
8989
- [Cargo denies `CARGO_HOME` in the `[env]` configuration table. Cargo itself doesn't pick up this value, but recursive calls to cargo would, which was not intended.](https://github.com/rust-lang/cargo/pull/11644/)
9090
- [Debuginfo for build dependencies is now off if not explicitly set. This is expected to improve the overall build time.](https://github.com/rust-lang/cargo/pull/11252/)
91-
91+
- [The Rust distribution no longer always includes rustdoc](https://github.com/rust-lang/rust/pull/106886)
92+
If `tools = [...]` is set in config.toml, we will respect a missing rustdoc in that list. By
93+
default rustdoc remains included. To retain the prior behavior explicitly add `"rustdoc"` to the
94+
list.
95+
9296
<a id="1.69.0-Internal-Changes"></a>
9397

9498
Internal Changes

compiler/rustc_hir_analysis/src/collect.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -1146,24 +1146,22 @@ fn infer_return_ty_for_fn_sig<'tcx>(
11461146

11471147
let mut visitor = HirPlaceholderCollector::default();
11481148
visitor.visit_ty(ty);
1149+
11491150
let mut diag = bad_placeholder(tcx, visitor.0, "return type");
11501151
let ret_ty = fn_sig.output();
1152+
// Don't leak types into signatures unless they're nameable!
1153+
// For example, if a function returns itself, we don't want that
1154+
// recursive function definition to leak out into the fn sig.
1155+
let mut should_recover = false;
1156+
11511157
if let Some(ret_ty) = ret_ty.make_suggestable(tcx, false) {
11521158
diag.span_suggestion(
11531159
ty.span,
11541160
"replace with the correct return type",
11551161
ret_ty,
11561162
Applicability::MachineApplicable,
11571163
);
1158-
} else if matches!(ret_ty.kind(), ty::FnDef(..))
1159-
&& let Some(fn_sig) = ret_ty.fn_sig(tcx).make_suggestable(tcx, false)
1160-
{
1161-
diag.span_suggestion(
1162-
ty.span,
1163-
"replace with the correct return type",
1164-
fn_sig,
1165-
Applicability::MachineApplicable,
1166-
);
1164+
should_recover = true;
11671165
} else if let Some(sugg) = suggest_impl_trait(tcx, ret_ty, ty.span, def_id) {
11681166
diag.span_suggestion(
11691167
ty.span,
@@ -1181,9 +1179,20 @@ fn infer_return_ty_for_fn_sig<'tcx>(
11811179
https://doc.rust-lang.org/book/ch13-01-closures.html",
11821180
);
11831181
}
1184-
diag.emit();
11851182

1186-
ty::Binder::dummy(fn_sig)
1183+
let guar = diag.emit();
1184+
1185+
if should_recover {
1186+
ty::Binder::dummy(fn_sig)
1187+
} else {
1188+
ty::Binder::dummy(tcx.mk_fn_sig(
1189+
fn_sig.inputs().iter().copied(),
1190+
tcx.ty_error(guar),
1191+
fn_sig.c_variadic,
1192+
fn_sig.unsafety,
1193+
fn_sig.abi,
1194+
))
1195+
}
11871196
}
11881197
None => icx.astconv().ty_of_fn(
11891198
hir_id,

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,14 @@ static size_t getLongestEntryLength(ArrayRef<KV> Table) {
310310
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
311311
const TargetMachine *Target = unwrap(TM);
312312
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
313-
const Triple::ArchType HostArch = Triple(sys::getProcessTriple()).getArch();
313+
const Triple::ArchType HostArch = Triple(sys::getDefaultTargetTriple()).getArch();
314314
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
315315
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
316316
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
317317

318318
printf("Available CPUs for this target:\n");
319+
// Don't print the "native" entry when the user specifies --target with a
320+
// different arch since that could be wrong or misleading.
319321
if (HostArch == TargetArch) {
320322
const StringRef HostCPU = sys::getHostCPUName();
321323
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",

library/core/src/hint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ use crate::intrinsics;
7373
/// ```
7474
///
7575
/// While using `unreachable_unchecked()` is perfectly sound in the following
76-
/// example, the compiler is able to prove that a division by zero is not
77-
/// possible. Benchmarking reveals that `unreachable_unchecked()` provides
76+
/// example, as the compiler is able to prove that a division by zero is not
77+
/// possible, benchmarking reveals that `unreachable_unchecked()` provides
7878
/// no benefit over using [`unreachable!`], while the latter does not introduce
7979
/// the possibility of Undefined Behavior.
8080
///

src/bootstrap/format.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,8 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) {
145145
let untracked_paths = untracked_paths_output
146146
.lines()
147147
.filter(|entry| entry.starts_with("??"))
148-
.filter_map(|entry| {
149-
let path =
150-
entry.split(' ').nth(1).expect("every git status entry should list a path");
151-
path.ends_with(".rs").then_some(path)
148+
.map(|entry| {
149+
entry.split(' ').nth(1).expect("every git status entry should list a path")
152150
});
153151
for untracked_path in untracked_paths {
154152
println!("skip untracked path {} during rustfmt invocations", untracked_path);

src/librustdoc/html/static/css/settings.css

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
margin-right: 0.3em;
88
height: 1.2rem;
99
width: 1.2rem;
10-
color: inherit;
1110
border: 2px solid var(--settings-input-border-color);
1211
outline: none;
1312
-webkit-appearance: none;

src/librustdoc/html/static/js/settings.js

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Local js definitions:
2-
/* global getSettingValue, getVirtualKey, updateLocalStorage, updateTheme */
2+
/* global getSettingValue, updateLocalStorage, updateTheme */
33
/* global addClass, removeClass, onEach, onEachLazy, blurHandler, elemIsInParent */
44
/* global MAIN_ID, getVar, getSettingsButton */
55

@@ -32,21 +32,6 @@
3232
}
3333
}
3434

35-
function handleKey(ev) {
36-
// Don't interfere with browser shortcuts
37-
if (ev.ctrlKey || ev.altKey || ev.metaKey) {
38-
return;
39-
}
40-
switch (getVirtualKey(ev)) {
41-
case "Enter":
42-
case "Return":
43-
case "Space":
44-
ev.target.checked = !ev.target.checked;
45-
ev.preventDefault();
46-
break;
47-
}
48-
}
49-
5035
function showLightAndDark() {
5136
removeClass(document.getElementById("preferred-light-theme"), "hidden");
5237
removeClass(document.getElementById("preferred-dark-theme"), "hidden");
@@ -77,8 +62,6 @@
7762
toggle.onchange = function() {
7863
changeSetting(this.id, this.checked);
7964
};
80-
toggle.onkeyup = handleKey;
81-
toggle.onkeyrelease = handleKey;
8265
});
8366
onEachLazy(settingsElement.querySelectorAll("input[type=\"radio\"]"), elem => {
8467
const settingId = elem.name;

tests/rustdoc-gui/settings.goml

+9
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ set-local-storage: {"rustdoc-disable-shortcuts": "false"}
256256
click: ".setting-line:last-child .setting-check span"
257257
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
258258

259+
// We now check that focusing a toggle and pressing Space is like clicking on it.
260+
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
261+
focus: ".setting-line:last-child .setting-check input"
262+
press-key: "Space"
263+
assert-local-storage: {"rustdoc-disable-shortcuts": "false"}
264+
focus: ".setting-line:last-child .setting-check input"
265+
press-key: "Space"
266+
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
267+
259268
// Make sure that "Disable keyboard shortcuts" actually took effect.
260269
press-key: "Escape"
261270
press-key: "?"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
fn a() -> _ {
2+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
3+
&a
4+
}
5+
6+
fn b() -> _ {
7+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
8+
&a
9+
}
10+
11+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
2+
--> $DIR/bad-recursive-type-sig-infer.rs:1:11
3+
|
4+
LL | fn a() -> _ {
5+
| ^ not allowed in type signatures
6+
7+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
8+
--> $DIR/bad-recursive-type-sig-infer.rs:6:11
9+
|
10+
LL | fn b() -> _ {
11+
| ^ not allowed in type signatures
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)