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

Commit 8235af0

Browse files
committed
Improve comment formatting.
By reflowing comment lines that are too long, and a few that are very short. Plus some other very minor formatting tweaks.
1 parent c2f74c3 commit 8235af0

27 files changed

+151
-111
lines changed

compiler/rustc_mir_transform/src/add_retag.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
6060
let basic_blocks = body.basic_blocks.as_mut();
6161
let local_decls = &body.local_decls;
6262
let needs_retag = |place: &Place<'tcx>| {
63-
!place.is_indirect_first_projection() // we're not really interested in stores to "outside" locations, they are hard to keep track of anyway
63+
// We're not really interested in stores to "outside" locations, they are hard to keep
64+
// track of anyway.
65+
!place.is_indirect_first_projection()
6466
&& may_contain_reference(place.ty(&*local_decls, tcx).ty, /*depth*/ 3, tcx)
6567
&& !local_decls[place.local].is_deref_temp()
6668
};
@@ -129,9 +131,9 @@ impl<'tcx> crate::MirPass<'tcx> for AddRetag {
129131
StatementKind::Assign(box (ref place, ref rvalue)) => {
130132
let add_retag = match rvalue {
131133
// Ptr-creating operations already do their own internal retagging, no
132-
// need to also add a retag statement.
133-
// *Except* if we are deref'ing a Box, because those get desugared to directly working
134-
// with the inner raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it
134+
// need to also add a retag statement. *Except* if we are deref'ing a
135+
// Box, because those get desugared to directly working with the inner
136+
// raw pointer! That's relevant for `RawPtr` as Miri otherwise makes it
135137
// a NOP when the original pointer is already raw.
136138
Rvalue::RawPtr(_mutbl, place) => {
137139
// Using `is_box_global` here is a bit sketchy: if this code is

compiler/rustc_mir_transform/src/check_const_item_mutation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
123123
self.super_statement(stmt, loc);
124124
self.target_local = None;
125125
}
126+
126127
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, loc: Location) {
127128
if let Rvalue::Ref(_, BorrowKind::Mut { .. }, place) = rvalue {
128129
let local = place.local;

compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
140140

141141
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, loc: Location) {
142142
if let Operand::Move(place) = *operand
143-
// A move out of a projection of a copy is equivalent to a copy of the original projection.
143+
// A move out of a projection of a copy is equivalent to a copy of the original
144+
// projection.
144145
&& !place.is_indirect_first_projection()
145146
&& !self.fully_moved.contains(place.local)
146147
{

compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ fn inject_mcdc_statements<'tcx>(
279279
basic_coverage_blocks: &CoverageGraph,
280280
extracted_mappings: &ExtractedMappings,
281281
) {
282-
// Inject test vector update first because `inject_statement` always insert new statement at head.
282+
// Inject test vector update first because `inject_statement` always insert new statement at
283+
// head.
283284
for &mappings::MCDCDecision {
284285
span: _,
285286
ref end_bcbs,

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ fn try_write_constant<'tcx>(
647647
ty::FnDef(..) => {}
648648

649649
// Those are scalars, must be handled above.
650-
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char => throw_machine_stop_str!("primitive type with provenance"),
650+
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char =>
651+
throw_machine_stop_str!("primitive type with provenance"),
651652

652653
ty::Tuple(elem_tys) => {
653654
for (i, elem) in elem_tys.iter().enumerate() {

compiler/rustc_mir_transform/src/deduce_param_attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ impl<'tcx> Visitor<'tcx> for DeduceReadOnly {
4242
}
4343
PlaceContext::NonMutatingUse(NonMutatingUseContext::RawBorrow) => {
4444
// Whether mutating though a `&raw const` is allowed is still undecided, so we
45-
// disable any sketchy `readonly` optimizations for now.
46-
// But we only need to do this if the pointer would point into the argument.
47-
// IOW: for indirect places, like `&raw (*local).field`, this surely cannot mutate `local`.
45+
// disable any sketchy `readonly` optimizations for now. But we only need to do
46+
// this if the pointer would point into the argument. IOW: for indirect places,
47+
// like `&raw (*local).field`, this surely cannot mutate `local`.
4848
!place.is_indirect()
4949
}
5050
PlaceContext::NonMutatingUse(..) | PlaceContext::NonUse(..) => {

compiler/rustc_mir_transform/src/deduplicate_blocks.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ fn find_duplicates(body: &Body<'_>) -> FxHashMap<BasicBlock, BasicBlock> {
6969
// For example, if bb1, bb2 and bb3 are duplicates, we will first insert bb3 in same_hashes.
7070
// Then we will see that bb2 is a duplicate of bb3,
7171
// and insert bb2 with the replacement bb3 in the duplicates list.
72-
// When we see bb1, we see that it is a duplicate of bb3, and therefore insert it in the duplicates list
73-
// with replacement bb3.
72+
// When we see bb1, we see that it is a duplicate of bb3, and therefore insert it in the
73+
// duplicates list with replacement bb3.
7474
// When the duplicates are removed, we will end up with only bb3.
7575
for (bb, bbd) in body.basic_blocks.iter_enumerated().rev().filter(|(_, bbd)| !bbd.is_cleanup) {
7676
// Basic blocks can get really big, so to avoid checking for duplicates in basic blocks
@@ -105,7 +105,8 @@ struct BasicBlockHashable<'tcx, 'a> {
105105
impl Hash for BasicBlockHashable<'_, '_> {
106106
fn hash<H: Hasher>(&self, state: &mut H) {
107107
hash_statements(state, self.basic_block_data.statements.iter());
108-
// Note that since we only hash the kind, we lose span information if we deduplicate the blocks
108+
// Note that since we only hash the kind, we lose span information if we deduplicate the
109+
// blocks.
109110
self.basic_block_data.terminator().kind.hash(state);
110111
}
111112
}

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ fn evaluate_candidate<'tcx>(
261261
// };
262262
// ```
263263
//
264-
// Hoisting the `discriminant(Q)` out of the `A` arm causes us to compute the discriminant of an
265-
// invalid value, which is UB.
264+
// Hoisting the `discriminant(Q)` out of the `A` arm causes us to compute the discriminant
265+
// of an invalid value, which is UB.
266266
// In order to fix this, **we would either need to show that the discriminant computation of
267267
// `place` is computed in all branches**.
268268
// FIXME(#95162) For the moment, we adopt a conservative approach and

compiler/rustc_mir_transform/src/elaborate_drops.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use tracing::{debug, instrument};
2020
use crate::deref_separator::deref_finder;
2121

2222
/// During MIR building, Drop terminators are inserted in every place where a drop may occur.
23-
/// However, in this phase, the presence of these terminators does not guarantee that a destructor will run,
24-
/// as the target of the drop may be uninitialized.
23+
/// However, in this phase, the presence of these terminators does not guarantee that a destructor
24+
/// will run, as the target of the drop may be uninitialized.
2525
/// In general, the compiler cannot determine at compile time whether a destructor will run or not.
2626
///
2727
/// At a high level, this pass refines Drop to only run the destructor if the
@@ -30,10 +30,10 @@ use crate::deref_separator::deref_finder;
3030
/// Once this is complete, Drop terminators in the MIR correspond to a call to the "drop glue" or
3131
/// "drop shim" for the type of the dropped place.
3232
///
33-
/// This pass relies on dropped places having an associated move path, which is then used to determine
34-
/// the initialization status of the place and its descendants.
35-
/// It's worth noting that a MIR containing a Drop without an associated move path is probably ill formed,
36-
/// as it would allow running a destructor on a place behind a reference:
33+
/// This pass relies on dropped places having an associated move path, which is then used to
34+
/// determine the initialization status of the place and its descendants.
35+
/// It's worth noting that a MIR containing a Drop without an associated move path is probably ill
36+
/// formed, as it would allow running a destructor on a place behind a reference:
3737
///
3838
/// ```text
3939
/// fn drop_term<T>(t: &mut T) {
@@ -377,8 +377,8 @@ impl<'a, 'tcx> ElaborateDropsCtxt<'a, 'tcx> {
377377
);
378378
}
379379
// A drop and replace behind a pointer/array/whatever.
380-
// The borrow checker requires that these locations are initialized before the assignment,
381-
// so we just leave an unconditional drop.
380+
// The borrow checker requires that these locations are initialized before the
381+
// assignment, so we just leave an unconditional drop.
382382
assert!(!data.is_cleanup);
383383
}
384384
}

compiler/rustc_mir_transform/src/ffi_unwind_calls.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
6060
let fn_def_id = match ty.kind() {
6161
ty::FnPtr(..) => None,
6262
&ty::FnDef(def_id, _) => {
63-
// Rust calls cannot themselves create foreign unwinds (even if they use a non-Rust ABI).
64-
// So the leak of the foreign unwind into Rust can only be elsewhere, not here.
63+
// Rust calls cannot themselves create foreign unwinds (even if they use a non-Rust
64+
// ABI). So the leak of the foreign unwind into Rust can only be elsewhere, not
65+
// here.
6566
if !tcx.is_foreign_item(def_id) {
6667
continue;
6768
}

compiler/rustc_mir_transform/src/function_item_references.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
9292
{
9393
let mut span = self.nth_arg_span(args, arg_num);
9494
if span.from_expansion() {
95-
// The operand's ctxt wouldn't display the lint since it's inside a macro so
96-
// we have to use the callsite's ctxt.
95+
// The operand's ctxt wouldn't display the lint since it's
96+
// inside a macro so we have to use the callsite's ctxt.
9797
let callsite_ctxt = span.source_callsite().ctxt();
9898
span = span.with_ctxt(callsite_ctxt);
9999
}

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ fn propagate_ssa<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
139139
// Try to get some insight.
140140
AssignedValue::Rvalue(rvalue) => {
141141
let value = state.simplify_rvalue(rvalue, location);
142-
// FIXME(#112651) `rvalue` may have a subtype to `local`. We can only mark `local` as
143-
// reusable if we have an exact type match.
142+
// FIXME(#112651) `rvalue` may have a subtype to `local`. We can only mark
143+
// `local` as reusable if we have an exact type match.
144144
if state.local_decls[local].ty != rvalue.ty(state.local_decls, tcx) {
145145
return;
146146
}
@@ -480,7 +480,8 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
480480
let pointer = self.evaluated[local].as_ref()?;
481481
let mut mplace = self.ecx.deref_pointer(pointer).ok()?;
482482
for proj in place.projection.iter().skip(1) {
483-
// We have no call stack to associate a local with a value, so we cannot interpret indexing.
483+
// We have no call stack to associate a local with a value, so we cannot
484+
// interpret indexing.
484485
if matches!(proj, ProjectionElem::Index(_)) {
485486
return None;
486487
}
@@ -1382,7 +1383,8 @@ fn op_to_prop_const<'tcx>(
13821383
return Some(ConstValue::ZeroSized);
13831384
}
13841385

1385-
// Do not synthetize too large constants. Codegen will just memcpy them, which we'd like to avoid.
1386+
// Do not synthetize too large constants. Codegen will just memcpy them, which we'd like to
1387+
// avoid.
13861388
if !matches!(op.layout.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
13871389
return None;
13881390
}

compiler/rustc_mir_transform/src/inline.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ impl<'tcx> Inliner<'tcx> {
568568
// if the no-attribute function ends up with the same instruction set anyway.
569569
return Err("Cannot move inline-asm across instruction sets");
570570
} else if let TerminatorKind::TailCall { .. } = term.kind {
571-
// FIXME(explicit_tail_calls): figure out how exactly functions containing tail calls can be inlined (and if they even should)
571+
// FIXME(explicit_tail_calls): figure out how exactly functions containing tail
572+
// calls can be inlined (and if they even should)
572573
return Err("can't inline functions with tail calls");
573574
} else {
574575
work_list.extend(term.successors())

compiler/rustc_mir_transform/src/known_panics_lint.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
//! A lint that checks for known panics like
2-
//! overflows, division by zero,
3-
//! out-of-bound access etc.
4-
//! Uses const propagation to determine the
5-
//! values of operands during checks.
1+
//! A lint that checks for known panics like overflows, division by zero,
2+
//! out-of-bound access etc. Uses const propagation to determine the values of
3+
//! operands during checks.
64
75
use std::fmt::Debug;
86

@@ -562,7 +560,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
562560

563561
let val = self.use_ecx(|this| this.ecx.binary_op(bin_op, &left, &right))?;
564562
if matches!(val.layout.abi, Abi::ScalarPair(..)) {
565-
// FIXME `Value` should properly support pairs in `Immediate`... but currently it does not.
563+
// FIXME `Value` should properly support pairs in `Immediate`... but currently
564+
// it does not.
566565
let (val, overflow) = val.to_pair(&self.ecx);
567566
Value::Aggregate {
568567
variant: VariantIdx::ZERO,

compiler/rustc_mir_transform/src/large_enums.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ use rustc_target::abi::{HasDataLayout, Size, TagEncoding, Variants};
1616
/// Large([u32; 1024]),
1717
/// }
1818
/// ```
19-
/// Instead of emitting moves of the large variant,
20-
/// Perform a memcpy instead.
19+
/// Instead of emitting moves of the large variant, perform a memcpy instead.
2120
/// Based off of [this HackMD](https://hackmd.io/@ft4bxUsFT5CEUBmRKYHr7w/rJM8BBPzD).
2221
///
2322
/// In summary, what this does is at runtime determine which enum variant is active,
@@ -34,6 +33,7 @@ impl<'tcx> crate::MirPass<'tcx> for EnumSizeOpt {
3433
// https://github.com/rust-lang/rust/pull/85158#issuecomment-1101836457
3534
sess.opts.unstable_opts.unsound_mir_opts || sess.mir_opt_level() >= 3
3635
}
36+
3737
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
3838
// NOTE: This pass may produce different MIR based on the alignment of the target
3939
// platform, but it will still be valid.
@@ -116,6 +116,7 @@ impl EnumSizeOpt {
116116
let alloc = tcx.reserve_and_set_memory_alloc(tcx.mk_const_alloc(alloc));
117117
Some((*adt_def, num_discrs, *alloc_cache.entry(ty).or_insert(alloc)))
118118
}
119+
119120
fn optim<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
120121
let mut alloc_cache = FxHashMap::default();
121122
let body_did = body.source.def_id();

0 commit comments

Comments
 (0)