Skip to content

Commit 406d4a9

Browse files
committed
Auto merge of rust-lang#86515 - JohnTitor:rollup-axzb4xh, r=JohnTitor
Rollup of 9 pull requests Successful merges: - rust-lang#86192 (Make OR_PATTERNS_BACK_COMPAT be a 2021 future-incompatible lint) - rust-lang#86248 (Add a regression test for issue-85113) - rust-lang#86274 (Spaces) - rust-lang#86349 (Add regression test for issue rust-lang#78632) - rust-lang#86424 (rustfmt: load nested out-of-line mods correctly) - rust-lang#86472 (Fix CI to fetch master on beta channel) - rust-lang#86473 (Rustdoc: Account for const-unstable functions) - rust-lang#86495 (Improve `proc_macro::{Punct, Spacing}` documentation) - rust-lang#86503 (Fix rust.css fonts.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6a5b97a + 599e8a7 commit 406d4a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+432
-134
lines changed

.github/ISSUE_TEMPLATE/diagnostics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ along with any information you feel relevant to replicating the bug.
99
1010
If you cannot produce a minimal reproduction case (something that would work in
1111
isolation), please provide the steps or even link to a repository that causes
12-
the problematic output to occur.
12+
the problematic output to occur.
1313
-->
1414

1515
Given the following code: <!-- Please provide a link to play.rust-lang.org -->

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Read ["Installation"] from [The Book].
2121
The Rust build system uses a Python script called `x.py` to build the compiler,
2222
which manages the bootstrapping process. It lives in the root of the project.
2323

24-
The `x.py` command can be run directly on most systems in the following format:
24+
The `x.py` command can be run directly on most systems in the following format:
2525

2626
```sh
2727
./x.py <subcommand> [flags]

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ Language
369369
--------
370370
- [You can now parameterize items such as functions, traits, and `struct`s by constant
371371
values in addition to by types and lifetimes.][79135] Also known as "const generics"
372-
E.g. you can now write the following. Note: Only values of primitive integers,
372+
E.g. you can now write the following. Note: Only values of primitive integers,
373373
`bool`, or `char` types are currently permitted.
374374
```rust
375375
struct GenericArray<T, const LENGTH: usize> {

compiler/rustc_lint_defs/src/builtin.rs

+4
Original file line numberDiff line numberDiff line change
@@ -3239,4 +3239,8 @@ declare_lint! {
32393239
pub OR_PATTERNS_BACK_COMPAT,
32403240
Allow,
32413241
"detects usage of old versions of or-patterns",
3242+
@future_incompatible = FutureIncompatibleInfo {
3243+
reference: "issue #84869 <https://github.com/rust-lang/rust/issues/84869>",
3244+
edition: Some(Edition::Edition2021),
3245+
};
32423246
}

config.toml.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ changelog-seen = 2
567567
# On Linux target, if crt-static is not enabled, 'no' means dynamic link to
568568
# `libgcc_s.so`, 'in-tree' means static link to the in-tree build of llvm libunwind
569569
# and 'system' means dynamic link to `libunwind.so`. If crt-static is enabled,
570-
# the behavior is depend on the libc. On musl target, 'no' and 'in-tree' both
571-
# means static link to the in-tree build of llvm libunwind, and 'system' means
570+
# the behavior is depend on the libc. On musl target, 'no' and 'in-tree' both
571+
# means static link to the in-tree build of llvm libunwind, and 'system' means
572572
# static link to `libunwind.a` provided by system. Due to the limitation of glibc,
573573
# it must link to `libgcc_eh.a` to get a working output, and this option have no effect.
574574
#llvm-libunwind = 'no'

library/proc_macro/src/lib.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl fmt::Debug for Group {
766766
}
767767
}
768768

769-
/// An `Punct` is an single punctuation character like `+`, `-` or `#`.
769+
/// A `Punct` is a single punctuation character such as `+`, `-` or `#`.
770770
///
771771
/// Multi-character operators like `+=` are represented as two instances of `Punct` with different
772772
/// forms of `Spacing` returned.
@@ -779,16 +779,19 @@ impl !Send for Punct {}
779779
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
780780
impl !Sync for Punct {}
781781

