Auto merge of #126144 - fmease:rollup-i9pcdys, r=fmease
Rollup of 6 pull requests Successful merges: - #125951 (Stabilize `error_in_core`) - #125998 (std::unix::fs::get_mode implementation for illumos/solaris.) - #126057 (Make html rendered by rustdoc allow searching non-English identifier / alias) - #126065 (mark binding undetermined if target name exist and not obtained) - #126105 (Add debugging utils and comments to Fuchsia scripts) - #126138 (Fix typo in docs for std::pin) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
ff014f5de0
28 changed files with 499 additions and 141 deletions
|
@ -998,14 +998,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
let Some(module) = single_import.imported_module.get() else {
|
let Some(module) = single_import.imported_module.get() else {
|
||||||
return Err((Undetermined, Weak::No));
|
return Err((Undetermined, Weak::No));
|
||||||
};
|
};
|
||||||
let ImportKind::Single { source: ident, source_bindings, .. } = &single_import.kind
|
let ImportKind::Single { source: ident, target, target_bindings, .. } =
|
||||||
|
&single_import.kind
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
if binding.map_or(false, |binding| binding.module().is_some())
|
if (ident != target) && target_bindings.iter().all(|binding| binding.get().is_none()) {
|
||||||
&& source_bindings.iter().all(|binding| matches!(binding.get(), Err(Undetermined)))
|
// This branch allows the binding to be defined or updated later if the target name
|
||||||
{
|
// can hide the source but these bindings are not obtained.
|
||||||
// This branch allows the binding to be defined or updated later,
|
|
||||||
// avoiding module inconsistency between the resolve process and the finalize process.
|
// avoiding module inconsistency between the resolve process and the finalize process.
|
||||||
// See more details in #124840
|
// See more details in #124840
|
||||||
return Err((Undetermined, Weak::No));
|
return Err((Undetermined, Weak::No));
|
||||||
|
|
|
@ -121,7 +121,6 @@
|
||||||
#![feature(deref_pure_trait)]
|
#![feature(deref_pure_trait)]
|
||||||
#![feature(dispatch_from_dyn)]
|
#![feature(dispatch_from_dyn)]
|
||||||
#![feature(error_generic_member_access)]
|
#![feature(error_generic_member_access)]
|
||||||
#![feature(error_in_core)]
|
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
#![feature(extend_one)]
|
#![feature(extend_one)]
|
||||||
#![feature(fmt_internals)]
|
#![feature(fmt_internals)]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#![doc = include_str!("error.md")]
|
#![doc = include_str!("error.md")]
|
||||||
#![unstable(feature = "error_in_core", issue = "103765")]
|
#![stable(feature = "error_in_core", since = "CURRENT_RUSTC_VERSION")]
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
@ -130,7 +130,6 @@ pub trait Error: Debug + Display {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
/// use core::fmt;
|
/// use core::fmt;
|
||||||
/// use core::error::{request_ref, Request};
|
/// use core::error::{request_ref, Request};
|
||||||
///
|
///
|
||||||
|
@ -361,8 +360,7 @@ impl dyn Error {
|
||||||
/// Get a string value from an error.
|
/// Get a string value from an error.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// # #![feature(error_in_core)]
|
|
||||||
/// use std::error::Error;
|
/// use std::error::Error;
|
||||||
/// use core::error::request_value;
|
/// use core::error::request_value;
|
||||||
///
|
///
|
||||||
|
@ -385,8 +383,7 @@ where
|
||||||
/// Get a string reference from an error.
|
/// Get a string reference from an error.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// # #![feature(error_in_core)]
|
|
||||||
/// use core::error::Error;
|
/// use core::error::Error;
|
||||||
/// use core::error::request_ref;
|
/// use core::error::request_ref;
|
||||||
///
|
///
|
||||||
|
@ -458,7 +455,6 @@ where
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
/// use core::fmt;
|
/// use core::fmt;
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
/// use core::error::request_ref;
|
/// use core::error::request_ref;
|
||||||
|
@ -529,7 +525,6 @@ impl<'a> Request<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
///
|
///
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
///
|
///
|
||||||
|
@ -564,7 +559,6 @@ impl<'a> Request<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
///
|
///
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
///
|
///
|
||||||
|
@ -600,7 +594,6 @@ impl<'a> Request<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
///
|
///
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
///
|
///
|
||||||
|
@ -633,7 +626,6 @@ impl<'a> Request<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
///
|
///
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
///
|
///
|
||||||
|
@ -700,7 +692,6 @@ impl<'a> Request<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
///
|
///
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
/// use core::error::request_value;
|
/// use core::error::request_value;
|
||||||
|
@ -788,7 +779,6 @@ impl<'a> Request<'a> {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(error_generic_member_access)]
|
/// #![feature(error_generic_member_access)]
|
||||||
/// #![feature(error_in_core)]
|
|
||||||
///
|
///
|
||||||
/// use core::error::Request;
|
/// use core::error::Request;
|
||||||
/// use core::error::request_ref;
|
/// use core::error::request_ref;
|
||||||
|
|
|
@ -184,7 +184,7 @@
|
||||||
//! requires at least a level of pointer indirection each time a new object is added to the mix
|
//! requires at least a level of pointer indirection each time a new object is added to the mix
|
||||||
//! (and, practically, a heap allocation).
|
//! (and, practically, a heap allocation).
|
||||||
//!
|
//!
|
||||||
//! Although there were other reason as well, this issue of expensive composition is the key thing
|
//! Although there were other reasons as well, this issue of expensive composition is the key thing
|
||||||
//! that drove Rust towards adopting a different model. It is particularly a problem
|
//! that drove Rust towards adopting a different model. It is particularly a problem
|
||||||
//! when one considers, for example, the implications of composing together the [`Future`]s which
|
//! when one considers, for example, the implications of composing together the [`Future`]s which
|
||||||
//! will eventually make up an asynchronous task (including address-sensitive `async fn` state
|
//! will eventually make up an asynchronous task (including address-sensitive `async fn` state
|
||||||
|
|
|
@ -112,7 +112,6 @@
|
||||||
#![feature(const_slice_from_ref)]
|
#![feature(const_slice_from_ref)]
|
||||||
#![feature(waker_getters)]
|
#![feature(waker_getters)]
|
||||||
#![feature(error_generic_member_access)]
|
#![feature(error_generic_member_access)]
|
||||||
#![feature(error_in_core)]
|
|
||||||
#![feature(trait_upcasting)]
|
#![feature(trait_upcasting)]
|
||||||
#![feature(is_ascii_octdigit)]
|
#![feature(is_ascii_octdigit)]
|
||||||
#![feature(get_many_mut)]
|
#![feature(get_many_mut)]
|
||||||
|
|
|
@ -324,7 +324,6 @@
|
||||||
#![feature(core_io_borrowed_buf)]
|
#![feature(core_io_borrowed_buf)]
|
||||||
#![feature(duration_constants)]
|
#![feature(duration_constants)]
|
||||||
#![feature(error_generic_member_access)]
|
#![feature(error_generic_member_access)]
|
||||||
#![feature(error_in_core)]
|
|
||||||
#![feature(error_iter)]
|
#![feature(error_iter)]
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
#![feature(exclusive_wrapper)]
|
#![feature(exclusive_wrapper)]
|
||||||
|
|
|
@ -1561,6 +1561,8 @@ impl fmt::Debug for File {
|
||||||
target_os = "netbsd",
|
target_os = "netbsd",
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_os = "vxworks",
|
target_os = "vxworks",
|
||||||
|
target_os = "solaris",
|
||||||
|
target_os = "illumos",
|
||||||
target_vendor = "apple",
|
target_vendor = "apple",
|
||||||
))]
|
))]
|
||||||
fn get_mode(fd: c_int) -> Option<(bool, bool)> {
|
fn get_mode(fd: c_int) -> Option<(bool, bool)> {
|
||||||
|
@ -1583,6 +1585,8 @@ impl fmt::Debug for File {
|
||||||
target_os = "netbsd",
|
target_os = "netbsd",
|
||||||
target_os = "openbsd",
|
target_os = "openbsd",
|
||||||
target_os = "vxworks",
|
target_os = "vxworks",
|
||||||
|
target_os = "solaris",
|
||||||
|
target_os = "illumos",
|
||||||
target_vendor = "apple",
|
target_vendor = "apple",
|
||||||
)))]
|
)))]
|
||||||
fn get_mode(_fd: c_int) -> Option<(bool, bool)> {
|
fn get_mode(_fd: c_int) -> Option<(bool, bool)> {
|
||||||
|
|
|
@ -61,8 +61,8 @@ ENV SCRIPT python3 ../x.py check --stage 0 --set build.optimized-compiler-builti
|
||||||
/scripts/validate-toolstate.sh && \
|
/scripts/validate-toolstate.sh && \
|
||||||
/scripts/validate-error-codes.sh && \
|
/scripts/validate-error-codes.sh && \
|
||||||
reuse --include-submodules lint && \
|
reuse --include-submodules lint && \
|
||||||
# Runs checks to ensure that there are no ES5 issues in our JS code.
|
# Runs checks to ensure that there are no issues in our JS code.
|
||||||
es-check es8 ../src/librustdoc/html/static/js/*.js && \
|
es-check es2019 ../src/librustdoc/html/static/js/*.js && \
|
||||||
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
|
eslint -c ../src/librustdoc/html/static/.eslintrc.js ../src/librustdoc/html/static/js/*.js && \
|
||||||
eslint -c ../src/tools/rustdoc-js/.eslintrc.js ../src/tools/rustdoc-js/tester.js && \
|
eslint -c ../src/tools/rustdoc-js/.eslintrc.js ../src/tools/rustdoc-js/tester.js && \
|
||||||
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js
|
eslint -c ../src/tools/rustdoc-gui/.eslintrc.js ../src/tools/rustdoc-gui/tester.js
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# This job builds a toolchain capable of building Fuchsia, and then builds
|
||||||
|
# Fuchsia. See the build-fuchsia.sh script in this directory for more details.
|
||||||
|
|
||||||
FROM ubuntu:22.04
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
|
@ -2,50 +2,87 @@
|
||||||
|
|
||||||
# Downloads and builds the Fuchsia operating system using a toolchain installed
|
# Downloads and builds the Fuchsia operating system using a toolchain installed
|
||||||
# in $RUST_INSTALL_DIR.
|
# in $RUST_INSTALL_DIR.
|
||||||
|
#
|
||||||
|
# You may run this script locally using Docker with the following command:
|
||||||
|
#
|
||||||
|
# $ src/ci/docker/run.sh x86_64-gnu-integration
|
||||||
|
#
|
||||||
|
# Alternatively, from within the container with --dev, assuming you have made it
|
||||||
|
# as far as building the toolchain with the above command:
|
||||||
|
#
|
||||||
|
# $ src/ci/docker/run.sh --dev x86_64-gnu-integration
|
||||||
|
# docker# git config --global --add safe.directory /checkout/obj/fuchsia
|
||||||
|
# docker# ../src/ci/docker/host-x86_64/x86_64-gnu-integration/build-fuchsia.sh
|
||||||
|
#
|
||||||
|
# Also see the docs in the rustc-dev-guide for more info:
|
||||||
|
# https://github.com/rust-lang/rustc-dev-guide/pull/1989
|
||||||
|
|
||||||
set -euf -o pipefail
|
set -euf -o pipefail
|
||||||
|
|
||||||
INTEGRATION_SHA=1011e3298775ee7cdf6f6dc73e808d6a86e33bd6
|
# Set this variable to 1 to disable updating the Fuchsia checkout. This is
|
||||||
|
# useful for making local changes. You can find the Fuchsia checkout in
|
||||||
|
# `obj/x86_64-gnu-integration/fuchsia` in your local checkout after running this
|
||||||
|
# job for the first time.
|
||||||
|
KEEP_CHECKOUT=
|
||||||
|
|
||||||
|
# Any upstream refs that should be cherry-picked. This can be used to include
|
||||||
|
# Gerrit changes from https://fxrev.dev during development (click the "Download"
|
||||||
|
# button on a changelist to see the cherry pick ref). Example:
|
||||||
|
# PICK_REFS=(refs/changes/71/1054071/2 refs/changes/74/1054574/2)
|
||||||
PICK_REFS=()
|
PICK_REFS=()
|
||||||
|
|
||||||
|
# The commit hash of Fuchsia's integration.git to check out. This controls the
|
||||||
|
# commit hash of fuchsia.git and some other repos in the "monorepo" checkout, in
|
||||||
|
# addition to versions of prebuilts. It should be bumped regularly by the
|
||||||
|
# Fuchsia team – we aim for every 1-2 months.
|
||||||
|
INTEGRATION_SHA=1011e3298775ee7cdf6f6dc73e808d6a86e33bd6
|
||||||
|
|
||||||
checkout=fuchsia
|
checkout=fuchsia
|
||||||
jiri=.jiri_root/bin/jiri
|
jiri=.jiri_root/bin/jiri
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# This script will:
|
if [ -z "$KEEP_CHECKOUT" ]; then
|
||||||
# - create a directory named "fuchsia" if it does not exist
|
# This script will:
|
||||||
# - download "jiri" to "fuchsia/.jiri_root/bin"
|
# - create a directory named "fuchsia" if it does not exist
|
||||||
curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" \
|
# - download "jiri" to "fuchsia/.jiri_root/bin"
|
||||||
| base64 --decode \
|
curl -s "https://fuchsia.googlesource.com/jiri/+/HEAD/scripts/bootstrap_jiri?format=TEXT" \
|
||||||
| bash -s $checkout
|
| base64 --decode \
|
||||||
|
| bash -s $checkout
|
||||||
|
|
||||||
cd $checkout
|
cd $checkout
|
||||||
|
|
||||||
$jiri init \
|
$jiri init \
|
||||||
-partial=true \
|
-partial=true \
|
||||||
-analytics-opt=false \
|
-analytics-opt=false \
|
||||||
.
|
.
|
||||||
|
|
||||||
$jiri import \
|
$jiri import \
|
||||||
-name=integration \
|
-name=integration \
|
||||||
-revision=$INTEGRATION_SHA \
|
-revision=$INTEGRATION_SHA \
|
||||||
-overwrite=true \
|
-overwrite=true \
|
||||||
flower \
|
flower \
|
||||||
"https://fuchsia.googlesource.com/integration"
|
"https://fuchsia.googlesource.com/integration"
|
||||||
|
|
||||||
if [ -d ".git" ]; then
|
if [ -d ".git" ]; then
|
||||||
# Wipe out any local changes if we're reusing a checkout.
|
# Wipe out any local changes if we're reusing a checkout.
|
||||||
git checkout --force JIRI_HEAD
|
git checkout --force JIRI_HEAD
|
||||||
|
fi
|
||||||
|
|
||||||
|
$jiri update -autoupdate=false
|
||||||
|
|
||||||
|
echo integration commit = $(git -C integration rev-parse HEAD)
|
||||||
|
|
||||||
|
for git_ref in "${PICK_REFS[@]}"; do
|
||||||
|
git fetch https://fuchsia.googlesource.com/fuchsia $git_ref
|
||||||
|
git cherry-pick --no-commit FETCH_HEAD
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo Reusing existing Fuchsia checkout
|
||||||
|
cd $checkout
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$jiri update -autoupdate=false
|
# Run the script inside the Fuchsia checkout responsible for building Fuchsia.
|
||||||
|
# You can change arguments to the build by setting KEEP_CHECKOUT=1 above and
|
||||||
echo integration commit = $(git -C integration rev-parse HEAD)
|
# modifying them in build_fuchsia_from_rust_ci.sh.
|
||||||
|
|
||||||
for git_ref in "${PICK_REFS[@]}"; do
|
|
||||||
git fetch https://fuchsia.googlesource.com/fuchsia $git_ref
|
|
||||||
git cherry-pick --no-commit FETCH_HEAD
|
|
||||||
done
|
|
||||||
|
|
||||||
bash scripts/rust/build_fuchsia_from_rust_ci.sh
|
bash scripts/rust/build_fuchsia_from_rust_ci.sh
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 8,
|
"ecmaVersion": 2019,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
@ -41,8 +41,9 @@ let ParserState;
|
||||||
* foundElems: number,
|
* foundElems: number,
|
||||||
* totalElems: number,
|
* totalElems: number,
|
||||||
* literalSearch: boolean,
|
* literalSearch: boolean,
|
||||||
* corrections: Array<{from: string, to: integer}>,
|
* corrections: Array<{from: string, to: integer}> | null,
|
||||||
* typeFingerprint: Uint32Array,
|
* typeFingerprint: Uint32Array,
|
||||||
|
* error: Array<string> | null,
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
let ParsedQuery;
|
let ParsedQuery;
|
||||||
|
|
|
@ -89,6 +89,10 @@ const ROOT_PATH = typeof window !== "undefined" ? window.rootPath : "../";
|
||||||
// of permutations we need to check.
|
// of permutations we need to check.
|
||||||
const UNBOXING_LIMIT = 5;
|
const UNBOXING_LIMIT = 5;
|
||||||
|
|
||||||
|
// used for search query verification
|
||||||
|
const REGEX_IDENT = /\p{ID_Start}\p{ID_Continue}*|_\p{ID_Continue}+/uy;
|
||||||
|
const REGEX_INVALID_TYPE_FILTER = /[^a-z]/ui;
|
||||||
|
|
||||||
// In the search display, allows to switch between tabs.
|
// In the search display, allows to switch between tabs.
|
||||||
function printTab(nb) {
|
function printTab(nb) {
|
||||||
let iter = 0;
|
let iter = 0;
|
||||||
|
@ -410,18 +414,21 @@ function initSearch(rawSearchIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns `true` if the given `c` character is valid for an ident.
|
* If the current parser position is at the beginning of an identifier,
|
||||||
|
* move the position to the end of it and return `true`. Otherwise, return `false`.
|
||||||
*
|
*
|
||||||
* @param {string} c
|
* @param {ParserState} parserState
|
||||||
*
|
*
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
function isIdentCharacter(c) {
|
function consumeIdent(parserState) {
|
||||||
return (
|
REGEX_IDENT.lastIndex = parserState.pos;
|
||||||
c === "_" ||
|
const match = parserState.userQuery.match(REGEX_IDENT);
|
||||||
(c >= "0" && c <= "9") ||
|
if (match) {
|
||||||
(c >= "a" && c <= "z") ||
|
parserState.pos += match[0].length;
|
||||||
(c >= "A" && c <= "Z"));
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -618,70 +625,62 @@ function initSearch(rawSearchIndex) {
|
||||||
* @return {integer}
|
* @return {integer}
|
||||||
*/
|
*/
|
||||||
function getIdentEndPosition(parserState) {
|
function getIdentEndPosition(parserState) {
|
||||||
const start = parserState.pos;
|
let afterIdent = consumeIdent(parserState);
|
||||||
let end = parserState.pos;
|
let end = parserState.pos;
|
||||||
let foundExclamation = -1;
|
let macroExclamation = -1;
|
||||||
while (parserState.pos < parserState.length) {
|
while (parserState.pos < parserState.length) {
|
||||||
const c = parserState.userQuery[parserState.pos];
|
const c = parserState.userQuery[parserState.pos];
|
||||||
if (!isIdentCharacter(c)) {
|
if (c === "!") {
|
||||||
if (c === "!") {
|
if (macroExclamation !== -1) {
|
||||||
if (foundExclamation !== -1) {
|
throw ["Cannot have more than one ", "!", " in an ident"];
|
||||||
throw ["Cannot have more than one ", "!", " in an ident"];
|
} else if (parserState.pos + 1 < parserState.length) {
|
||||||
} else if (parserState.pos + 1 < parserState.length &&
|
const pos = parserState.pos;
|
||||||
isIdentCharacter(parserState.userQuery[parserState.pos + 1])
|
parserState.pos++;
|
||||||
) {
|
const beforeIdent = consumeIdent(parserState);
|
||||||
|
parserState.pos = pos;
|
||||||
|
if (beforeIdent) {
|
||||||
throw ["Unexpected ", "!", ": it can only be at the end of an ident"];
|
throw ["Unexpected ", "!", ": it can only be at the end of an ident"];
|
||||||
}
|
}
|
||||||
foundExclamation = parserState.pos;
|
}
|
||||||
} else if (isPathSeparator(c)) {
|
if (afterIdent) macroExclamation = parserState.pos;
|
||||||
if (c === ":") {
|
} else if (isPathSeparator(c)) {
|
||||||
if (!isPathStart(parserState)) {
|
if (c === ":") {
|
||||||
|
if (!isPathStart(parserState)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Skip current ":".
|
||||||
|
parserState.pos += 1;
|
||||||
|
} else {
|
||||||
|
while (parserState.pos + 1 < parserState.length) {
|
||||||
|
const next_c = parserState.userQuery[parserState.pos + 1];
|
||||||
|
if (next_c !== " ") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Skip current ":".
|
|
||||||
parserState.pos += 1;
|
parserState.pos += 1;
|
||||||
} else {
|
|
||||||
while (parserState.pos + 1 < parserState.length) {
|
|
||||||
const next_c = parserState.userQuery[parserState.pos + 1];
|
|
||||||
if (next_c !== " ") {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
parserState.pos += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (foundExclamation !== -1) {
|
|
||||||
if (foundExclamation !== start &&
|
|
||||||
isIdentCharacter(parserState.userQuery[foundExclamation - 1])
|
|
||||||
) {
|
|
||||||
throw ["Cannot have associated items in macros"];
|
|
||||||
} else {
|
|
||||||
// while the never type has no associated macros, we still
|
|
||||||
// can parse a path like that
|
|
||||||
foundExclamation = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (
|
|
||||||
c === "[" ||
|
|
||||||
c === "(" ||
|
|
||||||
isEndCharacter(c) ||
|
|
||||||
isSpecialStartCharacter(c) ||
|
|
||||||
isSeparatorCharacter(c)
|
|
||||||
) {
|
|
||||||
break;
|
|
||||||
} else if (parserState.pos > 0) {
|
|
||||||
throw ["Unexpected ", c, " after ", parserState.userQuery[parserState.pos - 1]];
|
|
||||||
} else {
|
|
||||||
throw ["Unexpected ", c];
|
|
||||||
}
|
}
|
||||||
|
if (macroExclamation !== -1) {
|
||||||
|
throw ["Cannot have associated items in macros"];
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
c === "[" ||
|
||||||
|
c === "(" ||
|
||||||
|
isEndCharacter(c) ||
|
||||||
|
isSpecialStartCharacter(c) ||
|
||||||
|
isSeparatorCharacter(c)
|
||||||
|
) {
|
||||||
|
break;
|
||||||
|
} else if (parserState.pos > 0) {
|
||||||
|
throw ["Unexpected ", c, " after ", parserState.userQuery[parserState.pos - 1],
|
||||||
|
" (not a valid identifier)"];
|
||||||
|
} else {
|
||||||
|
throw ["Unexpected ", c, " (not a valid identifier)"];
|
||||||
}
|
}
|
||||||
parserState.pos += 1;
|
parserState.pos += 1;
|
||||||
|
afterIdent = consumeIdent(parserState);
|
||||||
end = parserState.pos;
|
end = parserState.pos;
|
||||||
}
|
}
|
||||||
// if start == end - 1, we got the never type
|
if (macroExclamation !== -1) {
|
||||||
if (foundExclamation !== -1 &&
|
|
||||||
foundExclamation !== start &&
|
|
||||||
isIdentCharacter(parserState.userQuery[foundExclamation - 1])
|
|
||||||
) {
|
|
||||||
if (parserState.typeFilter === null) {
|
if (parserState.typeFilter === null) {
|
||||||
parserState.typeFilter = "macro";
|
parserState.typeFilter = "macro";
|
||||||
} else if (parserState.typeFilter !== "macro") {
|
} else if (parserState.typeFilter !== "macro") {
|
||||||
|
@ -693,7 +692,7 @@ function initSearch(rawSearchIndex) {
|
||||||
" both specified",
|
" both specified",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
end = foundExclamation;
|
end = macroExclamation;
|
||||||
}
|
}
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
@ -1071,16 +1070,15 @@ function initSearch(rawSearchIndex) {
|
||||||
function checkExtraTypeFilterCharacters(start, parserState) {
|
function checkExtraTypeFilterCharacters(start, parserState) {
|
||||||
const query = parserState.userQuery.slice(start, parserState.pos).trim();
|
const query = parserState.userQuery.slice(start, parserState.pos).trim();
|
||||||
|
|
||||||
for (const c in query) {
|
const match = query.match(REGEX_INVALID_TYPE_FILTER);
|
||||||
if (!isIdentCharacter(query[c])) {
|
if (match) {
|
||||||
throw [
|
throw [
|
||||||
"Unexpected ",
|
"Unexpected ",
|
||||||
query[c],
|
match[0],
|
||||||
" in type filter (before ",
|
" in type filter (before ",
|
||||||
":",
|
":",
|
||||||
")",
|
")",
|
||||||
];
|
];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2127,7 +2125,7 @@ function initSearch(rawSearchIndex) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAliases(ret, query, filterCrates, currentCrate) {
|
async function handleAliases(ret, query, filterCrates, currentCrate) {
|
||||||
const lowerQuery = query.toLowerCase();
|
const lowerQuery = query.toLowerCase();
|
||||||
// We separate aliases and crate aliases because we want to have current crate
|
// We separate aliases and crate aliases because we want to have current crate
|
||||||
// aliases to be before the others in the displayed results.
|
// aliases to be before the others in the displayed results.
|
||||||
|
@ -2163,6 +2161,15 @@ function initSearch(rawSearchIndex) {
|
||||||
crateAliases.sort(sortFunc);
|
crateAliases.sort(sortFunc);
|
||||||
aliases.sort(sortFunc);
|
aliases.sort(sortFunc);
|
||||||
|
|
||||||
|
const fetchDesc = alias => {
|
||||||
|
return searchIndexEmptyDesc.get(alias.crate).contains(alias.bitIndex) ?
|
||||||
|
"" : searchState.loadDesc(alias);
|
||||||
|
};
|
||||||
|
const [crateDescs, descs] = await Promise.all([
|
||||||
|
Promise.all(crateAliases.map(fetchDesc)),
|
||||||
|
Promise.all(aliases.map(fetchDesc)),
|
||||||
|
]);
|
||||||
|
|
||||||
const pushFunc = alias => {
|
const pushFunc = alias => {
|
||||||
alias.alias = query;
|
alias.alias = query;
|
||||||
const res = buildHrefAndPath(alias);
|
const res = buildHrefAndPath(alias);
|
||||||
|
@ -2176,7 +2183,13 @@ function initSearch(rawSearchIndex) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
aliases.forEach((alias, i) => {
|
||||||
|
alias.desc = descs[i];
|
||||||
|
});
|
||||||
aliases.forEach(pushFunc);
|
aliases.forEach(pushFunc);
|
||||||
|
crateAliases.forEach((alias, i) => {
|
||||||
|
alias.desc = crateDescs[i];
|
||||||
|
});
|
||||||
crateAliases.forEach(pushFunc);
|
crateAliases.forEach(pushFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2538,7 +2551,8 @@ function initSearch(rawSearchIndex) {
|
||||||
sorted_returned,
|
sorted_returned,
|
||||||
sorted_others,
|
sorted_others,
|
||||||
parsedQuery);
|
parsedQuery);
|
||||||
handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate);
|
await handleAliases(ret, parsedQuery.original.replace(/"/g, ""),
|
||||||
|
filterCrates, currentCrate);
|
||||||
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
|
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
|
||||||
const descs = await Promise.all(list.map(result => {
|
const descs = await Promise.all(list.map(result => {
|
||||||
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
|
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
|
||||||
|
|
|
@ -45,8 +45,8 @@ fn std_instead_of_core() {
|
||||||
|
|
||||||
let _ = std::env!("PATH");
|
let _ = std::env!("PATH");
|
||||||
|
|
||||||
// do not lint until `error_in_core` is stable
|
use core::error::Error;
|
||||||
use std::error::Error;
|
//~^ ERROR: used import from `std` instead of `core`
|
||||||
|
|
||||||
// lint items re-exported from private modules, `core::iter::traits::iterator::Iterator`
|
// lint items re-exported from private modules, `core::iter::traits::iterator::Iterator`
|
||||||
use core::iter::Iterator;
|
use core::iter::Iterator;
|
||||||
|
|
|
@ -45,8 +45,8 @@ fn std_instead_of_core() {
|
||||||
|
|
||||||
let _ = std::env!("PATH");
|
let _ = std::env!("PATH");
|
||||||
|
|
||||||
// do not lint until `error_in_core` is stable
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
//~^ ERROR: used import from `std` instead of `core`
|
||||||
|
|
||||||
// lint items re-exported from private modules, `core::iter::traits::iterator::Iterator`
|
// lint items re-exported from private modules, `core::iter::traits::iterator::Iterator`
|
||||||
use std::iter::Iterator;
|
use std::iter::Iterator;
|
||||||
|
|
|
@ -49,6 +49,12 @@ error: used import from `std` instead of `core`
|
||||||
LL | let cell_absolute = ::std::cell::Cell::new(8u32);
|
LL | let cell_absolute = ::std::cell::Cell::new(8u32);
|
||||||
| ^^^ help: consider importing the item from `core`: `core`
|
| ^^^ help: consider importing the item from `core`: `core`
|
||||||
|
|
||||||
|
error: used import from `std` instead of `core`
|
||||||
|
--> tests/ui/std_instead_of_core.rs:48:9
|
||||||
|
|
|
||||||
|
LL | use std::error::Error;
|
||||||
|
| ^^^ help: consider importing the item from `core`: `core`
|
||||||
|
|
||||||
error: used import from `std` instead of `core`
|
error: used import from `std` instead of `core`
|
||||||
--> tests/ui/std_instead_of_core.rs:52:9
|
--> tests/ui/std_instead_of_core.rs:52:9
|
||||||
|
|
|
|
||||||
|
@ -79,5 +85,5 @@ LL | use alloc::slice::from_ref;
|
||||||
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
|
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
|
||||||
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
|
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
|
||||||
|
|
||||||
error: aborting due to 12 previous errors
|
error: aborting due to 13 previous errors
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 2018,
|
"ecmaVersion": 2019,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 8,
|
"ecmaVersion": 2019,
|
||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
|
|
|
@ -24,7 +24,7 @@ const PARSED = [
|
||||||
original: "-> *",
|
original: "-> *",
|
||||||
returned: [],
|
returned: [],
|
||||||
userQuery: "-> *",
|
userQuery: "-> *",
|
||||||
error: "Unexpected `*` after ` `",
|
error: "Unexpected `*` after ` ` (not a valid identifier)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
query: 'a<"P">',
|
query: 'a<"P">',
|
||||||
|
@ -204,16 +204,25 @@ const PARSED = [
|
||||||
original: "_:",
|
original: "_:",
|
||||||
returned: [],
|
returned: [],
|
||||||
userQuery: "_:",
|
userQuery: "_:",
|
||||||
error: "Unexpected `:` (expected path after type filter `_:`)",
|
error: "Unexpected `_` (not a valid identifier)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
query: "_:a",
|
query: "ab:",
|
||||||
elems: [],
|
elems: [],
|
||||||
foundElems: 0,
|
foundElems: 0,
|
||||||
original: "_:a",
|
original: "ab:",
|
||||||
returned: [],
|
returned: [],
|
||||||
userQuery: "_:a",
|
userQuery: "ab:",
|
||||||
error: "Unknown type filter `_`",
|
error: "Unexpected `:` (expected path after type filter `ab:`)",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: "a:b",
|
||||||
|
elems: [],
|
||||||
|
foundElems: 0,
|
||||||
|
original: "a:b",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "a:b",
|
||||||
|
error: "Unknown type filter `a`",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
query: "a-bb",
|
query: "a-bb",
|
||||||
|
@ -240,7 +249,7 @@ const PARSED = [
|
||||||
original: "ab'",
|
original: "ab'",
|
||||||
returned: [],
|
returned: [],
|
||||||
userQuery: "ab'",
|
userQuery: "ab'",
|
||||||
error: "Unexpected `'` after `b`",
|
error: "Unexpected `'` after `b` (not a valid identifier)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
query: "a->",
|
query: "a->",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const EXPECTED = {
|
const EXPECTED = {
|
||||||
'query': 'Fo',
|
'query': 'Fo',
|
||||||
'others': [
|
'others': [
|
||||||
{ 'path': 'basic', 'name': 'Foo' },
|
{ 'path': 'basic', 'name': 'Foo', 'desc': 'Docs for Foo' },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Struct',
|
'name': 'Struct',
|
||||||
|
'desc': 'Doc for <code>Struct</code>',
|
||||||
'alias': 'StructItem',
|
'alias': 'StructItem',
|
||||||
'href': '../doc_alias/struct.Struct.html',
|
'href': '../doc_alias/struct.Struct.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -17,6 +18,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Struct',
|
'path': 'doc_alias::Struct',
|
||||||
'name': 'field',
|
'name': 'field',
|
||||||
|
'desc': 'Doc for <code>Struct</code>’s <code>field</code>',
|
||||||
'alias': 'StructFieldItem',
|
'alias': 'StructFieldItem',
|
||||||
'href': '../doc_alias/struct.Struct.html#structfield.field',
|
'href': '../doc_alias/struct.Struct.html#structfield.field',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -29,6 +31,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Struct',
|
'path': 'doc_alias::Struct',
|
||||||
'name': 'method',
|
'name': 'method',
|
||||||
|
'desc': 'Doc for <code>Struct::method</code>',
|
||||||
'alias': 'StructMethodItem',
|
'alias': 'StructMethodItem',
|
||||||
'href': '../doc_alias/struct.Struct.html#method.method',
|
'href': '../doc_alias/struct.Struct.html#method.method',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -45,6 +48,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Struct',
|
'path': 'doc_alias::Struct',
|
||||||
'name': 'ImplConstItem',
|
'name': 'ImplConstItem',
|
||||||
|
'desc': 'Doc for <code>Struct::ImplConstItem</code>',
|
||||||
'alias': 'StructImplConstItem',
|
'alias': 'StructImplConstItem',
|
||||||
'href': '../doc_alias/struct.Struct.html#associatedconstant.ImplConstItem',
|
'href': '../doc_alias/struct.Struct.html#associatedconstant.ImplConstItem',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -57,6 +61,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Struct',
|
'path': 'doc_alias::Struct',
|
||||||
'name': 'function',
|
'name': 'function',
|
||||||
|
'desc': 'Doc for <code>Trait::function</code> implemented for Struct',
|
||||||
'alias': 'ImplTraitFunction',
|
'alias': 'ImplTraitFunction',
|
||||||
'href': '../doc_alias/struct.Struct.html#method.function',
|
'href': '../doc_alias/struct.Struct.html#method.function',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -69,6 +74,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Enum',
|
'name': 'Enum',
|
||||||
|
'desc': 'Doc for <code>Enum</code>',
|
||||||
'alias': 'EnumItem',
|
'alias': 'EnumItem',
|
||||||
'href': '../doc_alias/enum.Enum.html',
|
'href': '../doc_alias/enum.Enum.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -81,6 +87,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Enum',
|
'path': 'doc_alias::Enum',
|
||||||
'name': 'Variant',
|
'name': 'Variant',
|
||||||
|
'desc': 'Doc for <code>Enum::Variant</code>',
|
||||||
'alias': 'VariantItem',
|
'alias': 'VariantItem',
|
||||||
'href': '../doc_alias/enum.Enum.html#variant.Variant',
|
'href': '../doc_alias/enum.Enum.html#variant.Variant',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -93,6 +100,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Enum',
|
'path': 'doc_alias::Enum',
|
||||||
'name': 'method',
|
'name': 'method',
|
||||||
|
'desc': 'Doc for <code>Enum::method</code>',
|
||||||
'alias': 'EnumMethodItem',
|
'alias': 'EnumMethodItem',
|
||||||
'href': '../doc_alias/enum.Enum.html#method.method',
|
'href': '../doc_alias/enum.Enum.html#method.method',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -105,6 +113,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Typedef',
|
'name': 'Typedef',
|
||||||
|
'desc': 'Doc for type alias <code>Typedef</code>',
|
||||||
'alias': 'TypedefItem',
|
'alias': 'TypedefItem',
|
||||||
'href': '../doc_alias/type.Typedef.html',
|
'href': '../doc_alias/type.Typedef.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -117,6 +126,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Trait',
|
'name': 'Trait',
|
||||||
|
'desc': 'Doc for <code>Trait</code>',
|
||||||
'alias': 'TraitItem',
|
'alias': 'TraitItem',
|
||||||
'href': '../doc_alias/trait.Trait.html',
|
'href': '../doc_alias/trait.Trait.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -129,6 +139,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Trait',
|
'path': 'doc_alias::Trait',
|
||||||
'name': 'Target',
|
'name': 'Target',
|
||||||
|
'desc': 'Doc for <code>Trait::Target</code>',
|
||||||
'alias': 'TraitTypeItem',
|
'alias': 'TraitTypeItem',
|
||||||
'href': '../doc_alias/trait.Trait.html#associatedtype.Target',
|
'href': '../doc_alias/trait.Trait.html#associatedtype.Target',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -141,6 +152,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Trait',
|
'path': 'doc_alias::Trait',
|
||||||
'name': 'AssociatedConst',
|
'name': 'AssociatedConst',
|
||||||
|
'desc': 'Doc for <code>Trait::AssociatedConst</code>',
|
||||||
'alias': 'AssociatedConstItem',
|
'alias': 'AssociatedConstItem',
|
||||||
'href': '../doc_alias/trait.Trait.html#associatedconstant.AssociatedConst',
|
'href': '../doc_alias/trait.Trait.html#associatedconstant.AssociatedConst',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -153,6 +165,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Trait',
|
'path': 'doc_alias::Trait',
|
||||||
'name': 'function',
|
'name': 'function',
|
||||||
|
'desc': 'Doc for <code>Trait::function</code>',
|
||||||
'alias': 'TraitFunctionItem',
|
'alias': 'TraitFunctionItem',
|
||||||
'href': '../doc_alias/trait.Trait.html#tymethod.function',
|
'href': '../doc_alias/trait.Trait.html#tymethod.function',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -165,6 +178,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'function',
|
'name': 'function',
|
||||||
|
'desc': 'Doc for <code>function</code>',
|
||||||
'alias': 'FunctionItem',
|
'alias': 'FunctionItem',
|
||||||
'href': '../doc_alias/fn.function.html',
|
'href': '../doc_alias/fn.function.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -177,6 +191,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Module',
|
'name': 'Module',
|
||||||
|
'desc': 'Doc for <code>Module</code>',
|
||||||
'alias': 'ModuleItem',
|
'alias': 'ModuleItem',
|
||||||
'href': '../doc_alias/Module/index.html',
|
'href': '../doc_alias/Module/index.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -189,6 +204,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Const',
|
'name': 'Const',
|
||||||
|
'desc': 'Doc for <code>Const</code>',
|
||||||
'alias': 'ConstItem',
|
'alias': 'ConstItem',
|
||||||
'href': '../doc_alias/constant.Const.html',
|
'href': '../doc_alias/constant.Const.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -205,6 +221,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Static',
|
'name': 'Static',
|
||||||
|
'desc': 'Doc for <code>Static</code>',
|
||||||
'alias': 'StaticItem',
|
'alias': 'StaticItem',
|
||||||
'href': '../doc_alias/static.Static.html',
|
'href': '../doc_alias/static.Static.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -217,6 +234,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Union',
|
'name': 'Union',
|
||||||
|
'desc': 'Doc for <code>Union</code>',
|
||||||
'alias': 'UnionItem',
|
'alias': 'UnionItem',
|
||||||
'href': '../doc_alias/union.Union.html',
|
'href': '../doc_alias/union.Union.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -225,6 +243,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Union',
|
'path': 'doc_alias::Union',
|
||||||
'name': 'union_item',
|
'name': 'union_item',
|
||||||
|
'desc': 'Doc for <code>Union::union_item</code>',
|
||||||
'href': '../doc_alias/union.Union.html#structfield.union_item'
|
'href': '../doc_alias/union.Union.html#structfield.union_item'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -235,6 +254,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Union',
|
'path': 'doc_alias::Union',
|
||||||
'name': 'union_item',
|
'name': 'union_item',
|
||||||
|
'desc': 'Doc for <code>Union::union_item</code>',
|
||||||
'alias': 'UnionFieldItem',
|
'alias': 'UnionFieldItem',
|
||||||
'href': '../doc_alias/union.Union.html#structfield.union_item',
|
'href': '../doc_alias/union.Union.html#structfield.union_item',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -247,6 +267,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias::Union',
|
'path': 'doc_alias::Union',
|
||||||
'name': 'method',
|
'name': 'method',
|
||||||
|
'desc': 'Doc for <code>Union::method</code>',
|
||||||
'alias': 'UnionMethodItem',
|
'alias': 'UnionMethodItem',
|
||||||
'href': '../doc_alias/union.Union.html#method.method',
|
'href': '../doc_alias/union.Union.html#method.method',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
@ -259,6 +280,7 @@ const EXPECTED = [
|
||||||
{
|
{
|
||||||
'path': 'doc_alias',
|
'path': 'doc_alias',
|
||||||
'name': 'Macro',
|
'name': 'Macro',
|
||||||
|
'desc': 'Doc for <code>Macro</code>',
|
||||||
'alias': 'MacroItem',
|
'alias': 'MacroItem',
|
||||||
'href': '../doc_alias/macro.Macro.html',
|
'href': '../doc_alias/macro.Macro.html',
|
||||||
'is_alias': true
|
'is_alias': true
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
|
/// Doc for `Struct`
|
||||||
#[doc(alias = "StructItem")]
|
#[doc(alias = "StructItem")]
|
||||||
pub struct Struct {
|
pub struct Struct {
|
||||||
|
/// Doc for `Struct`'s `field`
|
||||||
#[doc(alias = "StructFieldItem")]
|
#[doc(alias = "StructFieldItem")]
|
||||||
pub field: u32,
|
pub field: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Struct {
|
impl Struct {
|
||||||
|
/// Doc for `Struct::ImplConstItem`
|
||||||
#[doc(alias = "StructImplConstItem")]
|
#[doc(alias = "StructImplConstItem")]
|
||||||
pub const ImplConstItem: i32 = 0;
|
pub const ImplConstItem: i32 = 0;
|
||||||
|
/// Doc for `Struct::method`
|
||||||
#[doc(alias = "StructMethodItem")]
|
#[doc(alias = "StructMethodItem")]
|
||||||
pub fn method(&self) {}
|
pub fn method(&self) {}
|
||||||
}
|
}
|
||||||
|
@ -15,61 +19,78 @@ impl Trait for Struct {
|
||||||
type Target = u32;
|
type Target = u32;
|
||||||
const AssociatedConst: i32 = 12;
|
const AssociatedConst: i32 = 12;
|
||||||
|
|
||||||
|
/// Doc for `Trait::function` implemented for Struct
|
||||||
#[doc(alias = "ImplTraitFunction")]
|
#[doc(alias = "ImplTraitFunction")]
|
||||||
fn function() -> Self::Target {
|
fn function() -> Self::Target {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Doc for `Enum`
|
||||||
#[doc(alias = "EnumItem")]
|
#[doc(alias = "EnumItem")]
|
||||||
pub enum Enum {
|
pub enum Enum {
|
||||||
|
/// Doc for `Enum::Variant`
|
||||||
#[doc(alias = "VariantItem")]
|
#[doc(alias = "VariantItem")]
|
||||||
Variant,
|
Variant,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Enum {
|
impl Enum {
|
||||||
|
/// Doc for `Enum::method`
|
||||||
#[doc(alias = "EnumMethodItem")]
|
#[doc(alias = "EnumMethodItem")]
|
||||||
pub fn method(&self) {}
|
pub fn method(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Doc for type alias `Typedef`
|
||||||
#[doc(alias = "TypedefItem")]
|
#[doc(alias = "TypedefItem")]
|
||||||
pub type Typedef = i32;
|
pub type Typedef = i32;
|
||||||
|
|
||||||
|
/// Doc for `Trait`
|
||||||
#[doc(alias = "TraitItem")]
|
#[doc(alias = "TraitItem")]
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
|
/// Doc for `Trait::Target`
|
||||||
#[doc(alias = "TraitTypeItem")]
|
#[doc(alias = "TraitTypeItem")]
|
||||||
type Target;
|
type Target;
|
||||||
|
/// Doc for `Trait::AssociatedConst`
|
||||||
#[doc(alias = "AssociatedConstItem")]
|
#[doc(alias = "AssociatedConstItem")]
|
||||||
const AssociatedConst: i32;
|
const AssociatedConst: i32;
|
||||||
|
|
||||||
|
/// Doc for `Trait::function`
|
||||||
#[doc(alias = "TraitFunctionItem")]
|
#[doc(alias = "TraitFunctionItem")]
|
||||||
fn function() -> Self::Target;
|
fn function() -> Self::Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Doc for `function`
|
||||||
#[doc(alias = "FunctionItem")]
|
#[doc(alias = "FunctionItem")]
|
||||||
pub fn function() {}
|
pub fn function() {}
|
||||||
|
|
||||||
|
/// Doc for `Module`
|
||||||
#[doc(alias = "ModuleItem")]
|
#[doc(alias = "ModuleItem")]
|
||||||
pub mod Module {}
|
pub mod Module {}
|
||||||
|
|
||||||
|
/// Doc for `Const`
|
||||||
#[doc(alias = "ConstItem")]
|
#[doc(alias = "ConstItem")]
|
||||||
pub const Const: u32 = 0;
|
pub const Const: u32 = 0;
|
||||||
|
|
||||||
|
/// Doc for `Static`
|
||||||
#[doc(alias = "StaticItem")]
|
#[doc(alias = "StaticItem")]
|
||||||
pub static Static: u32 = 0;
|
pub static Static: u32 = 0;
|
||||||
|
|
||||||
|
/// Doc for `Union`
|
||||||
#[doc(alias = "UnionItem")]
|
#[doc(alias = "UnionItem")]
|
||||||
pub union Union {
|
pub union Union {
|
||||||
|
/// Doc for `Union::union_item`
|
||||||
#[doc(alias = "UnionFieldItem")]
|
#[doc(alias = "UnionFieldItem")]
|
||||||
pub union_item: u32,
|
pub union_item: u32,
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Union {
|
impl Union {
|
||||||
|
/// Doc for `Union::method`
|
||||||
#[doc(alias = "UnionMethodItem")]
|
#[doc(alias = "UnionMethodItem")]
|
||||||
pub fn method(&self) {}
|
pub fn method(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Doc for `Macro`
|
||||||
#[doc(alias = "MacroItem")]
|
#[doc(alias = "MacroItem")]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! Macro {
|
macro_rules! Macro {
|
||||||
|
|
163
tests/rustdoc-js/non-english-identifier.js
Normal file
163
tests/rustdoc-js/non-english-identifier.js
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
const PARSED = [
|
||||||
|
{
|
||||||
|
query: '中文',
|
||||||
|
elems: [{
|
||||||
|
name: "中文",
|
||||||
|
fullPath: ["中文"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "中文",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
}],
|
||||||
|
returned: [],
|
||||||
|
foundElems: 1,
|
||||||
|
original: "中文",
|
||||||
|
userQuery: "中文",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: '_0Mixed中英文',
|
||||||
|
elems: [{
|
||||||
|
name: "_0mixed中英文",
|
||||||
|
fullPath: ["_0mixed中英文"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "_0mixed中英文",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
}],
|
||||||
|
foundElems: 1,
|
||||||
|
original: "_0Mixed中英文",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "_0mixed中英文",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: 'my_crate::中文API',
|
||||||
|
elems: [{
|
||||||
|
name: "my_crate::中文api",
|
||||||
|
fullPath: ["my_crate", "中文api"],
|
||||||
|
pathWithoutLast: ["my_crate"],
|
||||||
|
pathLast: "中文api",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
}],
|
||||||
|
foundElems: 1,
|
||||||
|
original: "my_crate::中文API",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "my_crate::中文api",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: '类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>',
|
||||||
|
elems: [{
|
||||||
|
name: "类型a",
|
||||||
|
fullPath: ["类型a"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "类型a",
|
||||||
|
generics: [],
|
||||||
|
}, {
|
||||||
|
name: "类型b",
|
||||||
|
fullPath: ["类型b"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "类型b",
|
||||||
|
generics: [{
|
||||||
|
name: "约束c",
|
||||||
|
fullPath: ["约束c"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "约束c",
|
||||||
|
generics: [],
|
||||||
|
}],
|
||||||
|
}],
|
||||||
|
foundElems: 3,
|
||||||
|
totalElems: 5,
|
||||||
|
literalSearch: true,
|
||||||
|
original: "类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>",
|
||||||
|
returned: [{
|
||||||
|
name: "返回类型",
|
||||||
|
fullPath: ["返回类型"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "返回类型",
|
||||||
|
generics: [],
|
||||||
|
}],
|
||||||
|
userQuery: "类型a,类型b<约束c>->返回类型<关联类型=路径::约束d>",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: 'my_crate 中文宏!',
|
||||||
|
elems: [{
|
||||||
|
name: "my_crate 中文宏",
|
||||||
|
fullPath: ["my_crate", "中文宏"],
|
||||||
|
pathWithoutLast: ["my_crate"],
|
||||||
|
pathLast: "中文宏",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: 16,
|
||||||
|
}],
|
||||||
|
foundElems: 1,
|
||||||
|
original: "my_crate 中文宏!",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "my_crate 中文宏!",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: '非法符号——',
|
||||||
|
elems: [],
|
||||||
|
foundElems: 0,
|
||||||
|
original: "非法符号——",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "非法符号——",
|
||||||
|
error: "Unexpected `—` after `号` (not a valid identifier)",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
const EXPECTED = [
|
||||||
|
{
|
||||||
|
query: '加法',
|
||||||
|
others: [
|
||||||
|
{
|
||||||
|
name: "add",
|
||||||
|
path: "non_english_identifier",
|
||||||
|
is_alias: true,
|
||||||
|
alias: "加法",
|
||||||
|
href: "../non_english_identifier/macro.add.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "add",
|
||||||
|
path: "non_english_identifier",
|
||||||
|
is_alias: true,
|
||||||
|
alias: "加法",
|
||||||
|
href: "../non_english_identifier/fn.add.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "加法",
|
||||||
|
path: "non_english_identifier",
|
||||||
|
href: "../non_english_identifier/trait.加法.html",
|
||||||
|
desc: "Add"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "中文名称的加法宏",
|
||||||
|
path: "non_english_identifier",
|
||||||
|
href: "../non_english_identifier/macro.中文名称的加法宏.html",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "中文名称的加法API",
|
||||||
|
path: "non_english_identifier",
|
||||||
|
href: "../non_english_identifier/fn.中文名称的加法API.html",
|
||||||
|
}],
|
||||||
|
in_args: [{
|
||||||
|
name: "加上",
|
||||||
|
path: "non_english_identifier::加法",
|
||||||
|
href: "../non_english_identifier/trait.加法.html#tymethod.加上",
|
||||||
|
}],
|
||||||
|
returned: [],
|
||||||
|
},
|
||||||
|
{ // Extensive type-based search is still buggy, experimental & work-in-progress.
|
||||||
|
query: '可迭代->可选',
|
||||||
|
others: [{
|
||||||
|
name: "总计",
|
||||||
|
path: "non_english_identifier",
|
||||||
|
href: "../non_english_identifier/fn.总计.html",
|
||||||
|
desc: "“sum”"
|
||||||
|
}],
|
||||||
|
in_args: [],
|
||||||
|
returned: [],
|
||||||
|
},
|
||||||
|
];
|
47
tests/rustdoc-js/non-english-identifier.rs
Normal file
47
tests/rustdoc-js/non-english-identifier.rs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#[doc(alias = "加法")]
|
||||||
|
pub fn add(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn 中文名称的加法API(left: usize, right: usize) -> usize {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! 中文名称的加法宏 {
|
||||||
|
($left:expr, $right:expr) => {
|
||||||
|
($left) + ($right)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "加法")]
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! add {
|
||||||
|
($left:expr, $right:expr) => {
|
||||||
|
($left) + ($right)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add
|
||||||
|
pub trait 加法<类型> {
|
||||||
|
type 结果;
|
||||||
|
fn 加上(self, 被加数: 类型) -> Self::结果;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// IntoIterator
|
||||||
|
pub trait 可迭代 {
|
||||||
|
type 项;
|
||||||
|
type 转为迭代器: Iterator<Item = Self::项>;
|
||||||
|
fn 迭代(self) -> Self::转为迭代器;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type 可选<类型> = Option<类型>;
|
||||||
|
|
||||||
|
/// "sum"
|
||||||
|
pub fn 总计<集合, 个体>(容器: 集合) -> 可选<集合::项>
|
||||||
|
where
|
||||||
|
集合: 可迭代<项 = 个体>,
|
||||||
|
个体: 加法<个体, 结果 = 个体>,
|
||||||
|
{
|
||||||
|
容器.迭代().reduce(|累计值, 当前值| 累计值.加上(当前值))
|
||||||
|
}
|
9
tests/ui/imports/cycle-import-in-std-1.rs
Normal file
9
tests/ui/imports/cycle-import-in-std-1.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
//@ edition: 2018
|
||||||
|
|
||||||
|
// https://github.com/rust-lang/rust/issues/124490
|
||||||
|
|
||||||
|
use ops::{self as std};
|
||||||
|
//~^ ERROR: unresolved import `ops`
|
||||||
|
use std::collections::{self as ops};
|
||||||
|
|
||||||
|
fn main() {}
|
13
tests/ui/imports/cycle-import-in-std-1.stderr
Normal file
13
tests/ui/imports/cycle-import-in-std-1.stderr
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
error[E0432]: unresolved import `ops`
|
||||||
|
--> $DIR/cycle-import-in-std-1.rs:5:11
|
||||||
|
|
|
||||||
|
LL | use ops::{self as std};
|
||||||
|
| ^^^^^^^^^^^ no external crate `ops`
|
||||||
|
|
|
||||||
|
= help: consider importing one of these items instead:
|
||||||
|
core::ops
|
||||||
|
std::ops
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0432`.
|
9
tests/ui/imports/cycle-import-in-std-2.rs
Normal file
9
tests/ui/imports/cycle-import-in-std-2.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
//@ edition: 2018
|
||||||
|
|
||||||
|
// https://github.com/rust-lang/rust/issues/125013
|
||||||
|
|
||||||
|
use ops::{self as std};
|
||||||
|
//~^ ERROR: unresolved import `ops`
|
||||||
|
use std::ops::Deref::{self as ops};
|
||||||
|
|
||||||
|
fn main() {}
|
13
tests/ui/imports/cycle-import-in-std-2.stderr
Normal file
13
tests/ui/imports/cycle-import-in-std-2.stderr
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
error[E0432]: unresolved import `ops`
|
||||||
|
--> $DIR/cycle-import-in-std-2.rs:5:11
|
||||||
|
|
|
||||||
|
LL | use ops::{self as std};
|
||||||
|
| ^^^^^^^^^^^ no external crate `ops`
|
||||||
|
|
|
||||||
|
= help: consider importing one of these items instead:
|
||||||
|
core::ops
|
||||||
|
std::ops
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0432`.
|
Loading…
Add table
Add a link
Reference in a new issue