rust-lang / rust · Issue No. 160638
(First noticed in #159490)
When the compiler is showing the declaration of a wrongly used item as a suggestion, it gives out the full system path for the source file :
fn main() {
let mut x = 0;
errored(&x);
}
fn errored(wrong: &mut u32) {}
note: function defined here
--> src\main.rs:6:4
|
6 | fn errored(wrong: &mut u32) {}
| ^^^^^^^ ---------------
This works out fine for local projects , as this diagnostic seems to give out the relative path in which cargo is invoked which invokes rustc. The issue arises when the wrongly invoked item is in something where you shouldn't change, namely the standard library source code in your system, for example the read_line function:
fn main() {
let input = String::new();
std::io::stdin().read_line(&input).unwrap();
}
note: method defined here
--> /rustc/1159e78c4747b02ef996e55082b704c09b970588\library\std\src\io\stdio.rs:411:12
It is probably not a good idea for the end user to go to this exact path if they ever feel the need to patch something, so in my opinion it doesn't make sense that we currently show where it is.
Of course this can make sense for anyone debugging and playing around with the compiler in any shape or form, but for the end user I think this issue is worth considering, perhaps it could be something more like:
note: method defined here
--> std\src\io\stdio.rs:411:12
This works out for basicest of compiler debugging, and doesn't confuse the end user on something that they shouldn't change, but it may also lead to them searching std as a literal path as well, in which case extra warnings (a note like "(not a literal path)" maybe?) work fine.
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.