-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distinguish versions of a crate loaded from the sysroot and from cargo #110055
Comments
Distinguish crates with the same name in type errors Previously, errors for crates with the same name would only distinguish them by the span of the source: ``` note: `HashMap<_, _, _, _>` is defined in crate `hashbrown` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1 note: `HashMap<u32, u32>` is defined in crate `hashbrown` --> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1 ``` When the same version of the crate is loaded twice, this isn't particularly helpful. Additionally show where the .rlib was loaded from (in this case one was loaded from the sysroot and the other from a cargo target dir). Fixes rust-lang#110055.
Distinguish crates with the same name in type errors Previously, errors for crates with the same name would only distinguish them by the span of the source: ``` note: `HashMap<_, _, _, _>` is defined in crate `hashbrown` --> /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1 note: `HashMap<u32, u32>` is defined in crate `hashbrown` --> /Users/jyn/.local/lib/cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1 ``` When the same version of the crate is loaded twice, this isn't particularly helpful. Additionally show where the .rlib was loaded from (in this case one was loaded from the sysroot and the other from a cargo target dir). --- This also remaps cargo paths more eagerly; particularly, it unconditionally remaps cargo paths for libstd unconditionally, even if `remap-debuginfo = false`. This is the first time that cargo paths have shown up in UI tests; if the paths aren't remapped, they will differ depending on the value of `remap-debuginfo`, which means tests will fail either locally or in CI. This can't be worked around with adhoc normalization in the test makefile because it impacts the column width used for line numbers (when paths are remapped, we don't show the cargo sources). I could be convinced this is not the best solution. It's possible we could take some other approach, like how `CFG_VIRTUAL_RUST_SOURCE_BASE_DIR` opportunistically reverses the mapping for `compiler/`, which doesn't impact the error messages standard library developers see. That would be a bit more involved to get working, though. --- Fixes rust-lang#110055.
Current output:
Do you feel this is enough specificity @jyn514? |
The language there seems mostly the same. The only thing that’s improved is that it now says /rust/deps instead of pointing to the cargo registry. And that’s easy to overlook, and I’m not entirely sure it’s not just because you don’t have the rustc-src component installed. So I would prefer to keep this open until the message explicitly mentions the sysroot. (I do think the message is more clear if you do in fact actually have two different versions of hashbrown, like would normally be the case when this error happens. but that is not the case in the original issue, notice how the version numbers are the same.) |
in particular, the new language about cargo tree is very helpful when you’re using cargo, and actively misleading if you’re loading dependencies from sysroot. |
For my locally built |
i would expect that rustc_metadata stores info somewhere about whether the crate was loaded from a -L deps/ folder or from the sysroot? i strongly think we should not do this based on the original source span, we should do it based on the location of the .rmeta that got loaded. |
I'm just not sure that we still have all of the necessary information by hir typeck. |
rustc_metadata stores the path to the rlib/dylib/rmeta file(s) for the crate. And it should be easy to add another flag stating if the crate came from the sysroot or not. |
Code
Current output
Desired output
Rationale and extra context
It's not clear that "/Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/hashbrown-0.12.3/src/map.rs:188:1" is referring to a crate loaded from the sysroot; that path doesn't correspond to anything on disk. It would be nice to explain what's going on; when dealing with sysroots the exact paths of the artifacts often really are important.
Other cases
No response
Anything else?
This is minimized from a real error @aDotInTheVoid saw in rustdoc:
The text was updated successfully, but these errors were encountered: