Skip to content

Rollup of 7 pull requests #86704

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 20 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7c7fcb2
Add support for OpenSSL 3.0.0
cuviper Jun 22, 2021
bf0da44
Fix `future_prelude_collision` false positive
jam1garner Jun 27, 2021
7f4e343
Add `explain_reason: false` in future_incompatible.
m-ou-se Jun 27, 2021
934e605
Turn non_fmt_panic into a future_incompatible edition lint.
m-ou-se Jun 27, 2021
4645679
Add `explain_reason: false` in future_incompatible.
m-ou-se Jun 27, 2021
3c95a28
Make disjoint_capture_migration an edition lint.
m-ou-se Jun 27, 2021
f333b47
Fix garbled suggestion for missing lifetime specifier
FabianWolff Jun 27, 2021
b89ea96
Editon 2021 enables precise capture
arora-aman Jun 27, 2021
10a37bf
fixup! Editon 2021 enables precise capture
arora-aman Jun 28, 2021
83a2bc3
Add new tool to check HTML:
GuillaumeGomez Apr 23, 2021
af37ed7
Install tidy on x86_64-gnu-aux target to run html check
GuillaumeGomez Apr 24, 2021
785b705
Only run HTML check on rustdoc generated items
GuillaumeGomez Jun 3, 2021
92eedb2
Bump the workspace dependency for OpenSSL 3
cuviper Jun 28, 2021
b5d4343
Rollup merge of #86059 - GuillaumeGomez:html-checker2, r=Mark-Simulacrum
JohnTitor Jun 28, 2021
c9ac096
Rollup merge of #86529 - cuviper:ssl3, r=Mark-Simulacrum
JohnTitor Jun 28, 2021
5028581
Rollup merge of #86657 - jam1garner:future_prelude_false_positive, r=…
JohnTitor Jun 28, 2021
22f2332
Rollup merge of #86661 - sexxi-goose:edition_fix, r=nikomatsakis
JohnTitor Jun 28, 2021
14f3335
Rollup merge of #86671 - m-ou-se:non-fmt-panic-future-incompatible, r…
JohnTitor Jun 28, 2021
af3c154
Rollup merge of #86673 - m-ou-se:disjoint-capture-edition-lint, r=nik…
JohnTitor Jun 28, 2021
a89c6be
Rollup merge of #86678 - FabianWolff:issue-86667, r=jackh726
JohnTitor Jun 28, 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
15 changes: 11 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,13 @@ dependencies = [
"winapi 0.3.9",
]

[[package]]
name = "html-checker"
version = "0.1.0"
dependencies = [
"walkdir",
]

