Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Minor clean-up
  • Loading branch information
Alexander Regueiro committed Dec 26, 2018
1 parent 67a30d2 commit 87532e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
22 changes: 12 additions & 10 deletions src/librustc_typeck/astconv.rs
Expand Up @@ -569,7 +569,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {

let has_self = generic_params.has_self;
let (_, potential_assoc_types) = Self::check_generic_arg_count(
self.tcx(),
tcx,
span,
&generic_params,
&generic_args,
Expand All @@ -594,7 +594,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
};

let substs = Self::create_substs_for_generic_args(
self.tcx(),
tcx,
def_id,
&[][..],
self_ty.is_some(),
Expand Down Expand Up @@ -1293,8 +1293,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
self.prohibit_generics(slice::from_ref(item_segment));

// Check if we have an enum variant here.
if let ty::Adt(adt_def, _) = ty.sty {
if adt_def.is_enum() {
match ty.sty {
ty::Adt(adt_def, _) if adt_def.is_enum() => {
let variant_def = adt_def.variants.iter().find(|vd| {
tcx.hygienic_eq(assoc_name, vd.ident, adt_def.did)
});
Expand All @@ -1305,7 +1305,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
tcx.check_stability(def.def_id(), Some(ref_id), span);
return (ty, def);
}
}
},
_ => (),
}

// Find the type of the associated item, and the trait where the associated
Expand Down Expand Up @@ -1339,7 +1340,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
}
(&ty::Adt(adt_def, _substs), Def::Enum(_did)) => {
let ty_str = ty.to_string();
// Incorrect enum variant
// Incorrect enum variant.
let mut err = tcx.sess.struct_span_err(
span,
&format!("no variant `{}` on enum `{}`", &assoc_name.as_str(), ty_str),
Expand Down Expand Up @@ -1669,23 +1670,24 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
tcx.mk_ty_param(index, tcx.hir().name(node_id).as_interned_str())
}
Def::SelfTy(_, Some(def_id)) => {
// `Self` in impl (we know the concrete type)
// `Self` in impl (we know the concrete type).
assert_eq!(opt_self_ty, None);
self.prohibit_generics(&path.segments);
tcx.at(span).type_of(def_id)
}
Def::SelfTy(Some(_), None) => {
// `Self` in trait
// `Self` in trait.
assert_eq!(opt_self_ty, None);
self.prohibit_generics(&path.segments);
tcx.mk_self_type()
}
Def::AssociatedTy(def_id) => {
self.prohibit_generics(&path.segments[..path.segments.len()-2]);
debug_assert!(path.segments.len() >= 2);
self.prohibit_generics(&path.segments[..path.segments.len() - 2]);
self.qpath_to_ty(span,
opt_self_ty,
def_id,
&path.segments[path.segments.len()-2],
&path.segments[path.segments.len() - 2],
path.segments.last().unwrap())
}
Def::PrimTy(prim_ty) => {
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_typeck/check/method/mod.rs
Expand Up @@ -372,8 +372,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let tcx = self.tcx;

// Check if we have an enum variant here.
if let ty::Adt(adt_def, _) = self_ty.sty {
if adt_def.is_enum() {
match self_ty.sty {
ty::Adt(adt_def, _) if adt_def.is_enum() => {
let variant_def = adt_def.variants.iter().find(|vd| {
tcx.hygienic_eq(method_name, vd.ident, adt_def.did)
});
Expand All @@ -384,7 +384,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
tcx.check_stability(def.def_id(), Some(expr_id), span);
return Ok(def);
}
}
},
_ => (),
}

let mode = probe::Mode::Path;
Expand Down

0 comments on commit 87532e9

Please sign in to comment.