Perhaps you’re thinking of the case of a laicized priest or one who is for whatever reason not functioning as a priest. Such a man would not be permitted to say Mass, for example. But he could hear the confession of a dying person.
From canon law:
Can. 292 A cleric who loses the clerical state according to the norm of law loses with it the rights proper to the clerical state and is no longer bound by any obligations of the clerical state, without prejudice to the prescript of ⇒ can. 291. He is prohibited from exercising the power of orders, without prejudice to the prescript of** ⇒ can. 976**. By the loss of the clerical state, he is deprived of all offices, functions, and any delegated power.
Can. 976 Even though a priest lacks the faculty to hear confessions, he absolves validly and licitly any penitents whatsoever in danger of death from any censures and sins, even if an approved priest is present.