TyTy::TypeBoundPredicate get_predicate_from_bound (
HIR::TypePath &path,
tl::optional<std::reference_wrapper<HIR::Type>> associated_self,
- BoundPolarity polarity = BoundPolarity::RegularBound);
+ BoundPolarity polarity = BoundPolarity::RegularBound,
+ bool is_qualified_type = false);
bool check_for_unconstrained (
const std::vector<TyTy::SubstitutionParamMapping> ¶ms_to_constrain,
return;
// get the predicate for the bound
- auto specified_bound = get_predicate_from_bound (qual_path_type.get_trait (),
- qual_path_type.get_type ());
+ auto specified_bound
+ = get_predicate_from_bound (qual_path_type.get_trait (),
+ qual_path_type.get_type (),
+ BoundPolarity::RegularBound, true);
if (specified_bound.is_error ())
return;
TypeCheckBase::get_predicate_from_bound (
HIR::TypePath &type_path,
tl::optional<std::reference_wrapper<HIR::Type>> associated_self,
- BoundPolarity polarity)
+ BoundPolarity polarity, bool is_qualified_type_path)
{
TyTy::TypeBoundPredicate lookup = TyTy::TypeBoundPredicate::error ();
bool already_resolved
if (final_generic_seg.has_generic_args ())
{
args = final_generic_seg.get_generic_args ();
+ if (args.get_binding_args ().size () > 0
+ && associated_self.has_value () && is_qualified_type_path)
+ {
+ auto &binding_args = args.get_binding_args ();
+
+ rich_location r (line_table, args.get_locus ());
+ for (auto it = binding_args.begin (); it != binding_args.end ();
+ it++)
+ {
+ auto &arg = *it;
+ r.add_fixit_remove (arg.get_locus ());
+ }
+ rust_error_at (r, ErrorCode::E0229,
+ "associated type bindings are not allowed here");
+ }
}
}
break;
--- /dev/null
+#[lang = "sized"]
+trait Sized {}
+
+fn main() {
+ pub trait Foo {
+ type A;
+ fn boo(&self) -> <Self as Foo>::A;
+ }
+
+ struct Bar;
+
+ impl Foo for isize {
+ type A = usize;
+ fn boo(&self) -> usize {
+ 42
+ }
+ }
+
+ fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
+ // { dg-error "associated type bindings are not allowed here .E0229." "" { target *-*-* } .-1 }
+}