[[package]]
name = "html5ever"
version = "0.25.1"
Expand Down Expand Up @@ -2433,9 +2440,9 @@ dependencies = [

[[package]]
name = "openssl"
version = "0.10.33"
version = "0.10.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577"
checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
Expand All @@ -2462,9 +2469,9 @@ dependencies = [

[[package]]
name = "openssl-sys"
version = "0.9.61"
version = "0.9.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f"
checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d"
dependencies = [
"autocfg",
"cc",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ members = [
"src/tools/unicode-table-generator",
"src/tools/expand-yaml-anchors",
"src/tools/jsondocck",
"src/tools/html-checker",
]

exclude = [
Expand Down
9 changes: 8 additions & 1 deletion compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use rustc_errors::{pluralize, Applicability};
use rustc_hir as hir;
use rustc_middle::ty;
use rustc_parse_format::{ParseMode, Parser, Piece};
use rustc_session::lint::FutureIncompatibilityReason;
use rustc_span::edition::Edition;
use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol};

declare_lint! {
Expand All @@ -30,6 +32,10 @@ declare_lint! {
NON_FMT_PANIC,
Warn,
"detect single-argument panic!() invocations in which the argument is not a format string",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
explain_reason: false,
};
report_in_external_macro
}

Expand Down Expand Up @@ -87,7 +93,8 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc

cx.struct_span_lint(NON_FMT_PANIC, arg_span, |lint| {
let mut l = lint.build("panic message is not a string literal");
l.note("this is no longer accepted in Rust 2021");
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
if !span.contains(arg_span) {
// No clue where this argument is coming from.
l.emit();
Expand Down
17 changes: 10 additions & 7 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3002,8 +3002,7 @@ declare_lint! {

declare_lint! {
/// The `disjoint_capture_migration` lint detects variables that aren't completely
/// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop
/// order of at least one path starting at this variable.
/// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable.
/// It can also detect when a variable implements a trait, but one of its field does not and
/// the field is captured by a closure and used with the assumption that said field implements
/// the same trait as the root variable.
Expand Down Expand Up @@ -3040,16 +3039,16 @@ declare_lint! {
///
/// ### Explanation
///
/// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if
/// the feature `capture_disjoint_fields` is enabled.
/// In the above example, `p.y` will be dropped at the end of `f` instead of
/// with `c` in Rust 2021.
///
/// ### Example of auto-trait
///
/// ```rust,compile_fail
/// #![deny(disjoint_capture_migration)]
/// use std::thread;
///
/// struct Pointer (*mut i32);
/// struct Pointer(*mut i32);
/// unsafe impl Send for Pointer {}
///
/// fn main() {
Expand All @@ -3065,12 +3064,16 @@ declare_lint! {
///
/// ### Explanation
///
/// In the above example `fptr.0` is captured when feature `capture_disjoint_fields` is enabled.
/// In the above example, only `fptr.0` is captured in Rust 2021.
/// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
/// field cannot be sent between thread safely.
pub DISJOINT_CAPTURE_MIGRATION,
Allow,
"Drop reorder and auto traits error because of `capture_disjoint_fields`"
"detects closures affected by Rust 2021 changes",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
explain_reason: false,
};
}

declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ pub struct FutureIncompatibleInfo {
/// The reason for the lint used by diagnostics to provide
/// the right help message
pub reason: FutureIncompatibilityReason,
/// Whether to explain the reason to the user.
///
/// Set to false for lints that already include a more detailed
/// explanation.
pub explain_reason: bool,
/// Information about a future breakage, which will
/// be emitted in JSON messages to be displayed by Cargo
/// for upstream deps
Expand Down Expand Up @@ -185,6 +190,7 @@ impl FutureIncompatibleInfo {
FutureIncompatibleInfo {
reference: "",
reason: FutureIncompatibilityReason::FutureReleaseError,
explain_reason: true,
future_breakage: None,
}
}
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,14 @@ pub fn struct_lint_level<'s, 'd>(
it will become a hard error in a future release!"
.to_owned()
};
let citation = format!("for more information, see {}", future_incompatible.reference);
err.warn(&explanation);
err.note(&citation);
if future_incompatible.explain_reason {
err.warn(&explanation);
}
if !future_incompatible.reference.is_empty() {
let citation =
format!("for more information, see {}", future_incompatible.reference);
err.note(&citation);
}
}

// Finally, run `decorate`. This function is also responsible for emitting the diagnostic.
Expand Down
15 changes: 12 additions & 3 deletions compiler/rustc_mir_build/src/build/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
ty::ClosureKind::FnOnce => {}
}

// We won't be building MIR if the closure wasn't local
let closure_hir_id = tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local());
let closure_span = tcx.hir().span(closure_hir_id);

let (capture_index, capture) = if let Some(capture_details) =
find_capture_matching_projections(
typeck_results,
Expand All @@ -226,7 +230,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
) {
capture_details
} else {
if !tcx.features().capture_disjoint_fields {
if !enable_precise_capture(tcx, closure_span) {
bug!(
"No associated capture found for {:?}[{:#?}] even though \
capture_disjoint_fields isn't enabled",
Expand All @@ -242,8 +246,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
return Err(from_builder);
};

let closure_ty = typeck_results
.node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()));
let closure_ty = typeck_results.node_type(closure_hir_id);

let substs = match closure_ty.kind() {
ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
Expand Down Expand Up @@ -780,3 +783,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}
}

/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
/// user is using Rust Edition 2021 or higher.
fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool {
tcx.features().capture_disjoint_fields || closure_span.rust_2021()
}
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
hir::GenericParamKind::Type {
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
..
} | hir::GenericParamKind::Lifetime {
kind: hir::LifetimeParamKind::Elided
}
)
}) {
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_typeck/src/check/method/prelude2021.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
return;
}

// if it's an inherent `self` method (not `&self` or `&mut self`), it will take
// precedence over the `TryInto` impl, and thus won't break in 2021 edition
if pick.autoderefs == 0 && pick.autoref_or_ptr_adjustment.is_none() {
return;
}

// Inherent impls only require not relying on autoref and autoderef in order to
// ensure that the trait implementation won't be used
self.tcx.struct_span_lint_hir(
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|lint| {
let mut diagnostics_builder = lint.build(
format!(
"{} affected for closure because of `capture_disjoint_fields`",
"{} will change in Rust 2021",
reasons
)
.as_str(),
);
diagnostics_builder.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>");
let closure_body_span = self.tcx.hir().span(body_id.hir_id);
let (sugg, app) =
match self.tcx.sess.source_map().span_to_snippet(closure_body_span) {
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ impl<'a> Builder<'a> {
test::RustdocTheme,
test::RustdocUi,
test::RustdocJson,
test::HtmlCheck,
// Run bootstrap close to the end as it's unlikely to fail
test::Bootstrap,
// Run run-make last, since these won't pass without make on Windows
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ impl Step for Std {

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Rustc {
stage: u32,
target: TargetSelection,
pub stage: u32,
pub target: TargetSelection,
}

impl Step for Rustc {
Expand Down
45 changes: 44 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::fmt;
use std::fs;
use std::iter;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::process::{Command, Stdio};

use build_helper::{self, output, t};

Expand Down Expand Up @@ -161,6 +161,49 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
}
}

fn check_if_tidy_is_installed() -> bool {
Command::new("tidy")
.arg("--version")
.stdout(Stdio::null())
.status()
.map_or(false, |status| status.success())
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct HtmlCheck {
target: TargetSelection,
}

impl Step for HtmlCheck {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
let run = run.path("src/tools/html-checker");
run.lazy_default_condition(Box::new(check_if_tidy_is_installed))
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(HtmlCheck { target: run.target });
}

fn run(self, builder: &Builder<'_>) {
if !check_if_tidy_is_installed() {
eprintln!("not running HTML-check tool because `tidy` is missing");
eprintln!(
"Note that `tidy` is not the in-tree `src/tools/tidy` but needs to be installed"
);
panic!("Cannot run html-check tests");
}
// Ensure that a few different kinds of documentation are available.
builder.default_doc(&[]);
builder.ensure(crate::doc::Rustc { target: self.target, stage: builder.top_stage });

try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Cargotest {
stage: u32,
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ bootstrap_tool!(
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
LintDocs, "src/tools/lint-docs", "lint-docs";
JsonDocCk, "src/tools/jsondocck", "jsondocck";
HtmlChecker, "src/tools/html-checker", "html-checker";
);

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-dev \
llvm-dev \
libfreetype6-dev \
libexpat1-dev
libexpat1-dev \
tidy

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
libssl-dev \
sudo \
xz-utils
xz-utils \
tidy

# Install dependencies for chromium browser
RUN apt-get install -y \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#![feature(capture_disjoint_fields)]
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
//~| `#[warn(incomplete_features)]` on by default
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
// edition:2021
#![feature(rustc_attrs)]

// Ensure that capture analysis results in arrays being completely captured.
Expand Down
Loading