Skip to content

Rollup of 9 pull requests #86515

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 23 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0fdd6cc
Make OR_PATTERNS_BACK_COMPAT be a 2021 future-incompatible lint
Rustin170506 Jun 10, 2021
c09b699
Add a regression test for issue-85113
JohnTitor Jun 12, 2021
782824c
add regression test for issue #78632
yerke Jun 16, 2021
d2f2237
fix(rustfmt): load nested out-of-line mods correctly
calebcartwright Jun 18, 2021
9c495b3
"(const: unstable)" for stable-but-const-unstable
fee1-dead Jun 20, 2021
f804d8d
Improve documentation
wooster0 Jun 20, 2021
61b453c
Fix CI to fetch master on beta channel
Mark-Simulacrum Jun 19, 2021
008d4d6
Fix rust.css fonts.
ehuss Jun 21, 2021
e84c9ae
Delete spaces
Jun 21, 2021
5fb27bc
Check for const_unstable before printing `const`
fee1-dead Jun 20, 2021
c4396f4
Added some tests for `unsafe` in const-dispay.rs
fee1-dead Jun 21, 2021
0d69a02
Removed/Updated some cases and simplified `match`
fee1-dead Jun 21, 2021
f82fb30
Update comment regarding staged_api
fee1-dead Jun 21, 2021
b57077b
Readd `unsafe` keyword in tests
fee1-dead Jun 21, 2021
3ee78b3
Rollup merge of #86192 - hi-rustin:rustin-patch-lint, r=nikomatsakis
JohnTitor Jun 21, 2021
ac41056
Rollup merge of #86248 - JohnTitor:issue-85113, r=Mark-Simulacrum
JohnTitor Jun 21, 2021
58e7411
Rollup merge of #86274 - alexander-melentyev:spaces, r=bjorn3
JohnTitor Jun 21, 2021
aba0bed
Rollup merge of #86349 - yerke:add-test-for-issue-78632, r=Mark-Simul…
JohnTitor Jun 21, 2021
a81f55f
Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Ma…
JohnTitor Jun 21, 2021
9c664b2
Rollup merge of #86472 - Mark-Simulacrum:fix-ci-beta, r=pietroalbini
JohnTitor Jun 21, 2021
f3fe5c3
Rollup merge of #86473 - fee1-dead:rustdoc-const-unstable, r=jyn514
JohnTitor Jun 21, 2021
2fdc2ea
Rollup merge of #86495 - r00ster91:patch-11, r=petrochenkov
JohnTitor Jun 21, 2021
599e8a7
Rollup merge of #86503 - ehuss:rustc.css-fonts, r=jyn514,GuillaumeGomez
JohnTitor Jun 21, 2021
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ along with any information you feel relevant to replicating the bug.

If you cannot produce a minimal reproduction case (something that would work in
isolation), please provide the steps or even link to a repository that causes
the problematic output to occur.
the problematic output to occur.
-->

Given the following code: <!-- Please provide a link to play.rust-lang.org -->
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Read ["Installation"] from [The Book].
The Rust build system uses a Python script called `x.py` to build the compiler,
which manages the bootstrapping process. It lives in the root of the project.

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

```sh
./x.py <subcommand> [flags]
Expand Down
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ 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,
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> {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3239,4 +3239,8 @@ declare_lint! {
pub OR_PATTERNS_BACK_COMPAT,
Allow,
"detects usage of old versions of or-patterns",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #84869 <https://github.com/rust-lang/rust/issues/84869>",
edition: Some(Edition::Edition2021),
};
}
4 changes: 2 additions & 2 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ changelog-seen = 2
# On Linux target, if crt-static is not enabled, 'no' means dynamic link to
# `libgcc_s.so`, 'in-tree' means static link to the in-tree build of llvm libunwind
# and 'system' means dynamic link to `libunwind.so`. If crt-static is enabled,
# the behavior is depend on the libc. On musl target, 'no' and 'in-tree' both
# means static link to the in-tree build of llvm libunwind, and 'system' means
# the behavior is depend on the libc. On musl target, 'no' and 'in-tree' both
# means static link to the in-tree build of llvm libunwind, and 'system' means
# static link to `libunwind.a` provided by system. Due to the limitation of glibc,
# it must link to `libgcc_eh.a` to get a working output, and this option have no effect.
#llvm-libunwind = 'no'
Expand Down
15 changes: 9 additions & 6 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ impl fmt::Debug for Group {
}
}

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

/// Whether an `Punct` is followed immediately by another `Punct` or
/// followed by another token or whitespace.
/// Describes whether a `Punct` is followed immediately by another `Punct` ([`Spacing::Joint`]) or
/// by a different token or whitespace ([`Spacing::Alone`]).
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
pub enum Spacing {
/// e.g., `+` is `Alone` in `+ =`, `+ident` or `+()`.
/// A `Punct` is not immediately followed by another `Punct`.
/// E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`.
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Alone,
/// e.g., `+` is `Joint` in `+=` or `'#`.
/// Additionally, single quote `'` can join with identifiers to form lifetimes `'ident`.
/// A `Punct` is immediately followed by another `Punct`.
/// E.g. `+` is `Joint` in `+=` and `++`.
///
/// Additionally, single quote `'` can join with identifiers to form lifetimes: `'ident`.
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Joint,
}
Expand Down
2 changes: 1 addition & 1 deletion src/ci/init_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mkdir "$CACHE_DIR"

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

