Skip to content

Rollup of 9 pull requests #101946

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

Merged
merged 22 commits into from
Sep 17, 2022
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
705a766
array docs - advertise how to get array from slice
Sep 11, 2022
1ec92c8
rustdoc: add test cases for turning ``[Vec<T>]`` into ``[`Vec<T>`]``
notriddle Sep 14, 2022
44506f3
add note for `layout_of` when query depth overflows
SparrowLii Sep 14, 2022
89fd6ae
correct span, add help message and add UI test when query depth overf…
SparrowLii Sep 15, 2022
9286c3c
Update stdarch
wesleywiser Sep 15, 2022
532e3a5
Allow building `rust-analyzer-proc-macro-srv` as a standalone tool
WaffleLapkin Sep 15, 2022
9c3c88c
Use `builder.sysroot(...)` instead of a hack
WaffleLapkin Sep 16, 2022
1c65997
Create new CSS variables for links color
GuillaumeGomez Sep 16, 2022
5d449a0
Add GUI test for links colors
GuillaumeGomez Sep 16, 2022
9995029
Remove the allow-list for dynamic linking of LLVM tools
chriswailes Sep 13, 2022
b72de9b
rustdoc: clean up CSS for All Items and All Crates lists
notriddle Sep 16, 2022
a87a883
rustdoc: update test case for All Crates page
notriddle Sep 16, 2022
d1291dc
Improve handing of env vars during bootstrap process
chriswailes Sep 13, 2022
00d88bd
Rollup merge of #101672 - idigdoug:array_try_into, r=Mark-Simulacrum
matthiaskrgr Sep 17, 2022
ec61047
Rollup merge of #101781 - chriswailes:dynamic-llvm-on-musl, r=jyn514
matthiaskrgr Sep 17, 2022
9c32773
Rollup merge of #101783 - chriswailes:env-vars, r=jyn514
matthiaskrgr Sep 17, 2022
4757d2d
Rollup merge of #101801 - SparrowLii:query_depth_note, r=estebank
matthiaskrgr Sep 17, 2022
030f453
Rollup merge of #101824 - notriddle:notriddle/html-as-generics-intra-…
matthiaskrgr Sep 17, 2022
92d8bf9
Rollup merge of #101861 - wesleywiser:update_stdarch, r=Amanieu
matthiaskrgr Sep 17, 2022
179fd13
Rollup merge of #101873 - WaffleLapkin:x-build-proc-macro-srv, r=jyn514
matthiaskrgr Sep 17, 2022
9702c6c
Rollup merge of #101918 - notriddle:notriddle/all, r=GuillaumeGomez
matthiaskrgr Sep 17, 2022
1f31bee
Rollup merge of #101934 - GuillaumeGomez:theme-links-cleanup, r=notri…
matthiaskrgr Sep 17, 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
8 changes: 6 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -507,6 +507,10 @@ name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
]

