-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Normally rustc will suggest what use
line to add, but for CommandExt its suggestion is impossible.
testcase.rs:
use std::process::Command;
// forgot this: use std::os::unix::process::CommandExt;
fn main() {
Command::new("echo").arg("hello").exec();
}
Compile with rustc testcase.rs
. Rust says it can't find exec
and explains:
= help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it: = help: candidate #1: `use std::os::ext::process::CommandExt;`
But the suggested trait doesn't exist; adding the suggested line gives an unresolved import error: "Could not find ext
in os
"
Rust should instead suggest the correct trait, std::os::unix::process::CommandExt
.
Tested with (rustc --version --verbose
):
Fedora 25's packaged rust:
rustc 1.10.0 (cfcb716cf 2016-07-03) binary: rustc commit-hash: cfcb716cf0961a7e3a4eceac828d94805cf8140b commit-date: 2016-07-03 host: x86_64-unknown-linux-gnu release: 1.10.0
And a recent source build:
rustc 1.16.0-dev (74c42ac17 2017-01-19) binary: rustc commit-hash: 74c42ac173bee900979870ed986c760596d1fbdb commit-date: 2017-01-19 host: x86_64-unknown-linux-gnu release: 1.16.0-dev LLVM version: 3.9
(The formatting of the error messages differs between versions but the errors are the same.)
kennytm, najamelan, reujab and Xion
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
pengowen123 commentedon Jan 23, 2017
The path is created at
librustc_typeck/check/method/suggest.rs
at line 333.item_path_str
seems to be following re-exports:std::os::ext::process::CommandExt
is a valid path because of a re-export inlibstd/os/mod.rs
. However, the re-export ispub use sys::ext as unix
, so the path should bestd::os::unix::process::CommandExt
.item_path_str
isn't taking this renaming into account, so it leads to an incorrect path.setharnold commentedon May 7, 2017
Other modules show this problem:
Thanks
Mark-Simulacrum commentedon Jun 22, 2017
Nominating for compiler team. If there's something we can do to fix this, that would be great -- I imagine most beginners hit this fairly often, and even experienced users. I don't know what the underlying problem here is, though, so perhaps it's very hard to fix.
nikomatsakis commentedon Jun 29, 2017
triage: P-medium
This would indeed be good to fix but doesn't rise to the urgency of P-high. The underlying problem is that we often print the "true path" but we should be printing the "visible" path. Not sure who would be best equipped to plan a solution to this -- @jseyfried ?
Ryan1729 commentedon Aug 4, 2018
Just ran into this with
1.28.0
on windows 10. I guess I'll add my example to the pile:This gives me the following absurd pair of errors:
ErichDonGubler commentedon Oct 10, 2018
I likewise get this issue with the following snippet:
Relevant
rustup show
output:Rollup merge of rust-lang#55007 - davidtwco:issue-39175, r=petrochenkov
6 remaining items