However, would it be safe to do so if the rainwater in your particular area has a pH that is considered as acidic or akaline? (The risks of which are outlined on this page and reproduced below)
It is doubtful the pH+ of rainwater anywhere, other than directly downwind of an erupting volcano, would be unsafe in terms of damaging plumbing fixtures or pipes.
That said, there is concern in how the rainwater is stored. It must be kept so as not to be a breeding place for mosquitoes, toxic algae or other noxious critters, nor should the container cause entrapment of wildlife. There also must be air breaks to ensure that the untreated rainwater does not enter and contaminate potable water. There may be local regulations regarding use of rainwater or "greywater".
Yes, you can do this, but you must make sure that the supplies to the wc are separated from the rest of the supplies to the taps, showers etc.
We planned this in the plumbing for our house so that we could easily separate the washing machine and 3 wc from the other items - plumber was not happy but we got what we wanted.
That meant we only needed a simple filter from the rain water tank as it never gets into the potable system.
Rainwater is regularly captured and used by rural domestic properties here in New Zealand for everything in a typical household - from drinking to flushing toilets, with minimal treatment.
Its pretty much the norm for people in rural locations (if you are a few miles outside a built up area, you wont have mains water or sewerage) - capture rainfall runoff and store it in large tanks for use in the home. The alternative is drilling a borehole (expensive and not always possible) or regular water deliveries (again, expensive).
Pretty much the only treatments the water goes under is to kill microbes and filter large detritus.
What can a rainwater contain? Something that was either in the air or on the roof.
Acids: sulfuric or nitric, coming from the air pollution. If the air is more or less safe to breath, water raining from it is acceptable for the purpouse intended in regard to the acidic content. Steel pipes may suffer some corrosion, but they are rarely used today. Plastic pipes are OK.
Bases: the only more or less gaseous base is ammonia. See about acids. Corrosion is less likely. You will pretty much know if there is unsafe level of ammonia in the air.
Dust: it may be dominated by soil, soot, tyre flakes or something else. May settle at the bottom of the container. Easy to filter out.
Microbes, tree leaves, bird feces and feathers, insects and other organic life-related things. Not always easy to filter out. May make water unsafe or unpleasant to drink. May clog something as well. The toilet will be still happy to flush with it.
Life may try to develop in the container. In order to prevent it, filter the input as much as practical, keep the container dark and covered. UV lamp may also help, but may as well damage a plastic container.
All things considered, go for it.
Virtually any water is safe for toilet water use as long as it has, at minimum, a "sand filter" of sufficient size to keep out sand and particulates. Even fresh water from a lake, river, or stream can suffice, with its entrapped microorganisms and impurities.
Ocean-going vessels utilize seawater for numerous functions, including firefighting and the supply plumbing of the urinals and toilets. This necessitates the use of stainless steel piping and fixtures for the toilets, but enables the use of the "free" water source that they float upon. (Granted, they may not be "flush" toilets onboard a ship, but the analogy is otherwise valid.)
For residential-grade installations, water quality will affect the looks and longevity of your piping and fixtures. If you are willing to use collected rainwater, then you can expect to suffer some additional costs of maintenance, filtration, storage, and possibly pumping that your neighbors wouldn't incur. Your tank and bowl might grow algae or become discolored without extra cleaning. An addition of copper to the holding tank or within your piping would help mitigate the algae. Even still, none of these factors affect the safety of the toilet: it will still work and not harm you.