[[package]]
name = "chalk-derive"
@@ -4613,7 +4617,7 @@ version = "0.0.0"
dependencies = [
"addr2line 0.16.0",
"alloc",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"compiler_builtins",
"core",
"dlmalloc",
@@ -4637,7 +4641,7 @@ dependencies = [
name = "std_detect"
version = "0.1.5"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"compiler_builtins",
"libc",
"rustc-std-workspace-alloc",
3 changes: 3 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/query_system.ftl
Original file line number Diff line number Diff line change
@@ -23,3 +23,6 @@ query_system_cycle_recursive_trait_alias = trait aliases cannot be recursive
query_system_cycle_which_requires = ...which requires {$desc}...
query_system_query_overflow = queries overflow the depth limit!
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]` attribute to your crate (`{$crate_name}`)
query_system_layout_of_depth = query depth increased by {$depth} when {$desc}
29 changes: 27 additions & 2 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
@@ -19,8 +19,10 @@ use rustc_query_system::query::{
force_query, QueryConfig, QueryContext, QueryDescription, QueryJobId, QueryMap,
QuerySideEffects, QueryStackFrame,
};
use rustc_query_system::Value;
use rustc_query_system::{LayoutOfDepth, QueryOverflow, Value};
use rustc_serialize::Decodable;
use rustc_session::Limit;
use rustc_span::def_id::LOCAL_CRATE;
use std::any::Any;
use std::num::NonZeroU64;
use thin_vec::ThinVec;
@@ -109,7 +111,7 @@ impl QueryContext for QueryCtxt<'_> {
// when accessing the `ImplicitCtxt`.
tls::with_related_context(**self, move |current_icx| {
if depth_limit && !self.recursion_limit().value_within_limit(current_icx.query_depth) {
self.depth_limit_error();
self.depth_limit_error(token);
}

// Update the `ImplicitCtxt` to point to our new query job.
@@ -127,6 +129,29 @@ impl QueryContext for QueryCtxt<'_> {
})
})
}

fn depth_limit_error(&self, job: QueryJobId) {
let mut span = None;
let mut layout_of_depth = None;
if let Some(map) = self.try_collect_active_jobs() {
if let Some((info, depth)) = job.try_find_layout_root(map) {
span = Some(info.job.span);
layout_of_depth = Some(LayoutOfDepth { desc: info.query.description, depth });
}
}

let suggested_limit = match self.recursion_limit() {
Limit(0) => Limit(2),
limit => limit * 2,
};

self.sess.emit_fatal(QueryOverflow {
span,
layout_of_depth,
suggested_limit,
crate_name: self.crate_name(LOCAL_CRATE),
});
}
}

impl<'tcx> QueryCtxt<'tcx> {
20 changes: 18 additions & 2 deletions compiler/rustc_query_system/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rustc_errors::AddSubdiagnostic;
use rustc_span::Span;
use rustc_session::Limit;
use rustc_span::{Span, Symbol};

pub struct CycleStack {
pub span: Span,
@@ -76,5 +77,20 @@ pub struct IncrementCompilation {
}

#[derive(SessionDiagnostic)]
#[help]
#[diag(query_system::query_overflow)]
pub struct QueryOverflow;
pub struct QueryOverflow {
#[primary_span]
pub span: Option<Span>,
#[subdiagnostic]
pub layout_of_depth: Option<LayoutOfDepth>,
pub suggested_limit: Limit,
pub crate_name: Symbol,
}

#[derive(SessionSubdiagnostic)]
#[note(query_system::layout_of_depth)]
pub struct LayoutOfDepth {
pub desc: String,
pub depth: usize,
}
2 changes: 2 additions & 0 deletions compiler/rustc_query_system/src/lib.rs
Original file line number Diff line number Diff line change
@@ -23,4 +23,6 @@ pub mod query;
mod values;

pub use error::HandleCycleError;
pub use error::LayoutOfDepth;
pub use error::QueryOverflow;
pub use values::Value;
21 changes: 20 additions & 1 deletion compiler/rustc_query_system/src/query/job.rs
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ impl QueryJobId {
}
}

#[derive(Clone)]
pub struct QueryJobInfo {
pub query: QueryStackFrame,
pub job: QueryJob,
@@ -116,10 +117,10 @@ impl QueryJob {
}
}

#[cfg(not(parallel_compiler))]
impl QueryJobId {
#[cold]
#[inline(never)]
#[cfg(not(parallel_compiler))]
pub(super) fn find_cycle_in_stack(
&self,
query_map: QueryMap,
@@ -156,6 +157,24 @@ impl QueryJobId {

panic!("did not find a cycle")
}

#[cold]
#[inline(never)]
pub fn try_find_layout_root(&self, query_map: QueryMap) -> Option<(QueryJobInfo, usize)> {
let mut last_layout = None;
let mut current_id = Some(*self);
let mut depth = 0;

while let Some(id) = current_id {
let info = query_map.get(&id).unwrap();
if info.query.name == "layout_of" {
depth += 1;
last_layout = Some((info.clone(), depth));
}
current_id = info.job.parent;
}
last_layout
}
}

#[cfg(parallel_compiler)]
6 changes: 2 additions & 4 deletions compiler/rustc_query_system/src/query/mod.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ pub use self::caches::{
mod config;
pub use self::config::{QueryConfig, QueryDescription, QueryVTable};

use crate::dep_graph::{DepContext, DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
use rustc_data_structures::sync::Lock;
use rustc_errors::Diagnostic;
use rustc_hir::def::DefKind;
@@ -123,7 +123,5 @@ pub trait QueryContext: HasDepContext {
compute: impl FnOnce() -> R,
) -> R;

fn depth_limit_error(&self) {
self.dep_context().sess().emit_fatal(crate::error::QueryOverflow);
}
fn depth_limit_error(&self, job: QueryJobId);
}
48 changes: 48 additions & 0 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
@@ -184,6 +184,18 @@ impl<T, const N: usize> const BorrowMut<[T]> for [T; N] {
}
}

/// Tries to create an array `[T; N]` by copying from a slice `&[T]`. Succeeds if
/// `slice.len() == N`.
///
/// ```
/// let bytes: [u8; 3] = [1, 0, 2];
///
/// let bytes_head: [u8; 2] = <[u8; 2]>::try_from(&bytes[0..2]).unwrap();
/// assert_eq!(1, u16::from_le_bytes(bytes_head));
///
/// let bytes_tail: [u8; 2] = bytes[1..3].try_into().unwrap();
/// assert_eq!(512, u16::from_le_bytes(bytes_tail));
/// ```
#[stable(feature = "try_from", since = "1.34.0")]
impl<T, const N: usize> TryFrom<&[T]> for [T; N]
where
@@ -196,6 +208,18 @@ where
}
}

/// Tries to create an array `[T; N]` by copying from a mutable slice `&mut [T]`.
/// Succeeds if `slice.len() == N`.
///
/// ```
/// let mut bytes: [u8; 3] = [1, 0, 2];
///
/// let bytes_head: [u8; 2] = <[u8; 2]>::try_from(&mut bytes[0..2]).unwrap();
/// assert_eq!(1, u16::from_le_bytes(bytes_head));
///
/// let bytes_tail: [u8; 2] = (&mut bytes[1..3]).try_into().unwrap();
/// assert_eq!(512, u16::from_le_bytes(bytes_tail));
/// ```
#[stable(feature = "try_from_mut_slice_to_array", since = "1.59.0")]
impl<T, const N: usize> TryFrom<&mut [T]> for [T; N]
where
@@ -208,6 +232,18 @@ where
}
}

