Local Constancy of Rank Function (Matsumura's definition) Recently I asked this question. I believe that I have come up with a solution, but I am unsure, because the proof I have seems too easy to be true, and doesn't make very many assumptions. My would-be-proof is provided below:

Claim: Let $M$ be a locally finite module over a commutative domain $R$. Then, the rank function $r_M:\text{Spec}(R)\to\mathbb{N}$ is locally constant (which in this context is the same thing as constant).
Proof: Choose prime $p$, $q$. Then for the fraction field $K$, we have $M \otimes K=M_p \otimes K$, and so $\dim(M\otimes K)=\dim(M_p\otimes K)$. But, since tensor products preserve dimension of free modules, $\dim(M_p\otimes K)=r_M(p)$.   By symmetry, $r_M(p)=r_M(q)=\dim(M\otimes K)$.

However, I am weary of this approach (which I believe could be modified for the non-domain case) because it doesn't assume finitely generatedness, nor does it use any topological information about $Spec$. Are my fears unfounded, or is there an actual problem with my proof?
 A: Let us take $R=\mathbb{Z}$ and $M=\mathbb{Z}/2\mathbb{Z}$. We have $M\otimes R_{(0)}=M\otimes \mathbb{Q}=0$ and $$M\otimes R_{(2)}=\mathbb{Z}/2\mathbb{Z}\otimes \mathbb{Z}/2\mathbb{Z}=\mathbb{Z}/2\mathbb{Z}$$
Since by definition the rank at a prime $p$ is 
$$\text{dim}_{R_p/pR_p}\ M\otimes R_p/pR_p$$ you see here that the rank at $(0)$ and at $(2)$ are $0$ and $1$ respectively. So your proof does not work if you just suppose $M$ locally finite. 
But if you suppose $M$ locally finite free, and consider two primes $p\subset q$ then if $M_q=R_q^n$ then $M_p=(M_q)_{pR_q}$ you get $$M_p=(R_q)^n_{pR_q}=R_p^n$$ so the rank at each point $p$ and $q$ are equal.
It means the rank function is determined by its value at the minimal primes of $R$. If $R$ is a domain, it is then constant as soon as $M$ is supposed to be finite free at each point of the spectrum of $R$. If $R$ has only finitely many minimal primes, the rank function is still locally constant right ? No need for other hypothesis.
Edit : If I look closely at your proof, I think you are using the definition of the rank function given in Matsumura's book Commutative Ring Theory which is $M\otimes K$ given only for a domain $R$ with fraction field $K$. This measure the maximum number of independent elements of $M$, which are not necessarily generators for general domains. In that case your demonstration is correct but there is no point to look at other points of the spectrum. As you noticed you always have $M_p\otimes K=M\otimes K$, meaning you always look at the point $(0)$ in $p$. If you want to see what happens locally at $p$ you have to use the residue field at $p$, $R_p/pR_p$. The rank function definition I gave is measuring minimal set of generators (to see that use Nakayama's lemma at maximal prime of the spectrum or this other question here
https://mathoverflow.net/a/30024/3333) that have no reason to be of the same cardinal everywhere ...
I also had problem at the beginning with all the definitions so I got the following clarification here
https://mathoverflow.net/a/153681/3333
