query part included in location match after rewrite (bug or feature?)

According to documentation, "location" matches only against URI path, ignoring query string. However, after "rewrite", when using variables containing "?" character (like $request_uri for illustration), query becomes part of $uri: