Whilst moving, a unit is not allowed to approach closer than 1" to another unit, friend or foe, or impassable terrain (as described in the Battlefield Terrain chapter). You may however, still pivot on the spot with your unit, as long as it does not end its movement within 1" of a unit or impassable terrain. If pivoting would cause you to come into base contact with another unit or impassable terrain, you must move your model back so that it is still 1" away from these after your pivot. If your model cannot be moved back because it is between two units or pieces of impassable terrain, you should, if possible, move the other unit back so the pivot can be performed. Note that units that are engaged in close combat may never be moved back in this way. On the off chance that neither unit can be moved back, the pivot may not be made.
This rule does not apply to charge moves, as the whole point of charging is to get a unit into base contact with an enemy. Occasionally, a unit will have approached to within 1" of a unit it did not charge as the result of moving into contact with a unit it did charge. This is perfectly acceptable, although players may wish to nudge the units further apart to maintain a suitable degree of clarity.