pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
let mut visitor = CollectItemTypesVisitor { tcx: tcx };
tcx.hir
- .krate()
- .visit_all_item_likes(&mut visitor.as_deep_visitor());
+ .krate()
+ .visit_all_item_likes(&mut visitor.as_deep_visitor());
}
pub fn provide(providers: &mut Providers) {
E0121,
"the type placeholder `_` is not allowed within types on item signatures"
).span_label(span, "not allowed in type signatures")
- .emit();
+ .emit();
+
self.tcx().types.err
}
).span_label(
variant.span,
format!("overflowed on value after {}", prev_discr.unwrap()),
- )
- .note(&format!(
- "explicitly set `{} = {}` if that is desired outcome",
- variant.node.name, wrapped_discr
- ))
- .emit();
+ ).note(&format!(
+ "explicitly set `{} = {}` if that is desired outcome",
+ variant.node.name, wrapped_discr
+ ))
+ .emit();
None
}.unwrap_or(wrapped_discr),
);
"field `{}` is already declared",
f.ident
).span_label(f.span, "field already declared")
- .span_label(prev_span, format!("`{}` first declared here", f.ident))
- .emit();
+ .span_label(prev_span, format!("`{}` first declared here", f.ident))
+ .emit();
} else {
seen_fields.insert(f.ident.modern(), f.span);
}
has_late_bound_regions: None,
};
for param in &generics.params {
- match param.kind {
- GenericParamKind::Lifetime { .. } => {
- let hir_id = tcx.hir.node_to_hir_id(param.id);
- if tcx.is_late_bound(hir_id) {
- return Some(param.span);
- }
+ if let GenericParamKind::Lifetime { .. } = param.kind {
+ let hir_id = tcx.hir.node_to_hir_id(param.id);
+ if tcx.is_late_bound(hir_id) {
+ return Some(param.span);
}
- _ => {}
}
}
visitor.visit_fn_decl(decl);
def_id: DefId,
found: Option<(Span, ty::Ty<'tcx>)>,
}
+
impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> {
fn check(&mut self, def_id: DefId) {
trace!("checking {:?}", def_id);
}
}
}
+
impl<'a, 'tcx> intravisit::Visitor<'tcx> for ConstraintLocator<'a, 'tcx> {
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
intravisit::NestedVisitorMap::All(&self.tcx.hir)
intravisit::walk_trait_item(self, it);
}
}
+
let mut locator = ConstraintLocator {
def_id,
tcx,
};
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
let parent = tcx.hir.get_parent(node_id);
+
trace!("parent_id: {:?}", parent);
+
if parent == ast::CRATE_NODE_ID {
intravisit::walk_crate(&mut locator, tcx.hir.krate());
} else {
),
}
}
+
match locator.found {
Some((_, ty)) => ty,
None => {
// Collect the predicates that were written inline by the user on each
// type parameter (e.g., `<T:Foo>`).
for param in &ast_generics.params {
- match param.kind {
- GenericParamKind::Type { .. } => {
- let name = param.name.ident().as_interned_str();
- let param_ty = ty::ParamTy::new(index, name).to_ty(tcx);
- index += 1;
-
- let sized = SizedByDefault::Yes;
- let bounds = compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span);
- predicates.extend(bounds.predicates(tcx, param_ty));
- }
- _ => {}
+ if let GenericParamKind::Type { .. } = param.kind {
+ let name = param.name.ident().as_interned_str();
+ let param_ty = ty::ParamTy::new(index, name).to_ty(tcx);
+ index += 1;
+
+ let sized = SizedByDefault::Yes;
+ let bounds = compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span);
+ predicates.extend(bounds.predicates(tcx, param_ty));
}
}
&mut projections,
);
- predicates.push((trait_ref.to_predicate(), poly_trait_ref.span));
- predicates.extend(projections.iter().map(|&(p, span)| {
- (p.to_predicate(), span)
- }));
+ predicates.extend(
+ iter::once((trait_ref.to_predicate(), poly_trait_ref.span)).chain(
+ projections.iter().map(|&(p, span)| (p.to_predicate(), span)
+ )));
}
&hir::GenericBound::Outlives(ref lifetime) => {
&hir::WherePredicate::RegionPredicate(ref region_pred) => {
let r1 = AstConv::ast_region_to_region(&icx, ®ion_pred.lifetime, None);
- for bound in ®ion_pred.bounds {
+ predicates.extend(region_pred.bounds.iter().map(|bound| {
let (r2, span) = match bound {
hir::GenericBound::Outlives(lt) => {
(AstConv::ast_region_to_region(&icx, lt, None), lt.span)
_ => bug!(),
};
let pred = ty::Binder::bind(ty::OutlivesPredicate(r1, r2));
- predicates.push((ty::Predicate::RegionOutlives(pred), span))
- }
+
+ (ty::Predicate::RegionOutlives(pred), span)
+ }))
}
&hir::WherePredicate::EqPredicate(..) => {
let trait_item = tcx.hir.trait_item(trait_item_ref.id);
let bounds = match trait_item.node {
hir::TraitItemKind::Type(ref bounds, _) => bounds,
- _ => {
- return vec![].into_iter();
- }
+ _ => return vec![].into_iter()
};
let assoc_ty =
) -> Bounds<'tcx> {
let mut region_bounds = vec![];
let mut trait_bounds = vec![];
+
for ast_bound in ast_bounds {
match *ast_bound {
hir::GenericBound::Trait(ref b, hir::TraitBoundModifier::None) => trait_bounds.push(b),
let check = |ast_ty: &hir::Ty, ty: Ty| {
if ty.is_simd() {
tcx.sess
- .struct_span_err(
- ast_ty.span,
- &format!(
- "use of SIMD type `{}` in FFI is highly experimental and \
- may result in invalid code",
- tcx.hir.node_to_pretty_string(ast_ty.id)
- ),
- )
- .help("add #![feature(simd_ffi)] to the crate attributes to enable")
- .emit();
+ .struct_span_err(
+ ast_ty.span,
+ &format!(
+ "use of SIMD type `{}` in FFI is highly experimental and \
+ may result in invalid code",
+ tcx.hir.node_to_pretty_string(ast_ty.id)
+ ),
+ )
+ .help("add #![feature(simd_ffi)] to the crate attributes to enable")
+ .emit();
}
};
for (input, ty) in decl.inputs.iter().zip(*fty.inputs().skip_binder()) {
};
// We allow comma separation to enable multiple features
- for feature in value.as_str().split(',') {
+ target_features.extend(value.as_str().split(',').filter_map(|feature| {
// Only allow whitelisted features per platform
let feature_gate = match whitelist.get(feature) {
Some(g) => g,
}
}
err.emit();
- continue;
+ return None;
}
};
feature_gate::GateIssue::Language,
&format!("the target feature `{}` is currently unstable", feature),
);
- continue;
+ return None;
}
- target_features.push(Symbol::intern(feature));
- }
+ Some(Symbol::intern(feature))
+ }));
}
}
tcx.sess.span_fatal(span, "invalid linkage specified")
} else {
tcx.sess
- .fatal(&format!("invalid linkage specified: {}", name))
+ .fatal(&format!("invalid linkage specified: {}", name))
}
}
}
E0558,
"`export_name` attribute has invalid format"
).span_label(attr.span, "did you mean #[export_name=\"*\"]?")
- .emit();
+ .emit();
}
} else if attr.check_name("target_feature") {
if tcx.fn_sig(id).unsafety() == Unsafety::Normal {