Skip to content

Commit 0c6b88d

Browse files
committed
Auto merge of #105041 - matthiaskrgr:rollup-7ffry90, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #104465 (Document more settings for building rustc for Fuchsia) - #104951 (Simplify checking for `GeneratorKind::Async`) - #104959 (Revert #104269 (to avoid spurious hang/test failure in CI)) - #104978 (notify the rust-analyzer team on changes to the rust-analyzer subtree) - #105010 (Fix documentation of asymptotic complexity for rustc_data_structures::SortedMap) - #105016 (Add sentence when rustdoc search is running) - #105020 (rustdoc: merge background-image rules in rustdoc-toggle CSS) - #105024 (rustdoc: remove `fnname` CSS class that's styled exactly like `fn`) - #105027 (Rustdoc-Json: Add tests for linking to foreign variants.) - #105038 (Clean up pr 104954) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1ef685e + 789b70d commit 0c6b88d

39 files changed

+154
-176
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
514514
span: *span,
515515
ty_err: match output_ty.kind() {
516516
ty::Closure(_, _) => FnMutReturnTypeErr::ReturnClosure { span: *span },
517-
ty::Generator(def, ..)
518-
if matches!(
519-
self.infcx.tcx.generator_kind(def),
520-
Some(hir::GeneratorKind::Async(_))
521-
) =>
522-
{
517+
ty::Generator(def, ..) if self.infcx.tcx.generator_is_async(*def) => {
523518
FnMutReturnTypeErr::ReturnAsyncBlock { span: *span }
524519
}
525520
_ => FnMutReturnTypeErr::ReturnRef { span: *span },

compiler/rustc_data_structures/src/sorted_map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ mod index_map;
1010
pub use index_map::SortedIndexMultiMap;
1111

1212
/// `SortedMap` is a data structure with similar characteristics as BTreeMap but
13-
/// slightly different trade-offs: lookup, insertion, and removal are *O*(log(*n*))
14-
/// and elements can be iterated in order cheaply.
13+
/// slightly different trade-offs: lookup is *O*(log(*n*)), insertion and removal
14+
/// are *O*(*n*) but elements can be iterated in order cheaply.
1515
///
1616
/// `SortedMap` can be faster than a `BTreeMap` for small sizes (<50) since it
1717
/// stores data in a more compact way. It also supports accessing contiguous

compiler/rustc_lint/src/unused.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
322322
ty::Closure(..) => Some(MustUsePath::Closure(span)),
323323
ty::Generator(def_id, ..) => {
324324
// async fn should be treated as "implementor of `Future`"
325-
let must_use = if matches!(
326-
cx.tcx.generator_kind(def_id),
327-
Some(hir::GeneratorKind::Async(..))
328-
) {
325+
let must_use = if cx.tcx.generator_is_async(def_id) {
329326
let def_id = cx.tcx.lang_items().future_trait().unwrap();
330327
is_def_must_use(cx, def_id, span)
331328
.map(|inner| MustUsePath::Opaque(Box::new(inner)))

compiler/rustc_middle/src/ty/context.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,11 @@ impl<'tcx> TyCtxt<'tcx> {
13611361
self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did)
13621362
}
13631363

1364+
/// Returns `true` if the node pointed to by `def_id` is a generator for an async construct.
1365+
pub fn generator_is_async(self, def_id: DefId) -> bool {
1366+
matches!(self.generator_kind(def_id), Some(hir::GeneratorKind::Async(_)))
1367+
}
1368+
13641369
pub fn stability(self) -> &'tcx stability::Index {
13651370
self.stability_index(())
13661371
}

compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
282282
"you may want to use a bool value instead",
283283
format!("{}", item_typo),
284284
))
285-
// FIXME(vicnenzopalazzo): make the check smarter,
285+
// FIXME(vincenzopalazzo): make the check smarter,
286286
// and maybe expand with levenshtein distance checks
287287
} else if item_str.as_str() == "printf" {
288288
Some((

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -2544,10 +2544,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
25442544
let obligation =
25452545
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);
25462546

2547-
// We don't use `InferCtxt::predicate_may_hold` because that
2548-
// will re-run predicates that overflow locally, which ends up
2549-
// taking a really long time to compute.
2550-
self.evaluate_obligation(&obligation).map_or(false, |eval| eval.may_apply())
2547+
self.predicate_may_hold(&obligation)
25512548
})
25522549
}
25532550

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
13361336
obligation.param_env,
13371337
trait_pred_and_suggested_ty,
13381338
);
1339-
let suggested_ty_would_satisfy_obligation =
1340-
self.predicate_must_hold_modulo_regions(&new_obligation);
1339+
let suggested_ty_would_satisfy_obligation = self
1340+
.evaluate_obligation_no_overflow(&new_obligation)
1341+
.must_apply_modulo_regions();
13411342
if suggested_ty_would_satisfy_obligation {
13421343
let sp = self
13431344
.tcx
@@ -1988,11 +1989,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
19881989
.as_local()
19891990
.and_then(|def_id| hir.maybe_body_owned_by(def_id))
19901991
.map(|body_id| hir.body(body_id));
1991-
let is_async = self
1992-
.tcx
1993-
.generator_kind(generator_did)
1994-
.map(|generator_kind| matches!(generator_kind, hir::GeneratorKind::Async(..)))
1995-
.unwrap_or(false);
19961992
let mut visitor = AwaitsVisitor::default();
19971993
if let Some(body) = generator_body {
19981994
visitor.visit_body(body);
@@ -2069,6 +2065,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
20692065

20702066
debug!(?interior_or_upvar_span);
20712067
if let Some(interior_or_upvar_span) = interior_or_upvar_span {
2068+
let is_async = self.tcx.generator_is_async(generator_did);
20722069
let typeck_results = match generator_data {
20732070
GeneratorData::Local(typeck_results) => Some(typeck_results),
20742071
GeneratorData::Foreign(_) => None,
@@ -2641,10 +2638,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
26412638
if is_future
26422639
&& obligated_types.last().map_or(false, |ty| match ty.kind() {
26432640
ty::Generator(last_def_id, ..) => {
2644-
matches!(
2645-
tcx.generator_kind(last_def_id),
2646-
Some(GeneratorKind::Async(..))
2647-
)
2641+
tcx.generator_is_async(*last_def_id)
26482642
}
26492643
_ => false,
26502644
})

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
430430
) {
431431
let self_ty = obligation.self_ty().skip_binder();
432432
if let ty::Generator(did, ..) = self_ty.kind() {
433-
if let Some(rustc_hir::GeneratorKind::Async(_generator_kind)) =
434-
self.tcx().generator_kind(did)
435-
{
433+
if self.tcx().generator_is_async(*did) {
436434
debug!(?self_ty, ?obligation, "assemble_future_candidates",);
437435

438436
candidates.vec.push(FutureCandidate);

src/ci/docker/scripts/fuchsia-test-runner.py

100644100755
File mode changed.

src/doc/rustc/src/platform-support/fuchsia.md

+60-23
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,45 @@ Fuchsia as well. A recent version (14+) of clang should be sufficient to compile
189189
Rust for Fuchsia.
190190

191191
x86-64 and AArch64 Fuchsia targets can be enabled using the following
192-
configuration.
193-
194-
In `config.toml`, add:
192+
configuration in `config.toml`:
195193

196194
```toml
197195
[build]
198196
target = ["<host_platform>", "aarch64-fuchsia", "x86_64-fuchsia"]
197+
198+
[rust]
199+
lld = true
200+
201+
[target.x86_64-fuchsia]
202+
cc = "clang"
203+
cxx = "clang++"
204+
205+
[target.aarch64-fuchsia]
206+
cc = "clang"
207+
cxx = "clang++"
208+
```
209+
210+
Though not strictly required, you may also want to use `clang` for your host
211+
target as well:
212+
213+
```toml
214+
[target.<host_platform>]
215+
cc = "clang"
216+
cxx = "clang++"
217+
```
218+
219+
By default, the Rust compiler installs itself to `/usr/local` on most UNIX
220+
systems. You may want to install it to another location (e.g. a local `install`
221+
directory) by setting a custom prefix in `config.toml`:
222+
223+
```toml
224+
[install]
225+
# Make sure to use the absolute path to your install directory
226+
prefix = "<RUST_SRC_PATH>/install"
199227
```
200228

201-
Additionally, the following environment variables must be configured (for
202-
example, using a script like `config-env.sh`):
229+
Next, the following environment variables must be configured. For example, using
230+
a script we name `config-env.sh`:
203231

204232
```sh
205233
# Configure this environment variable to be the path to the downloaded SDK
@@ -215,8 +243,11 @@ export LDFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arc
215243
export CARGO_TARGET_X86_64_FUCHSIA_RUSTFLAGS="-C link-arg=--sysroot=${SDK_PATH}/arch/x64/sysroot -Lnative=${SDK_PATH}/arch/x64/sysroot/lib -Lnative=${SDK_PATH}/arch/x64/lib"
216244
```
217245

218-
These can be run together in a shell environment by executing
219-
`(source config-env.sh && ./x.py install)`.
246+
Finally, the Rust compiler can be built and installed:
247+
248+
```sh
249+
(source config-env.sh && ./x.py install)
250+
```
220251

221252
Once `rustc` is installed, we can create a new working directory to work from,
222253
`hello_fuchsia` along with `hello_fuchsia/src`:
@@ -641,31 +672,38 @@ available on the [Fuchsia devsite].
641672

642673
### Running the compiler test suite
643674

644-
Pre-requisites for running the Rust test suite on Fuchsia are:
645-
1. Checkout of Rust source.
646-
1. Setup of `config-env.sh` and `config.toml` from "[Targeting Fuchsia with a compiler built from source](#targeting-fuchsia-with-a-compiler-built-from-source)".
647-
1. Download of the Fuchsia SDK. Minimum supported SDK version is [9.20220726.1.1](https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core/linux-amd64/+/version:9.20220726.1.1)
675+
The commands in this section assume that they are being run from inside your
676+
local Rust source checkout:
677+
678+
```sh
679+
cd ${RUST_SRC_PATH}
680+
```
681+
682+
To run the Rust test suite on an emulated Fuchsia device, you must install the
683+
Rust compiler locally. See "[Targeting Fuchsia with a compiler built from source](#targeting-fuchsia-with-a-compiler-built-from-source)"
684+
for the steps to build locally.
648685

649-
Interfacing with the Fuchsia emulator is handled by our test runner script located
650-
at `${RUST_SRC_PATH}/src/ci/docker/scripts/fuchsia-test-runner.py`.
686+
You'll also need to download a copy of the Fuchsia SDK. The current minimum
687+
supported SDK version is [9.20220726.1.1](https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core/linux-amd64/+/version:9.20220726.1.1).
651688

652-
We start by activating our Fuchsia test environment. From a terminal:
689+
Fuchsia's test runner interacts with the Fuchsia emulator and is located at
690+
`src/ci/docker/scripts/fuchsia-test-runner.py`. We can use it to start our
691+
test environment with:
653692

654-
**Issue command from ${RUST_SRC_PATH}**
655693
```sh
656694
src/ci/docker/scripts/fuchsia-test-runner.py start
657-
--rust .
695+
--rust ${RUST_SRC_PATH}/install
658696
--sdk ${SDK_PATH}
659697
--target-arch {x64,arm64}
660698
```
661699

662-
Next, for ease of commands, we copy `config-env.sh` and `config.toml` into our Rust source
663-
code path, `${RUST_SRC_PATH}`.
700+
Where `${RUST_SRC_PATH}/install` is the `prefix` set in `config.toml` and
701+
`${SDK_PATH}` is the path to the downloaded and unzipped SDK.
664702

665-
From there, we utilize `x.py` to run our tests, using the test runner script to
666-
run the tests on our emulator. To run the full `src/test/ui` test suite:
703+
Once our environment is started, we can run our tests using `x.py` as usual. The
704+
test runner script will run the compiled tests on an emulated Fuchsia device. To
705+
run the full `src/test/ui` test suite:
667706

668-
**Run from ${RUST_SRC_PATH}**
669707
```sh
670708
( \
671709
source config-env.sh && \
@@ -695,9 +733,8 @@ run the tests on our emulator. To run the full `src/test/ui` test suite:
695733
*Note: The test suite cannot be run in parallel at the moment, so `x.py`
696734
must be run with `--jobs 1` to ensure only one test runs at a time.*
697735

698-
When finished, stop the test environment:
736+
When finished, the test runner can be used to stop the test environment:
699737

700-
**Issue command from ${RUST_SRC_PATH}**
701738
```sh
702739
src/ci/docker/scripts/fuchsia-test-runner.py stop
703740
```

src/librustdoc/html/render/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -847,10 +847,10 @@ fn assoc_method(
847847
render_attributes_in_code(w, meth);
848848
(0, "", Ending::Newline)
849849
};
850-
w.reserve(header_len + "<a href=\"\" class=\"fnname\">{".len() + "</a>".len());
850+
w.reserve(header_len + "<a href=\"\" class=\"fn\">{".len() + "</a>".len());
851851
write!(
852852
w,
853-
"{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a{href} class=\"fnname\">{name}</a>\
853+
"{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a{href} class=\"fn\">{name}</a>\
854854
{generics}{decl}{notable_traits}{where_clause}",
855855
indent = indent_str,
856856
vis = vis,

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ h1 a,
242242
}
243243

244244
.content span.fn, .content a.fn,
245-
.content .fnname,
246245
.content span.method, .content a.method,
247246
.content span.tymethod, .content a.tymethod {
248247
color: var(--function-link-color);
@@ -1512,6 +1511,7 @@ details.rustdoc-toggle > summary.hideme > span {
15121511
}
15131512

15141513
details.rustdoc-toggle > summary::before {
1514+
background-image: url("toggle-plus-1092eb4930d581b0.svg");
15151515
content: "";
15161516
cursor: pointer;
15171517
width: 16px;
@@ -1599,14 +1599,6 @@ details.rustdoc-toggle[open] > summary.hideme > span {
15991599
details.rustdoc-toggle[open] > summary::before,
16001600
details.rustdoc-toggle[open] > summary.hideme::before {
16011601
background-image: url("toggle-minus-31bbd6e4c77f5c96.svg");
1602-
}
1603-
1604-
details.rustdoc-toggle > summary::before {
1605-
background-image: url("toggle-plus-1092eb4930d581b0.svg");
1606-
}
1607-
1608-
details.rustdoc-toggle[open] > summary::before,
1609-
details.rustdoc-toggle[open] > summary.hideme::before {
16101602
width: 16px;
16111603
height: 16px;
16121604
background-repeat: no-repeat;

src/librustdoc/html/static/js/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,15 @@ function loadCss(cssUrl) {
302302

303303
const params = searchState.getQueryStringParams();
304304
if (params.search !== undefined) {
305-
const search = searchState.outputElement();
306-
search.innerHTML = "<h3 class=\"search-loading\">" +
307-
searchState.loadingText + "</h3>";
308-
searchState.showResults(search);
305+
searchState.setLoadingSearch();
309306
loadSearch();
310307
}
311308
},
309+
setLoadingSearch: () => {
310+
const search = searchState.outputElement();
311+
search.innerHTML = "<h3 class=\"search-loading\">" + searchState.loadingText + "</h3>";
312+
searchState.showResults(search);
313+
},
312314
};
313315

314316
function getPageId() {

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -1766,21 +1766,23 @@ function initSearch(rawSearchIndex) {
17661766
* @param {boolean} [forced]
17671767
*/
17681768
function search(e, forced) {
1769-
const params = searchState.getQueryStringParams();
1770-
const query = parseQuery(searchState.input.value.trim());
1771-
17721769
if (e) {
17731770
e.preventDefault();
17741771
}
17751772

1773+
const query = parseQuery(searchState.input.value.trim());
1774+
let filterCrates = getFilterCrates();
1775+
17761776
if (!forced && query.userQuery === currentResults) {
17771777
if (query.userQuery.length > 0) {
17781778
putBackSearch();
17791779
}
17801780
return;
17811781
}
17821782

1783-
let filterCrates = getFilterCrates();
1783+
searchState.setLoadingSearch();
1784+
1785+
const params = searchState.getQueryStringParams();
17841786

17851787
// In case we have no information about the saved crate and there is a URL query parameter,
17861788
// we override it with the URL query parameter.

src/test/rustdoc-gui/item-decl-colors.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define-function: (
3030
("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)),
3131
("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"),
3232
("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)),
33-
("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)),
33+
("assert-css", (".item-decl .fn", {"color": |fn_color|}, ALL)),
3434
("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)),
3535
],
3636
)

src/test/rustdoc-gui/notable-trait.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ assert: "#method\.create_an_iterator_from_read .notable-traits:focus"
226226
// Now we check that the focus isn't given back to the wrong item when opening
227227
// another popover.
228228
store-window-property: (scroll, "scrollY")
229-
click: "#method\.create_an_iterator_from_read .fnname"
229+
click: "#method\.create_an_iterator_from_read .fn"
230230
// We ensure that the scroll position changed.
231231
assert-window-property-false: {"scrollY": |scroll|}
232232
// Store the new position.
@@ -240,7 +240,7 @@ assert-window-property-false: {"scrollY": |scroll|}
240240

241241
// Same but with Escape handling.
242242
store-window-property: (scroll, "scrollY")
243-
click: "#method\.create_an_iterator_from_read .fnname"
243+
click: "#method\.create_an_iterator_from_read .fn"
244244
// We ensure that the scroll position changed.
245245
assert-window-property-false: {"scrollY": |scroll|}
246246
// Store the new position.

src/test/rustdoc-gui/where-whitespace.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ show-text: true
55
// line than "pub trait Whitespace<Idx>").
66
compare-elements-position-false: (".item-decl code", ".where.fmt-newline", ("y"))
77
// And that the code following it isn't on the same line either.
8-
compare-elements-position-false: (".item-decl .fnname", ".where.fmt-newline", ("y"))
8+
compare-elements-position-false: (".item-decl .fn", ".where.fmt-newline", ("y"))
99

1010
goto: "file://" + |DOC_PATH| + "/lib2/struct.WhereWhitespace.html"
1111
// We make the screen a bit wider to ensure that the trait impl is on one line.
1212
size: (915, 915)
1313

14-
compare-elements-position-false: ("#method\.new .fnname", "#method\.new .where.fmt-newline", ("y"))
14+
compare-elements-position-false: ("#method\.new .fn", "#method\.new .where.fmt-newline", ("y"))
1515
// We ensure that both the trait name and the struct name are on the same line in
1616
// "impl<K, T> Whitespace<&K> for WhereWhitespace<T>".
1717
compare-elements-position: (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub enum Color {
2+
Red,
3+
Green,
4+
Blue,
5+
}

0 commit comments

Comments
 (0)