/// Tries to create an array ref `&[T; N]` from a slice ref `&[T]`. Succeeds if
/// `slice.len() == N`.
///
/// ```
/// let bytes: [u8; 3] = [1, 0, 2];
///
/// let bytes_head: &[u8; 2] = <&[u8; 2]>::try_from(&bytes[0..2]).unwrap();
/// assert_eq!(1, u16::from_le_bytes(*bytes_head));
///
/// let bytes_tail: &[u8; 2] = bytes[1..3].try_into().unwrap();
/// assert_eq!(512, u16::from_le_bytes(*bytes_tail));
/// ```
#[stable(feature = "try_from", since = "1.34.0")]
impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
type Error = TryFromSliceError;
@@ -223,6 +259,18 @@ impl<'a, T, const N: usize> TryFrom<&'a [T]> for &'a [T; N] {
}
}

/// Tries to create a mutable array ref `&mut [T; N]` from a mutable slice ref
/// `&mut [T]`. Succeeds if `slice.len() == N`.
///
/// ```
/// let mut bytes: [u8; 3] = [1, 0, 2];
///
/// let bytes_head: &mut [u8; 2] = <&mut [u8; 2]>::try_from(&mut bytes[0..2]).unwrap();
/// assert_eq!(1, u16::from_le_bytes(*bytes_head));
///
/// let bytes_tail: &mut [u8; 2] = (&mut bytes[1..3]).try_into().unwrap();
/// assert_eq!(512, u16::from_le_bytes(*bytes_tail));
/// ```
#[stable(feature = "try_from", since = "1.34.0")]
impl<'a, T, const N: usize> TryFrom<&'a mut [T]> for &'a mut [T; N] {
type Error = TryFromSliceError;
23 changes: 22 additions & 1 deletion library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
@@ -611,7 +611,19 @@ mod prim_pointer {}
///
/// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on
/// an array. Indeed, this provides most of the API for working with arrays.
/// Slices have a dynamic size and do not coerce to arrays.
///
/// Slices have a dynamic size and do not coerce to arrays. Instead, use
/// `slice.try_into().unwrap()` or `<ArrayType>::try_from(slice).unwrap()`.
///
/// Array's `try_from(slice)` implementations (and the corresponding `slice.try_into()`
/// array implementations) succeed if the input slice length is the same as the result
/// array length. They optimize especially well when the optimizer can easily determine
/// the slice length, e.g. `<[u8; 4]>::try_from(&slice[4..8]).unwrap()`. Array implements
/// [TryFrom](crate::convert::TryFrom) returning:
///
/// - `[T; N]` copies from the slice's elements
/// - `&[T; N]` references the original slice's elements
/// - `&mut [T; N]` references the original slice's elements
///
/// You can move elements out of an array with a [slice pattern]. If you want
/// one element, see [`mem::replace`].
@@ -640,6 +652,15 @@ mod prim_pointer {}
/// for x in &array { }
/// ```
///
/// You can use `<ArrayType>::try_from(slice)` or `slice.try_into()` to get an array from
/// a slice:
///
/// ```
/// let bytes: [u8; 3] = [1, 0, 2];
/// assert_eq!(1, u16::from_le_bytes(<[u8; 2]>::try_from(&bytes[0..2]).unwrap()));
/// assert_eq!(512, u16::from_le_bytes(bytes[1..3].try_into().unwrap()));
/// ```
///
/// You can use a [slice pattern] to move elements out of an array:
///
/// ```
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ crate-type = ["dylib", "rlib"]

[dependencies]
alloc = { path = "../alloc" }
cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core" }
23 changes: 22 additions & 1 deletion library/std/src/primitive_docs.rs
Original file line number Diff line number Diff line change
@@ -611,7 +611,19 @@ mod prim_pointer {}
///
/// Arrays coerce to [slices (`[T]`)][slice], so a slice method may be called on
/// an array. Indeed, this provides most of the API for working with arrays.
/// Slices have a dynamic size and do not coerce to arrays.
///
/// Slices have a dynamic size and do not coerce to arrays. Instead, use
/// `slice.try_into().unwrap()` or `<ArrayType>::try_from(slice).unwrap()`.
///
/// Array's `try_from(slice)` implementations (and the corresponding `slice.try_into()`
/// array implementations) succeed if the input slice length is the same as the result
/// array length. They optimize especially well when the optimizer can easily determine
/// the slice length, e.g. `<[u8; 4]>::try_from(&slice[4..8]).unwrap()`. Array implements
/// [TryFrom](crate::convert::TryFrom) returning:
///
/// - `[T; N]` copies from the slice's elements
/// - `&[T; N]` references the original slice's elements
/// - `&mut [T; N]` references the original slice's elements
///
/// You can move elements out of an array with a [slice pattern]. If you want
/// one element, see [`mem::replace`].
@@ -640,6 +652,15 @@ mod prim_pointer {}
/// for x in &array { }
/// ```
///
/// You can use `<ArrayType>::try_from(slice)` or `slice.try_into()` to get an array from
/// a slice:
///
/// ```
/// let bytes: [u8; 3] = [1, 0, 2];
/// assert_eq!(1, u16::from_le_bytes(<[u8; 2]>::try_from(&bytes[0..2]).unwrap()));
/// assert_eq!(512, u16::from_le_bytes(bytes[1..3].try_into().unwrap()));
/// ```
///
/// You can use a [slice pattern] to move elements out of an array:
///
/// ```
15 changes: 11 additions & 4 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
@@ -732,19 +732,26 @@ def build_bootstrap(self, color):
(os.pathsep + env["LIBRARY_PATH"]) \
if "LIBRARY_PATH" in env else ""

