I think the ideal solution here would be to modify libsyntax to provide a way to get comments from the tokenizer. Then you can simply tokenize the file and pull out any comment beginning with `//~` (and map the associated `Span` back to a line number).

Granted, that's a fair amount of work for this one small feature. It would help if there are more uses for getting comments from the tokenizer. My first thought is for doing a `rustfmt` tool, although @pcwalton already has one of those and I don't know what it uses for tokenizing.