use syntax::abi::Abi;
use syntax::ast;
use syntax::attr;
-use syntax::attr::AttrMetaMethods;
use syntax::codemap::{self, Spanned};
use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::parse::token::{self, InternedString, keywords};
if let Err(errors) = fulfillment_cx.select_all_or_error(&infcx) {
infcx.report_fulfillment_errors(&errors);
}
-
- if let Err(errors) = fulfillment_cx.select_rfc1592_obligations(&infcx) {
- infcx.report_fulfillment_errors_as_warnings(&errors, item_id);
- }
});
}
})
check_const(ccx, &expr, trait_item.id)
}
hir::MethodTraitItem(ref sig, Some(ref body)) => {
- check_trait_fn_not_const(ccx, trait_item.span, sig.constness);
-
check_bare_fn(ccx, &sig.decl, body, trait_item.id);
}
- hir::MethodTraitItem(ref sig, None) => {
- check_trait_fn_not_const(ccx, trait_item.span, sig.constness);
- }
+ hir::MethodTraitItem(_, None) |
hir::ConstTraitItem(_, None) |
hir::TypeTraitItem(..) => {
// Nothing to do.
}
}
-fn check_trait_fn_not_const<'a,'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
- span: Span,
- constness: hir::Constness)
-{
- match constness {
- hir::Constness::NotConst => {
- // good
- }
- hir::Constness::Const => {
- struct_span_err!(ccx.tcx.sess, span, E0379, "trait fns cannot be declared const")
- .span_label(span, &format!("trait fns cannot be const"))
- .emit()
- }
- }
-}
-
fn check_on_unimplemented<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
def_id: DefId,
item: &hir::Item) {
{
let mut err = struct_span_err!(
tcx.sess, impl_item.span, E0520,
- "item `{}` is provided by an `impl` that specializes \
- another, but the item in the parent `impl` is not \
- marked `default` and so it cannot be specialized.",
+ "`{}` specializes an item from a parent `impl`, but \
+ neither that item nor the `impl` are marked `default`",
impl_item.name);
+ err.span_label(impl_item.span, &format!("cannot specialize default item `{}`",
+ impl_item.name));
match tcx.span_of_impl(parent_impl) {
Ok(span) => {
- err.span_note(span, "parent implementation is here:");
+ err.span_label(span, &"parent `impl` is here");
+ err.note(&format!("to specialize, either the parent `impl` or `{}` \
+ in the parent `impl` must be marked `default`",
+ impl_item.name));
}
Err(cname) => {
err.note(&format!("parent implementation is in crate `{}`", cname));
err.emit()
}
}
- hir::ImplItemKind::Method(ref sig, ref body) => {
- check_trait_fn_not_const(ccx, impl_item.span, sig.constness);
-
+ hir::ImplItemKind::Method(_, ref body) => {
let impl_method = match ty_impl_item {
ty::MethodTraitItem(ref mti) => mti,
_ => span_bug!(impl_item.span, "non-method impl-item for method")
}
let e = fields[0].ty(tcx, substs);
if !fields.iter().all(|f| f.ty(tcx, substs) == e) {
- span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous");
+ struct_span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous")
+ .span_label(sp, &format!("SIMD elements must have the same type"))
+ .emit();
return;
}
match e.sty {
Ok(()) => { }
Err(errors) => { self.report_fulfillment_errors(&errors); }
}
-
- if let Err(ref errors) = fulfillment_cx.select_rfc1592_obligations(self) {
- self.report_fulfillment_errors_as_warnings(errors, self.body_id);
- }
}
/// Select as many obligations as we can at present.
// use inference variables instead of the provided types.
*segment = None;
} else if !(can_omit && types.len() == 0) && types.len() < required_len {
- let qualifier =
- if type_defs.len() != required_len { "at least " } else { "" };
- span_err!(self.tcx.sess, span, E0089,
- "too few type parameters provided: \
- expected {}{}, found {}",
- qualifier,
- count(required_len),
- count(types.len()));
+ let adjust = |len| if len > 1 { "parameters" } else { "parameter" };
+ let required_param_str = adjust(required_len);
+ let actual_param_str = adjust(types.len());
+ struct_span_err!(self.tcx.sess, span, E0089,
+ "too few type parameters provided: \
+ expected {} {}, found {} {}",
+ count(required_len),
+ required_param_str,
+ count(types.len()),
+ actual_param_str)
+ .span_label(span, &format!("expected {} type {}", required_len, required_param_str))
+ .emit();
}
if !bindings.is_empty() {