782-
/// Whether an `Punct` is followed immediately by another `Punct` or
783-
/// followed by another token or whitespace.
782+
/// Describes whether a `Punct` is followed immediately by another `Punct` ([`Spacing::Joint`]) or
783+
/// by a different token or whitespace ([`Spacing::Alone`]).
784784
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
785785
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
786786
pub enum Spacing {
787-
/// e.g., `+` is `Alone` in `+ =`, `+ident` or `+()`.
787+
/// A `Punct` is not immediately followed by another `Punct`.
788+
/// E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`.
788789
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
789790
Alone,
790-
/// e.g., `+` is `Joint` in `+=` or `'#`.
791-
/// Additionally, single quote `'` can join with identifiers to form lifetimes `'ident`.
791+
/// A `Punct` is immediately followed by another `Punct`.
792+
/// E.g. `+` is `Joint` in `+=` and `++`.
793+
///
794+
/// Additionally, single quote `'` can join with identifiers to form lifetimes: `'ident`.
792795
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
793796
Joint,
794797
}

src/ci/init_repo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mkdir "$CACHE_DIR"
3131

3232
# On the beta channel we'll be automatically calculating the prerelease version
3333
# via the git history, so unshallow our shallow clone from CI.
34-
if grep -q RUST_RELEASE_CHANNEL=beta src/ci/run.sh; then
34+
if [ "$(releaseChannel)" = "beta" ]; then
3535
git fetch origin --unshallow beta master
3636
fi
3737

src/ci/run.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ fi
6565
# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
6666
# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting
6767
# master, beta, or stable with a build to determine whether to run some checks (notably toolstate).
68-
if [[ -z "${RUST_CI_OVERRIDE_RELEASE_CHANNEL+x}" ]]; then
69-
export RUST_RELEASE_CHANNEL="$(cat "${ci_dir}/channel")"
70-
else
71-
export RUST_RELEASE_CHANNEL="${RUST_CI_OVERRIDE_RELEASE_CHANNEL}"
72-
fi
68+
export RUST_RELEASE_CHANNEL=$(releaseChannel)
7369
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
7470

7571
if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then

src/ci/shared.sh

+8
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,11 @@ function ciCommandSetEnv {
141141
exit 1
142142
fi
143143
}
144+
145+
function releaseChannel {
146+
if [[ -z "${RUST_CI_OVERRIDE_RELEASE_CHANNEL+x}" ]]; then
147+
cat "${ci_dir}/channel"
148+
else
149+
echo $RUST_CI_OVERRIDE_RELEASE_CHANNEL
150+
fi
151+
}

src/doc/rust.css

+33-10
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,68 @@
1+
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
12
@font-face {
23
font-family: 'Fira Sans';
34
font-style: normal;
45
font-weight: 400;
5-
src: local('Fira Sans'), url("FiraSans-Regular.woff") format('woff');
6+
src: local('Fira Sans'),
7+
url("FiraSans-Regular.woff2") format("woff2"),
8+
url("FiraSans-Regular.woff") format('woff');
69
font-display: swap;
710
}
811
@font-face {
912
font-family: 'Fira Sans';
1013
font-style: normal;
1114
font-weight: 500;
12-
src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff');
15+
src: local('Fira Sans Medium'),
16+
url("FiraSans-Medium.woff2") format("woff2"),
17+
url("FiraSans-Medium.woff") format('woff');
1318
font-display: swap;
1419
}
20+
21+
/* See SourceSerif4-LICENSE.md for the Source Serif 4 license. */
1522
@font-face {
16-
font-family: 'Source Serif Pro';
23+
font-family: 'Source Serif 4';
1724
font-style: normal;
1825
font-weight: 400;
19-
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff');
26+
src: local('Source Serif 4'), url("SourceSerif4-Regular.ttf.woff") format('woff');
2027
font-display: swap;
2128
}
2229
@font-face {
23-
font-family: 'Source Serif Pro';
30+
font-family: 'Source Serif 4';
2431
font-style: italic;
2532
font-weight: 400;
26-
src: url("SourceSerifPro-It.ttf.woff") format('woff');
33+
src: local('Source Serif 4 Italic'), url("SourceSerif4-It.ttf.woff") format('woff');
2734
font-display: swap;
2835
}
2936
@font-face {
30-
font-family: 'Source Serif Pro';
37+
font-family: 'Source Serif 4';
3138
font-style: normal;
3239
font-weight: 700;
33-
src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff');
40+
src: local('Source Serif 4 Bold'), url("SourceSerif4-Bold.ttf.woff") format('woff');
3441
font-display: swap;
3542
}
43+
44+
/* See SourceCodePro-LICENSE.txt for the Source Code Pro license. */
3645
@font-face {
3746
font-family: 'Source Code Pro';
3847
font-style: normal;
3948
font-weight: 400;
4049
/* Avoid using locally installed font because bad versions are in circulation:
4150
* see https://github.com/rust-lang/rust/issues/24355 */
42-
src: url("SourceCodePro-Regular.woff") format('woff');
51+
src: url("SourceCodePro-Regular.ttf.woff") format('woff');
52+
font-display: swap;
53+
}
54+
@font-face {
55+
font-family: 'Source Code Pro';
56+
font-style: italic;
57+
font-weight: 400;
58+
src: url("SourceCodePro-It.ttf.woff") format('woff');
59+
font-display: swap;
60+
}
61+
@font-face {
62+
font-family: 'Source Code Pro';
63+
font-style: normal;
64+
font-weight: 600;
65+
src: url("SourceCodePro-Semibold.ttf.woff") format('woff');
4366
font-display: swap;
4467
}
4568

