]> git.lizzy.rs Git - rust.git/commit
Only suggest paths that exist.
authorDavid Wood <david@davidtw.co>
Fri, 12 Oct 2018 11:47:37 +0000 (13:47 +0200)
committerDavid Wood <david@davidtw.co>
Fri, 19 Oct 2018 13:45:46 +0000 (15:45 +0200)
commit4334aaacf1da33ece0b13d845bf280aeddcb512b
tree5aea52e86426258c9e12d6562936e5f331c5c8bc
parentb8b4150c042b06c46e29a9d12101f91fe13996e0
Only suggest paths that exist.

In order to output a path that could actually be imported (valid and
visible), we need to handle re-exports correctly.

For example, take `std::os::unix::process::CommandExt`, this trait is
actually defined at `std::sys::unix::ext::process::CommandExt` (at time
of writing).

`std::os::unix` rexports the contents of `std::sys::unix::ext`.
`std::sys` is private so the "true" path to `CommandExt` isn't accessible.

In this case, the visible parent map will look something like this:

(child) -> (parent)
`std::sys::unix::ext::process::CommandExt` -> `std::sys::unix::ext::process`
`std::sys::unix::ext::process` -> `std::sys::unix::ext`
`std::sys::unix::ext` -> `std::os`

This is correct, as the visible parent of `std::sys::unix::ext` is in fact
`std::os`.

When printing the path to `CommandExt` and looking at the current
segment that corresponds to `std::sys::unix::ext`, we would normally
print `ext` and then go to the parent - resulting in a mangled path like
`std::os::ext::process::CommandExt`.

Instead, we must detect that there was a re-export and instead print `unix`
(which is the name `std::sys::unix::ext` was re-exported as in `std::os`).
src/librustc/ty/item_path.rs
src/test/ui/issues/issue-39175.rs [new file with mode: 0644]
src/test/ui/issues/issue-39175.stderr [new file with mode: 0644]