Skip to content

Commit 6e99101

Browse files
committed
Rollup merge of #58562 - dlrobertson:fix_nits, r=alexreg
Fix style nits Fix style nits discovered in reading code. r? @alexreg
2 parents e3a8f7d + f8b6449 commit 6e99101

File tree

16 files changed

+64
-48
lines changed

16 files changed

+64
-48
lines changed

src/librustc/cfg/construct.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
150150
}
151151
}
152152

153-
fn pats_all<'b, I: Iterator<Item=&'b P<hir::Pat>>>(&mut self,
154-
pats: I,
155-
pred: CFGIndex) -> CFGIndex {
153+
fn pats_all<'b, I: Iterator<Item=&'b P<hir::Pat>>>(
154+
&mut self,
155+
pats: I,
156+
pred: CFGIndex
157+
) -> CFGIndex {
156158
//! Handles case where all of the patterns must match.
157159
pats.fold(pred, |pred, pat| self.pat(&pat, pred))
158160
}

src/librustc/hir/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,14 +964,19 @@ pub enum PatKind {
964964
/// If the `..` pattern fragment is present, then `Option<usize>` denotes its position.
965965
/// `0 <= position <= subpats.len()`
966966
Tuple(HirVec<P<Pat>>, Option<usize>),
967+
967968
/// A `box` pattern.
968969
Box(P<Pat>),
970+
969971
/// A reference pattern (e.g., `&mut (a, b)`).
970972
Ref(P<Pat>, Mutability),
973+
971974
/// A literal.
972975
Lit(P<Expr>),
976+
973977
/// A range pattern (e.g., `1...2` or `1..2`).
974978
Range(P<Expr>, P<Expr>, RangeEnd),
979+
975980
/// `[a, b, ..i, y, z]` is represented as:
976981
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`.
977982
Slice(HirVec<P<Pat>>, Option<P<Pat>>, HirVec<P<Pat>>),

src/librustc/middle/mem_categorization.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,12 +1311,12 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
13111311
Def::Err => {
13121312
debug!("access to unresolvable pattern {:?}", pat);
13131313
return Err(())
1314-
},
1314+
}
13151315
Def::Variant(variant_did) |
13161316
Def::VariantCtor(variant_did, ..) => {
13171317
self.cat_downcast_if_needed(pat, cmt, variant_did)
1318-
},
1319-
_ => cmt
1318+
}
1319+
_ => cmt,
13201320
};
13211321

13221322
for fp in field_pats {
@@ -1347,7 +1347,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
13471347
}
13481348
}
13491349

1350-
PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => {
1350+
PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => {
13511351
// box p1, &p1, &mut p1. we can ignore the mutability of
13521352
// PatKind::Ref since that information is already contained
13531353
// in the type.

src/librustc/ty/sty.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,13 +1167,13 @@ pub type Region<'tcx> = &'tcx RegionKind;
11671167
/// [rustc guide]: https://rust-lang.github.io/rustc-guide/traits/hrtb.html
11681168
#[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
11691169
pub enum RegionKind {
1170-
// Region bound in a type or fn declaration which will be
1171-
// substituted 'early' -- that is, at the same time when type
1172-
// parameters are substituted.
1170+
/// Region bound in a type or fn declaration which will be
1171+
/// substituted 'early' -- that is, at the same time when type
1172+
/// parameters are substituted.
11731173
ReEarlyBound(EarlyBoundRegion),
11741174

1175-
// Region bound in a function scope, which will be substituted when the
1176-
// function is called.
1175+
/// Region bound in a function scope, which will be substituted when the
1176+
/// function is called.
11771177
ReLateBound(DebruijnIndex, BoundRegion),
11781178

11791179
/// When checking a function body, the types of all arguments and so forth

src/librustc_codegen_llvm/intrinsic.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
192192
"size_of_val" => {
193193
let tp_ty = substs.type_at(0);
194194
if let OperandValue::Pair(_, meta) = args[0].val {
195-
let (llsize, _) =
196-
glue::size_and_align_of_dst(self, tp_ty, Some(meta));
195+
let (llsize, _) = glue::size_and_align_of_dst(self, tp_ty, Some(meta));
197196
llsize
198197
} else {
199198
self.const_usize(self.size_of(tp_ty).bytes())
@@ -206,8 +205,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
206205
"min_align_of_val" => {
207206
let tp_ty = substs.type_at(0);
208207
if let OperandValue::Pair(_, meta) = args[0].val {
209-
let (_, llalign) =
210-
glue::size_and_align_of_dst(self, tp_ty, Some(meta));
208+
let (_, llalign) = glue::size_and_align_of_dst(self, tp_ty, Some(meta));
211209
llalign
212210
} else {
213211
self.const_usize(self.align_of(tp_ty).bytes())

src/librustc_codegen_llvm/type_.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
8282

8383
fn type_i16(&self) -> &'ll Type {
8484
unsafe {
85-
8685
llvm::LLVMInt16TypeInContext(self.llcx)
8786
}
8887
}

src/librustc_mir/build/matches/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
338338
self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard);
339339
block.unit()
340340
}
341+
341342
_ => {
342343
let place = unpack!(block = self.as_place(block, initializer));
343344
self.place_into_pattern(block, irrefutable_pat, &place, true)
@@ -534,6 +535,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
534535
self.visit_bindings(subpattern, pattern_user_ty, f);
535536
}
536537
}
538+
537539
PatternKind::Array {
538540
ref prefix,
539541
ref slice,
@@ -556,10 +558,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
556558
self.visit_bindings(subpattern, pattern_user_ty.clone().index(), f);
557559
}
558560
}
561+
559562
PatternKind::Constant { .. } | PatternKind::Range { .. } | PatternKind::Wild => {}
563+
560564
PatternKind::Deref { ref subpattern } => {
561565
self.visit_bindings(subpattern, pattern_user_ty.deref(), f);
562566
}
567+
563568
PatternKind::AscribeUserType {
564569
ref subpattern,
565570
ascription: hair::pattern::Ascription {

src/librustc_mir/build/matches/simplify.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
4545
}
4646
}
4747

48-
/// Tries to simplify `match_pair`, returning true if
48+
/// Tries to simplify `match_pair`, returning `Ok(())` if
4949
/// successful. If successful, new match pairs and bindings will
5050
/// have been pushed into the candidate. If no simplification is
51-
/// possible, Err is returned and no changes are made to
51+
/// possible, `Err` is returned and no changes are made to
5252
/// candidate.
5353
fn simplify_match_pair<'pat>(&mut self,
5454
match_pair: MatchPair<'pat, 'tcx>,
@@ -174,7 +174,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
174174
} else {
175175
Err(match_pair)
176176
}
177-
},
177+
}
178178

179179
PatternKind::Array { ref prefix, ref slice, ref suffix } => {
180180
self.prefix_slice_suffix(&mut candidate.match_pairs,

src/librustc_mir/build/matches/test.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
3535
}
3636
}
3737

38-
PatternKind::Constant { .. }
39-
if is_switch_ty(match_pair.pattern.ty) => {
40-
// for integers, we use a SwitchInt match, which allows
41-
// us to handle more cases
38+
PatternKind::Constant { .. } if is_switch_ty(match_pair.pattern.ty) => {
39+
// For integers, we use a `SwitchInt` match, which allows
40+
// us to handle more cases.
4241
Test {
4342
span: match_pair.pattern.span,
4443
kind: TestKind::SwitchInt {
@@ -253,12 +252,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
253252
TestKind::Eq { value, mut ty } => {
254253
let val = Operand::Copy(place.clone());
255254
let mut expect = self.literal_operand(test.span, ty, value);
256-
// Use PartialEq::eq instead of BinOp::Eq
255+
// Use `PartialEq::eq` instead of `BinOp::Eq`
257256
// (the binop can only handle primitives)
258257
let fail = self.cfg.start_new_block();
259258
if !ty.is_scalar() {
260-
// If we're using b"..." as a pattern, we need to insert an
261-
// unsizing coercion, as the byte string has the type &[u8; N].
259+
// If we're using `b"..."` as a pattern, we need to insert an
260+
// unsizing coercion, as the byte string has the type `&[u8; N]`.
262261
//
263262
// We want to do this even when the scrutinee is a reference to an
264263
// array, so we can call `<[u8]>::eq` rather than having to find an
@@ -503,6 +502,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
503502
resulting_candidates[variant_index.as_usize()].push(new_candidate);
504503
true
505504
}
505+
506506
(&TestKind::Switch { .. }, _) => false,
507507

508508
// If we are performing a switch over integers, then this informs integer
@@ -539,7 +539,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
539539

540540
(&TestKind::SwitchInt { .. }, _) => false,
541541

542-
543542
(&TestKind::Len { len: test_len, op: BinOp::Eq },
544543
&PatternKind::Slice { ref prefix, ref slice, ref suffix }) => {
545544
let pat_len = (prefix.len() + suffix.len()) as u64;

src/librustc_mir/build/matches/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
1313
subpatterns.iter()
1414
.map(|fieldpat| {
1515
let place = place.clone().field(fieldpat.field,
16-
fieldpat.pattern.ty);
16+
fieldpat.pattern.ty);
1717
MatchPair::new(place, &fieldpat.pattern)
1818
})
1919
.collect()

0 commit comments

Comments
 (0)