mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
e422612f8e
Fix stray notes when the source code is not available Fixes #87060. To reproduce it with a local build of rustc, you have to copy the compiler (e.g. `build/x86_64-unknown-linux-gnu/stage1/`) somewhere and then rename the compiler source directory (maybe there is a smarter way as well). Then, rustc won't find the standard library sources and report stray notes such as ``` note: deref defined here ``` with no location for "here". Another example I've found is this: ```rust use std::ops::Add; fn foo<T: Add<Output=()>>(x: T) { x + x; } fn main() {} ``` ``` error[E0382]: use of moved value: `x` --> binop.rs:4:9 | 3 | fn foo<T: Add<Output=()>>(x: T) { | - move occurs because `x` has type `T`, which does not implement the `Copy` trait 4 | x + x; | ----^ | | | | | value used here after move | `x` moved due to usage in operator | note: calling this operator moves the left-hand side help: consider further restricting this bound | 3 | fn foo<T: Add<Output=()> + Copy>(x: T) { | ^^^^^^ error: aborting due to previous error ``` where, again, the note is supposed to point somewhere but doesn't. I have fixed this by checking whether the corresponding source code is actually available before emitting the note.