@@ -55,7 +78,7 @@ body {
5578
background-color: white;
5679
margin: 0 auto;
5780
padding: 0 15px;
58-
font-family: "Source Serif Pro", Georgia, Times, "Times New Roman", serif;
81+
font-family: "Source Serif 4", Georgia, Times, "Times New Roman", serif;
5982
font-size: 18px;
6083
color: #333;
6184
line-height: 1.428571429;

src/librustdoc/html/format.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::cell::Cell;
99
use std::fmt;
1010
use std::iter;
1111

12+
use rustc_attr::{ConstStability, StabilityLevel};
1213
use rustc_data_structures::captures::Captures;
1314
use rustc_data_structures::fx::FxHashSet;
1415
use rustc_hir as hir;
@@ -1253,15 +1254,6 @@ impl PrintWithSpace for hir::Unsafety {
12531254
}
12541255
}
12551256

1256-
impl PrintWithSpace for hir::Constness {
1257-
fn print_with_space(&self) -> &str {
1258-
match self {
1259-
hir::Constness::Const => "const ",
1260-
hir::Constness::NotConst => "",
1261-
}
1262-
}
1263-
}
1264-
12651257
impl PrintWithSpace for hir::IsAsync {
12661258
fn print_with_space(&self) -> &str {
12671259
match self {
@@ -1280,6 +1272,22 @@ impl PrintWithSpace for hir::Mutability {
12801272
}
12811273
}
12821274

1275+
crate fn print_constness_with_space(
1276+
c: &hir::Constness,
1277+
s: Option<&ConstStability>,
1278+
) -> &'static str {
1279+
match (c, s) {
1280+
// const stable or when feature(staged_api) is not set
1281+
(
1282+
hir::Constness::Const,
1283+
Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }),
1284+
)
1285+
| (hir::Constness::Const, None) => "const ",
1286+
// const unstable or not const
1287+
_ => "",
1288+
}
1289+
}
1290+
12831291
impl clean::Import {
12841292
crate fn print<'a, 'tcx: 'a>(
12851293
&'a self,

src/librustdoc/html/render/mod.rs

+44-18
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use std::str;
4242
use std::string::ToString;
4343

4444
use rustc_ast_pretty::pprust;
45-
use rustc_attr::{Deprecation, StabilityLevel};
45+
use rustc_attr::{ConstStability, Deprecation, StabilityLevel};
4646
use rustc_data_structures::fx::FxHashSet;
4747
use rustc_hir as hir;
4848
use rustc_hir::def::CtorKind;
@@ -61,8 +61,8 @@ use crate::formats::item_type::ItemType;
6161
use crate::formats::{AssocItemRender, Impl, RenderMode};
6262
use crate::html::escape::Escape;
6363
use crate::html::format::{
64-
href, print_abi_with_space, print_default_space, print_generic_bounds, print_where_clause,
65-
Buffer, PrintWithSpace,
64+
href, print_abi_with_space, print_constness_with_space, print_default_space,
65+
print_generic_bounds, print_where_clause, Buffer, PrintWithSpace,
6666
};
6767
use crate::html::markdown::{Markdown, MarkdownHtml, MarkdownSummaryLine};
6868

@@ -826,21 +826,45 @@ fn assoc_type(
826826
fn render_stability_since_raw(
827827
w: &mut Buffer,
828828
ver: Option<&str>,
829-
const_ver: Option<&str>,
829+
const_stability: Option<&ConstStability>,
830830
containing_ver: Option<&str>,
831831
containing_const_ver: Option<&str>,
832832
) {
833833
let ver = ver.filter(|inner| !inner.is_empty());
834-
let const_ver = const_ver.filter(|inner| !inner.is_empty());
835834

836-
match (ver, const_ver) {
837-
(Some(v), Some(cv)) if const_ver != containing_const_ver => {
835+
match (ver, const_stability) {
836+
// stable and const stable
837+
(Some(v), Some(ConstStability { level: StabilityLevel::Stable { since }, .. }))
838+
if Some(since.as_str()).as_deref() != containing_const_ver =>
839+
{
838840
write!(
839841
w,
840842
"<span class=\"since\" title=\"Stable since Rust version {0}, const since {1}\">{0} (const: {1})</span>",
841-
v, cv
843+
v, since
842844
);
843845
}
846+
// stable and const unstable
847+
(
848+
Some(v),
849+
Some(ConstStability { level: StabilityLevel::Unstable { issue, .. }, feature, .. }),
850+
) => {
851+
write!(
852+
w,
853+
"<span class=\"since\" title=\"Stable since Rust version {0}, const unstable\">{0} (const: ",
854+
v
855+
);
856+
if let Some(n) = issue {
857+
write!(
858+
w,
859+
"<a href=\"https://github.com/rust-lang/rust/issues/{}\" title=\"Tracking issue for {}\">unstable</a>",
860+
n, feature
861+
);
862+
} else {
863+
write!(w, "unstable");
864+
}
865+
write!(w, ")</span>");
866+
}
867+
// stable
844868
(Some(v), _) if ver != containing_ver => {
845869
write!(
846870
w,
@@ -888,11 +912,13 @@ fn render_assoc_item(
888912
}
889913
};
890914
let vis = meth.visibility.print_with_space(meth.def_id, cx).to_string();
891-
let constness = header.constness.print_with_space();
915+
let constness =
916+
print_constness_with_space(&header.constness, meth.const_stability(cx.tcx()));
892917
let asyncness = header.asyncness.print_with_space();
893918
let unsafety = header.unsafety.print_with_space();
894919
let defaultness = print_default_space(meth.is_default());
895920
let abi = print_abi_with_space(header.abi).to_string();
921+
896922
// NOTE: `{:#}` does not print HTML formatting, `{}` does. So `g.print` can't be reused between the length calculation and `write!`.
897923
let generics_len = format!("{:#}", g.print(cx)).len();
898924
let mut header_len = "fn ".len()
@@ -917,15 +943,15 @@ fn render_assoc_item(
917943
w.reserve(header_len + "<a href=\"\" class=\"fnname\">{".len() + "</a>".len());
918944
write!(
919945
w,
920-
"{}{}{}{}{}{}{}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
946+
"{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
921947
{generics}{decl}{notable_traits}{where_clause}",
922-
indent_str,
923-
vis,
924-
constness,
925-
asyncness,
926-
unsafety,
927-
defaultness,
928-
abi,
948+
indent = indent_str,
949+
vis = vis,
950+
constness = constness,
951+
asyncness = asyncness,
952+
unsafety = unsafety,
953+
defaultness = defaultness,
954+
abi = abi,
929955
href = href,
930956
name = name,
931957
generics = g.print(cx),
@@ -1583,7 +1609,7 @@ fn render_rightside(
15831609
render_stability_since_raw(
15841610
w,
15851611
item.stable_since(tcx).as_deref(),
1586-
item.const_stable_since(tcx).as_deref(),
1612+
item.const_stability(tcx),
15871613
containing_item.stable_since(tcx).as_deref(),
15881614
containing_item.const_stable_since(tcx).as_deref(),
15891615
);

0 commit comments

Comments
 (0)