Skip to content

Commit 11adc13

Browse files
committed
Address minor comments
1 parent bfc3b20 commit 11adc13

File tree

6 files changed

+12
-26
lines changed

6 files changed

+12
-26
lines changed

src/librustc/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ impl<'a, 'gcx, 'tcx> Generics {
931931
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
932932
for param in &self.params {
933933
match param.kind {
934-
GenericParamDefKind::Type {..} => return true,
934+
GenericParamDefKind::Type { .. } => return true,
935935
GenericParamDefKind::Lifetime => {}
936936
}
937937
}

src/librustc/ty/subst.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
231231
mk_kind: &mut F)
232232
where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
233233
{
234-
235234
if let Some(def_id) = defs.parent {
236235
let parent_defs = tcx.generics_of(def_id);
237236
Substs::fill_item(substs, tcx, parent_defs, mk_kind);

src/librustc_lint/types.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -819,14 +819,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
819819
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
820820
if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
821821
let item_def_id = cx.tcx.hir.local_def_id(it.id);
822-
let generics = cx.tcx.generics_of(item_def_id);
823-
for param in &generics.params {
824-
match param.kind {
825-
ty::GenericParamDefKind::Lifetime { .. } => {},
826-
ty::GenericParamDefKind::Type { .. } => return,
827-
}
828-
}
829-
// Sizes only make sense for non-generic types.
830822
let t = cx.tcx.type_of(item_def_id);
831823
let ty = cx.tcx.erase_regions(&t);
832824
match cx.layout_of(ty) {

src/librustc_passes/ast_validation.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,7 @@ impl<'a> Visitor<'a> for NestedImplTraitVisitor<'a> {
539539
fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) {
540540
match *generic_args {
541541
GenericArgs::AngleBracketed(ref data) => {
542-
data.args.iter().for_each(|arg| match arg {
543-
GenericArg::Type(ty) => self.visit_ty(ty),
544-
_ => {}
545-
});
542+
data.args.iter().for_each(|arg| self.visit_generic_arg(arg));
546543
for type_binding in &data.bindings {
547544
// Type bindings such as `Item=impl Debug` in `Iterator<Item=Debug>`
548545
// are allowed to contain nested `impl Trait`.

src/librustc_privacy/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern crate rustc_typeck;
2323
extern crate syntax_pos;
2424
extern crate rustc_data_structures;
2525

26-
use rustc::hir::{self, GenericParamKind, PatKind};
26+
use rustc::hir::{self, PatKind};
2727
use rustc::hir::def::Def;
2828
use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, CrateNum, DefId};
2929
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
@@ -1270,14 +1270,11 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
12701270
}
12711271

12721272
fn visit_generics(&mut self, generics: &'tcx hir::Generics) {
1273-
generics.params.iter().for_each(|param| match param.kind {
1274-
GenericParamKind::Lifetime { .. } => {}
1275-
GenericParamKind::Type { .. } => {
1276-
for bound in &param.bounds {
1277-
self.check_generic_bound(bound);
1278-
}
1273+
for param in &generics.params {
1274+
for bound in &param.bounds {
1275+
self.check_generic_bound(bound);
12791276
}
1280-
});
1277+
}
12811278
for predicate in &generics.where_clause.predicates {
12821279
match predicate {
12831280
&hir::WherePredicate::BoundPredicate(ref bound_pred) => {

src/librustc_resolve/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,12 @@ impl<'a, 'tcx, 'cl> Visitor<'tcx> for Resolver<'a, 'cl> {
822822
.filter_map(|param| match param.kind {
823823
GenericParamKind::Lifetime { .. } => None,
824824
GenericParamKind::Type { ref default, .. } => {
825-
if found_default || default.is_some() {
826-
found_default = true;
827-
return Some((Ident::with_empty_ctxt(param.ident.name), Def::Err));
825+
found_default |= default.is_some();
826+
if found_default {
827+
Some((Ident::with_empty_ctxt(param.ident.name), Def::Err));
828+
} else {
829+
None
828830
}
829-
None
830831
}
831832
}));
832833

0 commit comments

Comments
 (0)