Skip to content

Rollup of 9 pull requests #105035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9ed2977
[fuchsia] Document more settings for building Rust
Nov 17, 2022
69a07f7
Revert "Add fatal overflow test"
compiler-errors Nov 26, 2022
c285218
Revert "Drive-by: Don't manually call evaluate_obligation_no_overflow"
compiler-errors Nov 26, 2022
4149923
Revert "Do not need to account for overflow in predicate_can_apply"
compiler-errors Nov 26, 2022
be18880
Assign myself for docs updates
ehuss Nov 26, 2022
e4c9915
notify the rust-analyzer team on changes to the rust-analyzer subtree
Veykril Nov 27, 2022
11525e5
fix document
Neutron3529 Nov 28, 2022
20f389d
Add sentence when rustdoc search is running
GuillaumeGomez Nov 28, 2022
7181b8f
rustdoc: merge background-image rules in rustdoc-toggle CSS
notriddle Nov 28, 2022
19e0200
rustdoc: remove `fnname` CSS class that's styled exactly like `fn`
notriddle Nov 28, 2022
d958f37
Rustdoc-Json: Add tests for linking to foreign variants.
aDotInTheVoid Nov 28, 2022
e2de1ef
Rollup merge of #104465 - djkoloski:improve_fuchsia_testing_docs, r=t…
matthiaskrgr Nov 28, 2022
e4ff0cb
Rollup merge of #104959 - compiler-errors:revert-104269, r=lcnr
matthiaskrgr Nov 28, 2022
c7f6342
Rollup merge of #104978 - Veykril:patch-2, r=jyn514
matthiaskrgr Nov 28, 2022
9e81877
Rollup merge of #104992 - ehuss:docs-triagebot-assign, r=Mark-Simulacrum
matthiaskrgr Nov 28, 2022
5ff29be
Rollup merge of #105010 - Neutron3529:patch-2, r=jyn514
matthiaskrgr Nov 28, 2022
6fedc0f
Rollup merge of #105016 - GuillaumeGomez:load-sentence-rustdoc, r=not…
matthiaskrgr Nov 28, 2022
76a57e7
Rollup merge of #105020 - notriddle:notriddle/rustdoc-toggle, r=Guill…
matthiaskrgr Nov 28, 2022
b52ea94
Rollup merge of #105024 - notriddle:notriddle/fnname, r=jyn514
matthiaskrgr Nov 28, 2022
720ccc2
Rollup merge of #105027 - aDotInTheVoid:rdj-foreign-variant-test, r=G…
matthiaskrgr Nov 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,
}
11 changes: 11 additions & 0 deletions src/test/rustdoc-json/enums/doc_link_to_foreign_variant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// aux-build: color.rs

//! The purpose of this test it to have a link to [a foreign variant](Red).

extern crate color;
use color::Color::Red;

// @set red = "$.index[*][?(@.inner.is_crate == true)].links.Red"

// @!has "$.index[*][?(@.name == 'Red')]"
// @!has "$.index[*][?(@.name == 'Color')]"
9 changes: 9 additions & 0 deletions src/test/rustdoc-json/enums/use_variant_foreign.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// aux-build: color.rs

extern crate color;

// @is "$.index[*][?(@.inner.name == 'Red')].kind" '"import"'
pub use color::Color::Red;

// @!has "$.index[*][?(@.name == 'Red')]"
// @!has "$.index[*][?(@.name == 'Color')]"
2 changes: 1 addition & 1 deletion src/test/rustdoc/anchors.no_method_anchor.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -&gt; Self</h4></section>
<section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#48">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>() -&gt; Self</h4></section>
2 changes: 1 addition & 1 deletion src/test/rustdoc/anchors.no_trait_method_anchor.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<section id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></section>
<section id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fn">bar</a>()</h4></section>
2 changes: 1 addition & 1 deletion src/test/rustdoc/anchors.no_tymethod_anchor.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<section id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></section>
<section id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fn">foo</a>()</h4></section>
Loading