Skip to content

Commit

Permalink
Auto merge of rust-lang#105041 - matthiaskrgr:rollup-7ffry90, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#104465 (Document more settings for building rustc for Fuchsia)
 - rust-lang#104951 (Simplify checking for `GeneratorKind::Async`)
 - rust-lang#104959 (Revert rust-lang#104269 (to avoid spurious hang/test failure in CI))
 - rust-lang#104978 (notify the rust-analyzer team on changes to the rust-analyzer subtree)
 - rust-lang#105010 (Fix documentation of asymptotic complexity for rustc_data_structures::SortedMap)
 - rust-lang#105016 (Add sentence when rustdoc search is running)
 - rust-lang#105020 (rustdoc: merge background-image rules in rustdoc-toggle CSS)
 - rust-lang#105024 (rustdoc: remove `fnname` CSS class that's styled exactly like `fn`)
 - rust-lang#105027 (Rustdoc-Json: Add tests for linking to foreign variants.)
 - rust-lang#105038 (Clean up pr 104954)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 29, 2022
2 parents 1ef685e + 789b70d commit 0c6b88d
Show file tree
Hide file tree
Showing 39 changed files with 154 additions and 176 deletions.
7 changes: 1 addition & 6 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
span: *span,
ty_err: match output_ty.kind() {
ty::Closure(_, _) => FnMutReturnTypeErr::ReturnClosure { span: *span },
ty::Generator(def, ..)
if matches!(
self.infcx.tcx.generator_kind(def),
Some(hir::GeneratorKind::Async(_))
) =>
{
ty::Generator(def, ..) if self.infcx.tcx.generator_is_async(*def) => {
FnMutReturnTypeErr::ReturnAsyncBlock { span: *span }
}
_ => FnMutReturnTypeErr::ReturnRef { span: *span },
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_data_structures/src/sorted_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ mod index_map;
pub use index_map::SortedIndexMultiMap;

/// `SortedMap` is a data structure with similar characteristics as BTreeMap but
/// slightly different trade-offs: lookup, insertion, and removal are *O*(log(*n*))
/// and elements can be iterated in order cheaply.
/// slightly different trade-offs: lookup is *O*(log(*n*)), insertion and removal
/// are *O*(*n*) but elements can be iterated in order cheaply.
///
/// `SortedMap` can be faster than a `BTreeMap` for small sizes (<50) since it
/// stores data in a more compact way. It also supports accessing contiguous
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
ty::Closure(..) => Some(MustUsePath::Closure(span)),
ty::Generator(def_id, ..) => {
// async fn should be treated as "implementor of `Future`"
let must_use = if matches!(
cx.tcx.generator_kind(def_id),
Some(hir::GeneratorKind::Async(..))
) {
let must_use = if cx.tcx.generator_is_async(def_id) {
let def_id = cx.tcx.lang_items().future_trait().unwrap();
is_def_must_use(cx, def_id, span)
.map(|inner| MustUsePath::Opaque(Box::new(inner)))
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,11 @@ impl<'tcx> TyCtxt<'tcx> {
self.diagnostic_items(did.krate).name_to_id.get(&name) == Some(&did)
}

/// Returns `true` if the node pointed to by `def_id` is a generator for an async construct.
pub fn generator_is_async(self, def_id: DefId) -> bool {
matches!(self.generator_kind(def_id), Some(hir::GeneratorKind::Async(_)))
}

pub fn stability(self) -> &'tcx stability::Index {
self.stability_index(())
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
"you may want to use a bool value instead",
format!("{}", item_typo),
))
// FIXME(vicnenzopalazzo): make the check smarter,
// FIXME(vincenzopalazzo): make the check smarter,
// and maybe expand with levenshtein distance checks
} else if item_str.as_str() == "printf" {
Some((
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2544,10 +2544,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let obligation =
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,8 +1336,9 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
obligation.param_env,
trait_pred_and_suggested_ty,
);
let suggested_ty_would_satisfy_obligation =
self.predicate_must_hold_modulo_regions(&new_obligation);
let suggested_ty_would_satisfy_obligation = self
.evaluate_obligation_no_overflow(&new_obligation)
.must_apply_modulo_regions();
if suggested_ty_would_satisfy_obligation {
let sp = self
.tcx
Expand Down Expand Up @@ -1988,11 +1989,6 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.as_local()
.and_then(|def_id| hir.maybe_body_owned_by(def_id))
.map(|body_id| hir.body(body_id));
let is_async = self
.tcx
.generator_kind(generator_did)
.map(|generator_kind| matches!(generator_kind, hir::GeneratorKind::Async(..)))
.unwrap_or(false);
let mut visitor = AwaitsVisitor::default();
if let Some(body) = generator_body {
visitor.visit_body(body);
Expand Down Expand Up @@ -2069,6 +2065,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {

debug!(?interior_or_upvar_span);
if let Some(interior_or_upvar_span) = interior_or_upvar_span {
let is_async = self.tcx.generator_is_async(generator_did);
let typeck_results = match generator_data {
GeneratorData::Local(typeck_results) => Some(typeck_results),
GeneratorData::Foreign(_) => None,
Expand Down Expand Up @@ -2641,10 +2638,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
if is_future
&& obligated_types.last().map_or(false, |ty| match ty.kind() {
ty::Generator(last_def_id, ..) => {
matches!(
tcx.generator_kind(last_def_id),
Some(GeneratorKind::Async(..))
)
tcx.generator_is_async(*last_def_id)
}
_ => false,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
) {
let self_ty = obligation.self_ty().skip_binder();
if let ty::Generator(did, ..) = self_ty.kind() {
if let Some(rustc_hir::GeneratorKind::Async(_generator_kind)) =
self.tcx().generator_kind(did)
{
if self.tcx().generator_is_async(*did) {
debug!(?self_ty, ?obligation, "assemble_future_candidates",);

candidates.vec.push(FutureCandidate);
Expand Down
Empty file modified src/ci/docker/scripts/fuchsia-test-runner.py
100644 → 100755
Empty file.
83 changes: 60 additions & 23 deletions src/doc/rustc/src/platform-support/fuchsia.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,45 @@ Fuchsia as well. A recent version (14+) of clang should be sufficient to compile
Rust for Fuchsia.

x86-64 and AArch64 Fuchsia targets can be enabled using the following
configuration.

In `config.toml`, add:
configuration in `config.toml`:

```toml
[build]
target = ["<host_platform>", "aarch64-fuchsia", "x86_64-fuchsia"]

[rust]
lld = true

[target.x86_64-fuchsia]
cc = "clang"
cxx = "clang++"

[target.aarch64-fuchsia]
cc = "clang"
cxx = "clang++"
```

Though not strictly required, you may also want to use `clang` for your host
target as well:

```toml
[target.<host_platform>]
cc = "clang"
cxx = "clang++"
```

By default, the Rust compiler installs itself to `/usr/local` on most UNIX
systems. You may want to install it to another location (e.g. a local `install`
directory) by setting a custom prefix in `config.toml`:

```toml
[install]
# Make sure to use the absolute path to your install directory
prefix = "<RUST_SRC_PATH>/install"
```

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

```sh
# Configure this environment variable to be the path to the downloaded SDK
Expand All @@ -215,8 +243,11 @@ export LDFLAGS_x86_64_fuchsia="--target=x86_64-fuchsia --sysroot=${SDK_PATH}/arc
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"
```

These can be run together in a shell environment by executing
`(source config-env.sh && ./x.py install)`.
Finally, the Rust compiler can be built and installed:

```sh
(source config-env.sh && ./x.py install)
```

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

### Running the compiler test suite

Pre-requisites for running the Rust test suite on Fuchsia are:
1. Checkout of Rust source.
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)".
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)
The commands in this section assume that they are being run from inside your
local Rust source checkout:

```sh
cd ${RUST_SRC_PATH}
```

To run the Rust test suite on an emulated Fuchsia device, you must install the
Rust compiler locally. See "[Targeting Fuchsia with a compiler built from source](#targeting-fuchsia-with-a-compiler-built-from-source)"
for the steps to build locally.

Interfacing with the Fuchsia emulator is handled by our test runner script located
at `${RUST_SRC_PATH}/src/ci/docker/scripts/fuchsia-test-runner.py`.
You'll also need to download a copy of the Fuchsia SDK. The current 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).

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

**Issue command from ${RUST_SRC_PATH}**
```sh
src/ci/docker/scripts/fuchsia-test-runner.py start
--rust .
--rust ${RUST_SRC_PATH}/install
--sdk ${SDK_PATH}
--target-arch {x64,arm64}
```

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

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

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

When finished, stop the test environment:
When finished, the test runner can be used to stop the test environment:

**Issue command from ${RUST_SRC_PATH}**
```sh
src/ci/docker/scripts/fuchsia-test-runner.py stop
```
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,10 @@ fn assoc_method(
render_attributes_in_code(w, meth);
(0, "", Ending::Newline)
};
w.reserve(header_len + "<a href=\"\" class=\"fnname\">{".len() + "</a>".len());
w.reserve(header_len + "<a href=\"\" class=\"fn\">{".len() + "</a>".len());
write!(
w,
"{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a{href} class=\"fnname\">{name}</a>\
"{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a{href} class=\"fn\">{name}</a>\
{generics}{decl}{notable_traits}{where_clause}",
indent = indent_str,
vis = vis,
Expand Down
10 changes: 1 addition & 9 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ h1 a,
}

.content span.fn, .content a.fn,
.content .fnname,
.content span.method, .content a.method,
.content span.tymethod, .content a.tymethod {
color: var(--function-link-color);
Expand Down Expand Up @@ -1512,6 +1511,7 @@ details.rustdoc-toggle > summary.hideme > span {
}

details.rustdoc-toggle > summary::before {
background-image: url("toggle-plus-1092eb4930d581b0.svg");
content: "";
cursor: pointer;
width: 16px;
Expand Down Expand Up @@ -1599,14 +1599,6 @@ details.rustdoc-toggle[open] > summary.hideme > span {
details.rustdoc-toggle[open] > summary::before,
details.rustdoc-toggle[open] > summary.hideme::before {
background-image: url("toggle-minus-31bbd6e4c77f5c96.svg");
}

details.rustdoc-toggle > summary::before {
background-image: url("toggle-plus-1092eb4930d581b0.svg");
}

details.rustdoc-toggle[open] > summary::before,
details.rustdoc-toggle[open] > summary.hideme::before {
width: 16px;
height: 16px;
background-repeat: no-repeat;
Expand Down
10 changes: 6 additions & 4 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,15 @@ function loadCss(cssUrl) {

const params = searchState.getQueryStringParams();
if (params.search !== undefined) {
const search = searchState.outputElement();
search.innerHTML = "<h3 class=\"search-loading\">" +
searchState.loadingText + "</h3>";
searchState.showResults(search);
searchState.setLoadingSearch();
loadSearch();
}
},
setLoadingSearch: () => {
const search = searchState.outputElement();
search.innerHTML = "<h3 class=\"search-loading\">" + searchState.loadingText + "</h3>";
searchState.showResults(search);
},
};

function getPageId() {
Expand Down
10 changes: 6 additions & 4 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1766,21 +1766,23 @@ function initSearch(rawSearchIndex) {
* @param {boolean} [forced]
*/
function search(e, forced) {
const params = searchState.getQueryStringParams();
const query = parseQuery(searchState.input.value.trim());

if (e) {
e.preventDefault();
}

const query = parseQuery(searchState.input.value.trim());
let filterCrates = getFilterCrates();

if (!forced && query.userQuery === currentResults) {
if (query.userQuery.length > 0) {
putBackSearch();
}
return;
}

let filterCrates = getFilterCrates();
searchState.setLoadingSearch();

const params = searchState.getQueryStringParams();

// In case we have no information about the saved crate and there is a URL query parameter,
// we override it with the URL query parameter.
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/item-decl-colors.goml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define-function: (
("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)),
("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"),
("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)),
("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)),
("assert-css", (".item-decl .fn", {"color": |fn_color|}, ALL)),
("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)),
],
)
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-gui/notable-trait.goml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ assert: "#method\.create_an_iterator_from_read .notable-traits:focus"
// Now we check that the focus isn't given back to the wrong item when opening
// another popover.
store-window-property: (scroll, "scrollY")
click: "#method\.create_an_iterator_from_read .fnname"
click: "#method\.create_an_iterator_from_read .fn"
// We ensure that the scroll position changed.
assert-window-property-false: {"scrollY": |scroll|}
// Store the new position.
Expand All @@ -240,7 +240,7 @@ assert-window-property-false: {"scrollY": |scroll|}

// Same but with Escape handling.
store-window-property: (scroll, "scrollY")
click: "#method\.create_an_iterator_from_read .fnname"
click: "#method\.create_an_iterator_from_read .fn"
// We ensure that the scroll position changed.
assert-window-property-false: {"scrollY": |scroll|}
// Store the new position.
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-gui/where-whitespace.goml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ show-text: true
// line than "pub trait Whitespace<Idx>").
compare-elements-position-false: (".item-decl code", ".where.fmt-newline", ("y"))
// And that the code following it isn't on the same line either.
compare-elements-position-false: (".item-decl .fnname", ".where.fmt-newline", ("y"))
compare-elements-position-false: (".item-decl .fn", ".where.fmt-newline", ("y"))

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

compare-elements-position-false: ("#method\.new .fnname", "#method\.new .where.fmt-newline", ("y"))
compare-elements-position-false: ("#method\.new .fn", "#method\.new .where.fmt-newline", ("y"))
// We ensure that both the trait name and the struct name are on the same line in
// "impl<K, T> Whitespace<&K> for WhereWhitespace<T>".
compare-elements-position: (
Expand Down
5 changes: 5 additions & 0 deletions src/test/rustdoc-json/enums/auxiliary/color.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub enum Color {
Red,
Green,
Blue,
}
Loading

0 comments on commit 0c6b88d

Please sign in to comment.