Expand Down
6 changes: 1 addition & 5 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ fi
# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting
# master, beta, or stable with a build to determine whether to run some checks (notably toolstate).
if [[ -z "${RUST_CI_OVERRIDE_RELEASE_CHANNEL+x}" ]]; then
export RUST_RELEASE_CHANNEL="$(cat "${ci_dir}/channel")"
else
export RUST_RELEASE_CHANNEL="${RUST_CI_OVERRIDE_RELEASE_CHANNEL}"
fi
export RUST_RELEASE_CHANNEL=$(releaseChannel)
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"

if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
Expand Down
8 changes: 8 additions & 0 deletions src/ci/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,11 @@ function ciCommandSetEnv {
exit 1
fi
}

function releaseChannel {
if [[ -z "${RUST_CI_OVERRIDE_RELEASE_CHANNEL+x}" ]]; then
cat "${ci_dir}/channel"
else
echo $RUST_CI_OVERRIDE_RELEASE_CHANNEL
fi
}
43 changes: 33 additions & 10 deletions src/doc/rust.css
Original file line number Diff line number Diff line change
@@ -1,45 +1,68 @@
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
@font-face {
font-family: 'Fira Sans';
font-style: normal;
font-weight: 400;
src: local('Fira Sans'), url("FiraSans-Regular.woff") format('woff');
src: local('Fira Sans'),
url("FiraSans-Regular.woff2") format("woff2"),
url("FiraSans-Regular.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Fira Sans';
font-style: normal;
font-weight: 500;
src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff');
src: local('Fira Sans Medium'),
url("FiraSans-Medium.woff2") format("woff2"),
url("FiraSans-Medium.woff") format('woff');
font-display: swap;
}

/* See SourceSerif4-LICENSE.md for the Source Serif 4 license. */
@font-face {
font-family: 'Source Serif Pro';
font-family: 'Source Serif 4';
font-style: normal;
font-weight: 400;
src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff');
src: local('Source Serif 4'), url("SourceSerif4-Regular.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-family: 'Source Serif 4';
font-style: italic;
font-weight: 400;
src: url("SourceSerifPro-It.ttf.woff") format('woff');
src: local('Source Serif 4 Italic'), url("SourceSerif4-It.ttf.woff") format('woff');
font-display: swap;
}
@font-face {
font-family: 'Source Serif Pro';
font-family: 'Source Serif 4';
font-style: normal;
font-weight: 700;
src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff');
src: local('Source Serif 4 Bold'), url("SourceSerif4-Bold.ttf.woff") format('woff');
font-display: swap;
}

/* See SourceCodePro-LICENSE.txt for the Source Code Pro license. */
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 400;
/* Avoid using locally installed font because bad versions are in circulation:
* 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-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
src: url("SourceCodePro-Semibold.ttf.woff") format('woff');
font-display: swap;
}

Expand All @@ -55,7 +78,7 @@ body {
background-color: white;
margin: 0 auto;
padding: 0 15px;
font-family: "Source Serif Pro", Georgia, Times, "Times New Roman", serif;
font-family: "Source Serif 4", Georgia, Times, "Times New Roman", serif;
font-size: 18px;
color: #333;
line-height: 1.428571429;
Expand Down
26 changes: 17 additions & 9 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::cell::Cell;
use std::fmt;
use std::iter;

use rustc_attr::{ConstStability, StabilityLevel};
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
Expand Down Expand Up @@ -1253,15 +1254,6 @@ impl PrintWithSpace for hir::Unsafety {
}
}

impl PrintWithSpace for hir::Constness {
fn print_with_space(&self) -> &str {
match self {
hir::Constness::Const => "const ",
hir::Constness::NotConst => "",
}
}
}

impl PrintWithSpace for hir::IsAsync {
fn print_with_space(&self) -> &str {
match self {
Expand All @@ -1280,6 +1272,22 @@ impl PrintWithSpace for hir::Mutability {
}
}

crate fn print_constness_with_space(
c: &hir::Constness,
s: Option<&ConstStability>,
) -> &'static str {
match (c, s) {
// const stable or when feature(staged_api) is not set
(
hir::Constness::Const,
Some(ConstStability { level: StabilityLevel::Stable { .. }, .. }),
)
| (hir::Constness::Const, None) => "const ",
// const unstable or not const
_ => "",
}
}

impl clean::Import {
crate fn print<'a, 'tcx: 'a>(
&'a self,
Expand Down
62 changes: 44 additions & 18 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use std::str;
use std::string::ToString;

use rustc_ast_pretty::pprust;
use rustc_attr::{Deprecation, StabilityLevel};
use rustc_attr::{ConstStability, Deprecation, StabilityLevel};
use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_hir::def::CtorKind;
Expand All @@ -61,8 +61,8 @@ use crate::formats::item_type::ItemType;
use crate::formats::{AssocItemRender, Impl, RenderMode};
use crate::html::escape::Escape;
use crate::html::format::{
href, print_abi_with_space, print_default_space, print_generic_bounds, print_where_clause,
Buffer, PrintWithSpace,
href, print_abi_with_space, print_constness_with_space, print_default_space,
print_generic_bounds, print_where_clause, Buffer, PrintWithSpace,
};
use crate::html::markdown::{Markdown, MarkdownHtml, MarkdownSummaryLine};

Expand Down Expand Up @@ -826,21 +826,45 @@ fn assoc_type(
fn render_stability_since_raw(
w: &mut Buffer,
ver: Option<&str>,
const_ver: Option<&str>,
const_stability: Option<&ConstStability>,
containing_ver: Option<&str>,
containing_const_ver: Option<&str>,
) {
let ver = ver.filter(|inner| !inner.is_empty());
let const_ver = const_ver.filter(|inner| !inner.is_empty());

match (ver, const_ver) {
(Some(v), Some(cv)) if const_ver != containing_const_ver => {
match (ver, const_stability) {
// stable and const stable
(Some(v), Some(ConstStability { level: StabilityLevel::Stable { since }, .. }))
if Some(since.as_str()).as_deref() != containing_const_ver =>
{
write!(
w,
"<span class=\"since\" title=\"Stable since Rust version {0}, const since {1}\">{0} (const: {1})</span>",
v, cv
v, since
);
}
// stable and const unstable
(
Some(v),
Some(ConstStability { level: StabilityLevel::Unstable { issue, .. }, feature, .. }),
) => {
write!(
w,
"<span class=\"since\" title=\"Stable since Rust version {0}, const unstable\">{0} (const: ",
v
);
if let Some(n) = issue {
write!(
w,
"<a href=\"https://github.com/rust-lang/rust/issues/{}\" title=\"Tracking issue for {}\">unstable</a>",
n, feature
);
} else {
write!(w, "unstable");
}
write!(w, ")</span>");
}
// stable
(Some(v), _) if ver != containing_ver => {
write!(
w,
Expand Down Expand Up @@ -888,11 +912,13 @@ fn render_assoc_item(
}
};
let vis = meth.visibility.print_with_space(meth.def_id, cx).to_string();
let constness = header.constness.print_with_space();
let constness =
print_constness_with_space(&header.constness, meth.const_stability(cx.tcx()));
let asyncness = header.asyncness.print_with_space();
let unsafety = header.unsafety.print_with_space();
let defaultness = print_default_space(meth.is_default());
let abi = print_abi_with_space(header.abi).to_string();

// NOTE: `{:#}` does not print HTML formatting, `{}` does. So `g.print` can't be reused between the length calculation and `write!`.
let generics_len = format!("{:#}", g.print(cx)).len();
let mut header_len = "fn ".len()
Expand All @@ -917,15 +943,15 @@ fn render_assoc_item(
w.reserve(header_len + "<a href=\"\" class=\"fnname\">{".len() + "</a>".len());
write!(
w,
"{}{}{}{}{}{}{}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
"{indent}{vis}{constness}{asyncness}{unsafety}{defaultness}{abi}fn <a href=\"{href}\" class=\"fnname\">{name}</a>\
{generics}{decl}{notable_traits}{where_clause}",
indent_str,
vis,
constness,
asyncness,
unsafety,
defaultness,
abi,
indent = indent_str,
vis = vis,
constness = constness,
asyncness = asyncness,
unsafety = unsafety,
defaultness = defaultness,
abi = abi,
href = href,
name = name,
generics = g.print(cx),
Expand Down Expand Up @@ -1583,7 +1609,7 @@ fn render_rightside(
render_stability_since_raw(
w,
item.stable_since(tcx).as_deref(),
item.const_stable_since(tcx).as_deref(),
item.const_stability(tcx),
containing_item.stable_since(tcx).as_deref(),
containing_item.const_stable_since(tcx).as_deref(),
);
Expand Down
Loading