# Export Stage0 snapshot compiler related env variables
build_section = "target.{}".format(self.build)
host_triple_sanitized = self.build.replace("-", "_")
var_data = {
"CC": "cc", "CXX": "cxx", "LD": "linker", "AR": "ar", "RANLIB": "ranlib"
}
for var_name, toml_key in var_data.items():
toml_val = self.get_toml(toml_key, build_section)
if toml_val != None:
env["{}_{}".format(var_name, host_triple_sanitized)] = toml_val

# preserve existing RUSTFLAGS
env.setdefault("RUSTFLAGS", "")
build_section = "target.{}".format(self.build)
target_features = []
if self.get_toml("crt-static", build_section) == "true":
target_features += ["+crt-static"]
elif self.get_toml("crt-static", build_section) == "false":
target_features += ["-crt-static"]
if target_features:
env["RUSTFLAGS"] += " -C target-feature=" + (",".join(target_features))
target_linker = self.get_toml("linker", build_section)
if target_linker is not None:
env["RUSTFLAGS"] += " -C linker=" + target_linker
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
env["RUSTFLAGS"] += " -Wsemicolon_in_expressions_from_macros"
if self.get_toml("deny-warnings", "rust") != "false":
13 changes: 7 additions & 6 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
@@ -1940,25 +1940,26 @@ impl<'a> Builder<'a> {
_ => s.display().to_string(),
}
};
let triple_underscored = target.triple.replace("-", "_");
let cc = ccacheify(&self.cc(target));
cargo.env(format!("CC_{}", target.triple), &cc);
cargo.env(format!("CC_{}", triple_underscored), &cc);

let cflags = self.cflags(target, GitRepo::Rustc, CLang::C).join(" ");
cargo.env(format!("CFLAGS_{}", target.triple), &cflags);
cargo.env(format!("CFLAGS_{}", triple_underscored), &cflags);

if let Some(ar) = self.ar(target) {
let ranlib = format!("{} s", ar.display());
cargo
.env(format!("AR_{}", target.triple), ar)
.env(format!("RANLIB_{}", target.triple), ranlib);
.env(format!("AR_{}", triple_underscored), ar)
.env(format!("RANLIB_{}", triple_underscored), ranlib);
}

if let Ok(cxx) = self.cxx(target) {
let cxx = ccacheify(&cxx);
let cxxflags = self.cflags(target, GitRepo::Rustc, CLang::Cxx).join(" ");
cargo
.env(format!("CXX_{}", target.triple), &cxx)
.env(format!("CXXFLAGS_{}", target.triple), cxxflags);
.env(format!("CXX_{}", triple_underscored), &cxx)
.env(format!("CXXFLAGS_{}", triple_underscored), cxxflags);
}
}

4 changes: 0 additions & 4 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
@@ -1307,10 +1307,6 @@ impl Build {
self.package_vers(&self.version)
}

fn llvm_link_tools_dynamically(&self, target: TargetSelection) -> bool {
target.contains("linux-gnu") || target.contains("apple-darwin")
}

