if (trait->is_error ())
return TyTy::TypeBoundPredicate::error ();
- TyTy::TypeBoundPredicate predicate (*trait, type_path.get_locus ());
+ TyTy::TypeBoundPredicate predicate (*trait, BoundPolarity::RegularBound,
+ type_path.get_locus ());
HIR::GenericArgs args
= HIR::GenericArgs::create_empty (type_path.get_locus ());
namespace TyTy {
TypeBoundPredicate::TypeBoundPredicate (
- const Resolver::TraitReference &trait_reference, location_t locus)
+ const Resolver::TraitReference &trait_reference, BoundPolarity polarity,
+ location_t locus)
: SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()),
reference (trait_reference.get_mappings ().get_defid ()), locus (locus),
- error_flag (false)
+ error_flag (false), polarity (polarity)
{
substitutions.clear ();
for (const auto &p : trait_reference.get_trait_substs ())
TypeBoundPredicate::TypeBoundPredicate (
DefId reference, std::vector<SubstitutionParamMapping> subst,
- location_t locus)
+ BoundPolarity polarity, location_t locus)
: SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()),
- reference (reference), locus (locus), error_flag (false)
+ reference (reference), locus (locus), error_flag (false),
+ polarity (polarity)
{
substitutions.clear ();
for (const auto &p : subst)
TypeBoundPredicate::TypeBoundPredicate (const TypeBoundPredicate &other)
: SubstitutionRef ({}, SubstitutionArgumentMappings::empty ()),
reference (other.reference), locus (other.locus),
- error_flag (other.error_flag)
+ error_flag (other.error_flag), polarity (other.polarity)
{
substitutions.clear ();
for (const auto &p : other.get_substs ())
reference = other.reference;
locus = other.locus;
error_flag = other.error_flag;
+ polarity = other.polarity;
used_arguments = SubstitutionArgumentMappings::empty ();
substitutions.clear ();
TypeBoundPredicate
TypeBoundPredicate::error ()
{
- auto p = TypeBoundPredicate (UNKNOWN_DEFID, {}, UNDEF_LOCATION);
+ auto p = TypeBoundPredicate (UNKNOWN_DEFID, {}, BoundPolarity::RegularBound,
+ UNDEF_LOCATION);
p.error_flag = true;
return p;
}
{
public:
TypeBoundPredicate (const Resolver::TraitReference &trait_reference,
- location_t locus);
+ BoundPolarity polarity, location_t locus);
TypeBoundPredicate (DefId reference,
std::vector<SubstitutionParamMapping> substitutions,
- location_t locus);
+ BoundPolarity polarity, location_t locus);
TypeBoundPredicate (const TypeBoundPredicate &other);
DefId get_id () const { return reference; }
+ BoundPolarity get_polarity () const { return polarity; }
+
std::vector<TypeBoundPredicateItem> get_associated_type_items ();
size_t get_num_associated_bindings () const override final;
DefId reference;
location_t locus;
bool error_flag;
+ BoundPolarity polarity;
};
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.VariantDef.html