Similar to how the alignment is already checked, this adds a check
for null pointer dereferences in debug mode. It is implemented similarly
to the alignment check as a MirPass.
This is related to a 2025H1 project goal for better UB checks in debug
mode: https://github.com/rust-lang/rust-project-goals/pull/177.
Previously it may have been possible for different completion items to
produce colliding hashes, not because of the hash but because of how
the items were serialized into byte streams for hashing. See #19071
for details.
The chances of that happening were low, if it was actually possible at
all. Nevertheless, this commit ensures that it definitely can't happen.
This commit uses a handful of techniques used to fix this, but they all
boil down to "ensure this could be re-parsed". If it's possible to parse
to recreate the original item, then by construction there is no chance
of two different items getting serialized to identical byte streams.
The TentHash spec was frozen Jan 1st 2025, and release 1.0 of the Rust
crate is a minor cleanup as a follow-up to that, representing a
commitment to API stability as well.
The hash output remains the same as version 0.4, which rust-analyzer was
previously using. The only API change was a struct rename.
Currently, running rust-analyzer tests on FreeBSD produces an "unused
variable" warning. The code is fully compatible with FreeBSD and doesn't
have to be omitted.
Signed-off-by: Vladimir Krivopalov <vladimir@krivopalov.ru>
I added it by mistake in #18927.
I chose to keep the method as not static, because it's more comfortable, and keep the name `add_reference()` and not `reference()`, because it is clearer and better matches `strip_reference[s]()`.
That was used as a fallback, causing a panic when the fallback was chosen.
I also made sure this won't happen again by guaranteeing in the macro generating the tokens that they all exist.
It should be considered by the edition of the caller, not the callee.
Technically we still don't do it correctly - we need the span of the method name (if it comes from a macro), but we don't keep it and this is good enough for now.