use syntax::ptr::P;
use syntax::symbol::{Symbol, InternedString, keywords};
use syntax::util::lev_distance::find_best_match_for_name;
-use syntax_pos::{self, BytePos, Span, DUMMY_SP};
+use syntax_pos::{self, BytePos, Span};
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
}
}
- let signature = |item: &ty::AssociatedItem| {
- match item.kind {
- ty::AssociatedKind::Method => {
- format!("{}", tcx.type_of(item.def_id).fn_sig().0)
- }
- ty::AssociatedKind::Type => format!("type {};", item.name.to_string()),
- ty::AssociatedKind::Const => {
- format!("const {}: {:?};", item.name.to_string(), tcx.type_of(item.def_id))
- }
- }
- };
-
if !missing_items.is_empty() {
let mut err = struct_span_err!(tcx.sess, impl_span, E0046,
"not all trait items implemented, missing: `{}`",
if let Some(span) = tcx.hir.span_if_local(trait_item.def_id) {
err.span_label(span, format!("`{}` from trait", trait_item.name));
} else {
- err.note(&format!("`{}` from trait: `{}`",
- trait_item.name,
- signature(&trait_item)));
+ err.note_trait_signature(trait_item.name.to_string(),
+ trait_item.signature(&tcx));
}
}
err.emit();
value)
}
- pub fn write_nil(&self, node_id: ast::NodeId) {
- self.write_ty(node_id, self.tcx.mk_nil());
- }
-
- pub fn write_error(&self, node_id: ast::NodeId) {
- self.write_ty(node_id, self.tcx.types.err);
- }
-
pub fn require_type_meets(&self,
ty: Ty<'tcx>,
span: Span,
pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
// Don't do all the complex logic below for DeclItem.
match stmt.node {
- hir::StmtDecl(ref decl, id) => {
+ hir::StmtDecl(ref decl, _) => {
match decl.node {
hir::DeclLocal(_) => {}
hir::DeclItem(_) => {
- self.write_nil(id);
return;
}
}
self.diverges.set(Diverges::Maybe);
self.has_errors.set(false);
- let (node_id, _span) = match stmt.node {
- hir::StmtDecl(ref decl, id) => {
- let span = match decl.node {
+ match stmt.node {
+ hir::StmtDecl(ref decl, _) => {
+ match decl.node {
hir::DeclLocal(ref l) => {
self.check_decl_local(&l);
- l.span
}
- hir::DeclItem(_) => {/* ignore for now */
- DUMMY_SP
- }
- };
- (id, span)
+ hir::DeclItem(_) => {/* ignore for now */}
+ }
}
- hir::StmtExpr(ref expr, id) => {
+ hir::StmtExpr(ref expr, _) => {
// Check with expected type of ()
self.check_expr_has_type(&expr, self.tcx.mk_nil());
- (id, expr.span)
}
- hir::StmtSemi(ref expr, id) => {
+ hir::StmtSemi(ref expr, _) => {
self.check_expr(&expr);
- (id, expr.span)
}
- };
-
- if self.has_errors.get() {
- self.write_error(node_id);
- } else {
- self.write_nil(node_id);
}
// Combine the diverging and has_error flags.
hir::StmtSemi(ref e, _) => e,
_ => return,
};
- let last_expr_ty = self.expr_ty(last_expr);
+ let last_expr_ty = self.node_ty(last_expr.id);
if self.can_sub(self.param_env, last_expr_ty, expected_ty).is_err() {
return;
}