The gemara Megilla 26b quotes Rava that when you sell a synagogue (even not in front of the 7 city trustees) the kedusha transfers onto the money and the buyer is free to use the former shul however he wants. However, Rashi's comment on 26a (Lo shanu etc.) seems to say explicitly that when one sells a synagogue, it retains its holiness (unless it is in front of the 7 city trustees). How does Rashi understand that gemara? (IIRC Hagahos R' Akiva Eiger there seems to ask something similar, but I think it is a different question.)
דאין מורידין דמים מקדושתן ובית הכנסת בחשיבותו עומד
The money is not removed from its kedusha and the shul stays in its original status.
Rashi is explaining לא שנו that the original statement that the kedusha was not removed from the money unless ... then follows the circumstance that the kedusha remains on the money unless the טובי העיר, the trustees of the city authorize the sale. Rava the continues (on daf 26a - Art Scroll 26a4) that if on the other hand the seven trustees of the city sold the synagogue or other sacred property in the presence of the towns people even
then continues at the top of 27a
למישתא ביה שיכרא שפיר דמי
to drink beer with it, i.e. to purchase beer with it, it is acceptable
Rashi is not objecting to what Rava is saying. He is explaining that Rava is saying that when the seven trustees of the city did not explicitly authorize the sale the kedusha remains. When the seven trustees of the city, in front of the townspeople did authorize the sale, then and only then is nonsacred use allowed. See the last Rashi on 26a אלא שלא מכרו and the first Rashi on 26b למישתא בה שיכרא
You need to read the entire segment to understand what is being said.
The question is premised on the assumption that one is permitted to rent out a shul with the permission of the city trustees, so Rava means a case where the trustees were not consulted. However that assumption is not true. As the Tur writes:
אבל אסור למשכנן או להשכירן אפי' ע"י שבעה טובי העיר שעדיין נשארין בקדושתן שאין כאן דבר אחר שתחול קדושתן עליו
This is also the psak of the Shulchan Aruch