use middle::def;
use middle::ty::{self, Ty};
-use syntax::ast;
-pub const NO_REGIONS: usize = 1;
-pub const NO_TPS: usize = 2;
+use syntax::codemap::Span;
+use rustc_front::hir as ast;
-pub fn check_path_args(tcx: &ty::ctxt, segments: &[ast::PathSegment], flags: usize) {
+pub fn prohibit_type_params(tcx: &ty::ctxt, segments: &[ast::PathSegment]) {
for segment in segments {
- if (flags & NO_TPS) != 0 {
- for typ in segment.parameters.types() {
- span_err!(tcx.sess, typ.span, E0109,
- "type parameters are not allowed on this type");
- break;
- }
+ for typ in segment.parameters.types() {
+ span_err!(tcx.sess, typ.span, E0109,
+ "type parameters are not allowed on this type");
+ break;
}
-
- if (flags & NO_REGIONS) != 0 {
- for lifetime in segment.parameters.lifetimes() {
- span_err!(tcx.sess, lifetime.span, E0110,
- "lifetime parameters are not allowed on this type");
- break;
- }
+ for lifetime in segment.parameters.lifetimes() {
+ span_err!(tcx.sess, lifetime.span, E0110,
+ "lifetime parameters are not allowed on this type");
+ break;
+ }
+ for binding in segment.parameters.bindings() {
+ prohibit_projection(tcx, binding.span);
+ break;
}
}
}
+pub fn prohibit_projection(tcx: &ty::ctxt, span: Span)
+{
+ span_err!(tcx.sess, span, E0229,
+ "associated type bindings are not allowed here");
+}
+
pub fn prim_ty_to_ty<'tcx>(tcx: &ty::ctxt<'tcx>,
segments: &[ast::PathSegment],
nty: ast::PrimTy)
-> Ty<'tcx> {
- check_path_args(tcx, segments, NO_TPS | NO_REGIONS);
+ prohibit_type_params(tcx, segments);
match nty {
ast::TyBool => tcx.types.bool,
ast::TyChar => tcx.types.char,
}
}
+/// If a type in the AST is a primitive type, return the ty::Ty corresponding
+/// to it.
pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
-> Option<Ty<'tcx>> {
if let ast::TyPath(None, ref path) = ast_ty.node {