Skip to content

Commit 87532e9

Browse files
author
Alexander Regueiro
committed
Minor clean-up
1 parent 67a30d2 commit 87532e9

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

src/librustc_typeck/astconv.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
569569

570570
let has_self = generic_params.has_self;
571571
let (_, potential_assoc_types) = Self::check_generic_arg_count(
572-
self.tcx(),
572+
tcx,
573573
span,
574574
&generic_params,
575575
&generic_args,
@@ -594,7 +594,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
594594
};
595595

596596
let substs = Self::create_substs_for_generic_args(
597-
self.tcx(),
597+
tcx,
598598
def_id,
599599
&[][..],
600600
self_ty.is_some(),
@@ -1293,8 +1293,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
12931293
self.prohibit_generics(slice::from_ref(item_segment));
12941294

12951295
// Check if we have an enum variant here.
1296-
if let ty::Adt(adt_def, _) = ty.sty {
1297-
if adt_def.is_enum() {
1296+
match ty.sty {
1297+
ty::Adt(adt_def, _) if adt_def.is_enum() => {
12981298
let variant_def = adt_def.variants.iter().find(|vd| {
12991299
tcx.hygienic_eq(assoc_name, vd.ident, adt_def.did)
13001300
});
@@ -1305,7 +1305,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
13051305
tcx.check_stability(def.def_id(), Some(ref_id), span);
13061306
return (ty, def);
13071307
}
1308-
}
1308+
},
1309+
_ => (),
13091310
}
13101311

13111312
// Find the type of the associated item, and the trait where the associated
@@ -1339,7 +1340,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
13391340
}
13401341
(&ty::Adt(adt_def, _substs), Def::Enum(_did)) => {
13411342
let ty_str = ty.to_string();
1342-
// Incorrect enum variant
1343+
// Incorrect enum variant.
13431344
let mut err = tcx.sess.struct_span_err(
13441345
span,
13451346
&format!("no variant `{}` on enum `{}`", &assoc_name.as_str(), ty_str),
@@ -1669,23 +1670,24 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
16691670
tcx.mk_ty_param(index, tcx.hir().name(node_id).as_interned_str())
16701671
}
16711672
Def::SelfTy(_, Some(def_id)) => {
1672-
// `Self` in impl (we know the concrete type)
1673+
// `Self` in impl (we know the concrete type).
16731674
assert_eq!(opt_self_ty, None);
16741675
self.prohibit_generics(&path.segments);
16751676
tcx.at(span).type_of(def_id)
16761677
}
16771678
Def::SelfTy(Some(_), None) => {
1678-
// `Self` in trait
1679+
// `Self` in trait.
16791680
assert_eq!(opt_self_ty, None);
16801681
self.prohibit_generics(&path.segments);
16811682
tcx.mk_self_type()
16821683
}
16831684
Def::AssociatedTy(def_id) => {
1684-
self.prohibit_generics(&path.segments[..path.segments.len()-2]);
1685+
debug_assert!(path.segments.len() >= 2);
1686+
self.prohibit_generics(&path.segments[..path.segments.len() - 2]);
16851687
self.qpath_to_ty(span,
16861688
opt_self_ty,
16871689
def_id,
1688-
&path.segments[path.segments.len()-2],
1690+
&path.segments[path.segments.len() - 2],
16891691
path.segments.last().unwrap())
16901692
}
16911693
Def::PrimTy(prim_ty) => {

src/librustc_typeck/check/method/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
372372
let tcx = self.tcx;
373373

374374
// Check if we have an enum variant here.
375-
if let ty::Adt(adt_def, _) = self_ty.sty {
376-
if adt_def.is_enum() {
375+
match self_ty.sty {
376+
ty::Adt(adt_def, _) if adt_def.is_enum() => {
377377
let variant_def = adt_def.variants.iter().find(|vd| {
378378
tcx.hygienic_eq(method_name, vd.ident, adt_def.did)
379379
});
@@ -384,7 +384,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
384384
tcx.check_stability(def.def_id(), Some(expr_id), span);
385385
return Ok(def);
386386
}
387-
}
387+
},
388+
_ => (),
388389
}
389390

390391
let mode = probe::Mode::Path;

0 commit comments

Comments
 (0)