We study matchings on sequences of diluted random graphs converging to trees (for the local weak convergence). We prove the cavity prediction for the asymptotic size of maximum matchings and show its relation with the resolvent of the limiting tree seen as an operator. As a result, we compute the limit for the rank of the sequence of graphs.