Skip to content

Commit 1ea0e28

Browse files
committed
Auto merge of #86704 - JohnTitor:rollup-lnrxo4i, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #86059 (Add new tool to check HTML) - #86529 (Add support for OpenSSL 3.0.0) - #86657 (Fix `future_prelude_collision` false positive) - #86661 (Editon 2021 enables precise capture) - #86671 (Turn non_fmt_panic into a future_incompatible edition lint.) - #86673 (Make disjoint_capture_migration an edition lint.) - #86678 (Fix garbled suggestion for missing lifetime specifier) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 18db83f + a89c6be commit 1ea0e28

File tree

184 files changed

+945
-1420
lines changed

Some content is hidden

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

184 files changed

+945
-1420
lines changed

Cargo.lock

+11-4
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,13 @@ dependencies = [
15781578
"winapi 0.3.9",
15791579
]
15801580

1581+
[[package]]
1582+
name = "html-checker"
1583+
version = "0.1.0"
1584+
dependencies = [
1585+
"walkdir",
1586+
]
1587+
15811588
[[package]]
15821589
name = "html5ever"
15831590
version = "0.25.1"
@@ -2433,9 +2440,9 @@ dependencies = [
24332440

24342441
[[package]]
24352442
name = "openssl"
2436-
version = "0.10.33"
2443+
version = "0.10.35"
24372444
source = "registry+https://github.com/rust-lang/crates.io-index"
2438-
checksum = "a61075b62a23fef5a29815de7536d940aa35ce96d18ce0cc5076272db678a577"
2445+
checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885"
24392446
dependencies = [
24402447
"bitflags",
24412448
"cfg-if 1.0.0",
@@ -2462,9 +2469,9 @@ dependencies = [
24622469

24632470
[[package]]
24642471
name = "openssl-sys"
2465-
version = "0.9.61"
2472+
version = "0.9.65"
24662473
source = "registry+https://github.com/rust-lang/crates.io-index"
2467-
checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f"
2474+
checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d"
24682475
dependencies = [
24692476
"autocfg",
24702477
"cc",

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ members = [
3434
"src/tools/unicode-table-generator",
3535
"src/tools/expand-yaml-anchors",
3636
"src/tools/jsondocck",
37+
"src/tools/html-checker",
3738
]
3839

3940
exclude = [

compiler/rustc_lint/src/non_fmt_panic.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use rustc_errors::{pluralize, Applicability};
44
use rustc_hir as hir;
55
use rustc_middle::ty;
66
use rustc_parse_format::{ParseMode, Parser, Piece};
7+
use rustc_session::lint::FutureIncompatibilityReason;
8+
use rustc_span::edition::Edition;
79
use rustc_span::{hygiene, sym, symbol::kw, symbol::SymbolStr, InnerSpan, Span, Symbol};
810

911
declare_lint! {
@@ -30,6 +32,10 @@ declare_lint! {
3032
NON_FMT_PANIC,
3133
Warn,
3234
"detect single-argument panic!() invocations in which the argument is not a format string",
35+
@future_incompatible = FutureIncompatibleInfo {
36+
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
37+
explain_reason: false,
38+
};
3339
report_in_external_macro
3440
}
3541

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

8894
cx.struct_span_lint(NON_FMT_PANIC, arg_span, |lint| {
8995
let mut l = lint.build("panic message is not a string literal");
90-
l.note("this is no longer accepted in Rust 2021");
96+
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
97+
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
9198
if !span.contains(arg_span) {
9299
// No clue where this argument is coming from.
93100
l.emit();

compiler/rustc_lint_defs/src/builtin.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -3002,8 +3002,7 @@ declare_lint! {
30023002

30033003
declare_lint! {
30043004
/// The `disjoint_capture_migration` lint detects variables that aren't completely
3005-
/// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop
3006-
/// order of at least one path starting at this variable.
3005+
/// captured in Rust 2021 and affect the Drop order of at least one path starting at this variable.
30073006
/// It can also detect when a variable implements a trait, but one of its field does not and
30083007
/// the field is captured by a closure and used with the assumption that said field implements
30093008
/// the same trait as the root variable.
@@ -3040,16 +3039,16 @@ declare_lint! {
30403039
///
30413040
/// ### Explanation
30423041
///
3043-
/// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if
3044-
/// the feature `capture_disjoint_fields` is enabled.
3042+
/// In the above example, `p.y` will be dropped at the end of `f` instead of
3043+
/// with `c` in Rust 2021.
30453044
///
30463045
/// ### Example of auto-trait
30473046
///
30483047
/// ```rust,compile_fail
30493048
/// #![deny(disjoint_capture_migration)]
30503049
/// use std::thread;
30513050
///
3052-
/// struct Pointer (*mut i32);
3051+
/// struct Pointer(*mut i32);
30533052
/// unsafe impl Send for Pointer {}
30543053
///
30553054
/// fn main() {
@@ -3065,12 +3064,16 @@ declare_lint! {
30653064
///
30663065
/// ### Explanation
30673066
///
3068-
/// In the above example `fptr.0` is captured when feature `capture_disjoint_fields` is enabled.
3067+
/// In the above example, only `fptr.0` is captured in Rust 2021.
30693068
/// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
30703069
/// field cannot be sent between thread safely.
30713070
pub DISJOINT_CAPTURE_MIGRATION,
30723071
Allow,
3073-
"Drop reorder and auto traits error because of `capture_disjoint_fields`"
3072+
"detects closures affected by Rust 2021 changes",
3073+
@future_incompatible = FutureIncompatibleInfo {
3074+
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
3075+
explain_reason: false,
3076+
};
30743077
}
30753078

30763079
declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);

compiler/rustc_lint_defs/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ pub struct FutureIncompatibleInfo {
145145
/// The reason for the lint used by diagnostics to provide
146146
/// the right help message
147147
pub reason: FutureIncompatibilityReason,
148+
/// Whether to explain the reason to the user.
149+
///
150+
/// Set to false for lints that already include a more detailed
151+
/// explanation.
152+
pub explain_reason: bool,
148153
/// Information about a future breakage, which will
149154
/// be emitted in JSON messages to be displayed by Cargo
150155
/// for upstream deps
@@ -185,6 +190,7 @@ impl FutureIncompatibleInfo {
185190
FutureIncompatibleInfo {
186191
reference: "",
187192
reason: FutureIncompatibilityReason::FutureReleaseError,
193+
explain_reason: true,
188194
future_breakage: None,
189195
}
190196
}

compiler/rustc_middle/src/lint.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,14 @@ pub fn struct_lint_level<'s, 'd>(
398398
it will become a hard error in a future release!"
399399
.to_owned()
400400
};
401-
let citation = format!("for more information, see {}", future_incompatible.reference);
402-
err.warn(&explanation);
403-
err.note(&citation);
401+
if future_incompatible.explain_reason {
402+
err.warn(&explanation);
403+
}
404+
if !future_incompatible.reference.is_empty() {
405+
let citation =
406+
format!("for more information, see {}", future_incompatible.reference);
407+
err.note(&citation);
408+
}
404409
}
405410

406411
// Finally, run `decorate`. This function is also responsible for emitting the diagnostic.

compiler/rustc_mir_build/src/build/expr/as_place.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
217217
ty::ClosureKind::FnOnce => {}
218218
}
219219

220+
// We won't be building MIR if the closure wasn't local
221+
let closure_hir_id = tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local());
222+
let closure_span = tcx.hir().span(closure_hir_id);
223+
220224
let (capture_index, capture) = if let Some(capture_details) =
221225
find_capture_matching_projections(
222226
typeck_results,
@@ -226,7 +230,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
226230
) {
227231
capture_details
228232
} else {
229-
if !tcx.features().capture_disjoint_fields {
233+
if !enable_precise_capture(tcx, closure_span) {
230234
bug!(
231235
"No associated capture found for {:?}[{:#?}] even though \
232236
capture_disjoint_fields isn't enabled",
@@ -242,8 +246,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>(
242246
return Err(from_builder);
243247
};
244248

245-
let closure_ty = typeck_results
246-
.node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local()));
249+
let closure_ty = typeck_results.node_type(closure_hir_id);
247250

248251
let substs = match closure_ty.kind() {
249252
ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
@@ -780,3 +783,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
780783
}
781784
}
782785
}
786+
787+
/// Precise capture is enabled if the feature gate `capture_disjoint_fields` is enabled or if
788+
/// user is using Rust Edition 2021 or higher.
789+
fn enable_precise_capture(tcx: TyCtxt<'_>, closure_span: Span) -> bool {
790+
tcx.features().capture_disjoint_fields || closure_span.rust_2021()
791+
}

compiler/rustc_resolve/src/late/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
19621962
hir::GenericParamKind::Type {
19631963
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
19641964
..
1965+
} | hir::GenericParamKind::Lifetime {
1966+
kind: hir::LifetimeParamKind::Elided
19651967
}
19661968
)
19671969
}) {

compiler/rustc_typeck/src/check/method/prelude2021.rs

+7
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5757
{
5858
return;
5959
}
60+
61+
// if it's an inherent `self` method (not `&self` or `&mut self`), it will take
62+
// precedence over the `TryInto` impl, and thus won't break in 2021 edition
63+
if pick.autoderefs == 0 && pick.autoref_or_ptr_adjustment.is_none() {
64+
return;
65+
}
66+
6067
// Inherent impls only require not relying on autoref and autoderef in order to
6168
// ensure that the trait implementation won't be used
6269
self.tcx.struct_span_lint_hir(

compiler/rustc_typeck/src/check/upvar.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
495495
|lint| {
496496
let mut diagnostics_builder = lint.build(
497497
format!(
498-
"{} affected for closure because of `capture_disjoint_fields`",
498+
"{} will change in Rust 2021",
499499
reasons
500500
)
501501
.as_str(),
502502
);
503+
diagnostics_builder.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>");
503504
let closure_body_span = self.tcx.hir().span(body_id.hir_id);
504505
let (sugg, app) =
505506
match self.tcx.sess.source_map().span_to_snippet(closure_body_span) {

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ impl<'a> Builder<'a> {
450450
test::RustdocTheme,
451451
test::RustdocUi,
452452
test::RustdocJson,
453+
test::HtmlCheck,
453454
// Run bootstrap close to the end as it's unlikely to fail
454455
test::Bootstrap,
455456
// Run run-make last, since these won't pass without make on Windows

src/bootstrap/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ impl Step for Std {
501501

502502
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
503503
pub struct Rustc {
504-
stage: u32,
505-
target: TargetSelection,
504+
pub stage: u32,
505+
pub target: TargetSelection,
506506
}
507507

508508
impl Step for Rustc {

src/bootstrap/test.rs

+44-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fmt;
99
use std::fs;
1010
use std::iter;
1111
use std::path::{Path, PathBuf};
12-
use std::process::Command;
12+
use std::process::{Command, Stdio};
1313

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

@@ -161,6 +161,49 @@ You can skip linkcheck with --exclude src/tools/linkchecker"
161161
}
162162
}
163163

164+
fn check_if_tidy_is_installed() -> bool {
165+
Command::new("tidy")
166+
.arg("--version")
167+
.stdout(Stdio::null())
168+
.status()
169+
.map_or(false, |status| status.success())
170+
}
171+
172+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
173+
pub struct HtmlCheck {
174+
target: TargetSelection,
175+
}
176+
177+
impl Step for HtmlCheck {
178+
type Output = ();
179+
const DEFAULT: bool = true;
180+
const ONLY_HOSTS: bool = true;
181+
182+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
183+
let run = run.path("src/tools/html-checker");
184+
run.lazy_default_condition(Box::new(check_if_tidy_is_installed))
185+
}
186+
187+
fn make_run(run: RunConfig<'_>) {
188+
run.builder.ensure(HtmlCheck { target: run.target });
189+
}
190+
191+
fn run(self, builder: &Builder<'_>) {
192+
if !check_if_tidy_is_installed() {
193+
eprintln!("not running HTML-check tool because `tidy` is missing");
194+
eprintln!(
195+
"Note that `tidy` is not the in-tree `src/tools/tidy` but needs to be installed"
196+
);
197+
panic!("Cannot run html-check tests");
198+
}
199+
// Ensure that a few different kinds of documentation are available.
200+
builder.default_doc(&[]);
201+
builder.ensure(crate::doc::Rustc { target: self.target, stage: builder.top_stage });
202+
203+
try_run(builder, builder.tool_cmd(Tool::HtmlChecker).arg(builder.doc_out(self.target)));
204+
}
205+
}
206+
164207
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
165208
pub struct Cargotest {
166209
stage: u32,

src/bootstrap/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ bootstrap_tool!(
376376
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
377377
LintDocs, "src/tools/lint-docs", "lint-docs";
378378
JsonDocCk, "src/tools/jsondocck", "jsondocck";
379+
HtmlChecker, "src/tools/html-checker", "html-checker";
379380
);
380381

381382
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]

src/ci/docker/host-x86_64/x86_64-gnu-aux/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1717
libgl1-mesa-dev \
1818
llvm-dev \
1919
libfreetype6-dev \
20-
libexpat1-dev
20+
libexpat1-dev \
21+
tidy
2122

2223
COPY scripts/sccache.sh /scripts/
2324
RUN sh /scripts/sccache.sh

src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1212
cmake \
1313
libssl-dev \
1414
sudo \
15-
xz-utils
15+
xz-utils \
16+
tidy
1617

1718
# Install dependencies for chromium browser
1819
RUN apt-get install -y \

src/test/ui/closures/2229_closure_analysis/arrays-completely-captured.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#![feature(capture_disjoint_fields)]
2-
//~^ WARNING: the feature `capture_disjoint_fields` is incomplete
3-
//~| `#[warn(incomplete_features)]` on by default
4-
//~| see issue #53488 <https://github.com/rust-lang/rust/issues/53488>
1+
// edition:2021
52
#![feature(rustc_attrs)]
63

74
// Ensure that capture analysis results in arrays being completely captured.

0 commit comments

Comments
 (0)