$\int\tan x\ dx$ by integration by parts [duplicate]
What you've lost is constant of integration of $\sin x$. If instead of $-\cos x$ you take $C-\cos x$, then you'll have:
$$\int \tan x\;dx=\int(\sec x\sin x)\;dx=\\ =-\sec x\cos x+C\sec x+\int(\cos x-C)\tan x\sec x\;dx=\\ =-1+C\sec x+\int \tan x\;dx-C\int \tan x\sec x\;dx.$$
Then instead of $-1=0$ you'll have
$$C\left(\sec x-\int \tan x\sec x\;dx\right)=1,$$
which does make sense.
Think it in this way, say you're evaluating the definite integral $$\int_{a}^b \tan x dx$$ Then according to your steps you'll get $$\int_{a}^b\tan x \ dx=[-1]_a^b+\int_{a}^b \tan x\ dx=\int_{a}^b\tan x \ dx$$So nothing gets changed.