提交 ad3e7481 编写于 作者: F Flavio Percoco

Don't allow default impls for traits outside their crate

上级 839a9de8
......@@ -96,6 +96,16 @@ fn visit_item(&mut self, item: &'v ast::Item) {
}
}
}
ast::ItemDefTrait(_, ref ast_trait_ref) => {
// "Trait" impl
debug!("coherence2::orphan check: default trait impl {}", item.repr(self.tcx));
let trait_ref = ty::node_id_to_trait_ref(self.tcx, ast_trait_ref.ref_id);
if trait_ref.def_id.krate != ast::LOCAL_CRATE {
span_err!(self.tcx.sess, item.span, E0316,
"cannot create default implementations for traits outside the \
crate they're defined in; define a new trait instead.");
}
}
_ => {
// Not an impl
}
......
......@@ -171,7 +171,8 @@
E0247, // found module name used as a type
E0248, // found value name used as a type
E0249, // expected constant expr for array length
E0250 // expected constant expr for array length
E0250, // expected constant expr for array length
E0316 // can't create default impls for traits outside their crates
}
__build_diagnostic_array! { DIAGNOSTICS }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册