1
Fork 0

Auto merge of #83398 - JohnTitor:rollup-om80krv, r=JohnTitor

Rollup of 7 pull requests

Successful merges:

 - #80705 (Update Source Code Pro and include italics)
 - #81917 (Update RELEASES.md for 1.51.0)
 - #82732 (Remove theme.js file)
 - #83356 (rustdoc: Replace pair of `Option`s with an enum)
 - #83384 (rename :pat2018 -> :pat2015)
 - #83385 (⬆️ rust-analyzer)
 - #83389 (add rust-analyzer rustc_private option in librustdoc Cargo.toml)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2021-03-23 02:01:14 +00:00
commit 2bd94f4aa9
26 changed files with 314 additions and 114 deletions

View file

@ -1,3 +1,174 @@
Version 1.51.0 (2021-03-25)
============================
Language
--------
- [You can now parameterize items such as functions, traits, and `struct`s by constant
values in addition to by types and lifetimes.][79135] Also known as "const generics"
E.g. you can now write the following. Note: Only values of primitive integers,
`bool`, or `char` types are currently permitted.
```rust
struct GenericArray<T, const LENGTH: usize> {
inner: [T; LENGTH]
}
impl<T, const LENGTH: usize> GenericArray<T, LENGTH> {
const fn last(&self) -> Option<&T> {
if LENGTH == 0 {
None
} else {
Some(&self.inner[LENGTH - 1])
}
}
}
```
Compiler
--------
- [Added the `-Csplit-debuginfo` codegen option for macOS platforms.][79570]
This option controls whether debug information is split across multiple files
or packed into a single file. **Note** This option is unstable on other platforms.
- [Added tier 3\* support for `aarch64_be-unknown-linux-gnu`,
`aarch64-unknown-linux-gnu_ilp32`, and `aarch64_be-unknown-linux-gnu_ilp32` targets.][81455]
- [Added tier 3 support for `i386-unknown-linux-gnu` and `i486-unknown-linux-gnu` targets.][80662]
- [The `target-cpu=native` option will now detect individual features of CPUs.][80749]
- [Rust now uses `inline-asm` for stack probes when used with LLVM 11.0.1+][77885]
\* Refer to Rust's [platform support page][forge-platform-support] for more
information on Rust's tiered platform support.
Libraries
---------
- [`Box::downcast` is now also implemented for any `dyn Any + Send + Sync` object.][80945]
- [`str` now implements `AsMut<str>`.][80279]
- [`u64` and `u128` now implement `From<char>`.][79502]
- [`Error` is now implemented for `&T` where `T` implements `Error`.][75180]
- [`Poll::{map_ok, map_err}` are now implemented for `Poll<Option<Result<T, E>>>`.][80968]
- [`unsigned_abs` is now implemented for all signed integer types.][80959]
- [`io::Empty` now implements `io::Seek`.][78044]
- [`rc::Weak<T>` and `sync::Weak<T>`'s methods such as `as_ptr` are now implemented for
`T: ?Sized` types.][80764]
Stabilized APIs
---------------
- [`Arc::decrement_strong_count`]
- [`Arc::increment_strong_count`]
- [`Once::call_once_force`]
- [`Peekable::next_if_eq`]
- [`Peekable::next_if`]
- [`Seek::stream_position`]
- [`array::IntoIter`]
- [`panic::panic_any`]
- [`ptr::addr_of!`]
- [`ptr::addr_of_mut!`]
- [`slice::fill_with`]
- [`slice::split_inclusive_mut`]
- [`slice::split_inclusive`]
- [`slice::strip_prefix`]
- [`slice::strip_suffix`]
- [`str::split_inclusive`]
- [`sync::OnceState`]
- [`task::Wake`]
Cargo
-----
- [Added the `split-debuginfo` profile option to control the -Csplit-debuginfo
codegen option.][cargo/9112]
- [Added the `resolver` field to `Cargo.toml` to enable the new feature resolver
and CLI option behavior.][cargo/8997] Version 2 of the feature resolver will try
to avoid unifying features of dependencies where that unification could be unwanted.
Such as using the same dependency with a `std` feature in a build scripts and
proc-macros, while using the `no-std` feature in the final binary. See the
[Cargo book documentation][feature-resolver@2.0] for more information on the feature.
Rustdoc
-------
- [Rustdoc will now include documentation for methods available from `Deref` traits.][80653]
- [You can now provide a `--default-theme` flag which sets the default theme to use for
documentation.][79642]
Various improvements to intra-doc links:
- [You can link to non-path primitives such as `slice`.][80181]
- [You can link to associated items.][74489]
- [You can now include generic parameters when linking to items, like `Vec<T>`.][76934]
Misc
----
- [You can now pass `--include-ignored` to tests (e.g. with
`cargo test -- --include-ignored`) to include testing tests marked `#[ignore]`.][80053]
Compatibility Notes
-------------------
- [WASI platforms no longer use the `wasm-bindgen` ABI, and instead use the wasm32 ABI.][79998]
- [`rustc` no longer promotes division, modulo and indexing operations to `const` that
could fail.][80579]
- [The minimum version of glibc for the following platforms has been bumped to version 2.31
for the distributed artifacts.][81521]
- `armv5te-unknown-linux-gnueabi`
- `sparc64-unknown-linux-gnu`
- `thumbv7neon-unknown-linux-gnueabihf`
- `armv7-unknown-linux-gnueabi`
- `x86_64-unknown-linux-gnux32`
Internal Only
-------------
- [Consistently avoid constructing optimized MIR when not doing codegen][80718]
[79135]: https://github.com/rust-lang/rust/pull/79135
[74489]: https://github.com/rust-lang/rust/pull/74489
[76934]: https://github.com/rust-lang/rust/pull/76934
[79570]: https://github.com/rust-lang/rust/pull/79570
[80181]: https://github.com/rust-lang/rust/pull/80181
[79642]: https://github.com/rust-lang/rust/pull/79642
[80945]: https://github.com/rust-lang/rust/pull/80945
[80279]: https://github.com/rust-lang/rust/pull/80279
[80053]: https://github.com/rust-lang/rust/pull/80053
[79502]: https://github.com/rust-lang/rust/pull/79502
[75180]: https://github.com/rust-lang/rust/pull/75180
[79135]: https://github.com/rust-lang/rust/pull/79135
[81521]: https://github.com/rust-lang/rust/pull/81521
[80968]: https://github.com/rust-lang/rust/pull/80968
[80959]: https://github.com/rust-lang/rust/pull/80959
[80718]: https://github.com/rust-lang/rust/pull/80718
[80653]: https://github.com/rust-lang/rust/pull/80653
[80579]: https://github.com/rust-lang/rust/pull/80579
[79998]: https://github.com/rust-lang/rust/pull/79998
[78044]: https://github.com/rust-lang/rust/pull/78044
[81455]: https://github.com/rust-lang/rust/pull/81455
[80764]: https://github.com/rust-lang/rust/pull/80764
[80749]: https://github.com/rust-lang/rust/pull/80749
[80662]: https://github.com/rust-lang/rust/pull/80662
[77885]: https://github.com/rust-lang/rust/pull/77885
[cargo/8997]: https://github.com/rust-lang/cargo/pull/8997
[cargo/9112]: https://github.com/rust-lang/cargo/pull/9112
[feature-resolver@2.0]: https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2
[`Once::call_once_force`]: https://doc.rust-lang.org/stable/std/sync/struct.Once.html#method.call_once_force
[`sync::OnceState`]: https://doc.rust-lang.org/stable/std/sync/struct.OnceState.html
[`panic::panic_any`]: https://doc.rust-lang.org/stable/std/panic/fn.panic_any.html
[`slice::strip_prefix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
[`slice::strip_suffix`]: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.strip_prefix
[`Arc::increment_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.increment_strong_count
[`Arc::decrement_strong_count`]: https://doc.rust-lang.org/nightly/std/sync/struct.Arc.html#method.decrement_strong_count
[`slice::fill_with`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.fill_with
[`ptr::addr_of!`]: https://doc.rust-lang.org/nightly/std/ptr/macro.addr_of.html
[`ptr::addr_of_mut!`]: https://doc.rust-lang.org/nightly/std/ptr/macro.addr_of_mut.html
[`array::IntoIter`]: https://doc.rust-lang.org/nightly/std/array/struct.IntoIter.html
[`slice::split_inclusive`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_inclusive
[`slice::split_inclusive_mut`]: https://doc.rust-lang.org/nightly/std/primitive.slice.html#method.split_inclusive_mut
[`str::split_inclusive`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_inclusive
[`task::Wake`]: https://doc.rust-lang.org/nightly/std/task/trait.Wake.html
[`Seek::stream_position`]: https://doc.rust-lang.org/nightly/std/io/trait.Seek.html#method.stream_position
[`Peekable::next_if`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if
[`Peekable::next_if_eq`]: https://doc.rust-lang.org/nightly/std/iter/struct.Peekable.html#method.next_if_eq
Version 1.50.0 (2021-02-11) Version 1.50.0 (2021-02-11)
============================ ============================

View file

@ -688,13 +688,13 @@ pub enum NonterminalKind {
Item, Item,
Block, Block,
Stmt, Stmt,
Pat2018 { Pat2015 {
/// Keep track of whether the user used `:pat2018` or `:pat` and we inferred it from the /// Keep track of whether the user used `:pat2015` or `:pat` and we inferred it from the
/// edition of the span. This is used for diagnostics. /// edition of the span. This is used for diagnostics.
inferred: bool, inferred: bool,
}, },
Pat2021 { Pat2021 {
/// Keep track of whether the user used `:pat2018` or `:pat` and we inferred it from the /// Keep track of whether the user used `:pat2015` or `:pat` and we inferred it from the
/// edition of the span. This is used for diagnostics. /// edition of the span. This is used for diagnostics.
inferred: bool, inferred: bool,
}, },
@ -722,11 +722,11 @@ impl NonterminalKind {
sym::stmt => NonterminalKind::Stmt, sym::stmt => NonterminalKind::Stmt,
sym::pat => match edition() { sym::pat => match edition() {
Edition::Edition2015 | Edition::Edition2018 => { Edition::Edition2015 | Edition::Edition2018 => {
NonterminalKind::Pat2018 { inferred: true } NonterminalKind::Pat2015 { inferred: true }
} }
Edition::Edition2021 => NonterminalKind::Pat2021 { inferred: true }, Edition::Edition2021 => NonterminalKind::Pat2021 { inferred: true },
}, },
sym::pat2018 => NonterminalKind::Pat2018 { inferred: false }, sym::pat2015 => NonterminalKind::Pat2015 { inferred: false },
sym::pat2021 => NonterminalKind::Pat2021 { inferred: false }, sym::pat2021 => NonterminalKind::Pat2021 { inferred: false },
sym::expr => NonterminalKind::Expr, sym::expr => NonterminalKind::Expr,
sym::ty => NonterminalKind::Ty, sym::ty => NonterminalKind::Ty,
@ -745,9 +745,9 @@ impl NonterminalKind {
NonterminalKind::Item => sym::item, NonterminalKind::Item => sym::item,
NonterminalKind::Block => sym::block, NonterminalKind::Block => sym::block,
NonterminalKind::Stmt => sym::stmt, NonterminalKind::Stmt => sym::stmt,
NonterminalKind::Pat2018 { inferred: false } => sym::pat2018, NonterminalKind::Pat2015 { inferred: false } => sym::pat2015,
NonterminalKind::Pat2021 { inferred: false } => sym::pat2021, NonterminalKind::Pat2021 { inferred: false } => sym::pat2021,
NonterminalKind::Pat2018 { inferred: true } NonterminalKind::Pat2015 { inferred: true }
| NonterminalKind::Pat2021 { inferred: true } => sym::pat, | NonterminalKind::Pat2021 { inferred: true } => sym::pat,
NonterminalKind::Expr => sym::expr, NonterminalKind::Expr => sym::expr,
NonterminalKind::Ty => sym::ty, NonterminalKind::Ty => sym::ty,

View file

@ -1080,7 +1080,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
_ => IsInFollow::No(TOKENS), _ => IsInFollow::No(TOKENS),
} }
} }
NonterminalKind::Pat2018 { .. } | NonterminalKind::Pat2021 { .. } => { NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => {
const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`|`", "`if`", "`in`"]; const TOKENS: &[&str] = &["`=>`", "`,`", "`=`", "`|`", "`if`", "`in`"];
match tok { match tok {
TokenTree::Token(token) => match token.kind { TokenTree::Token(token) => match token.kind {

View file

@ -63,13 +63,13 @@ pub(super) fn parse(
let span = token.span.with_lo(start_sp.lo()); let span = token.span.with_lo(start_sp.lo());
match frag.name { match frag.name {
sym::pat2018 | sym::pat2021 => { sym::pat2015 | sym::pat2021 => {
if !features.edition_macro_pats { if !features.edition_macro_pats {
feature_err( feature_err(
sess, sess,
sym::edition_macro_pats, sym::edition_macro_pats,
frag.span, frag.span,
"`pat2018` and `pat2021` are unstable.", "`pat2015` and `pat2021` are unstable.",
) )
.emit(); .emit();
} }

View file

@ -611,7 +611,7 @@ declare_features! (
/// Allows arbitrary expressions in key-value attributes at parse time. /// Allows arbitrary expressions in key-value attributes at parse time.
(active, extended_key_value_attributes, "1.50.0", Some(78835), None), (active, extended_key_value_attributes, "1.50.0", Some(78835), None),
/// `:pat2018` and `:pat2021` macro matchers. /// `:pat2015` and `:pat2021` macro matchers.
(active, edition_macro_pats, "1.51.0", Some(54883), None), (active, edition_macro_pats, "1.51.0", Some(54883), None),
/// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`). /// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`).

View file

@ -61,7 +61,7 @@ impl<'a> Parser<'a> {
}, },
_ => false, _ => false,
}, },
NonterminalKind::Pat2018 { .. } | NonterminalKind::Pat2021 { .. } => match token.kind { NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => match token.kind {
token::Ident(..) | // box, ref, mut, and other identifiers (can stricten) token::Ident(..) | // box, ref, mut, and other identifiers (can stricten)
token::OpenDelim(token::Paren) | // tuple pattern token::OpenDelim(token::Paren) | // tuple pattern
token::OpenDelim(token::Bracket) | // slice pattern token::OpenDelim(token::Bracket) | // slice pattern
@ -118,9 +118,9 @@ impl<'a> Parser<'a> {
return Err(self.struct_span_err(self.token.span, "expected a statement")); return Err(self.struct_span_err(self.token.span, "expected a statement"));
} }
}, },
NonterminalKind::Pat2018 { .. } | NonterminalKind::Pat2021 { .. } => { NonterminalKind::Pat2015 { .. } | NonterminalKind::Pat2021 { .. } => {
token::NtPat(self.collect_tokens_no_attrs(|this| match kind { token::NtPat(self.collect_tokens_no_attrs(|this| match kind {
NonterminalKind::Pat2018 { .. } => this.parse_pat_no_top_alt(None), NonterminalKind::Pat2015 { .. } => this.parse_pat_no_top_alt(None),
NonterminalKind::Pat2021 { .. } => { NonterminalKind::Pat2021 { .. } => {
this.parse_pat_allow_top_alt(None, RecoverComma::No) this.parse_pat_allow_top_alt(None, RecoverComma::No)
} }

View file

@ -845,7 +845,7 @@ symbols! {
partial_ord, partial_ord,
passes, passes,
pat, pat,
pat2018, pat2015,
pat2021, pat2021,
path, path,
pattern_parentheses, pattern_parentheses,

View file

@ -29,3 +29,6 @@ features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"]
[dev-dependencies] [dev-dependencies]
expect-test = "1.0" expect-test = "1.0"
[package.metadata.rust-analyzer]
rustc_private = true

View file

@ -88,7 +88,6 @@ crate fn render<T: Print, S: Print>(
</button>\ </button>\
<div id=\"theme-choices\" role=\"menu\"></div>\ <div id=\"theme-choices\" role=\"menu\"></div>\
</div>\ </div>\
<script src=\"{static_root_path}theme{suffix}.js\"></script>\
<nav class=\"sub\">\ <nav class=\"sub\">\
<form class=\"search-form\">\ <form class=\"search-form\">\
<div class=\"search-container\">\ <div class=\"search-container\">\

View file

@ -690,25 +690,29 @@ crate fn find_testable_code<T: doctest::Tester>(
} }
crate struct ExtraInfo<'tcx> { crate struct ExtraInfo<'tcx> {
hir_id: Option<HirId>, id: ExtraInfoId,
item_did: Option<DefId>,
sp: Span, sp: Span,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
} }
enum ExtraInfoId {
Hir(HirId),
Def(DefId),
}
impl<'tcx> ExtraInfo<'tcx> { impl<'tcx> ExtraInfo<'tcx> {
crate fn new(tcx: TyCtxt<'tcx>, hir_id: HirId, sp: Span) -> ExtraInfo<'tcx> { crate fn new(tcx: TyCtxt<'tcx>, hir_id: HirId, sp: Span) -> ExtraInfo<'tcx> {
ExtraInfo { hir_id: Some(hir_id), item_did: None, sp, tcx } ExtraInfo { id: ExtraInfoId::Hir(hir_id), sp, tcx }
} }
crate fn new_did(tcx: TyCtxt<'tcx>, did: DefId, sp: Span) -> ExtraInfo<'tcx> { crate fn new_did(tcx: TyCtxt<'tcx>, did: DefId, sp: Span) -> ExtraInfo<'tcx> {
ExtraInfo { hir_id: None, item_did: Some(did), sp, tcx } ExtraInfo { id: ExtraInfoId::Def(did), sp, tcx }
} }
fn error_invalid_codeblock_attr(&self, msg: &str, help: &str) { fn error_invalid_codeblock_attr(&self, msg: &str, help: &str) {
let hir_id = match (self.hir_id, self.item_did) { let hir_id = match self.id {
(Some(h), _) => h, ExtraInfoId::Hir(hir_id) => hir_id,
(None, Some(item_did)) => { ExtraInfoId::Def(item_did) => {
match item_did.as_local() { match item_did.as_local() {
Some(item_did) => self.tcx.hir().local_def_id_to_hir_id(item_did), Some(item_did) => self.tcx.hir().local_def_id_to_hir_id(item_did),
None => { None => {
@ -717,7 +721,6 @@ impl<'tcx> ExtraInfo<'tcx> {
} }
} }
} }
(None, None) => return,
}; };
self.tcx.struct_span_lint_hir( self.tcx.struct_span_lint_hir(
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,

View file

@ -30,8 +30,9 @@ crate static FILES_UNVERSIONED: Lazy<FxHashMap<&str, &[u8]>> = Lazy::new(|| {
"SourceSerifPro-Bold.ttf.woff" => static_files::source_serif_pro::BOLD, "SourceSerifPro-Bold.ttf.woff" => static_files::source_serif_pro::BOLD,
"SourceSerifPro-It.ttf.woff" => static_files::source_serif_pro::ITALIC, "SourceSerifPro-It.ttf.woff" => static_files::source_serif_pro::ITALIC,
"SourceSerifPro-LICENSE.md" => static_files::source_serif_pro::LICENSE, "SourceSerifPro-LICENSE.md" => static_files::source_serif_pro::LICENSE,
"SourceCodePro-Regular.woff" => static_files::source_code_pro::REGULAR, "SourceCodePro-Regular.ttf.woff" => static_files::source_code_pro::REGULAR,
"SourceCodePro-Semibold.woff" => static_files::source_code_pro::SEMIBOLD, "SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD,
"SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC,
"SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE, "SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE,
"LICENSE-MIT.txt" => static_files::LICENSE_MIT, "LICENSE-MIT.txt" => static_files::LICENSE_MIT,
"LICENSE-APACHE.txt" => static_files::LICENSE_APACHE, "LICENSE-APACHE.txt" => static_files::LICENSE_APACHE,
@ -129,65 +130,14 @@ pub(super) fn write_shared(
let mut themes: Vec<&String> = themes.iter().collect(); let mut themes: Vec<&String> = themes.iter().collect();
themes.sort(); themes.sort();
// To avoid theme switch latencies as much as possible, we put everything theme related
// at the beginning of the html files into another js file.
let theme_js = format!(
r#"var themes = document.getElementById("theme-choices");
var themePicker = document.getElementById("theme-picker");
function showThemeButtonState() {{
themes.style.display = "block";
themePicker.style.borderBottomRightRadius = "0";
themePicker.style.borderBottomLeftRadius = "0";
}}
function hideThemeButtonState() {{
themes.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
}}
function switchThemeButtonState() {{
if (themes.style.display === "block") {{
hideThemeButtonState();
}} else {{
showThemeButtonState();
}}
}};
function handleThemeButtonsBlur(e) {{
var active = document.activeElement;
var related = e.relatedTarget;
if (active.id !== "theme-picker" &&
(!active.parentNode || active.parentNode.id !== "theme-choices") &&
(!related ||
(related.id !== "theme-picker" &&
(!related.parentNode || related.parentNode.id !== "theme-choices")))) {{
hideThemeButtonState();
}}
}}
themePicker.onclick = switchThemeButtonState;
themePicker.onblur = handleThemeButtonsBlur;
{}.forEach(function(item) {{
var but = document.createElement("button");
but.textContent = item;
but.onclick = function(el) {{
switchTheme(currentTheme, mainTheme, item, true);
useSystemTheme(false);
}};
but.onblur = handleThemeButtonsBlur;
themes.appendChild(but);
}});"#,
serde_json::to_string(&themes).unwrap()
);
write_minify(&cx.shared.fs, cx.path("theme.js"), &theme_js, options.enable_minification)?;
write_minify( write_minify(
&cx.shared.fs, &cx.shared.fs,
cx.path("main.js"), cx.path("main.js"),
static_files::MAIN_JS, &static_files::MAIN_JS.replace(
"/* INSERT THEMES HERE */",
&format!(" = {}", serde_json::to_string(&themes).unwrap()),
),
options.enable_minification, options.enable_minification,
)?; )?;
write_minify( write_minify(

View file

@ -23,7 +23,8 @@ included, and carry their own copyright notices and license terms:
Copyright (c) Nicolas Gallagher and Jonathan Neal. Copyright (c) Nicolas Gallagher and Jonathan Neal.
Licensed under the MIT license (see LICENSE-MIT.txt). Licensed under the MIT license (see LICENSE-MIT.txt).
* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): * Source Code Pro (SourceCodePro-Regular.ttf.woff,
SourceCodePro-Semibold.ttf.woff, SourceCodePro-It.ttf.woff):
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark

Binary file not shown.

View file

@ -2,7 +2,7 @@
// Local js definitions: // Local js definitions:
/* global addClass, getSettingValue, hasClass */ /* global addClass, getSettingValue, hasClass */
/* global onEach, onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */ /* global onEach, onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */
/* global hideThemeButtonState, showThemeButtonState */ /* global switchTheme, useSystemTheme */
if (!String.prototype.startsWith) { if (!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position) { String.prototype.startsWith = function(searchString, position) {
@ -85,12 +85,15 @@ function getSearchElement() {
return document.getElementById("search"); return document.getElementById("search");
} }
var THEME_PICKER_ELEMENT_ID = "theme-picker";
var THEMES_ELEMENT_ID = "theme-choices";
function getThemesElement() { function getThemesElement() {
return document.getElementById("theme-choices"); return document.getElementById(THEMES_ELEMENT_ID);
} }
function getThemePickerElement() { function getThemePickerElement() {
return document.getElementById("theme-picker"); return document.getElementById(THEME_PICKER_ELEMENT_ID);
} }
// Returns the current URL without any query parameter or hash. // Returns the current URL without any query parameter or hash.
@ -108,6 +111,65 @@ function defocusSearchBar() {
getSearchInput().blur(); getSearchInput().blur();
} }
function showThemeButtonState() {
var themePicker = getThemePickerElement();
var themeChoices = getThemesElement();
themeChoices.style.display = "block";
themePicker.style.borderBottomRightRadius = "0";
themePicker.style.borderBottomLeftRadius = "0";
}
function hideThemeButtonState() {
var themePicker = getThemePickerElement();
var themeChoices = getThemesElement();
themeChoices.style.display = "none";
themePicker.style.borderBottomRightRadius = "3px";
themePicker.style.borderBottomLeftRadius = "3px";
}
// Set up the theme picker list.
(function () {
var themeChoices = getThemesElement();
var themePicker = getThemePickerElement();
var availableThemes/* INSERT THEMES HERE */;
function switchThemeButtonState() {
if (themeChoices.style.display === "block") {
hideThemeButtonState();
} else {
showThemeButtonState();
}
}
function handleThemeButtonsBlur(e) {
var active = document.activeElement;
var related = e.relatedTarget;
if (active.id !== THEME_PICKER_ELEMENT_ID &&
(!active.parentNode || active.parentNode.id !== THEMES_ELEMENT_ID) &&
(!related ||
(related.id !== THEME_PICKER_ELEMENT_ID &&
(!related.parentNode || related.parentNode.id !== THEMES_ELEMENT_ID)))) {
hideThemeButtonState();
}
}
themePicker.onclick = switchThemeButtonState;
themePicker.onblur = handleThemeButtonsBlur;
availableThemes.forEach(function(item) {
var but = document.createElement("button");
but.textContent = item;
but.onclick = function() {
switchTheme(window.currentTheme, window.mainTheme, item, true);
useSystemTheme(false);
};
but.onblur = handleThemeButtonsBlur;
themeChoices.appendChild(but);
});
}());
(function() { (function() {
"use strict"; "use strict";
@ -461,8 +523,7 @@ function defocusSearchBar() {
break; break;
default: default:
var themePicker = getThemePickerElement(); if (getThemePickerElement().parentNode.contains(ev.target)) {
if (themePicker.parentNode.contains(ev.target)) {
handleThemeKeyDown(ev); handleThemeKeyDown(ev);
} }
} }
@ -475,7 +536,7 @@ function defocusSearchBar() {
switch (getVirtualKey(ev)) { switch (getVirtualKey(ev)) {
case "ArrowUp": case "ArrowUp":
ev.preventDefault(); ev.preventDefault();
if (active.previousElementSibling && ev.target.id !== "theme-picker") { if (active.previousElementSibling && ev.target.id !== THEME_PICKER_ELEMENT_ID) {
active.previousElementSibling.focus(); active.previousElementSibling.focus();
} else { } else {
showThemeButtonState(); showThemeButtonState();
@ -484,7 +545,7 @@ function defocusSearchBar() {
break; break;
case "ArrowDown": case "ArrowDown":
ev.preventDefault(); ev.preventDefault();
if (active.nextElementSibling && ev.target.id !== "theme-picker") { if (active.nextElementSibling && ev.target.id !== THEME_PICKER_ELEMENT_ID) {
active.nextElementSibling.focus(); active.nextElementSibling.focus();
} else { } else {
showThemeButtonState(); showThemeButtonState();
@ -494,7 +555,7 @@ function defocusSearchBar() {
case "Enter": case "Enter":
case "Return": case "Return":
case "Space": case "Space":
if (ev.target.id === "theme-picker" && themes.style.display === "none") { if (ev.target.id === THEME_PICKER_ELEMENT_ID && themes.style.display === "none") {
ev.preventDefault(); ev.preventDefault();
showThemeButtonState(); showThemeButtonState();
themes.firstElementChild.focus(); themes.firstElementChild.focus();

View file

@ -48,14 +48,21 @@
font-weight: 400; font-weight: 400;
/* Avoid using locally installed font because bad versions are in circulation: /* Avoid using locally installed font because bad versions are in circulation:
* see https://github.com/rust-lang/rust/issues/24355 */ * see https://github.com/rust-lang/rust/issues/24355 */
src: url("SourceCodePro-Regular.woff") format('woff'); src: url("SourceCodePro-Regular.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Code Pro';
font-style: italic;
font-weight: 400;
src: url("SourceCodePro-It.ttf.woff") format('woff');
font-display: swap; font-display: swap;
} }
@font-face { @font-face {
font-family: 'Source Code Pro'; font-family: 'Source Code Pro';
font-style: normal; font-style: normal;
font-weight: 600; font-weight: 600;
src: url("SourceCodePro-Semibold.woff") format('woff'); src: url("SourceCodePro-Semibold.ttf.woff") format('woff');
font-display: swap; font-display: swap;
} }

View file

@ -2,8 +2,8 @@
/* global resourcesSuffix */ /* global resourcesSuffix */
var darkThemes = ["dark", "ayu"]; var darkThemes = ["dark", "ayu"];
var currentTheme = document.getElementById("themeStyle"); window.currentTheme = document.getElementById("themeStyle");
var mainTheme = document.getElementById("mainThemeStyle"); window.mainTheme = document.getElementById("mainThemeStyle");
var settingsDataset = (function () { var settingsDataset = (function () {
var settingsElement = document.getElementById("default-settings"); var settingsElement = document.getElementById("default-settings");
@ -137,7 +137,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
} }
} }
// This function is called from "theme.js", generated in `html/render/mod.rs`. // This function is called from "main.js".
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function useSystemTheme(value) { function useSystemTheme(value) {
if (value === undefined) { if (value === undefined) {
@ -161,8 +161,8 @@ var updateSystemTheme = (function() {
.getPropertyValue('content'); .getPropertyValue('content');
switchTheme( switchTheme(
currentTheme, window.currentTheme,
mainTheme, window.mainTheme,
JSON.parse(cssTheme) || "light", JSON.parse(cssTheme) || "light",
true true
); );
@ -180,10 +180,10 @@ var updateSystemTheme = (function() {
if (mql.matches) { if (mql.matches) {
// prefers a dark theme // prefers a dark theme
switchTheme(currentTheme, mainTheme, darkTheme, true); switchTheme(window.currentTheme, window.mainTheme, darkTheme, true);
} else { } else {
// prefers a light theme, or has no preference // prefers a light theme, or has no preference
switchTheme(currentTheme, mainTheme, lightTheme, true); switchTheme(window.currentTheme, window.mainTheme, lightTheme, true);
} }
// note: we save the theme so that it doesn't suddenly change when // note: we save the theme so that it doesn't suddenly change when
@ -212,8 +212,8 @@ if (getSettingValue("use-system-theme") !== "false" && window.matchMedia) {
updateSystemTheme(); updateSystemTheme();
} else { } else {
switchTheme( switchTheme(
currentTheme, window.currentTheme,
mainTheme, window.mainTheme,
getSettingValue("theme") || "light", getSettingValue("theme") || "light",
false false
); );

View file

@ -107,11 +107,15 @@ crate mod source_serif_pro {
/// Files related to the Source Code Pro font. /// Files related to the Source Code Pro font.
crate mod source_code_pro { crate mod source_code_pro {
/// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font. /// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font.
crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.woff"); crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff");
/// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font. /// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro
crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.woff"); /// font.
crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff");
/// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font.
crate static ITALIC: &[u8] = include_bytes!("static/SourceCodePro-It.ttf.woff");
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font. /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
crate static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); crate static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");

View file

@ -6,9 +6,10 @@ FiraSans-Regular.woff
FiraSans-Regular.woff2 FiraSans-Regular.woff2
LICENSE-APACHE.txt LICENSE-APACHE.txt
LICENSE-MIT.txt LICENSE-MIT.txt
SourceCodePro-It.ttf.woff
SourceCodePro-LICENSE.txt SourceCodePro-LICENSE.txt
SourceCodePro-Regular.woff SourceCodePro-Regular.ttf.woff
SourceCodePro-Semibold.woff SourceCodePro-Semibold.ttf.woff
SourceSerifPro-Bold.ttf.woff SourceSerifPro-Bold.ttf.woff
SourceSerifPro-It.ttf.woff SourceSerifPro-It.ttf.woff
SourceSerifPro-LICENSE.md SourceSerifPro-LICENSE.md

View file

@ -1,8 +1,8 @@
// Feature gate test for `edition_macro_pats` feature. // Feature gate test for `edition_macro_pats` feature.
macro_rules! foo { macro_rules! foo {
($x:pat2018) => {}; //~ERROR `pat2018` and `pat2021` are unstable ($x:pat2015) => {}; //~ERROR `pat2015` and `pat2021` are unstable
($x:pat2021) => {}; //~ERROR `pat2018` and `pat2021` are unstable ($x:pat2021) => {}; //~ERROR `pat2015` and `pat2021` are unstable
} }
fn main() {} fn main() {}

View file

@ -1,13 +1,13 @@
error[E0658]: `pat2018` and `pat2021` are unstable. error[E0658]: `pat2015` and `pat2021` are unstable.
--> $DIR/feature-gate-edition_macro_pats.rs:4:9 --> $DIR/feature-gate-edition_macro_pats.rs:4:9
| |
LL | ($x:pat2018) => {}; LL | ($x:pat2015) => {};
| ^^^^^^^ | ^^^^^^^
| |
= note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
= help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable = help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable
error[E0658]: `pat2018` and `pat2021` are unstable. error[E0658]: `pat2015` and `pat2021` are unstable.
--> $DIR/feature-gate-edition_macro_pats.rs:5:9 --> $DIR/feature-gate-edition_macro_pats.rs:5:9
| |
LL | ($x:pat2021) => {}; LL | ($x:pat2021) => {};

View file

@ -3,7 +3,7 @@
#![feature(edition_macro_pats)] #![feature(edition_macro_pats)]
macro_rules! foo { macro_rules! foo {
(a $x:pat2018) => {}; (a $x:pat2015) => {};
(b $x:pat2021) => {}; (b $x:pat2021) => {};
} }

@ -1 +1 @@
Subproject commit 5ba7852cf153688d5b5035a9a2a2145aa7334d79 Subproject commit 858ad554374a8b1ad67692558a0878391abfdd86