I am not an expert, but…

Maybe you could assume f(x) is continuous, is irrational when x is rational, and rational when x is irrational, and try to do a proof by contradiction.

Then you could consider the function >! g(x) = f(x) - x !<

Next, you could show that >! g(x) is continuous !<

Also, >! g(x) is irrational for any x !<

From that, you can find that >! g(x) = f(x) - x is constant !<.

Therefore, >! f(x) - x = k => f(x) = x + k, where k is a constant irrational !<

However, >! f(k) = k + k = 2k. k is irrational and 2k is also irrational. This contradicts the original assumptions, so f(x) does not exist. !<

I know the proof is missing details, but I hope that someone with more knowledge can verify the method and correct any mistakes!