Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 51748a8

Browse files
committed
Auto merge of rust-lang#82816 - GuillaumeGomez:rollup-hxohu2e, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#80845 (Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make transition over hir::ItemKind simpler) - rust-lang#82708 (Warn on `#![doc(test(...))]` on items other than the crate root and use future incompatible lint) - rust-lang#82714 (Detect match arm body without braces) - rust-lang#82736 (Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default) - rust-lang#82782 (Make rustc shim's verbose output include crate_name being compiled.) - rust-lang#82797 (Update tests names to start with `issue-`) - rust-lang#82809 (rustdoc: Use substrings instead of split to grab enum variant paths) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents caca212 + 8dfbc00 commit 51748a8

File tree

113 files changed

+665
-188
lines changed

Some content is hidden

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

113 files changed

+665
-188
lines changed

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ fn test_debugging_options_tracking_hash() {
566566
tracked!(link_only, true);
567567
tracked!(merge_functions, Some(MergeFunctions::Disabled));
568568
tracked!(mir_emit_retag, true);
569-
tracked!(mir_opt_level, 3);
569+
tracked!(mir_opt_level, Some(4));
570570
tracked!(mutable_noalias, true);
571571
tracked!(new_llvm_pass_manager, true);
572572
tracked!(no_codegen, true);

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,3 +3059,33 @@ declare_lint! {
30593059
Allow,
30603060
"No declared ABI for extern declaration"
30613061
}
3062+
3063+
declare_lint! {
3064+
/// The `invalid_doc_attributes` lint detects when the `#[doc(...)]` is
3065+
/// misused.
3066+
///
3067+
/// ### Example
3068+
///
3069+
/// ```rust,compile_fail
3070+
/// #![deny(warnings)]
3071+
///
3072+
/// pub mod submodule {
3073+
/// #![doc(test(no_crate_inject))]
3074+
/// }
3075+
/// ```
3076+
///
3077+
/// {{produces}}
3078+
///
3079+
/// ### Explanation
3080+
///
3081+
/// Previously, there were very like checks being performed on `#[doc(..)]`
3082+
/// unlike the other attributes. It'll now catch all the issues that it
3083+
/// silently ignored previously.
3084+
pub INVALID_DOC_ATTRIBUTES,
3085+
Warn,
3086+
"detects invalid `#[doc(...)]` attributes",
3087+
@future_incompatible = FutureIncompatibleInfo {
3088+
reference: "issue #82730 <https://github.com/rust-lang/rust/issues/82730>",
3089+
edition: None,
3090+
};
3091+
}

compiler/rustc_mir/src/transform/const_goto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct ConstGoto;
2828

2929
impl<'tcx> MirPass<'tcx> for ConstGoto {
3030
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
31-
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 {
31+
if tcx.sess.mir_opt_level() < 4 {
3232
return;
3333
}
3434
trace!("Running ConstGoto on {:?}", body.source);

compiler/rustc_mir/src/transform/const_prop.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
725725
return None;
726726
}
727727

728-
if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 3 {
728+
if self.tcx.sess.mir_opt_level() >= 4 {
729729
self.eval_rvalue_with_identities(rvalue, place)
730730
} else {
731731
self.use_ecx(|this| this.ecx.eval_rvalue_into_place(rvalue, place))
@@ -903,7 +903,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
903903

904904
/// Returns `true` if and only if this `op` should be const-propagated into.
905905
fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
906-
let mir_opt_level = self.tcx.sess.opts.debugging_opts.mir_opt_level;
906+
let mir_opt_level = self.tcx.sess.mir_opt_level();
907907

908908
if mir_opt_level == 0 {
909909
return false;
@@ -1071,9 +1071,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
10711071
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
10721072
self.super_operand(operand, location);
10731073

1074-
// Only const prop copies and moves on `mir_opt_level=2` as doing so
1074+
// Only const prop copies and moves on `mir_opt_level=3` as doing so
10751075
// currently slightly increases compile time in some cases.
1076-
if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
1076+
if self.tcx.sess.mir_opt_level() >= 3 {
10771077
self.propagate_operand(operand)
10781078
}
10791079
}
@@ -1253,7 +1253,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
12531253
TerminatorKind::SwitchInt { ref mut discr, .. } => {
12541254
// FIXME: This is currently redundant with `visit_operand`, but sadly
12551255
// always visiting operands currently causes a perf regression in LLVM codegen, so
1256-
// `visit_operand` currently only runs for propagates places for `mir_opt_level=3`.
1256+
// `visit_operand` currently only runs for propagates places for `mir_opt_level=4`.
12571257
self.propagate_operand(discr)
12581258
}
12591259
// None of these have Operands to const-propagate.
@@ -1272,7 +1272,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
12721272
// Every argument in our function calls have already been propagated in `visit_operand`.
12731273
//
12741274
// NOTE: because LLVM codegen gives slight performance regressions with it, so this is
1275-
// gated on `mir_opt_level=2`.
1275+
// gated on `mir_opt_level=3`.
12761276
TerminatorKind::Call { .. } => {}
12771277
}
12781278

compiler/rustc_mir/src/transform/deduplicate_blocks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct DeduplicateBlocks;
1616

1717
impl<'tcx> MirPass<'tcx> for DeduplicateBlocks {
1818
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
19-
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 {
19+
if tcx.sess.mir_opt_level() < 4 {
2020
return;
2121
}
2222
debug!("Running DeduplicateBlocks on `{:?}`", body.source);

compiler/rustc_mir/src/transform/dest_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ pub struct DestinationPropagation;
127127

128128
impl<'tcx> MirPass<'tcx> for DestinationPropagation {
129129
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
130-
// Only run at mir-opt-level=2 or higher for now (we don't fix up debuginfo and remove
130+
// Only run at mir-opt-level=3 or higher for now (we don't fix up debuginfo and remove
131131
// storage statements at the moment).
132-
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {
132+
if tcx.sess.mir_opt_level() < 3 {
133133
return;
134134
}
135135

compiler/rustc_mir/src/transform/early_otherwise_branch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct EarlyOtherwiseBranch;
2626

2727
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
2828
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
29-
if tcx.sess.opts.debugging_opts.mir_opt_level < 2 {
29+
if tcx.sess.mir_opt_level() < 3 {
3030
return;
3131
}
3232
trace!("running EarlyOtherwiseBranch on {:?}", body.source);

compiler/rustc_mir/src/transform/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ crate fn is_enabled(tcx: TyCtxt<'_>) -> bool {
5252
return enabled;
5353
}
5454

55-
tcx.sess.opts.debugging_opts.mir_opt_level >= 2
55+
tcx.sess.mir_opt_level() >= 3
5656
}
5757

5858
impl<'tcx> MirPass<'tcx> for Inline {

compiler/rustc_mir/src/transform/match_branches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct MatchBranchSimplification;
4040
4141
impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
4242
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
43-
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {
43+
if tcx.sess.mir_opt_level() < 3 {
4444
return;
4545
}
4646

compiler/rustc_mir/src/transform/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
475475
}
476476

477477
fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
478-
let mir_opt_level = tcx.sess.opts.debugging_opts.mir_opt_level;
478+
let mir_opt_level = tcx.sess.mir_opt_level();
479479

480480
// Lowering generator control-flow and variables has to happen before we do anything else
481481
// to them. We run some optimizations before that, because they may be harder to do on the state

0 commit comments

Comments
 (0)