提交 8c7f2bf4 编写于 作者: B bors

Auto merge of #93482 - ehuss:rollup-qjyppci, r=ehuss

Rollup of 5 pull requests

Successful merges:

 - #92887 (Bootstrap compiler update)
 - #92908 (Render more readable macro matcher tokens in rustdoc)
 - #93183 (rustdoc: mobile nav fixes)
 - #93192 (Add VS 2022 into error message)
 - #93475 (Add test to ensure that theme is applied correctly when going back in history)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
......@@ -457,7 +457,7 @@ fn spaces(&mut self, n: usize) {
self.break_offset(n, 0)
}
crate fn zerobreak(&mut self) {
pub fn zerobreak(&mut self) {
self.spaces(0)
}
......
......@@ -932,7 +932,7 @@ fn is_illegal_instruction(_status: &ExitStatus) -> bool {
but `link.exe` was not found",
);
sess.note_without_error(
"please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 \
"please ensure that VS 2013, VS 2015, VS 2017, VS 2019 or VS 2022 \
was installed with the Visual C++ option",
);
}
......
......@@ -2,7 +2,6 @@
#![feature(associated_type_defaults)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![cfg_attr(bootstrap, feature(destructuring_assignment))]
#![feature(if_let_guard)]
#![feature(let_else)]
#![feature(proc_macro_diagnostic)]
......
......@@ -784,24 +784,11 @@
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
cache_on_disk_if { true }
load_cached(tcx, id) {
#[cfg(bootstrap)]
{
match match tcx.on_disk_cache().as_ref() {
Some(c) => c.try_load_query_result(*tcx, id),
None => None,
} {
Some(x) => Some(&*tcx.arena.alloc(x)),
None => None,
}
}
#[cfg(not(bootstrap))]
{
let typeck_results: Option<ty::TypeckResults<'tcx>> = tcx
.on_disk_cache().as_ref()
.and_then(|c| c.try_load_query_result(*tcx, id));
let typeck_results: Option<ty::TypeckResults<'tcx>> = tcx
.on_disk_cache().as_ref()
.and_then(|c| c.try_load_query_result(*tcx, id));
typeck_results.map(|x| &*tcx.arena.alloc(x))
}
typeck_results.map(|x| &*tcx.arena.alloc(x))
}
}
......
......@@ -67,17 +67,14 @@
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(allow(unused_variables), deny(warnings)))
)]
#![cfg_attr(
not(bootstrap),
doc(cfg_hide(
not(test),
not(any(test, bootstrap)),
any(not(feature = "miri-test-libstd"), test, doctest),
no_global_oom_handling,
not(no_global_oom_handling),
target_has_atomic = "ptr"
))
)]
#![doc(cfg_hide(
not(test),
not(any(test, bootstrap)),
any(not(feature = "miri-test-libstd"), test, doctest),
no_global_oom_handling,
not(no_global_oom_handling),
target_has_atomic = "ptr"
))]
#![no_std]
#![needs_allocator]
//
......@@ -151,7 +148,6 @@
#![feature(const_precise_live_drops)]
#![feature(const_trait_impl)]
#![feature(const_try)]
#![cfg_attr(bootstrap, feature(destructuring_assignment))]
#![feature(dropck_eyepatch)]
#![feature(exclusive_range_pattern)]
#![feature(fundamental)]
......
......@@ -1310,11 +1310,7 @@ fn clone(&self) -> Self {
///
/// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "holding a Ref across suspend \
points can cause BorrowErrors"
)]
#[must_not_suspend = "holding a Ref across suspend points can cause BorrowErrors"]
pub struct Ref<'b, T: ?Sized + 'b> {
value: &'b T,
borrow: BorrowRef<'b>,
......@@ -1692,11 +1688,7 @@ fn clone(&self) -> BorrowRefMut<'b> {
///
/// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "holding a RefMut across suspend \
points can cause BorrowErrors"
)]
#[must_not_suspend = "holding a RefMut across suspend points can cause BorrowErrors"]
pub struct RefMut<'b, T: ?Sized + 'b> {
value: &'b mut T,
borrow: BorrowRefMut<'b>,
......
......@@ -13,7 +13,7 @@ pub trait IntoFuture {
/// Creates a future from a value.
#[unstable(feature = "into_future", issue = "67644")]
#[cfg_attr(not(bootstrap), lang = "into_future")]
#[lang = "into_future"]
fn into_future(self) -> Self::Future;
}
......
......@@ -60,32 +60,29 @@
test(no_crate_inject, attr(deny(warnings))),
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
)]
#![cfg_attr(
not(bootstrap),
doc(cfg_hide(
not(test),
any(not(feature = "miri-test-libstd"), test, doctest),
no_fp_fmt_parse,
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64",
target_has_atomic = "8",
target_has_atomic = "16",
target_has_atomic = "32",
target_has_atomic = "64",
target_has_atomic = "ptr",
target_has_atomic_equal_alignment = "8",
target_has_atomic_equal_alignment = "16",
target_has_atomic_equal_alignment = "32",
target_has_atomic_equal_alignment = "64",
target_has_atomic_equal_alignment = "ptr",
target_has_atomic_load_store = "8",
target_has_atomic_load_store = "16",
target_has_atomic_load_store = "32",
target_has_atomic_load_store = "64",
target_has_atomic_load_store = "ptr",
))
)]
#![doc(cfg_hide(
not(test),
any(not(feature = "miri-test-libstd"), test, doctest),
no_fp_fmt_parse,
target_pointer_width = "16",
target_pointer_width = "32",
target_pointer_width = "64",
target_has_atomic = "8",
target_has_atomic = "16",
target_has_atomic = "32",
target_has_atomic = "64",
target_has_atomic = "ptr",
target_has_atomic_equal_alignment = "8",
target_has_atomic_equal_alignment = "16",
target_has_atomic_equal_alignment = "32",
target_has_atomic_equal_alignment = "64",
target_has_atomic_equal_alignment = "ptr",
target_has_atomic_load_store = "8",
target_has_atomic_load_store = "16",
target_has_atomic_load_store = "32",
target_has_atomic_load_store = "64",
target_has_atomic_load_store = "ptr",
))]
#![no_core]
//
// Lints:
......
......@@ -1003,7 +1003,6 @@ pub(crate) mod builtin {
/// assert_eq!(s, b"ABCDEF");
/// # }
/// ```
#[cfg(not(bootstrap))]
#[unstable(feature = "concat_bytes", issue = "87555")]
#[rustc_builtin_macro]
#[macro_export]
......
......@@ -65,7 +65,6 @@
issue = "87555",
reason = "`concat_bytes` is not stable enough for use and is subject to change"
)]
#[cfg(not(bootstrap))]
#[doc(no_inline)]
pub use crate::concat_bytes;
......
......@@ -204,7 +204,6 @@ fn partial_cmp(&self, other: &RevInt) -> Option<Ordering> {
assert_eq!(Fool(false), Fool(true));
}
#[cfg(not(bootstrap))]
mod const_cmp {
use super::*;
......
......@@ -37,7 +37,6 @@ fn test_assume_can_be_in_const_contexts() {
}
#[test]
#[cfg(not(bootstrap))]
const fn test_write_bytes_in_const_contexts() {
use core::intrinsics::write_bytes;
......
......@@ -251,7 +251,6 @@ fn test_set_memory() {
}
#[test]
#[cfg(not(bootstrap))]
fn test_set_memory_const() {
const XS: [u8; 20] = {
let mut xs = [0u8; 20];
......
......@@ -195,15 +195,12 @@
test(no_crate_inject, attr(deny(warnings))),
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
)]
#![cfg_attr(
not(bootstrap),
doc(cfg_hide(
not(test),
not(any(test, bootstrap)),
no_global_oom_handling,
not(no_global_oom_handling)
))
)]
#![doc(cfg_hide(
not(test),
not(any(test, bootstrap)),
no_global_oom_handling,
not(no_global_oom_handling)
))]
// Don't link to std. We are std.
#![no_std]
#![warn(deprecated_in_future)]
......@@ -249,7 +246,7 @@
#![feature(cfg_target_thread_local)]
#![feature(char_error_internals)]
#![feature(char_internals)]
#![cfg_attr(not(bootstrap), feature(concat_bytes))]
#![feature(concat_bytes)]
#![feature(concat_idents)]
#![feature(const_fn_floating_point_arithmetic)]
#![feature(const_fn_fn_ptr_basics)]
......@@ -585,7 +582,6 @@ pub mod arch {
issue = "87555",
reason = "`concat_bytes` is not stable enough for use and is subject to change"
)]
#[cfg(not(bootstrap))]
pub use core::concat_bytes;
#[stable(feature = "core_primitive", since = "1.43.0")]
......
......@@ -49,7 +49,6 @@
issue = "87555",
reason = "`concat_bytes` is not stable enough for use and is subject to change"
)]
#[cfg(not(bootstrap))]
#[doc(no_inline)]
pub use core::prelude::v1::concat_bytes;
......
......@@ -188,12 +188,9 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {}
/// [`lock`]: Mutex::lock
/// [`try_lock`]: Mutex::try_lock
#[must_use = "if unused the Mutex will immediately unlock"]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "holding a MutexGuard across suspend \
#[must_not_suspend = "holding a MutexGuard across suspend \
points can cause deadlocks, delays, \
and cause Futures to not implement `Send`"
)]
and cause Futures to not implement `Send`"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct MutexGuard<'a, T: ?Sized + 'a> {
lock: &'a Mutex<T>,
......
......@@ -95,12 +95,9 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
/// [`read`]: RwLock::read
/// [`try_read`]: RwLock::try_read
#[must_use = "if unused the RwLock will immediately unlock"]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "holding a RwLockReadGuard across suspend \
#[must_not_suspend = "holding a RwLockReadGuard across suspend \
points can cause deadlocks, delays, \
and cause Futures to not implement `Send`"
)]
and cause Futures to not implement `Send`"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
lock: &'a RwLock<T>,
......@@ -121,12 +118,9 @@ unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {}
/// [`write`]: RwLock::write
/// [`try_write`]: RwLock::try_write
#[must_use = "if unused the RwLock will immediately unlock"]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "holding a RwLockWriteGuard across suspend \
#[must_not_suspend = "holding a RwLockWriteGuard across suspend \
points can cause deadlocks, delays, \
and cause Future's to not implement `Send`"
)]
and cause Future's to not implement `Send`"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
lock: &'a RwLock<T>,
......
......@@ -1088,20 +1088,11 @@ pub fn cargo(
}
};
// cfg(bootstrap) -- drop the compiler.stage == 0 branch.
if compiler.stage == 0 {
if use_new_symbol_mangling {
rustflags.arg("-Zsymbol-mangling-version=v0");
} else {
rustflags.arg("-Zsymbol-mangling-version=legacy");
}
if use_new_symbol_mangling {
rustflags.arg("-Csymbol-mangling-version=v0");
} else {
if use_new_symbol_mangling {
rustflags.arg("-Csymbol-mangling-version=v0");
} else {
rustflags.arg("-Csymbol-mangling-version=legacy");
rustflags.arg("-Zunstable-options");
}
rustflags.arg("-Csymbol-mangling-version=legacy");
rustflags.arg("-Zunstable-options");
}
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
......
......@@ -5,6 +5,7 @@
mod blanket_impl;
crate mod cfg;
crate mod inline;
mod render_macro_matchers;
mod simplify;
crate mod types;
crate mod utils;
......
use rustc_ast::token::{self, BinOpToken, DelimToken};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_ast_pretty::pprust::state::State as Printer;
use rustc_ast_pretty::pprust::PrintState;
use rustc_middle::ty::TyCtxt;
use rustc_session::parse::ParseSess;
use rustc_span::source_map::FilePathMapping;
use rustc_span::symbol::{kw, Ident, Symbol};
use rustc_span::Span;
/// Render a macro matcher in a format suitable for displaying to the user
/// as part of an item declaration.
pub(super) fn render_macro_matcher(tcx: TyCtxt<'_>, matcher: &TokenTree) -> String {
if let Some(snippet) = snippet_equal_to_token(tcx, matcher) {
// If the original source code is known, we display the matcher exactly
// as present in the source code.
return snippet;
}
// If the matcher is macro-generated or some other reason the source code
// snippet is not available, we attempt to nicely render the token tree.
let mut printer = Printer::new();
// If the inner ibox fits on one line, we get:
//
// macro_rules! macroname {
// (the matcher) => {...};
// }
//
// If the inner ibox gets wrapped, the cbox will break and get indented:
//
// macro_rules! macroname {
// (
// the matcher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
// ) => {...};
// }
printer.cbox(8);
printer.word("(");
printer.zerobreak();
printer.ibox(0);
match matcher {
TokenTree::Delimited(_span, _delim, tts) => print_tts(&mut printer, tts),
// Matcher which is not a Delimited is unexpected and should've failed
// to compile, but we render whatever it is wrapped in parens.
TokenTree::Token(_) => print_tt(&mut printer, matcher),
}
printer.end();
printer.break_offset_if_not_bol(0, -4);
printer.word(")");
printer.end();
printer.s.eof()
}
/// Find the source snippet for this token's Span, reparse it, and return the
/// snippet if the reparsed TokenTree matches the argument TokenTree.
fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String> {
// Find what rustc thinks is the source snippet.
// This may not actually be anything meaningful if this matcher was itself
// generated by a macro.
let source_map = tcx.sess.source_map();
let span = matcher.span();
let snippet = source_map.span_to_snippet(span).ok()?;
// Create a Parser.
let sess = ParseSess::new(FilePathMapping::empty());
let file_name = source_map.span_to_filename(span);
let mut parser =
match rustc_parse::maybe_new_parser_from_source_str(&sess, file_name, snippet.clone()) {
Ok(parser) => parser,
Err(diagnostics) => {
for mut diagnostic in diagnostics {
diagnostic.cancel();
}
return None;
}
};
// Reparse a single token tree.
let mut reparsed_trees = match parser.parse_all_token_trees() {
Ok(reparsed_trees) => reparsed_trees,
Err(mut diagnostic) => {
diagnostic.cancel();
return None;
}
};
if reparsed_trees.len() != 1 {
return None;
}
let reparsed_tree = reparsed_trees.pop().unwrap();
// Compare against the original tree.
if reparsed_tree.eq_unspanned(matcher) { Some(snippet) } else { None }
}
fn print_tt(printer: &mut Printer<'_>, tt: &TokenTree) {
match tt {
TokenTree::Token(token) => {
let token_str = printer.token_to_string(token);
printer.word(token_str);
if let token::DocComment(..) = token.kind {
printer.hardbreak()
}
}
TokenTree::Delimited(_span, delim, tts) => {
let open_delim = printer.token_kind_to_string(&token::OpenDelim(*delim));
printer.word(open_delim);
if !tts.is_empty() {
if *delim == DelimToken::Brace {
printer.space();
}
print_tts(printer, tts);
if *delim == DelimToken::Brace {
printer.space();
}
}
let close_delim = printer.token_kind_to_string(&token::CloseDelim(*delim));
printer.word(close_delim);
}
}
}
fn print_tts(printer: &mut Printer<'_>, tts: &TokenStream) {
#[derive(Copy, Clone, PartialEq)]
enum State {
Start,
Dollar,
DollarIdent,
DollarIdentColon,
DollarParen,
DollarParenSep,
Pound,
PoundBang,
Ident,
Other,
}
use State::*;
let mut state = Start;
for tt in tts.trees() {
let (needs_space, next_state) = match &tt {
TokenTree::Token(tt) => match (state, &tt.kind) {
(Dollar, token::Ident(..)) => (false, DollarIdent),
(DollarIdent, token::Colon) => (false, DollarIdentColon),
(DollarIdentColon, token::Ident(..)) => (false, Other),
(
DollarParen,
token::BinOp(BinOpToken::Plus | BinOpToken::Star) | token::Question,
) => (false, Other),
(DollarParen, _) => (false, DollarParenSep),
(DollarParenSep, token::BinOp(BinOpToken::Plus | BinOpToken::Star)) => {
(false, Other)
}
(Pound, token::Not) => (false, PoundBang),
(_, token::Ident(symbol, /* is_raw */ false))
if !usually_needs_space_between_keyword_and_open_delim(*symbol, tt.span) =>
{
(true, Ident)
}
(_, token::Comma | token::Semi) => (false, Other),
(_, token::Dollar) => (true, Dollar),
(_, token::Pound) => (true, Pound),
(_, _) => (true, Other),
},
TokenTree::Delimited(_, delim, _) => match (state, delim) {
(Dollar, DelimToken::Paren) => (false, DollarParen),
(Pound | PoundBang, DelimToken::Bracket) => (false, Other),
(Ident, DelimToken::Paren | DelimToken::Bracket) => (false, Other),
(_, _) => (true, Other),
},
};
if state != Start && needs_space {
printer.space();
}
print_tt(printer, &tt);
state = next_state;
}
}
fn usually_needs_space_between_keyword_and_open_delim(symbol: Symbol, span: Span) -> bool {
let ident = Ident { name: symbol, span };
let is_keyword = ident.is_used_keyword() || ident.is_unused_keyword();
if !is_keyword {
// An identifier that is not a keyword usually does not need a space
// before an open delim. For example: `f(0)` or `f[0]`.
return false;
}
match symbol {
// No space after keywords that are syntactically an expression. For
// example: a tuple struct created with `let _ = Self(0, 0)`, or if
// someone has `impl Index<MyStruct> for bool` then `true[MyStruct]`.
kw::False | kw::SelfLower | kw::SelfUpper | kw::True => false,
// No space, as in `let _: fn();`
kw::Fn => false,
// No space, as in `pub(crate) type T;`
kw::Pub => false,
// No space for keywords that can end an expression, as in `fut.await()`
// where fut's Output type is `fn()`.
kw::Await => false,
// Otherwise space after keyword. Some examples:
//
// `expr as [T; 2]`
// ^
// `box (tuple,)`
// ^
// `break (tuple,)`
// ^
// `type T = dyn (Fn() -> dyn Trait) + Send;`
// ^
// `for (tuple,) in iter {}`
// ^
// `if (tuple,) == v {}`
// ^
// `impl [T] {}`
// ^
// `for x in [..] {}`
// ^
// `let () = unit;`
// ^
// `match [x, y] {...}`
// ^
// `&mut (x as T)`
// ^
// `return [];`
// ^
// `fn f<T>() where (): Into<T>`
// ^
// `while (a + b).what() {}`
// ^
// `yield [];`
// ^
_ => true,
}
}
use crate::clean::auto_trait::AutoTraitFinder;
use crate::clean::blanket_impl::BlanketImplFinder;
use crate::clean::render_macro_matchers::render_macro_matcher;
use crate::clean::{
inline, Clean, Crate, ExternalCrate, Generic, GenericArg, GenericArgs, ImportSource, Item,
ItemKind, Lifetime, Path, PathSegment, Primitive, PrimitiveType, Type, TypeBinding, Visibility,
......@@ -17,8 +18,6 @@
use rustc_middle::mir::interpret::ConstValue;
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
use rustc_session::parse::ParseSess;
use rustc_span::source_map::FilePathMapping;
use rustc_span::symbol::{kw, sym, Symbol};
use std::fmt::Write as _;
use std::mem;
......@@ -500,57 +499,6 @@ pub(super) fn render_macro_arms<'a>(
out
}
/// Render a macro matcher in a format suitable for displaying to the user
/// as part of an item declaration.
pub(super) fn render_macro_matcher(tcx: TyCtxt<'_>, matcher: &TokenTree) -> String {
if let Some(snippet) = snippet_equal_to_token(tcx, matcher) {
snippet
} else {
rustc_ast_pretty::pprust::tt_to_string(matcher)
}
}
/// Find the source snippet for this token's Span, reparse it, and return the
/// snippet if the reparsed TokenTree matches the argument TokenTree.
fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String> {
// Find what rustc thinks is the source snippet.
// This may not actually be anything meaningful if this matcher was itself
// generated by a macro.
let source_map = tcx.sess.source_map();
let span = matcher.span();
let snippet = source_map.span_to_snippet(span).ok()?;
// Create a Parser.
let sess = ParseSess::new(FilePathMapping::empty());
let file_name = source_map.span_to_filename(span);
let mut parser =
match rustc_parse::maybe_new_parser_from_source_str(&sess, file_name, snippet.clone()) {
Ok(parser) => parser,
Err(diagnostics) => {
for mut diagnostic in diagnostics {
diagnostic.cancel();
}
return None;
}
};
// Reparse a single token tree.
let mut reparsed_trees = match parser.parse_all_token_trees() {
Ok(reparsed_trees) => reparsed_trees,
Err(mut diagnostic) => {
diagnostic.cancel();
return None;
}
};
if reparsed_trees.len() != 1 {
return None;
}
let reparsed_tree = reparsed_trees.pop().unwrap();
// Compare against the original tree.
if reparsed_tree.eq_unspanned(matcher) { Some(snippet) } else { None }
}
pub(super) fn display_macro_source(
cx: &mut DocContext<'_>,
name: Symbol,
......
......@@ -1799,8 +1799,9 @@ details.rustdoc-toggle[open] > summary.hideme::after {
background-color: rgba(0,0,0,0);
margin: 0;
padding: 0;
padding-left: 15px;
z-index: 11;
/* Reduce height slightly to account for mobile topbar. */
height: calc(100vh - 45px);
}
/* The source view uses a different design for the sidebar toggle, and doesn't have a topbar,
......@@ -1831,7 +1832,13 @@ details.rustdoc-toggle[open] > summary.hideme::after {
padding: 0.3em;
padding-right: 0.6em;
text-overflow: ellipsis;
overflow-x: hidden;
overflow: hidden;
white-space: nowrap;
/* Rare exception to specifying font sizes in rem. Since the topbar
height is specified in pixels, this also has to be specified in
pixels to avoid overflowing the topbar when the user sets a bigger
font size. */
font-size: 22.4px;
}
.mobile-topbar .logo-container {
......@@ -1864,6 +1871,9 @@ details.rustdoc-toggle[open] > summary.hideme::after {
.sidebar-menu-toggle {
width: 45px;
/* Rare exception to specifying font sizes in rem. Since this is acting
as an icon, it's okay to specify its sizes in pixels. */
font-size: 32px;
border: none;
}
......
......@@ -216,6 +216,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #c5c5c5;
}
......
......@@ -192,6 +192,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #ddd;
}
......
......@@ -189,6 +189,7 @@ a.anchor,
pre.rust a,
.sidebar h2 a,
.sidebar h3 a,
.mobile-topbar h2 a,
.in-band a {
color: #000;
}
......
......@@ -72,7 +72,7 @@ function resourcePath(basename, extension) {
var mobileLocationTitle = document.querySelector(".mobile-topbar h2.location");
var locationTitle = document.querySelector(".sidebar h2.location");
if (mobileLocationTitle && locationTitle) {
mobileLocationTitle.innerText = locationTitle.innerText;
mobileLocationTitle.innerHTML = locationTitle.innerHTML;
}
}
}());
......
此差异已折叠。
......@@ -2,6 +2,8 @@
goto: file://|DOC_PATH|/staged_api/struct.Foo.html
size: (400, 600)
font-size: 18
// The out-of-band info (source, stable version, collapse) should be below the
// h1 when the screen gets narrow enough.
assert-css: (".main-heading", {
......@@ -9,6 +11,8 @@ assert-css: (".main-heading", {
"flex-direction": "column"
})
assert-property: (".mobile-topbar h2.location", {"offsetHeight": 45})
// Note: We can't use assert-text here because the 'Since' is set by CSS and
// is therefore not part of the DOM.
assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" })
......
......@@ -35,3 +35,8 @@ assert-property: (".mobile-topbar", {"clientHeight": "45"})
click: ".sidebar-menu-toggle"
click: ".sidebar-links a"
assert-position: ("#method\.must_use", {"y": 45})
// Check that the bottom-most item on the sidebar menu can be scrolled fully into view.
click: ".sidebar-menu-toggle"
scroll-to: ".block.keyword li:nth-child(1)"
assert-position: (".block.keyword li:nth-child(1)", {"y": 542.96875})
// Ensures that the theme is working when going back in history.
goto: file://|DOC_PATH|/test_docs/index.html
// Set the theme to dark.
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
// We reload the page so the local storage settings are being used.
reload:
assert-css: ("body", { "background-color": "rgb(53, 53, 53)" })
assert-local-storage: { "rustdoc-theme": "dark" }
// Now we go to the settings page.
click: "#settings-menu"
wait-for: ".settings"
// We change the theme to "light".
click: "#theme-light"
wait-for: 250
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
assert-local-storage: { "rustdoc-theme": "light" }
// We go back in history.
history-go-back:
// Confirm that we're not on the settings page.
assert-false: ".settings"
// Check that the current theme is still "light".
assert-css: ("body", { "background-color": "rgb(255, 255, 255)" })
assert-local-storage: { "rustdoc-theme": "light" }
......@@ -31,6 +31,6 @@ assert-property: (".item-decl pre", {"scrollWidth": "950"})
// On mobile:
size: (600, 600)
goto: file://|DOC_PATH|/lib2/too_long/struct.SuperIncrediblyLongLongLongLongLongLongLongGigaGigaGigaMegaLongLongLongStructName.html
assert-property: (".mobile-topbar .location", {"scrollWidth": "504"})
assert-property: (".mobile-topbar .location", {"scrollWidth": "986"})
assert-property: (".mobile-topbar .location", {"clientWidth": "504"})
assert-css: (".mobile-topbar .location", {"overflow-x": "hidden"})
macro_rules! linebreak {
(
<= 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
26 27 28 =>
) => { ... };
}
\ No newline at end of file
macro_rules! morestuff {
(
<= "space between most kinds of tokens" : 1 $x + @ :: >>= 'static
"no space inside paren or bracket" : (2 a) [2 a] $(2 $a:tt)*
"space inside curly brace" : { 2 a }
"no space inside empty delimiters" : () [] {}
"no space before comma or semicolon" : a, (a), { a }, a; [T; 0];
"the three repetition specifiers" : $(@)*, $(@)+, $(@)?
"repetition separators" : $(@)|*, $(@)|+, $(@)==*, $(@)static*
"plus or star cannot be a repetition separator" : $(@)+ * $(@)* +
"no space between ident and paren" : let _ = f(0) + f[0] + Struct {};
"space between keyword and paren" : return (a,) & for x in (..)
"some special case keywords" : pub(crate), fn() -> u8, Self(0, 0) =>
) => { ... };
}
\ No newline at end of file
macro_rules! outer {
($($matcher:tt)*) => {
macro_rules! make_macro {
($macro_name:ident $($matcher:tt)*) => {
#[macro_export]
macro_rules! inner {
macro_rules! $macro_name {
(<= $($matcher)* =>) => {};
}
}
}
// @has macro_generated_macro/macro.inner.html //pre 'macro_rules! inner {'
// @has - //pre '(<= type $($i : ident) :: * + $e : expr =>) => { ... };'
outer!(type $($i:ident)::* + $e:expr);
// @has macro_generated_macro/macro.interpolations.html //pre 'macro_rules! interpolations {'
// @has - //pre '(<= type $($i:ident)::* + $e:expr =>) => { ... };'
make_macro!(interpolations type $($i:ident)::* + $e:expr);
interpolations!(<= type foo::bar + x.sort() =>);
inner!(<= type foo::bar + x.sort() =>);
// @has macro_generated_macro/macro.attributes.html //pre 'macro_rules! attributes {'
// @has - //pre '(<= #![no_std] #[cfg(feature = "alloc")] =>) => { ... };'
make_macro!(attributes #![no_std] #[cfg(feature = "alloc")]);
// @has macro_generated_macro/macro.groups.html //pre 'macro_rules! groups {'
// @has - //pre '(<= fn {} () { foo[0] } =>) => { ... };'
make_macro!(groups fn {}() {foo[0]});
// @snapshot macro_linebreak_pre macro_generated_macro/macro.linebreak.html //pre/text()
make_macro!(linebreak 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28);
// @snapshot macro_morestuff_pre macro_generated_macro/macro.morestuff.html //pre/text()
make_macro!(morestuff
"space between most kinds of tokens": 1 $x + @ :: >>= 'static
"no space inside paren or bracket": (2 a) [2 a] $(2 $a:tt)*
"space inside curly brace": { 2 a }
"no space inside empty delimiters": () [] {}
"no space before comma or semicolon": a, (a), { a }, a; [T; 0];
"the three repetition specifiers": $(@)*, $(@)+, $(@)?
"repetition separators": $(@)|*, $(@)|+, $(@)==*, $(@)static*
"plus or star cannot be a repetition separator": $(@)+ * $(@)* +
"no space between ident and paren": let _ = f(0) + f[0] + Struct {};
"space between keyword and paren": return (a,) & for x in (..)
"some special case keywords": pub(crate), fn() -> u8, Self(0, 0)
);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册