Skip to content

Commit

Permalink
typecheck: Add note about erorring out on additional trait bounds.
Browse files Browse the repository at this point in the history
If additional trait bounds aren't auto traits, then the typechecker
must error out (Rust-GCC#3008)

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-type.cc: Add TODO note.
  • Loading branch information
CohenArthur committed Dec 25, 2024
1 parent 67033b0 commit 30b948c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gcc/rust/typecheck/rust-hir-type-check-type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,11 @@ TypeCheckType::visit (HIR::TraitObjectType &type)
std::vector<TyTy::TypeBoundPredicate> specified_bounds;
for (auto &bound : type.get_type_param_bounds ())
{
// TODO: here we need to check if there are additional bounds that aren't
// auto traits. this is an error. for example, `dyn A + Sized + Sync` is
// okay, because Sized and Sync are both auto traits but `dyn A + Copy +
// Clone` is not okay and should error out.

if (bound->get_bound_type ()
!= HIR::TypeParamBound::BoundType::TRAITBOUND)
continue;
Expand Down

0 comments on commit 30b948c

Please sign in to comment.