E0172,
E0173,
E0174,
- E0175,
- E0176,
E0177,
- E0178,
- E0179
+ E0178
)
}
for predicate in generics.where_clause.predicates.iter() {
match predicate {
- &ast::BoundPredicate(ref bound_pred) => {
+ &ast::WherePredicate::BoundPredicate(ref bound_pred) => {
for bound in bound_pred.bounds.iter() {
self.check_ty_param_bound(bound_pred.span, bound)
}
}
- &ast::EqPredicate(ref eq_pred) => {
+ &ast::WherePredicate::EqPredicate(ref eq_pred) => {
self.visit_ty(&*eq_pred.ty);
}
}
fn resolve_where_clause(&mut self, where_clause: &ast::WhereClause) {
for predicate in where_clause.predicates.iter() {
match predicate {
- &ast::BoundPredicate(ref bound_pred) => {
+ &ast::WherePredicate::BoundPredicate(ref bound_pred) => {
match self.resolve_identifier(bound_pred.ident,
TypeNS,
true,
TraitBoundingTypeParameter);
}
}
- &ast::EqPredicate(ref eq_pred) => {
+ &ast::WherePredicate::EqPredicate(ref eq_pred) => {
match self.resolve_path(eq_pred.id, &eq_pred.path, TypeNS, true) {
Some((def @ DefTyParam(..), last_private)) => {
self.record_def(eq_pred.id, (def, last_private));
}
for predicate in generics.where_clause.predicates.iter() {
match predicate {
- &ast::BoundPredicate(ast::WhereBoundPredicate{ident, ref bounds, span, ..}) => {
+ &ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ ident,
+ ref bounds,
+ span,
+ .. }) => {
self.visit_ident(span, ident);
visit::walk_ty_param_bounds_helper(self, bounds);
}
- &ast::EqPredicate(ast::WhereEqPredicate{id, ref path, ref ty, ..}) => {
+ &ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ id,
+ ref path,
+ ref ty,
+ .. }) => {
self.visit_path(path, id);
self.visit_ty(&**ty);
}
}
for predicate in generics.where_clause.predicates.iter() {
match predicate {
- &ast::BoundPredicate(ast::WhereBoundPredicate{ref bounds, ..}) => {
+ &ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bounds, ..}) => {
visit::walk_ty_param_bounds_helper(&mut collector, bounds);
}
- _ => {}
+ &ast::WherePredicate::EqPredicate(_) => unimplemented!()
}
}
}
}
}
- let mut matched_assoc = 0u;
for formal_assoc in decl_generics.types.get_slice(AssocSpace).iter() {
let mut found = false;
for &(ident, ty) in assoc_bindings.iter() {
if formal_assoc.name.ident() == ident {
substs.types.push(AssocSpace, ty);
- matched_assoc += 1;
found = true;
break;
}
formal_assoc.def_id) {
Some(ty) => {
substs.types.push(AssocSpace, ty);
- matched_assoc += 1;
}
None => {
- span_err!(this.tcx().sess, span, E0179,
+ substs.types.push(AssocSpace, ty::mk_err());
+ span_err!(this.tcx().sess, span, E0171,
"missing type for associated type `{}`",
token::get_ident(formal_assoc.name.ident()));
}
}
}
- if decl_generics.types.get_slice(AssocSpace).len() != matched_assoc {
- span_err!(tcx.sess, span, E0171,
- "wrong number of associated type parameters: expected {}, found {}",
- decl_generics.types.get_slice(AssocSpace).len(), matched_assoc);
- }
-
for &(ident, _) in assoc_bindings.iter() {
let mut formal_idents = decl_generics.types.get_slice(AssocSpace)
.iter().map(|t| t.name.ident());
}
Some(space) => {
- let trait_def_id = match def {
- def::DefTrait(did) => Some(did),
- _ => None
- };
push_explicit_parameters_from_segment_to_substs(fcx,
space,
path.span,
type_defs,
region_defs,
segment,
- trait_def_id,
- path.span,
&mut substs);
}
}
type_defs: &VecPerParamSpace<ty::TypeParameterDef<'tcx>>,
region_defs: &VecPerParamSpace<ty::RegionParameterDef>,
segment: &ast::PathSegment,
- trait_def_id: Option<DefId>,
- path_span: Span,
substs: &mut Substs<'tcx>)
{
match segment.parameters {
ast::AngleBracketedParameters(ref data) => {
push_explicit_angle_bracketed_parameters_from_segment_to_substs(
- fcx, space, type_defs, region_defs, data, trait_def_id, path_span, substs);
+ fcx, space, type_defs, region_defs, data, substs);
}
ast::ParenthesizedParameters(ref data) => {
type_defs: &VecPerParamSpace<ty::TypeParameterDef<'tcx>>,
region_defs: &VecPerParamSpace<ty::RegionParameterDef>,
data: &ast::AngleBracketedParameterData,
- trait_def_id: Option<DefId>,
- path_span: Span,
substs: &mut Substs<'tcx>)
{
{
}
}
- if let Some(trait_def_id) = trait_def_id {
- let ref items = fcx.tcx().trait_item_def_ids.borrow()[trait_def_id];
- let mut assoc_tys = Vec::new();
- for item in items.iter() {
- if let &ty::ImplOrTraitItemId::TypeTraitItemId(id) = item {
- if let ty::ImplOrTraitItem::TypeTraitItem(ref ty) =
- fcx.tcx().impl_or_trait_items.borrow()[id] {
- assoc_tys.push(ty.clone());
- }
- }
- }
-
- if data.bindings.len() > assoc_tys.len() {
- span_err!(fcx.tcx().sess, data.bindings[assoc_tys.len()].span, E0174,
- "too many type equality constraints provided: \
- expected at most {} constraint(s), \
- found {} constraint(s)",
- assoc_tys.len(), data.types.len());
- substs.types.truncate(space, 0);
- } else if data.bindings.len() > 0 {
- for assoc_ty in assoc_tys.iter() {
- let mut matched = false;
- for binding in data.bindings.iter() {
- if assoc_ty.name.ident() == binding.ident {
- let t = fcx.to_ty(&*binding.ty);
- substs.types.push(space, t);
- matched = true;
- break;
- }
- }
- if !matched {
- span_err!(fcx.tcx().sess, path_span, E0176,
- "missing type equality constraint for associated type: {}",
- assoc_ty.name);
- substs.types.truncate(space, 0);
- break;
- }
- }
- }
- } else if data.bindings.len() > 0 {
- span_err!(fcx.tcx().sess, path_span, E0175,
- "type equality constraints provided on a non-trait type");
- substs.types.truncate(space, 0);
+ if data.bindings.len() > 0 {
+ span_err!(fcx.tcx().sess, data.bindings[0].span, E0182,
+ "unexpected binding of associated item in expression path \
+ (only allowed in type paths)");
+ substs.types.truncate(subst::ParamSpace::AssocSpace, 0);
}
{
} else {
return // everything OK
};
- span_err!(tcx.sess, sp, E0173, "manual implementations of `{}` are experimental", trait_name);
+ span_err!(tcx.sess, sp, E0183, "manual implementations of `{}` are experimental", trait_name);
span_help!(tcx.sess, sp,
"add `#![feature(unboxed_closures)]` to the crate attributes to enable");
}
let trait_def = ty::lookup_trait_def(this.tcx(), trait_def_id);
let associated_type_defs = trait_def.generics.types.get_slice(subst::AssocSpace);
- // Find any assocaited type bindings in the bound.
+ // Find any associated type bindings in the bound.
let ref segments = ast_trait_ref.trait_ref.path.segments;
let bindings = segments[segments.len() -1].parameters.bindings();
for predicate in where_clause.predicates.iter() {
match predicate {
- &ast::BoundPredicate(ref bound_pred) => {
+ &ast::WherePredicate::BoundPredicate(ref bound_pred) => {
let predicate_param_id =
tcx.def_map
.borrow()
result.push(bound);
}
}
- &ast::EqPredicate(_) => panic!("not implemented")
+ &ast::WherePredicate::EqPredicate(_) => panic!("not implemented")
}
}
E0171,
E0172,
E0173, // manual implementations of unboxed closure traits are experimental
- E0174 // explicit use of unboxed closure methods are experimental
+ E0174, // explicit use of unboxed closure methods are experimental
+ E0177,
+ E0178,
+ E0180,
+ E0181,
+ E0182,
+ E0183
)
impl Clean<WherePredicate> for ast::WherePredicate {
fn clean(&self, cx: &DocContext) -> WherePredicate {
- WherePredicate {
- name: self.ident.clean(cx),
- bounds: self.bounds.clean(cx)
+ match *self {
+ ast::WherePredicate::BoundPredicate(ref wbp) => {
+ WherePredicate {
+ name: wbp.ident.clean(cx),
+ bounds: wbp.bounds.clean(cx)
+ }
+ }
+ ast::WherePredicate::EqPredicate(_) => {
+ unimplemented!();
+ }
}
}
}
fn main() {
macro_crate_test::foo();
- //~^ ERROR failed to resolve. Use of undeclared module `macro_crate_test`
+ //~^ ERROR failed to resolve. Use of undeclared type or module `macro_crate_test`
//~^^ ERROR unresolved name `macro_crate_test::foo`
}
--- /dev/null
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check that an associated type cannot be bound in an expression path.
+
+#![feature(associated_types)]
+
+trait Foo {
+ type A;
+ fn bar() -> int;
+}
+
+impl Foo for int {
+ type A = uint;
+ fn bar() -> int { 42 }
+}
+
+pub fn main() {
+ let x: int = Foo::<A=uint>::bar();
+ //~^ERROR unexpected binding of associated item in expression path
+}
struct Foo<'a> {
a: &'a Bar+'a,
- //~^ ERROR E0171
+ //~^ ERROR E0178
//~^^ NOTE perhaps you meant `&'a (Bar + 'a)`?
b: &'a mut Bar+'a,
- //~^ ERROR E0171
+ //~^ ERROR E0178
//~^^ NOTE perhaps you meant `&'a mut (Bar + 'a)`?
c: Box<Bar+'a>, // OK, no paren needed in this context
d: fn() -> Bar+'a,
- //~^ ERROR E0171
+ //~^ ERROR E0178
//~^^ NOTE perhaps you forgot parentheses
//~^^^ WARN deprecated syntax
}