Index: trunk/src/wp-admin/includes/ms.php
===================================================================
--- trunk/src/wp-admin/includes/ms.php	(revision 58132)
+++ trunk/src/wp-admin/includes/ms.php	(revision 59901)
@@ -1173,2 +1173,16 @@
 		'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support forums</a>' ) . '</p>';
 }
+
+/**
+ * Stop execution if the role can not be assigned by the current user.
+ *
+ * @since 6.8.0
+ *
+ * @param string $role Role the user is attempting to assign.
+ */
+function wp_ensure_editable_role( $role ) {
+	$roles = get_editable_roles();
+	if ( ! isset( $roles[ $role ] ) ) {
+		wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
+	}
+}