/// Returns the `version` string associated with this compiler for Rust
/// itself.
///
9 changes: 2 additions & 7 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
@@ -423,12 +423,7 @@ impl Step for Llvm {
// which saves both memory during parallel links and overall disk space
// for the tools. We don't do this on every platform as it doesn't work
// equally well everywhere.
//
// If we're not linking rustc to a dynamic LLVM, though, then don't link
// tools to it.
let llvm_link_shared =
builder.llvm_link_tools_dynamically(target) && builder.llvm_link_shared();
if llvm_link_shared {
if builder.llvm_link_shared() {
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
}

@@ -553,7 +548,7 @@ impl Step for Llvm {
// libLLVM.dylib will be built. However, llvm-config will still look
// for a versioned path like libLLVM-14.dylib. Manually create a symbolic
// link to make llvm-config happy.
if llvm_link_shared && target.contains("apple-darwin") {
if builder.llvm_link_shared() && target.contains("apple-darwin") {
let mut cmd = Command::new(&build_llvm_config);
let version = output(cmd.arg("--version"));
let major = version.split('.').next().unwrap();
32 changes: 22 additions & 10 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
@@ -746,14 +746,18 @@ impl Step for RustAnalyzerProcMacroSrv {

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let builder = run.builder;
run.path("src/tools/rust-analyzer").default_condition(
builder.config.extended
&& builder
.config
.tools
.as_ref()
.map_or(true, |tools| tools.iter().any(|tool| tool == "rust-analyzer")),
)

// Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool.
run.path("src/tools/rust-analyzer")
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
.default_condition(
builder.config.extended
&& builder.config.tools.as_ref().map_or(true, |tools| {
tools.iter().any(|tool| {
tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv"
})
}),
)
}

fn make_run(run: RunConfig<'_>) {
@@ -764,7 +768,7 @@ impl Step for RustAnalyzerProcMacroSrv {
}

fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
builder.ensure(ToolBuild {
let path = builder.ensure(ToolBuild {
compiler: self.compiler,
target: self.target,
tool: "rust-analyzer-proc-macro-srv",
@@ -773,7 +777,15 @@ impl Step for RustAnalyzerProcMacroSrv {
extra_features: vec!["proc-macro-srv/sysroot-abi".to_owned()],
is_optional_tool: false,
source_type: SourceType::InTree,
})
})?;

// Copy `rust-analyzer-proc-macro-srv` to `<sysroot>/libexec/`
// so that r-a can use it.
let libexec_path = builder.sysroot(self.compiler).join("libexec");
t!(fs::create_dir_all(&libexec_path));
builder.copy(&path, &libexec_path.join("rust-analyzer-proc-macro-srv"));

Some(path)
}
}

2 changes: 1 addition & 1 deletion src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
@@ -286,7 +286,7 @@ jobs:

- name: x86_64-gnu-llvm-13
<<: *job-linux-xl

- name: x86_64-gnu-tools
env:
CI_ONLY_WHEN_SUBMODULES_CHANGED: 1
35 changes: 17 additions & 18 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
@@ -294,16 +294,15 @@ impl AllTypes {

impl AllTypes {
fn print(self, f: &mut Buffer) {
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str, class: &str) {
fn print_entries(f: &mut Buffer, e: &FxHashSet<ItemEntry>, title: &str) {
if !e.is_empty() {
let mut e: Vec<&ItemEntry> = e.iter().collect();
e.sort();
write!(
f,
"<h3 id=\"{}\">{}</h3><ul class=\"{} docblock\">",
"<h3 id=\"{}\">{}</h3><ul class=\"all-items\">",
title.replace(' ', "-"), // IDs cannot contain whitespaces.
title,
class
title
);

for s in e.iter() {
@@ -321,20 +320,20 @@ impl AllTypes {
);
// Note: print_entries does not escape the title, because we know the current set of titles
// doesn't require escaping.
print_entries(f, &self.structs, "Structs", "structs");
print_entries(f, &self.enums, "Enums", "enums");
print_entries(f, &self.unions, "Unions", "unions");
print_entries(f, &self.primitives, "Primitives", "primitives");
print_entries(f, &self.traits, "Traits", "traits");
print_entries(f, &self.macros, "Macros", "macros");
print_entries(f, &self.attributes, "Attribute Macros", "attributes");
print_entries(f, &self.derives, "Derive Macros", "derives");
print_entries(f, &self.functions, "Functions", "functions");
print_entries(f, &self.typedefs, "Typedefs", "typedefs");
print_entries(f, &self.trait_aliases, "Trait Aliases", "trait-aliases");
print_entries(f, &self.opaque_tys, "Opaque Types", "opaque-types");
print_entries(f, &self.statics, "Statics", "statics");
print_entries(f, &self.constants, "Constants", "constants")
print_entries(f, &self.structs, "Structs");
print_entries(f, &self.enums, "Enums");
print_entries(f, &self.unions, "Unions");
print_entries(f, &self.primitives, "Primitives");
print_entries(f, &self.traits, "Traits");
print_entries(f, &self.macros, "Macros");
print_entries(f, &self.attributes, "Attribute Macros");
print_entries(f, &self.derives, "Derive Macros");
print_entries(f, &self.functions, "Functions");
print_entries(f, &self.typedefs, "Typedefs");
print_entries(f, &self.trait_aliases, "Trait Aliases");
print_entries(f, &self.opaque_tys, "Opaque Types");
print_entries(f, &self.statics, "Statics");
print_entries(f, &self.constants, "Constants");
}
}

4 changes: 2 additions & 2 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
@@ -519,12 +519,12 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
let content = format!(
"<h1 class=\"fqn\">\
<span class=\"in-band\">List of all crates</span>\
</h1><ul class=\"crate mod\">{}</ul>",
</h1><ul class=\"all-items\">{}</ul>",
krates
.iter()
.map(|s| {
format!(
"<li><a class=\"crate mod\" href=\"{}index.html\">{}</a></li>",
"<li><a href=\"{}index.html\">{}</a></li>",
ensure_trailing_slash(s),
s
)
52 changes: 46 additions & 6 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
@@ -207,7 +207,6 @@ a.source,
.out-of-band,
span.since,
details.rustdoc-toggle > summary::before,
.content ul.crate a.crate,
a.srclink,
#help-button > button,
details.rustdoc-toggle.top-doc > summary,
@@ -218,7 +217,7 @@ details.rustdoc-toggle.non-exhaustive > summary::before,
.more-examples-toggle summary, .more-examples-toggle .hide-more,
.example-links a,
/* This selector is for the items listed in the "all items" page. */
#main-content > ul.docblock > li > a {
ul.all-items {
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
}

@@ -241,6 +240,49 @@ pre.rust a,
color: var(--main-color);
}

.content span.enum, .content a.enum,
.content span.struct, .content a.struct,
.content span.union, .content a.union,
.content span.primitive, .content a.primitive,
.content span.type, .content a.type,
.content span.foreigntype, .content a.foreigntype {
color: var(--type-link-color);
}

.content span.trait, .content a.trait,
.content span.traitalias, .content a.traitalias {
color: var(--trait-link-color);
}

.content span.associatedtype, .content a.associatedtype,
.content span.constant, .content a.constant,
.content span.static, .content a.static {
color: var(--assoc-item-link-color);
}

.content span.fn, .content a.fn,
.content .fnname {
color: var(--function-link-color);
}

.content span.attr, .content a.attr,
.content span.derive, .content a.derive,
.content span.macro, .content a.macro {
color: var(--macro-link-color);
}

.content span.mod, .content a.mod, .block a.current.mod {
color: var(--mod-link-color);
}

.content span.keyword, .content a.keyword {
color: var(--keyword-link-color);
}

a {
color: var(--link-color);
}

ol, ul {
padding-left: 24px;
}
@@ -786,6 +828,7 @@ h2.small-section-header > .anchor {
content: '§';
}

.all-items a:hover,
.docblock a:not(.srclink):not(.test-arrow):not(.scrape-help):hover,
.docblock-short a:not(.srclink):not(.test-arrow):not(.scrape-help):hover, .item-info a {
text-decoration: underline;
@@ -1515,10 +1558,7 @@ kbd {
cursor: default;
}

#main-content > ul {
padding-left: 10px;
}
#main-content > ul > li {
ul.all-items > li {
list-style: none;
}

40 changes: 8 additions & 32 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
@@ -27,6 +27,14 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0);
--codeblock-ignore-color: rgba(255, 142, 0, .6);
--type-link-color: #ffa0a5;
--trait-link-color: #39afd7;
--assoc-item-link-color: #39afd7;
--function-link-color: #fdd687;
--macro-link-color: #a37acc;
--keyword-link-color: #39afd7;
--mod-link-color: #39afd7;
--link-color: #39afd7;
}

.slider {
@@ -111,44 +119,12 @@ pre, .rustdoc.source .example-wrap {

.content .item-info::before { color: #ccc; }

.content span.foreigntype, .content a.foreigntype { color: #ffa0a5; }
.content span.union, .content a.union { color: #ffa0a5; }
.content span.constant, .content a.constant,
.content span.static, .content a.static { color: #39AFD7; }
.content span.primitive, .content a.primitive { color: #ffa0a5; }
.content span.traitalias, .content a.traitalias { color: #39AFD7; }
.content span.keyword, .content a.keyword { color: #39AFD7; }
.content span.mod, .content a.mod {
color: #39AFD7;
}
.content span.struct, .content a.struct {
color: #ffa0a5;
}
.content span.enum, .content a.enum {
color: #ffa0a5;
}
.content span.trait, .content a.trait {
color: #39AFD7;
}
.content span.type, .content a.type { color: #39AFD7; }
.content span.associatedtype, .content a.associatedtype { color: #39AFD7; }
.content span.fn, .content a.fn,
.content .fnname { color: #fdd687; }
.content span.attr, .content a.attr, .content span.derive,
.content a.derive, .content span.macro, .content a.macro {
color: #a37acc;
}

.sidebar a { color: #53b1db; }
.sidebar a.current.type { color: #53b1db; }

pre.rust .comment { color: #788797; }
pre.rust .doccomment { color: #a1ac88; }

a {
color: #39AFD7;
}

.sidebar h2 a,
.sidebar h3 a {
color: white;
31 changes: 8 additions & 23 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
@@ -22,6 +22,14 @@
--codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0);
--codeblock-ignore-color: rgba(255, 142, 0, .6);
--type-link-color: #2dbfb8;
--trait-link-color: #b78cf2;
--assoc-item-link-color: #d2991d;
--function-link-color: #2bab63;
--macro-link-color: #09bd00;
--keyword-link-color: #d2991d;
--mod-link-color: #d2991d;
--link-color: #d2991d;
}

.slider {
@@ -83,25 +91,6 @@ a.result-keyword:focus { background-color: #884719; }

.content .item-info::before { color: #ccc; }

.content span.enum, .content a.enum { color: #2dbfb8; }
.content span.struct, .content a.struct { color: #2dbfb8; }
.content span.type, .content a.type { color: #2dbfb8; }
.content span.associatedtype, .content a.associatedtype { color: #D2991D; }
.content span.foreigntype, .content a.foreigntype { color: #2dbfb8; }
.content span.attr, .content a.attr,
.content span.derive, .content a.derive,
.content span.macro, .content a.macro { color: #09bd00; }
.content span.union, .content a.union { color: #2dbfb8; }
.content span.constant, .content a.constant,
.content span.static, .content a.static { color: #D2991D; }
.content span.primitive, .content a.primitive { color: #2dbfb8; }
.content span.mod, .content a.mod { color: #D2991D; }
.content span.trait, .content a.trait { color: #b78cf2; }
.content span.traitalias, .content a.traitalias { color: #b78cf2; }
.content span.fn, .content a.fn,
.content .fnname { color: #2BAB63; }
.content span.keyword, .content a.keyword { color: #D2991D; }

.sidebar a { color: #fdbf35; }
.sidebar a.current.enum { color: #12ece2; }
.sidebar a.current.struct { color: #12ece2; }
@@ -122,10 +111,6 @@ a.result-keyword:focus { background-color: #884719; }
pre.rust .comment { color: #8d8d8b; }
pre.rust .doccomment { color: #8ca375; }

a {
color: #D2991D;
}

body.source .example-wrap pre.rust a {
background: #333;
}
31 changes: 8 additions & 23 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
@@ -22,6 +22,14 @@
--codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0);
--codeblock-ignore-color: rgba(255, 142, 0, .6);
--type-link-color: #ad378a;
--trait-link-color: #6e4fc9;
--assoc-item-link-color: #3873ad;
--function-link-color: #ad7c37;
--macro-link-color: #068000;
--keyword-link-color: #3873ad;
--mod-link-color: #3873ad;
--link-color: #3873ad;
}

.slider {
@@ -82,25 +90,6 @@ a.result-keyword:focus { background-color: #afc6e4; }

.content .item-info::before { color: #ccc; }

.content span.enum, .content a.enum { color: #AD378A; }
.content span.struct, .content a.struct { color: #AD378A; }
.content span.type, .content a.type { color: #AD378A; }
.content span.associatedtype, .content a.associatedtype { color: #3873AD; }
.content span.foreigntype, .content a.foreigntype { color: #3873AD; }
.content span.attr, .content a.attr,
.content span.derive, .content a.derive,
.content span.macro, .content a.macro { color: #068000; }
.content span.union, .content a.union { color: #AD378A; }
.content span.constant, .content a.constant,
.content span.static, .content a.static { color: #3873AD; }
.content span.primitive, .content a.primitive { color: #AD378A; }
.content span.mod, .content a.mod { color: #3873AD; }
.content span.trait, .content a.trait { color: #6E4FC9; }
.content span.traitalias, .content a.traitalias { color: #5137AD; }
.content span.fn, .content a.fn,
.content .fnname { color: #AD7C37; }
.content span.keyword, .content a.keyword { color: #3873AD; }

.sidebar a { color: #356da4; }
.sidebar a.current.enum { color: #a63283; }
.sidebar a.current.struct { color: #a63283; }
@@ -118,10 +107,6 @@ a.result-keyword:focus { background-color: #afc6e4; }
.sidebar a.current.fn { color: #a67736; }
.sidebar a.current.keyword { color: #356da4; }

a {
color: #3873AD;
}

body.source .example-wrap pre.rust a {
background: #eee;
}
85 changes: 85 additions & 0 deletions src/test/rustdoc-gui/links-color.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// This test checks links colors.
goto: file://|DOC_PATH|/test_docs/index.html

// This is needed so that the text color is computed.
show-text: true

// Ayu theme
local-storage: {
"rustdoc-theme": "ayu",
"rustdoc-use-system-theme": "false",
}
reload:

assert-css: (".item-table .mod", {"color": "rgb(57, 175, 215)"}, ALL)
assert-css: (".item-table .macro", {"color": "rgb(163, 122, 204)"}, ALL)
assert-css: (".item-table .struct", {"color": "rgb(255, 160, 165)"}, ALL)
assert-css: (".item-table .enum", {"color": "rgb(255, 160, 165)"}, ALL)
assert-css: (".item-table .trait", {"color": "rgb(57, 175, 215)"}, ALL)
assert-css: (".item-table .fn", {"color": "rgb(253, 214, 135)"}, ALL)
assert-css: (".item-table .type", {"color": "rgb(255, 160, 165)"}, ALL)
assert-css: (".item-table .union", {"color": "rgb(255, 160, 165)"}, ALL)
assert-css: (".item-table .keyword", {"color": "rgb(57, 175, 215)"}, ALL)

assert-css: (
".sidebar-elems a:not(.current)",
{"color": "rgb(83, 177, 219)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
ALL,
)
assert-css: (
".sidebar-elems a.current",
{"color": "rgb(255, 180, 76)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "500"},
ALL,
)


// Dark theme
local-storage: {"rustdoc-theme": "dark"}
reload:

assert-css: (".item-table .mod", {"color": "rgb(210, 153, 29)"}, ALL)
assert-css: (".item-table .macro", {"color": "rgb(9, 189, 0)"}, ALL)
assert-css: (".item-table .struct", {"color": "rgb(45, 191, 184)"}, ALL)
assert-css: (".item-table .enum", {"color": "rgb(45, 191, 184)"}, ALL)
assert-css: (".item-table .trait", {"color": "rgb(183, 140, 242)"}, ALL)
assert-css: (".item-table .fn", {"color": "rgb(43, 171, 99)"}, ALL)
assert-css: (".item-table .type", {"color": "rgb(45, 191, 184)"}, ALL)
assert-css: (".item-table .union", {"color": "rgb(45, 191, 184)"}, ALL)
assert-css: (".item-table .keyword", {"color": "rgb(210, 153, 29)"}, ALL)

assert-css: (
".sidebar-elems a:not(.current)",
{"color": "rgb(253, 191, 53)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
ALL,
)
assert-css: (
".sidebar-elems a.current",
{"color": "rgb(253, 191, 53)", "background-color": "rgb(68, 68, 68)", "font-weight": "500"},
ALL,
)


// Light theme
local-storage: {"rustdoc-theme": "light"}
reload:

assert-css: (".item-table .mod", {"color": "rgb(56, 115, 173)"}, ALL)
assert-css: (".item-table .macro", {"color": "rgb(6, 128, 0)"}, ALL)
assert-css: (".item-table .struct", {"color": "rgb(173, 55, 138)"}, ALL)
assert-css: (".item-table .enum", {"color": "rgb(173, 55, 138)"}, ALL)
assert-css: (".item-table .trait", {"color": "rgb(110, 79, 201)"}, ALL)
assert-css: (".item-table .fn", {"color": "rgb(173, 124, 55)"}, ALL)
assert-css: (".item-table .type", {"color": "rgb(173, 55, 138)"}, ALL)
assert-css: (".item-table .union", {"color": "rgb(173, 55, 138)"}, ALL)
assert-css: (".item-table .keyword", {"color": "rgb(56, 115, 173)"}, ALL)

assert-css: (
".sidebar-elems a:not(.current)",
{"color": "rgb(53, 109, 164)", "background-color": "rgba(0, 0, 0, 0)", "font-weight": "400"},
ALL,
)
assert-css: (
".sidebar-elems a.current",
{"color": "rgb(53, 109, 164)", "background-color": "rgb(255, 255, 255)", "font-weight": "500"},
ALL,
)
10 changes: 10 additions & 0 deletions src/test/rustdoc-ui/suggestions/html-as-generics.fixed
Original file line number Diff line number Diff line change
@@ -70,3 +70,13 @@ pub struct NestedGenericsWithPunct;
//~^ ERROR unclosed HTML tag `i32`
//~|HELP try marking as source
pub struct NestedGenericsWithPunct2;

/// This [`Vec<i32>`] thing!
//~^ERROR unclosed HTML tag `i32`
//~|HELP try marking as source
pub struct IntraDocLink;

/// This [`Vec::<i32>`] thing!
//~^ERROR unclosed HTML tag `i32`
//~|HELP try marking as source
pub struct IntraDocLinkTurbofish;
10 changes: 10 additions & 0 deletions src/test/rustdoc-ui/suggestions/html-as-generics.rs
Original file line number Diff line number Diff line change
@@ -70,3 +70,13 @@ pub struct NestedGenericsWithPunct;
//~^ ERROR unclosed HTML tag `i32`
//~|HELP try marking as source
pub struct NestedGenericsWithPunct2;

/// This [Vec<i32>] thing!
//~^ERROR unclosed HTML tag `i32`
//~|HELP try marking as source
pub struct IntraDocLink;

/// This [Vec::<i32>] thing!
//~^ERROR unclosed HTML tag `i32`
//~|HELP try marking as source
pub struct IntraDocLinkTurbofish;
24 changes: 23 additions & 1 deletion src/test/rustdoc-ui/suggestions/html-as-generics.stderr
Original file line number Diff line number Diff line change
@@ -157,5 +157,27 @@ help: try marking as source code
LL | /// Generics with punct `Vec<Vec<i32>>`!
| + +

error: aborting due to 14 previous errors
error: unclosed HTML tag `i32`
--> $DIR/html-as-generics.rs:74:14
|
LL | /// This [Vec<i32>] thing!
| ^^^^^
|
help: try marking as source code
|
LL | /// This [`Vec<i32>`] thing!
| + +

error: unclosed HTML tag `i32`
--> $DIR/html-as-generics.rs:79:16
|
LL | /// This [Vec::<i32>] thing!
| ^^^^^
|
help: try marking as source code
|
LL | /// This [`Vec::<i32>`] thing!
| + +

error: aborting due to 16 previous errors

4 changes: 2 additions & 2 deletions src/test/rustdoc/index-page.rs
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@

// @has foo/../index.html
// @has - '//span[@class="in-band"]' 'List of all crates'
// @has - '//ul[@class="crate mod"]//a[@href="foo/index.html"]' 'foo'
// @has - '//ul[@class="crate mod"]//a[@href="all_item_types/index.html"]' 'all_item_types'
// @has - '//ul[@class="all-items"]//a[@href="foo/index.html"]' 'foo'
// @has - '//ul[@class="all-items"]//a[@href="all_item_types/index.html"]' 'all_item_types'
pub struct Foo;
31 changes: 31 additions & 0 deletions src/test/ui/query-system/query_depth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// build-fail

#![recursion_limit = "64"]
type Byte = Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Option<Option<Option<Option< Option<Option<Option<Option<
Box<String>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>;

fn main() {
//~^ ERROR: queries overflow the depth limit!
println!("{}", std::mem::size_of::<Byte>());
}
11 changes: 11 additions & 0 deletions src/test/ui/query-system/query_depth.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: queries overflow the depth limit!
--> $DIR/query_depth.rs:28:1
|
LL | fn main() {
| ^^^^^^^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "128"]` attribute to your crate (`query_depth`)
= note: query depth increased by 66 when computing layout of `core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<core::option::Option<alloc::boxed::Box<alloc::string::String>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`

error: aborting due to previous error